|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
knutdock.cpp - description
|
|
|
|
|
-------------------
|
|
|
|
|
begin : Út zari 23 2003
|
|
|
|
|
begin : <EFBFBD>t zari 23 2003
|
|
|
|
|
copyright : (C) 2003 by Daniel Prynych
|
|
|
|
|
email : Daniel.Prynych@alo.cz
|
|
|
|
|
***************************************************************************/
|
|
|
|
@ -96,6 +96,11 @@ KNutDock::~KNutDock(){
|
|
|
|
|
delete m_menu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KNutDock::resizeEvent ( QResizeEvent * ){
|
|
|
|
|
initImage();
|
|
|
|
|
changeKIcon(); // this function calls function repaintIcon
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KNutDock::changeUps (void) {
|
|
|
|
|
|
|
|
|
|
m_upsServerMenu->clear();
|
|
|
|
@ -575,18 +580,18 @@ void KNutDock::paintEvent (QPaintEvent *e) {
|
|
|
|
|
// painter.begin();
|
|
|
|
|
if (m_statusValue & KNutNet::OL) { // ONLINE - icon of UPS
|
|
|
|
|
painter.setPen(Qt::black);
|
|
|
|
|
paintNumbers (m_upsLoadValue, -2, 15, &painter );
|
|
|
|
|
paintNumbers (m_upsLoadValue, (width()/-11), ((float) width()/(float) 1.46666666667), &painter, ((float) width()/(float) 22) );
|
|
|
|
|
}
|
|
|
|
|
else { // OFFLINE icon of battery
|
|
|
|
|
if (m_batteryChargeValue != knc::numberVarError) {
|
|
|
|
|
if (m_batteryChargeValue < 40) painter.setPen(Qt::red);
|
|
|
|
|
else painter.setPen(Qt::black);
|
|
|
|
|
paintNumbers(m_batteryChargeValue,-2,16,&painter);
|
|
|
|
|
paintNumbers(m_batteryChargeValue,(width()/-11),((float) width()/(float) 1.375),&painter, ((float) width()/(float) 22));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
painter.setPen(Qt::black);
|
|
|
|
|
paintDash (3,16,&painter);
|
|
|
|
|
paintDash (8,16,&painter);
|
|
|
|
|
paintDash (((float) width()/(float) 7.33333333333),((float) width()/(float) 1.375),&painter, ((float) width()/(float) 22));
|
|
|
|
|
paintDash (((float) width()/(float) 2.75),((float) width()/(float) 1.375),&painter, ((float) width()/(float) 22));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// painter.end();
|
|
|
|
@ -660,12 +665,12 @@ void KNutDock::paintCharge (int charge ) {
|
|
|
|
|
if (charge != knc::numberVarError) {
|
|
|
|
|
if (charge < 40) paint.setPen(Qt::red);
|
|
|
|
|
else paint.setPen(Qt::black);
|
|
|
|
|
paintNumbers(charge,8,2,&paint);
|
|
|
|
|
paintNumbers(charge,8,2,&paint, 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
paint.setPen(Qt::black);
|
|
|
|
|
paintDash (13,2,&paint);
|
|
|
|
|
paintDash (18,2,&paint);
|
|
|
|
|
paintDash (13,2,&paint, 1);
|
|
|
|
|
paintDash (18,2,&paint, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -673,7 +678,7 @@ void KNutDock::paintCharge (int charge ) {
|
|
|
|
|
if (charge != knc::numberVarError) {
|
|
|
|
|
if (charge < 40) paint.setPen(Qt::red);
|
|
|
|
|
else paint.setPen(Qt::black);
|
|
|
|
|
paintNumbers(charge,-2,16,&paint);
|
|
|
|
|
paintNumbers(charge,-2,16,&paint, 1);
|
|
|
|
|
|
|
|
|
|
if (charge < 40) paint.setPen(Qt::red);
|
|
|
|
|
else {
|
|
|
|
@ -688,8 +693,8 @@ void KNutDock::paintCharge (int charge ) {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
paint.setPen(Qt::black);
|
|
|
|
|
paintDash (3,16,&paint);
|
|
|
|
|
paintDash (8,16,&paint);
|
|
|
|
|
paintDash (3,16,&paint, 1);
|
|
|
|
|
paintDash (8,16,&paint, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -777,16 +782,16 @@ void KNutDock::paintRuntime (int runtime, int status ) {
|
|
|
|
|
int min = abs(runtime/60);
|
|
|
|
|
int sec = runtime - (min*60);
|
|
|
|
|
|
|
|
|
|
paintNumber(1,11, abs(min/10) ,&paint);
|
|
|
|
|
paintNumber(6,11,min-((abs(min/10))*10) ,&paint);
|
|
|
|
|
paintNumber(13,11, abs(sec/10) ,&paint);
|
|
|
|
|
paintNumber(18,11,sec-((abs(sec/10))*10) ,&paint);
|
|
|
|
|
paintNumber(1,11, abs(min/10) ,&paint, 1);
|
|
|
|
|
paintNumber(6,11,min-((abs(min/10))*10) ,&paint, 1);
|
|
|
|
|
paintNumber(13,11, abs(sec/10) ,&paint, 1);
|
|
|
|
|
paintNumber(18,11,sec-((abs(sec/10))*10) ,&paint, 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
paintDash (1,11,&paint);
|
|
|
|
|
paintDash (6,11,&paint);
|
|
|
|
|
paintDash (13,11,&paint);
|
|
|
|
|
paintDash (18,11,&paint);
|
|
|
|
|
paintDash (1,11,&paint, 1);
|
|
|
|
|
paintDash (6,11,&paint, 1);
|
|
|
|
|
paintDash (13,11,&paint, 1);
|
|
|
|
|
paintDash (18,11,&paint, 1);
|
|
|
|
|
}
|
|
|
|
|
paint.drawLine (11,12,11,13);
|
|
|
|
|
paint.drawLine (11,15,11,16);
|
|
|
|
@ -828,7 +833,7 @@ void KNutDock::paintLoad (int load ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutDock::paintNumbers (int numbers, int x, int y, QPainter* p ) {
|
|
|
|
|
void KNutDock::paintNumbers (int numbers, int x, int y, QPainter* p, float sizeMult ) {
|
|
|
|
|
bool first = false;
|
|
|
|
|
|
|
|
|
|
if (numbers > 199) numbers = 199;
|
|
|
|
@ -836,87 +841,96 @@ void KNutDock::paintNumbers (int numbers, int x, int y, QPainter* p ) {
|
|
|
|
|
if (numbers != knc::numberVarError) {
|
|
|
|
|
|
|
|
|
|
if (numbers > 99) {
|
|
|
|
|
paintNumber (x,y,1,p);
|
|
|
|
|
paintNumber (x,y,1,p,sizeMult);
|
|
|
|
|
numbers -= 100;
|
|
|
|
|
first=true;
|
|
|
|
|
}
|
|
|
|
|
int second = abs (numbers/10);
|
|
|
|
|
int third = numbers - (second * 10);
|
|
|
|
|
|
|
|
|
|
if ((second != 0) || (first)) paintNumber (x+5,y,second,p);
|
|
|
|
|
paintNumber (x+10,y,third,p);
|
|
|
|
|
if ((second != 0) || (first)) paintNumber (((float) x+(5*sizeMult)),y,second,p,sizeMult);
|
|
|
|
|
paintNumber (((float) x+(10*sizeMult)),y,third,p,sizeMult);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
p->setPen(Qt::black);
|
|
|
|
|
paintDash (x+5,y,p);
|
|
|
|
|
paintDash (x+10,y,p);
|
|
|
|
|
paintDash (((float) x+(5*sizeMult)),y,p,sizeMult);
|
|
|
|
|
paintDash (((float) x+(10*sizeMult)),y,p,sizeMult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutDock::paintDash (int x, int y, QPainter *p) {
|
|
|
|
|
|
|
|
|
|
p->drawLine(x,y+3,x+3,y+3);
|
|
|
|
|
void KNutDock::paintDash (int x, int y, QPainter *p, float sizeMult) {
|
|
|
|
|
QPen oldPen = p->pen();
|
|
|
|
|
QPen newPen;
|
|
|
|
|
newPen.setWidth(((float) (oldPen.width()+1)*sizeMult)-1);
|
|
|
|
|
p->setPen(newPen);
|
|
|
|
|
p->drawLine(x,((float) y+(3*sizeMult)),((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
p->setPen(oldPen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KNutDock::paintNumber (int x, int y, int number, QPainter *p) {
|
|
|
|
|
void KNutDock::paintNumber (int x, int y, int number, QPainter *p, float sizeMult) {
|
|
|
|
|
// x and y are left top corner
|
|
|
|
|
QPen oldPen = p->pen();
|
|
|
|
|
QPen newPen;
|
|
|
|
|
newPen.setWidth(((float) (oldPen.width()+1)*sizeMult)-1);
|
|
|
|
|
p->setPen(newPen);
|
|
|
|
|
|
|
|
|
|
if ((number > -1) && (number < 10)) {
|
|
|
|
|
// painting - kreslim
|
|
|
|
|
switch (number) {
|
|
|
|
|
case 0:
|
|
|
|
|
p->drawRect(x,y,4,7);
|
|
|
|
|
p->drawRect(x,y,((float) 4*sizeMult),((float) 7*sizeMult));
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
p->drawLine (x+3,y,x+3,y+6);
|
|
|
|
|
p->drawLine (((float) x+(3*sizeMult)),y,((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
p->drawLine(x,y,x+3,y);
|
|
|
|
|
p->lineTo(x+3,y+3);
|
|
|
|
|
p->lineTo(x,y+3);
|
|
|
|
|
p->lineTo(x,y+6);
|
|
|
|
|
p->lineTo(x+3,y+6);
|
|
|
|
|
p->drawLine(x,y,((float) x+(3*sizeMult)),y);
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
p->lineTo(x,((float) y+(3*sizeMult)));
|
|
|
|
|
p->lineTo(x,((float) y+(6*sizeMult)));
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
p->drawLine(x,y,x+3,y);
|
|
|
|
|
p->lineTo(x+3,y+6);
|
|
|
|
|
p->lineTo(x,y+6);
|
|
|
|
|
p->drawLine(x,y+3,x+3,y+3);
|
|
|
|
|
p->drawLine(x,y,((float) x+(3*sizeMult)),y);
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
p->lineTo(x,((float) y+(6*sizeMult)));
|
|
|
|
|
p->drawLine(x,((float) y+(3*sizeMult)),((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
p->drawLine(x,y,x,y+3);
|
|
|
|
|
p->lineTo(x+3,y+3);
|
|
|
|
|
p->drawLine (x+3,y,x+3,y+6);
|
|
|
|
|
p->drawLine(x,y,x,((float) y+(3*sizeMult)));
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
p->drawLine (((float) x+(3*sizeMult)),y,((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
p->drawLine(x+3,y,x,y);
|
|
|
|
|
p->lineTo(x,y+3);
|
|
|
|
|
p->lineTo(x+3,y+3);
|
|
|
|
|
p->lineTo(x+3,y+6);
|
|
|
|
|
p->lineTo(x,y+6);
|
|
|
|
|
p->drawLine(((float) x+(3*sizeMult)),y,x,y);
|
|
|
|
|
p->lineTo(x,((float) y+(3*sizeMult)));
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
p->lineTo(x,((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
p->drawRect(x,y+3,4,4);
|
|
|
|
|
p->drawLine(x,y+3,x,y);
|
|
|
|
|
p->lineTo(x+3,y);
|
|
|
|
|
p->drawRect(x,((float) y+(3*sizeMult)),((float) 4*sizeMult),((float) 4*sizeMult));
|
|
|
|
|
p->drawLine(x,((float) y+(3*sizeMult)),x,y);
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),y);
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
p->drawLine(x,y,x+3,y);
|
|
|
|
|
p->lineTo(x+3,y+6);
|
|
|
|
|
p->drawLine(x,y,((float) x+(3*sizeMult)),y);
|
|
|
|
|
p->lineTo(((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
p->drawRect(x,y,4,7);
|
|
|
|
|
p->drawLine(x,y+3,x+3,y+3);
|
|
|
|
|
p->drawRect(x,y,((float) 4*sizeMult),((float) 7*sizeMult));
|
|
|
|
|
p->drawLine(x,((float) y+(3*sizeMult)),((float) x+(3*sizeMult)),((float) y+(3*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
p->drawRect(x,y,4,4);
|
|
|
|
|
p->drawLine(x+3,y+3,x+3,y+6);
|
|
|
|
|
p->lineTo(x,y+6);
|
|
|
|
|
p->drawRect(x,y,((float) 4*sizeMult),((float) 4*sizeMult));
|
|
|
|
|
p->drawLine(((float) x+(3*sizeMult)),((float) y+(3*sizeMult)),((float) x+(3*sizeMult)),((float) y+(6*sizeMult)));
|
|
|
|
|
p->lineTo(x,((float) y+(6*sizeMult)));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
p->setPen(oldPen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|