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