~ubuntu-branches/ubuntu/wily/knutclient/wily

« back to all changes in this revision

Viewing changes to src/knutdock.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2013-12-15 01:56:29 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131215015629-kbtxdi17e1gmxb5e
Tags: 1.0.5-1
Re-packaged and re-introduced to Debian (Closes: #695840).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
 
1
/**************************************************************************
2
2
                          knutdock.cpp  -  description
3
3
                             -------------------
4
4
    begin                : �t zari 23 2003
5
5
    copyright            : (C) 2003 by Daniel Prynych
6
 
    email                : Daniel.Prynych@alo.cz
 
6
    email                : Daniel@Prynych.cz
7
7
 ***************************************************************************/
8
8
 
9
9
/***************************************************************************
18
18
#include "knutdock.h"
19
19
#include "knutnet.h"
20
20
 
21
 
//#include <kglobal.h>
22
 
#include <kiconloader.h>
23
 
#include <klocale.h>
24
 
#include <kapp.h>
25
 
#include <kaboutapplication.h>
26
 
#include <kmessagebox.h>
27
 
 
28
 
#include <qpainter.h>
29
 
#include <qtooltip.h>
30
 
#include <qpixmap.h>
31
 
#include <qbitmap.h>
32
 
#include <qstring.h>
 
21
#include <KDE/KIconLoader>
 
22
#include <KDE/KLocale>
 
23
#include <KDE/KApplication>
 
24
#include <KDE/KMenu>
 
25
#include <KDE/KAboutData>
 
26
#include <KDE/KAboutApplicationDialog>
 
27
#include <KDE/KAction>
 
28
#include <KDE/KColorScheme>
 
29
 
 
30
 
 
31
#include <QtGui/QPalette>
 
32
#include <QtGui/QPainter>
 
33
#include <QtGui/QToolTip>
 
34
#include <QtGui/QPixmap>
 
35
#include <QtGui/QImage>
 
36
#include <QtGui/QBrush>
 
37
#include <QtCore/QString>
 
38
#include <QtGui/QActionGroup>
33
39
 
34
40
 
35
41
#include <math.h>
38
44
 
39
45
//#include <iostream>
40
46
 
41
 
KNutDock::KNutDock(KNutVarData::upsInfoDef* activeUpsInfo, KNutVarData::SettingDataDef* settingData, KNutUpsData* upsRecords){
 
47
KNutDock::KNutDock(KNutVarData::upsInfoDef* activeUpsInfo, KNutVarData::SettingDataDef* settingData, KNutUpsData* upsRecords, QWidget* ) : KSystemTrayIcon (NULL) {
42
48
  QString valueName;
43
49
 
44
50
  m_settingData = settingData;
45
51
  m_upsRecords = upsRecords;
46
52
  m_activeUpsInfo = activeUpsInfo;
47
53
 
48
 
//saves backgroundcolor of kicker  
49
 
  backgroundColor = paletteBackgroundColor();
 
54
//saves backgroundcolor of kicker 
 
55
//+++++++  bude potreba zjistit tuto hodnotu odjinut 
 
56
KColorScheme sysTrayColorScheme(QPalette::Active,KColorScheme::View);
 
57
 
 
58
m_backgroundGlobalBrush = sysTrayColorScheme.background(KColorScheme::NormalBackground);
 
59
 
 
60
m_textBrush = sysTrayColorScheme.foreground(KColorScheme::NormalText);
 
61
m_textColor = m_textBrush.color();
 
62
//m_textBrush.setColor();
50
63
 
51
64
  m_typeOfIcon = m_settingData->typeOfKIcon;
52
65
 
53
 
  if (!m_settingData->customKIconColor) m_myBGColor = backgroundColor;
54
 
  else m_myBGColor = m_settingData->kIconBackgroundColor;
55
 
 
56
 
  m_toolTipFlags=m_settingData->toolTipFlags;
 
66
  if (!m_settingData->customKIconColor) {
 
67
     m_backgroundBrush = m_backgroundGlobalBrush;
 
68
     }
 
69
  else {
 
70
     m_backgroundBrush = QBrush(m_settingData->kIconBackgroundColor);
 
71
 
 
72
     }
 
73
 
 
74
  m_toolTipFlags=m_settingData->toolTipDockFlags;
57
75
 
58
76
  clearValues();
59
77
 
60
 
 
61
 
  KIconLoader *loader = KGlobal::iconLoader();
62
 
  m_mainPix = loader->loadIcon ("knutclient",KIcon::Small,16);
63
 
 
64
 
  // aplications's own icons
65
 
  m_errorPix = UserIcon ("knc_error");
66
 
  m_connectPix = UserIcon ("knc_conn");
67
 
  m_upsPix = UserIcon ("knc_ups");
68
 
  m_battPix = UserIcon ("knc_batt");
 
78
  loadIcons();
 
79
  loadImages();
69
80
 
70
81
  createMainMenu();
71
82
 
72
 
  m_statusLayer = 0;
73
 
  m_runtimeLayer = 0;
74
 
 
75
 
  m_loadLayer = new QPixmap(24,24);
76
 
  m_chargeLayer = new QPixmap(24,24);
77
 
  m_mainLayer = new QPixmap(24,24);
78
 
 
79
 
 
80
 
  initImage();
 
83
  m_mainLayer = new QImage(22,22,QImage::Format_ARGB32);
 
84
  m_backgroundLayer = new QImage(22,22,QImage::Format_ARGB32);
 
85
  setIconBackgroundLayer();
 
86
 
 
87
  initSysTrayImage();
 
88
  setToolTip("KNutClient");
 
89
 
81
90
  changeKIcon(); // this function calls function repaintIcon 
82
91
 
 
92
  // Uses own working of signal activated because in parent class signal activated is connected to activatedOrHide,
 
93
  //  but procedure activatedOrHide doesn't work when parent object is 0.
 
94
  connect (this, SIGNAL (activated ( QSystemTrayIcon::ActivationReason )), this, SLOT(slotActivated ( QSystemTrayIcon::ActivationReason ))); 
83
95
  }
84
96
 
85
97
 
86
98
KNutDock::~KNutDock(){
87
99
 
88
 
  if (m_statusLayer) delete m_statusLayer;
89
 
  if (m_runtimeLayer) delete m_runtimeLayer;
90
 
 
91
 
  delete m_loadLayer;
92
 
  delete m_chargeLayer;
93
100
  delete m_mainLayer;
94
 
 
95
 
  delete m_upsServerMenu;
 
101
  delete m_backgroundLayer;
96
102
  delete m_menu;
97
103
  }
98
104
 
 
105
 
 
106
 
 
107
void KNutDock::loadIcons (void) {
 
108
  m_errorIcon = KIcon(UserIcon("knc_error"));
 
109
  m_connectionIcon = KIcon (UserIcon("knc_conn"));
 
110
 
 
111
  m_idleIcon = KIcon (UserIcon("knc_main.png"));
 
112
}
 
113
 
 
114
 
 
115
void KNutDock::setIconBackgroundLayer (void) {
 
116
  QPainter paint; 
 
117
  paint.begin(m_backgroundLayer);
 
118
  paint.fillRect(QRect(0,0,22,22),m_backgroundBrush);
 
119
  paint.end();
 
120
}
 
121
 
 
122
 
 
123
void KNutDock::loadImages (void) {
 
124
  // aplications's own icons  -- there are beckground for dock icons
 
125
  m_upsPix = UserIcon("knc_ups").toImage();
 
126
  m_battPix = UserIcon("knc_batt").toImage();
 
127
}
 
128
 
 
129
 
99
130
void KNutDock::changeUps (void) {
100
131
 
101
132
  m_upsServerMenu->clear();
105
136
 
106
137
void KNutDock::clearDockValues(void){
107
138
 
108
 
  initImage(); // paints standart icon
109
 
 
110
139
  clearValues();
111
 
  repaintDock(true);
 
140
  initSysTrayImage(); // paints standart icon
112
141
  }
113
142
 
114
143
 
115
144
void KNutDock::changeToolTip(void){
116
145
 
117
 
  m_toolTipFlags=m_settingData->toolTipFlags;
 
146
  m_toolTipFlags=m_settingData->toolTipDockFlags;
118
147
  toolTip(m_runtimeValue, m_statusValue, m_batteryChargeValue, m_upsLoadValue);
119
148
  }
120
149
 
121
150
 
122
151
void KNutDock::changeKIBColor(void) {
123
152
 
124
 
  if (!m_settingData->customKIconColor) m_myBGColor = backgroundColor;
125
 
  else m_myBGColor = m_settingData->kIconBackgroundColor; // uses defined color
126
 
 
 
153
  if (!m_settingData->customKIconColor) {
 
154
    m_backgroundBrush = m_backgroundGlobalBrush;
 
155
    }
 
156
  else {
 
157
    m_backgroundBrush = QBrush(m_settingData->kIconBackgroundColor);
 
158
    }
 
159
  setIconBackgroundLayer();
127
160
  repaintDock(true);
128
161
  }
129
162
 
130
163
void KNutDock::changeKIcon (void) {
131
 
 
132
164
  m_typeOfIcon = m_settingData->typeOfKIcon;
133
 
  if ( m_typeOfIcon == generalKI) {
134
 
 
135
 
    if (m_mainLayer) {
136
 
    delete m_mainLayer;
137
 
    m_mainLayer=new QPixmap(24,24);
138
 
    }
139
 
 
140
 
    if (!m_statusLayer) {
141
 
      m_statusLayer = new QPixmap(24,24);
142
 
      }
143
 
    if (!m_runtimeLayer) {
144
 
      m_runtimeLayer = new QPixmap(24,24);
145
 
      }
146
 
    paintStatus(m_statusValue);
147
 
    paintRuntime(m_runtimeValue, m_statusValue);
148
 
    }
149
 
  else {  // picture Icon
150
 
    delete m_statusLayer;
151
 
    m_statusLayer = 0;
152
 
    delete m_runtimeLayer;
153
 
    m_runtimeLayer=0;
154
 
    }
155
 
  paintLoad(m_upsLoadValue);
156
 
  paintCharge(m_batteryChargeValue);
157
165
 
158
166
  m_statusWarningValue = m_statusValue & (KNutNet::CAL | KNutNet::TRIM | KNutNet::BOOST
159
167
                     | KNutNet::OVER | KNutNet::RB);
160
168
  repaintDock(true);
161
169
  }
162
170
 
163
 
void KNutDock::initImage(void) {
164
 
  setPixmap(m_mainPix);
165
 
  m_dataOk = idle;
166
 
  m_dataOkOld = m_dataOk;
 
171
void KNutDock::initSysTrayImage(void) {
 
172
  setIcon(m_idleIcon);
 
173
  m_dataOk = m_dataOkOld= idle;  //status of ups connecting -- ups isn't connected
167
174
  }
168
175
 
169
176
void KNutDock::setNewUPS(void) {
171
178
  createUpsMenu();
172
179
  }
173
180
 
174
 
 
175
181
void KNutDock::repaintDock (const bool always) {
 
182
 
 
183
  if (m_activeUpsInfo->upsNet == 0)  return;
 
184
 
 
185
  m_dataOkOld=m_dataOk; 
 
186
  
 
187
  if (m_activeUpsInfo->netError)  m_dataOk = error; // error is value not variable
 
188
  else { // makes OKIcon when is needed and sets m_dataOk - status of Icon
 
189
    if ((m_activeUpsInfo->upsNet->getState() == KNutNet::Connected) &&
 
190
       (m_activeUpsInfo->upsNet->readStatus() != KNutNet::NS)) { // paints icons with information values //m_statusValue : NS  is  NONE STATUS
 
191
      m_dataOk = ok;
 
192
      if (dataValueIsChanged() || always) makeOkIcon();
 
193
      toolTip(m_runtimeValue, m_statusValue, m_batteryChargeValue, m_upsLoadValue);
 
194
      }
 
195
    else {
 
196
      if ((m_activeUpsInfo->upsNet->getState() == KNutNet::Connecting) ||
 
197
        (m_activeUpsInfo->upsNet->getState() == KNutNet::HostLookup))
 
198
        m_dataOk = connecting;
 
199
      else m_dataOk = idle; 
 
200
      }
 
201
    }
 
202
 
 
203
  if (m_dataOk == ok) {
 
204
    setIcon(KIcon( QPixmap::fromImage(*m_mainLayer)));
 
205
    }
 
206
  else {
 
207
    if ((m_dataOk != m_dataOkOld) or always) {
 
208
      toolTip(0, -1, 0, 0);
 
209
      m_dataOkOld=m_dataOk; 
 
210
      if (m_dataOk == connecting) setIcon(m_connectionIcon);  // knutNet is in connecting state
 
211
      else {
 
212
        if (m_dataOk == error) setIcon(m_errorIcon);  // knutNet is in error state
 
213
        else  {
 
214
          setIcon(m_idleIcon);  // knutNet is in idle state
 
215
          }
 
216
        }
 
217
      }
 
218
    }
 
219
  }
 
220
 
 
221
 
 
222
bool KNutDock::dataValueIsChanged(void) {
 
223
  QString valueName;
 
224
  bool okFloat;
176
225
  QString nutStringVar;
 
226
 
 
227
  int myStatusValue;
 
228
  int myStatusBatValue;
177
229
  int myRuntimeValue;
178
230
  int myUpsLoadValue;
179
 
  int myStatusValue;  
180
 
  int myStatusBatValue;
181
231
  int myBatteryChargeValue;
182
 
  bool repaintNow = false;
183
 
  // value repaintNow is seted when some ups values are changed
184
 
  bool okFloat;
185
 
  QString valueName;
186
 
  QPainter paint;
187
 
 
188
 
 
189
 
  if (m_activeUpsInfo->upsNet == 0) { repaint(); return;}
190
 
 
191
 
  m_dataOkOld=m_dataOk; 
192
 
 
193
 
  if ((m_activeUpsInfo->upsNet->getState() == KNutNet::Connected) // paints icons with information values
194
 
       && (!m_activeUpsInfo->netError))  {
195
 
    // ups is connected dataOK is ok (program shows icon of connecting UPS)
196
 
    m_dataOk = ok; // pro paint event udava ze mam pouzit nase ikony
197
 
 
 
232
 
 
233
  bool repaintNow = false;  //value isn't changed
 
234
 
 
235
//  **********reads values of STATUS ***************
 
236
   myStatusValue = m_activeUpsInfo->upsNet->readStatus();
 
237
   myStatusBatValue = myStatusValue & KNutNet::OB; // OB = UPS runs on battery 
 
238
 
 
239
//  **********reads value of RUNTIME***************
198
240
    if (!m_activeUpsInfo->upsNet->existName(m_activeUpsInfo->runtimeVar)) {
199
241
      nutStringVar = m_activeUpsInfo->upsNet->readStringVar(m_activeUpsInfo->runtimeVar);
200
 
//std::cout << "KNutDock::repaintDock RUNTIME " << nutStringVar << std::endl;
201
242
      if (nutStringVar.isEmpty()) myRuntimeValue=knc::numberVarError;
202
243
      else {
203
244
        myRuntimeValue = (int)nutStringVar.toFloat(&okFloat);
206
247
      }
207
248
    else myRuntimeValue = knc::numberVarError;
208
249
 
209
 
    myStatusValue = m_activeUpsInfo->upsNet->readStatus();
210
 
 
211
 
 
212
 
    switch (m_typeOfIcon) {
213
 
      case generalKI:
214
 
//    *********STATUS****************  
215
 
      if (myStatusValue !=m_statusValue  ) {
216
 
        m_statusValue = myStatusValue;
217
 
        paintStatus(m_statusValue);
218
 
        repaintNow = true;
219
 
        }
220
 
 
221
 
//   **********RUNTIME***********
222
 
      myStatusBatValue = myStatusValue & KNutNet::OB; // OB = UPS runs on battery 
223
 
      if ((myRuntimeValue != m_runtimeValue) || (myStatusBatValue != m_statusBatValue)) {
224
 
        // when runtime is changed or flags OB is changed we must repaint icons
225
 
        // when OB is changed same items in icon will change color
226
 
        m_runtimeValue = myRuntimeValue; // runtime is old value of runtime, one is defined like global value of class
227
 
        m_statusBatValue = myStatusBatValue;
228
 
        paintRuntime(m_runtimeValue, m_statusValue);
229
 
        repaintNow = true;
230
 
        }
231
 
      break;
232
 
 
233
 
      case pictureKI:
234
 
//    *********STATUS****************
235
 
      if (myStatusValue !=m_statusValue  ) {
236
 
        m_statusValue = myStatusValue;
237
 
        m_statusWarningValue = myStatusValue & (KNutNet::CAL | KNutNet::TRIM | KNutNet::BOOST
238
 
                         | KNutNet::OVER | KNutNet::RB);
239
 
        repaintNow = true;
240
 
        }
241
 
 
242
 
//   **********RUNTIME***********
243
 
      if (myRuntimeValue != m_runtimeValue) {
244
 
        m_runtimeValue = myRuntimeValue;
245
 
        repaintNow = true;
246
 
        }
247
 
      break;
248
 
      } /////////////////////  end of models
249
 
 
250
 
    // Other values are for all modes
251
 
 
252
 
//  **********UPS LOAD***************
 
250
//  **********reads value of UPS LOAD***************
253
251
    if (m_activeUpsInfo->nutVariables == 1) valueName = "LOADPCT";
254
252
    else valueName = "ups.load";
255
253
    if (!m_activeUpsInfo->upsNet->existName(valueName)) {
262
260
      }
263
261
    else myUpsLoadValue=knc::numberVarError;
264
262
 
265
 
    if (myUpsLoadValue != m_upsLoadValue) {
266
 
      m_upsLoadValue = myUpsLoadValue;
267
 
      if (m_typeOfIcon == generalKI) paintLoad(m_upsLoadValue);
268
 
      repaintNow = true;
269
 
      }
270
 
 
271
 
//  *********BATTERY CHARGE****************
 
263
//  *********reads value of  BATTERY CHARGE****************
272
264
    if (m_activeUpsInfo->nutVariables == 1) valueName="BATTPCT";
273
265
    else valueName="battery.charge";
274
266
    if (!m_activeUpsInfo->upsNet->existName(valueName)) {
281
273
      }
282
274
    else myBatteryChargeValue=knc::numberVarError;
283
275
 
 
276
 
 
277
//   **********STATUS**************
 
278
    if (myStatusValue !=m_statusValue  ) {
 
279
      m_statusValue = myStatusValue;
 
280
      m_statusWarningValue = myStatusValue & (KNutNet::CAL | KNutNet::TRIM | KNutNet::BOOST
 
281
                         | KNutNet::OVER | KNutNet::RB);
 
282
      repaintNow = true;
 
283
      }
 
284
 
 
285
//   **********RUNTIME***********
 
286
      if (myRuntimeValue != m_runtimeValue)  {
 
287
        m_runtimeValue = myRuntimeValue; // runtime is old value of runtime, one is defined like global value of class
 
288
        repaintNow = true;
 
289
        }
 
290
 
 
291
//  ************LOAD********************
 
292
    if (myUpsLoadValue != m_upsLoadValue) {
 
293
      m_upsLoadValue = myUpsLoadValue;
 
294
      repaintNow = true;
 
295
    }
 
296
 
 
297
 
 
298
//  ***********CHARGE******************
284
299
    if (myBatteryChargeValue != m_batteryChargeValue) {
285
300
      m_batteryChargeValue = myBatteryChargeValue;
286
 
      if (m_typeOfIcon == generalKI)paintCharge(m_batteryChargeValue);
287
301
      repaintNow = true;
288
302
      }
289
 
//  ************* End of values********************
290
 
 
291
 
    if (repaintNow || always  || (m_dataOk != m_dataOkOld)) {
292
 
 
293
 
 
294
 
      switch (m_typeOfIcon) {
295
 
        case generalKI:
296
 
          m_mainLayer->fill(m_myBGColor);
297
 
//          copyBlt (m_mainLayer,0,0,m_runtimeLayer,0,0,24,24);
298
 
          bitBlt (m_mainLayer,0,0,m_runtimeLayer,0,0,24,24,AndROP);
299
 
          bitBlt (m_mainLayer,0,0,m_loadLayer,0,0,24,24,AndROP);
300
 
          bitBlt (m_mainLayer,0,0,m_chargeLayer,0,0,24,24,AndROP);
301
 
          bitBlt (m_mainLayer,0,0,m_statusLayer,0,0,24,24,AndROP);
302
 
        break;
303
 
        case pictureKI:
304
 
//          if (m_statusValue & KNutNet::OL) bitBlt (m_mainLayer,0,0,m_loadLayer,0,0,24,24,AndROP); // icon of UPS
305
 
          if (m_statusValue & KNutNet::OL) {  // ONLINE - icon of UPS
306
 
            int myLoad;
307
 
            QPainter paint;
308
 
            copyBlt (m_mainLayer,0,0,&m_upsPix,0,0,24,24); // icon of UPS
309
 
 
310
 
            paint.begin(m_mainLayer);
311
 
            if (m_upsLoadValue == knc::numberVarError) myLoad=0;
312
 
            else myLoad = abs(m_upsLoadValue/10);
313
 
 
314
 
            if (m_upsLoadValue != knc::numberVarError) {
315
 
            if (myLoad > 12) myLoad=12;
316
 
            if (myLoad > 10) myLoad++; // preskocime rysku pro 100 %
317
 
            if (myLoad < 9) paint.setPen(QColor(0,192,0)); //green
318
 
            else {
319
 
              if (myLoad < 11) paint.setPen(QColor(255,255,0)); //yellow
320
 
              else paint.setPen(QColor(255,0,0));//red
321
 
              }
322
 
            for (int i = 19; i < 22; i++) paint.drawLine(i,13,i,13-myLoad +1);
323
 
 
324
 
            if (myLoad < 13) {
325
 
              paint.setPen(QColor(168,220,255));
326
 
                for (int i = 20; i < 23; i++ ) paint.drawLine(i,1,i,13-myLoad);
327
 
                }
328
 
              }
329
 
            paint.setPen(QColor(Qt::black)); // line for 100 % load
330
 
            paint.drawLine(19,3,22,3);
331
 
            if (!m_statusWarningValue) paintOKPoint(paint);
332
 
            else paintErrorPoint(paint);
333
 
            paint.end();
334
 
            }
335
 
          else {
336
 
            QPainter paint;
337
 
            copyBlt (m_mainLayer,0,0,&m_battPix,0,0,24,24); // icon of Battery
338
 
            paint.begin(m_mainLayer);
339
 
            if (m_batteryChargeValue != knc::numberVarError) {
340
 
              if (m_batteryChargeValue < 40) paint.setPen(Qt::red);
341
 
              else paint.setPen(Qt::black);
342
 
              if (m_batteryChargeValue < 40) paint.setPen(Qt::red);
343
 
              else {
344
 
                if (m_batteryChargeValue < 50) paint.setPen(Qt::yellow);
345
 
                else paint.setPen(Qt::green);
346
 
                }
347
 
              int delka = abs((16*m_batteryChargeValue)/100);
348
 
              delka += abs((delka-1)/4) -1;
349
 
              paint.drawLine (2,7,2+delka,7);
350
 
              paint.drawLine (2,8,2+delka,8);
351
 
              paint.drawLine (2,9,2+delka,9);
352
 
              }
353
 
            paint.end();
354
 
            }
355
 
        break;
356
 
        }
357
 
      toolTip(m_runtimeValue, m_statusValue, m_batteryChargeValue, m_upsLoadValue);
358
 
 
359
 
      setPixmap(*m_mainLayer);
360
 
      }
361
 
    }
362
 
  else { // KNutNet->state isn't  connected
363
 
     // we must test activeUpsInfo->netError because error can rise higher level
364
 
    if (m_activeUpsInfo->netError)
365
 
      m_dataOk = error; // error is value not variable
366
 
    else {
367
 
      if ((m_activeUpsInfo->upsNet->getState() == KNutNet::Connecting) ||
368
 
        (m_activeUpsInfo->upsNet->getState() == KNutNet::HostLookup))
369
 
        m_dataOk = connecting;
370
 
      else m_dataOk = idle; 
371
 
      } 
372
 
    if ((m_dataOk != m_dataOkOld) or always) {
373
 
      toolTip(0, -1, 0, 0);
374
 
      m_dataOkOld=m_dataOk; 
375
 
      if (m_dataOk == connecting) setPixmap(m_connectPix);
376
 
      else {
377
 
        if (m_dataOk == error) setPixmap(m_errorPix);
378
 
        else  {
379
 
          setPixmap(m_mainPix);
380
 
          }
381
 
        }
382
 
      }
383
 
    }
384
 
  repaint();
385
 
  }
386
 
 
387
 
 
 
303
 
 
304
//  ************** STATUS BATT***************
 
305
//   for set repaintNow only 
 
306
      if  (myStatusBatValue != m_statusBatValue) {
 
307
        m_statusBatValue = myStatusBatValue;
 
308
        repaintNow = true;
 
309
        }
 
310
 
 
311
  return repaintNow;
 
312
}
 
313
 
 
314
void KNutDock::makeOkIcon(void) {
 
315
QPainter paint;
 
316
 
 
317
    switch (m_typeOfIcon) {
 
318
      case generalKI:
 
319
 
 
320
      *m_mainLayer = m_backgroundLayer->copy(QRect(0,0,22,22)); 
 
321
      paint.begin(m_mainLayer);
 
322
 
 
323
      paintStatus(paint, m_statusValue);
 
324
 
 
325
      paintRuntime(paint, m_runtimeValue, m_statusValue);
 
326
 
 
327
      paintLoadGeneralKI(paint, m_upsLoadValue);
 
328
      paintChargeGeneralKI(paint, m_batteryChargeValue);
 
329
      paint.end();
 
330
      break;
 
331
 
 
332
      case pictureKI:
 
333
     
 
334
      if (m_statusValue & KNutNet::OL) {  // ONLINE - icon of UPS
 
335
        int myLoad;
 
336
 
 
337
        QPainter paint;
 
338
        *m_mainLayer = m_upsPix.copy(QRect(0,0,22,22)); 
 
339
         paint.begin(m_mainLayer);
 
340
 
 
341
         if (m_upsLoadValue == knc::numberVarError) myLoad=0;
 
342
         else {
 
343
            myLoad = (int)(((double)m_upsLoadValue/10)+0.5);
 
344
            } 
 
345
 
 
346
         if (m_upsLoadValue != knc::numberVarError) {
 
347
         if (myLoad > 12) myLoad=12;
 
348
         if (myLoad > 10) myLoad++; // preskocime rysku pro 100 %
 
349
         if (myLoad < 9) paint.setPen(QColor(0,192,0)); //green
 
350
         else {
 
351
           if (myLoad < 11) paint.setPen(QColor(255,255,0)); //yellow
 
352
           else paint.setPen(QColor(255,0,0));//red
 
353
           }
 
354
        for (int i = 19; i < 22; i++) paint.drawLine(i,12,i,12-myLoad +1);
 
355
 
 
356
         if (myLoad < 13) {
 
357
           paint.setPen(QColor(168,220,255));
 
358
           for (int i = 20; i < 23; i++ ) paint.drawLine(i,0,i,12-myLoad);
 
359
           }
 
360
        }
 
361
        paint.setPen(m_textColor); // line for 100 % load
 
362
        paint.drawLine(18,2,21,2);
 
363
 
 
364
        paintNumbers (m_upsLoadValue, -2, 15, &paint );
 
365
 
 
366
        if (!m_statusWarningValue) paintOKPoint(paint);
 
367
        else paintErrorPoint(paint);
 
368
        paint.end();
 
369
        }
 
370
      else {  // offline -- battery icon
 
371
        *m_mainLayer = m_battPix.copy(QRect(0,0,22,22)); 
 
372
        paint.begin(m_mainLayer);
 
373
        paintChargePictureKI(paint, m_batteryChargeValue);
 
374
        paint.end();
 
375
        }
 
376
      break;
 
377
      } /////////////////////  end of models
 
378
}
388
379
 
389
380
void KNutDock::toolTip (int runtime, int status, int batteryCharge, int upsLoad ) {
390
381
 
401
392
  if (m_activeUpsInfo->upsNet != 0) {
402
393
    myNetErr= m_activeUpsInfo->upsNet->getError();
403
394
    switch (m_activeUpsInfo->nutVariables) {
404
 
      case 1:
 
395
      case KNutNet::versionVarOne:
405
396
        manufacturer = m_activeUpsInfo->upsNet->readStringVar("MFR");
406
397
        upsModel = m_activeUpsInfo->upsNet->readStringVar("MODEL");
407
398
        serial = m_activeUpsInfo->upsNet->readStringVar("SERIAL");
408
399
        firmware = m_activeUpsInfo->upsNet->readStringVar("FIRMREV");
409
400
      break;
410
 
      case 2:
 
401
      case KNutNet::versionVarTwo:
411
402
        manufacturer = m_activeUpsInfo->upsNet->readStringVar("ups.mfr");
412
403
        upsModel = m_activeUpsInfo->upsNet->readStringVar("ups.model");
413
404
        serial = m_activeUpsInfo->upsNet->readStringVar("ups.serial");
414
405
        firmware = m_activeUpsInfo->upsNet->readStringVar("ups.firmware");
415
406
      break;
 
407
      case KNutNet::versionVarUnknown:
 
408
        manufacturer = "";
 
409
        upsModel = "";
 
410
        serial = "";
 
411
        firmware = "";
 
412
      break;
416
413
      }
417
414
    }
418
415
 
486
483
    if (upsLoad != knc::numberVarError)
487
484
      text += "\n" + i18n("UPS Load") + QString(" : %1 %").arg(upsLoad);
488
485
    }
489
 
 
490
 
  QToolTip::remove(this);
491
 
  QToolTip::add(this,text);
 
486
  setToolTip(text);
492
487
 }
493
488
 
494
489
 
499
494
/*                                                                                           */
500
495
/*********************************************************************************************/
501
496
 
502
 
 void KNutDock::slotShowMyAbout() {
503
 
  KAboutApplication *dialog;
504
 
 
505
 
  dialog= new KAboutApplication;
 
497
 void KNutDock::slotActivated ( QSystemTrayIcon::ActivationReason reason ) {
 
498
 
 
499
 if (reason == QSystemTrayIcon::Trigger) { 
 
500
   activeMainWindow();
 
501
   }
 
502
 }
 
503
 
 
504
  void KNutDock::slotShowMyAbout() {
 
505
 
 
506
  KAboutApplicationDialog *dialog = new KAboutApplicationDialog(KGlobal::config()->componentData().aboutData());
506
507
  dialog->exec();
507
508
  delete dialog;
508
 
}
 
509
  }
509
510
 
510
511
void KNutDock::slotExitApplication (void) {
511
512
 
512
 
  if (m_settingData->areYouSure) {
513
 
    if (KMessageBox::warningYesNo (0,i18n("Are you sure ?")) == 3)
514
513
      emit endApplication();
515
 
    }
516
 
  else emit endApplication();
517
514
  }
518
515
 
519
 
void KNutDock::slotUpsName(int i) {
 
516
void KNutDock::slotUpsName(QAction *upsAction) {
520
517
 
521
 
  emit UPSChanged(m_upsRecords->getName(i-101));
 
518
  QString upsName(upsAction->text());
 
519
  upsName.remove('&');
 
520
  emit UPSChanged(upsName);
522
521
  }
523
522
 
524
523
 
525
524
void KNutDock::slotMinimize(void) {
526
525
 
527
 
  emit minimize ();
 
526
  emit minimize();
528
527
  }
529
528
 
530
529
void KNutDock::slotPreferences(void) {
555
554
 
556
555
//------------------------------------------
557
556
 
558
 
void KNutDock::mousePressEvent(QMouseEvent *e) {
559
 
 
560
 
//qDebug("KNutDock::mousePressEvent");
561
 
  if( e->button()==LeftButton  ) emit activeMainWindow();
562
 
  if( e->button()==RightButton ) m_menu->popup(e->globalPos());
563
 
  }
564
 
 
565
 
 
566
 
 
567
 
 
568
 
void KNutDock::paintEvent (QPaintEvent *e) {
569
 
 
570
 
  KSystemTray::paintEvent(e);
571
 
  if ((m_activeUpsInfo->upsNet->getState() == KNutNet::Connected) and
572
 
     (m_statusValue != KNutNet::NS)) { // When driver isn't connected, getState is connected and m_statusValue is NS // NONE STATUS
573
 
    if (m_typeOfIcon == pictureKI) {
574
 
      QPainter painter(this);
575
 
//      painter.begin();
576
 
      if (m_statusValue & KNutNet::OL) {  // ONLINE - icon of UPS
577
 
        painter.setPen(Qt::black);
578
 
        paintNumbers (m_upsLoadValue, -2, 15, &painter );
579
 
        }
580
 
      else {  // OFFLINE icon of battery
581
 
        if (m_batteryChargeValue != knc::numberVarError) {
582
 
          if (m_batteryChargeValue < 40) painter.setPen(Qt::red);
583
 
          else painter.setPen(Qt::black);
584
 
          paintNumbers(m_batteryChargeValue,-2,16,&painter);
585
 
          }
586
 
        else {
587
 
          painter.setPen(Qt::black);
588
 
          paintDash (3,16,&painter);
589
 
          paintDash (8,16,&painter);
590
 
          }
591
 
        }
592
 
 //     painter.end();
593
 
      }
594
 
    }
595
 
  }
 
557
//bool KNutDock::event(QEvent *e) {
 
558
//
 
559
//  if ( e->type() == QEvent::MouseButtonPress) {
 
560
//    qDebug("KNutDock::mousePressEvent");
 
561
//    QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(e);
 
562
//    if( mouseEvent->button()==Qt::LeftButton  ) emit activeMainWindow();
 
563
//    if( mouseEvent->button()==Qt::RightButton ) m_menu->popup(mouseEvent->globalPos());
 
564
//    }
 
565
//  else {
 
566
//    return KSystemTrayIcon::event( e ); 
 
567
//    }
 
568
// return true; 
 
569
// }
 
570
 
596
571
 
597
572
 
598
573
 
613
588
 
614
589
 
615
590
void KNutDock::createUpsMenu(void) {
 
591
  QActionGroup *upsGroup = new QActionGroup(this);
616
592
 
617
593
  int n = m_upsRecords->getCount();
618
594
  for (int i =0; i < n; i++) {
619
 
    if (m_activeUpsInfo->record.name == m_upsRecords->getName(i))
620
 
      m_upsServerMenu->insertItem(kapp->miniIcon(),m_upsRecords->getName(i), this, SLOT(slotUpsName(int)),0,101+i);
621
 
    else
622
 
      m_upsServerMenu->insertItem(m_upsRecords->getName(i), this, SLOT(slotUpsName(int)),0,101+i);
 
595
 
 
596
    KAction *upsAction = new KAction (m_upsRecords->getName(i),this);
 
597
    upsAction->setCheckable (true);
 
598
    upsGroup->addAction(upsAction);
 
599
    if (m_activeUpsInfo->record.name == m_upsRecords->getName(i)) {
 
600
      upsAction->setChecked(true);
 
601
      }
 
602
    m_upsServerMenu->addAction(upsAction);
623
603
    }
624
 
  }
 
604
    connect( upsGroup, SIGNAL( triggered(QAction *) ), this, SLOT(slotUpsName(QAction *) ));
 
605
 }
625
606
 
626
607
void KNutDock::createMainMenu(void) {
627
 
 
628
 
  m_menu = new KPopupMenu;
629
 
  m_upsServerMenu = new KPopupMenu;
 
608
  m_menu = new KMenu();
 
609
 
 
610
  QString KNCName = KGlobal::config()->componentData().aboutData()->appName();
 
611
  m_menu->addTitle (KIcon(KNCName),KNCName);
 
612
  m_menu->addSeparator();
 
613
 
 
614
  m_upsServerMenu = (KMenu *)m_menu->addMenu(KIcon(),"UPS");
 
615
  m_menu->addSeparator();
 
616
 
 
617
  m_menu->addAction(KIcon("view-list-tree"),i18n("&Showing UPS variables and commands"), this, SLOT(slotPrintUPSVars()));
 
618
  m_menu->addAction(i18n("&Running instant commands"), this, SLOT(slotInstComms()));
 
619
  m_menu->addAction(i18n("Setting R&W variables"), this, SLOT(slotRWVars()));
 
620
  m_menu->addSeparator();
 
621
  m_menu->addAction(KIcon("view-refresh"),i18n("Reconnect"), this, SLOT(slotRefreshConnection()));
 
622
  m_menu->addSeparator();
 
623
  m_menu->addAction(KIcon("configure"),i18n("&Preferences"), this, SLOT(slotPreferences()));
 
624
  m_menu->addSeparator();
 
625
  m_menu->addAction(KIcon(KNCName),i18n("&About KNutClient"), this, SLOT(slotShowMyAbout()));
 
626
  m_menu->addSeparator();
 
627
  m_menu->addAction(i18n("&Minimize"), this, SLOT(slotMinimize()));
 
628
  m_menu->addSeparator();
 
629
  m_menu->addAction (KIcon("application-exit"),i18n("&Exit"),this ,SLOT(slotExitApplication()));
 
630
  
630
631
  createUpsMenu();
631
 
 
632
 
  m_menu->insertTitle (kapp->miniIcon(),"knutclient");
633
 
  m_menu->insertSeparator();
634
 
  m_menu->insertItem("UPS",m_upsServerMenu);
635
 
  m_menu->insertSeparator();
636
 
  m_menu->insertItem(i18n("&Showing UPS variables and commands"), this, SLOT(slotPrintUPSVars()));
637
 
  m_menu->insertItem(i18n("&Running instant commands"), this, SLOT(slotInstComms()));
638
 
  m_menu->insertItem(i18n("Setting R&W variables"), this, SLOT(slotRWVars()));
639
 
  m_menu->insertSeparator();
640
 
  m_menu->insertItem(SmallIcon("reload"),i18n("Reconnect"), this, SLOT(slotRefreshConnection()));
641
 
  m_menu->insertSeparator();
642
 
  m_menu->insertItem(SmallIcon("configure"),i18n("&Preferences"), this, SLOT(slotPreferences()));
643
 
  m_menu->insertSeparator();
644
 
  m_menu->insertItem(kapp->miniIcon(),i18n("&About KNutClient"), this, SLOT(slotShowMyAbout()));
645
 
  m_menu->insertSeparator();
646
 
  m_menu->insertItem(i18n("&Minimize"), this, SLOT(slotMinimize()));
647
 
  m_menu->insertSeparator();
648
 
  m_menu->insertItem (SmallIcon("exit"),i18n("&Exit"),this ,SLOT(slotExitApplication()));
 
632
  setContextMenu(m_menu);
649
633
  }
650
634
 
651
635
 
652
 
void KNutDock::paintCharge (int charge ) {
653
 
  QPainter paint;
 
636
void KNutDock::paintChargeGeneralKI (QPainter &paint, int charge ) {
654
637
 
655
 
  m_chargeLayer->fill(Qt::white);
656
 
  paint.begin(m_chargeLayer);
657
638
  if (charge > 199) charge = 199;
658
639
 
659
640
  if (m_typeOfIcon == generalKI) {
660
641
    if (charge != knc::numberVarError) {
661
642
      if (charge < 40) paint.setPen(Qt::red);
662
 
      else paint.setPen(Qt::black);
 
643
      else paint.setPen(m_textColor);
663
644
      paintNumbers(charge,8,2,&paint);
664
645
      }
665
646
    else {
666
 
      paint.setPen(Qt::black);
 
647
      paint.setPen(m_textColor);
667
648
      paintDash (13,2,&paint);
668
649
      paintDash (18,2,&paint);
669
650
      }
670
651
    }
 
652
  }
 
653
 
 
654
 
 
655
void KNutDock::paintChargePictureKI (QPainter &paint, int charge ) {
 
656
 
 
657
  if (charge != knc::numberVarError) {
 
658
    if (m_batteryChargeValue < 40) paint.setPen(Qt::red);
 
659
    else paint.setPen(m_textColor);
 
660
    
 
661
    paintNumbers(m_batteryChargeValue,-2,15,&paint);
 
662
    
 
663
    if (m_batteryChargeValue < 40) paint.setPen(Qt::red);
 
664
    else paint.setPen(Qt::green);
 
665
 
 
666
    int delka = abs((16*m_batteryChargeValue)/100);
 
667
    delka += abs((delka-1)/4) -1;
 
668
    paint.drawLine (1,7,1+delka,7);
 
669
    paint.drawLine (1,8,1+delka,8);
 
670
    paint.drawLine (1,9,1+delka,9);
 
671
    
 
672
    paint.setPen(m_textColor);
 
673
 
 
674
    paint.drawLine (5,6,5,10);
 
675
    paint.drawLine (10,6,10,10);
 
676
    paint.drawLine (15,6,15,10);
 
677
 
 
678
    }
671
679
  else {
672
 
    // picture version
673
 
    if (charge != knc::numberVarError) {
674
 
      if (charge < 40) paint.setPen(Qt::red);
675
 
      else paint.setPen(Qt::black);
676
 
      paintNumbers(charge,-2,16,&paint);
677
 
 
678
 
      if (charge < 40) paint.setPen(Qt::red);
679
 
      else {
680
 
        if (charge < 50) paint.setPen(Qt::yellow);
681
 
        else paint.setPen(Qt::green);
682
 
        }
683
 
      int delka = abs((16*charge)/100);
684
 
      delka += abs((delka-1)/4) -1;
685
 
      paint.drawLine (2,7,2+delka,7);
686
 
      paint.drawLine (2,8,2+delka,8);
687
 
      paint.drawLine (2,9,2+delka,9);
688
 
      }
689
 
    else {
690
 
      paint.setPen(Qt::black);
691
 
      paintDash (3,16,&paint);
692
 
      paintDash (8,16,&paint);
693
 
      }
694
 
 
 
680
    paint.setPen(m_textColor);
 
681
    paintDash (3,15,&paint);
 
682
    paintDash (8,15,&paint);
695
683
    }
696
 
  paint.end();
697
 
  }
698
 
 
 
684
}
699
685
 
700
686
void KNutDock::paintErrorPoint ( QPainter& paint ) {
701
687
 
702
 
  paint.setPen(QColor(0,0,255));
 
688
//  paint.setPen(QColor(0,0,255));
703
689
  paint.setPen(QColor(255,0,0));
704
690
 
 
691
  paint.drawLine(19,17,21,17);
705
692
  paint.drawLine(19,18,21,18);
706
693
  paint.drawLine(19,19,21,19);
707
 
  paint.drawLine(19,20,21,20);
708
694
  }
709
695
 
710
 
 
711
696
void KNutDock::paintOKPoint (QPainter& paint  ) {
712
697
 
713
698
  paint.setPen(QColor(0,255,0));
 
699
  paint.drawLine(19,17,21,17);
714
700
  paint.drawLine(19,18,21,18);
715
701
  paint.drawLine(19,19,21,19);
716
 
  paint.drawLine(19,20,21,20);
717
702
  }
718
703
 
719
704
 
720
 
void KNutDock::paintStatus (int status ) {
721
 
  QPainter paint;
 
705
void KNutDock::paintStatus (QPainter &paint, int status ) {
 
706
 
722
707
  int lastPos = 0;
723
708
 
724
 
  m_statusLayer->fill(Qt::white);
725
 
  paint.begin(m_statusLayer);
726
 
 
727
709
  if (status & KNutNet::OL) {
728
 
    paint.setPen(Qt::black);
 
710
    paint.setPen(m_textColor);
729
711
    paintChar (1,2,'P',&paint);
730
712
    }
731
713
  else {
759
741
    paintChar (6,2,'C',&paint);
760
742
    lastPos++;
761
743
    }
762
 
  paint.end();
763
744
  }
764
745
 
765
 
void KNutDock::paintRuntime (int runtime, int status ) {
766
 
  QPainter paint;
767
 
 
768
 
  m_runtimeLayer->fill(Qt::white);
769
 
  paint.begin(m_runtimeLayer);
 
746
void KNutDock::paintRuntime (QPainter &paint, int runtime, int status ) {
770
747
 
771
748
  if (status & KNutNet::OB)
772
749
    paint.setPen(Qt::red);
773
750
  else
774
 
    paint.setPen(Qt::black);
 
751
    paint.setPen(m_textColor);
 
752
 
775
753
  if (runtime != knc::numberVarError) {
776
754
 
777
755
    int min = abs(runtime/60);
788
766
    paintDash (13,11,&paint);
789
767
    paintDash (18,11,&paint);
790
768
    }
 
769
 
791
770
  paint.drawLine (11,12,11,13);
792
771
  paint.drawLine (11,15,11,16);
793
 
  paint.end();
794
772
  }
795
773
 
796
 
void KNutDock::paintLoad (int load ) {
797
 
  QPainter paint;
 
774
void KNutDock::paintLoadGeneralKI (QPainter &paint,  int load ) {
798
775
  int myLoad;
799
776
 
800
 
//  if (m_typeOfIcon != generalKI) bitBlt (m_loadLayer,0,0,m_upsLayer,0,0,24,24,AndROP);
801
 
  m_loadLayer->fill(Qt::white);
802
 
  paint.begin(m_loadLayer);
803
777
  if (load == knc::numberVarError) myLoad=0;
804
778
  else myLoad = abs(load/10);
805
779
 
808
782
      if (myLoad > 11) myLoad=11;
809
783
      if (myLoad < 9) paint.setPen(Qt::green);
810
784
      else {
811
 
      if (myLoad < 11) paint.setPen(Qt::yellow);
812
 
      else paint.setPen(Qt::red);
813
 
      }
814
 
    paint.setPen(Qt::green.light(60));
815
 
    for (int i = 0; i < myLoad; i++) {
816
 
      paint.drawLine((i*2)+1,19,(i*2)+1,21);
817
 
      }
818
 
    paint.setPen(Qt::cyan.light(150));
 
785
        if (myLoad < 11) paint.setPen(Qt::yellow);
 
786
        else paint.setPen(Qt::red);
 
787
        }
 
788
      paint.setPen(QColor(Qt::green).light(60));
 
789
      for (int i = 0; i < myLoad; i++) {
 
790
        paint.drawLine((i*2)+1,19,(i*2)+1,21);
 
791
        }
 
792
      paint.setPen(QColor(Qt::cyan).light(150));
819
793
      for (int i = myLoad; i < 11; i++) {
820
794
        paint.drawLine((i*2)+1,19,(i*2)+1,21);
 
795
        }
821
796
      }
822
797
    }
823
798
  }
824
 
  paint.end();
825
 
 
826
 
  }
827
799
 
828
800
 
829
801
 
848
820
 
849
821
    }
850
822
  else {
851
 
    p->setPen(Qt::black);
 
823
    p->setPen(m_textColor);
852
824
    paintDash (x+5,y,p);
853
825
    paintDash (x+10,y,p);
854
826
    }
867
839
   // painting - kreslim
868
840
    switch (number) {
869
841
      case 0:
870
 
      p->drawRect(x,y,4,7);
 
842
      p->drawRect(x,y,3,6);
871
843
      break;
872
844
      case 1:
873
845
        p->drawLine (x+3,y,x+3,y+6);
874
846
      break;
875
847
      case 2:
876
848
        p->drawLine(x,y,x+3,y);
877
 
        p->lineTo(x+3,y+3);
878
 
        p->lineTo(x,y+3);
879
 
        p->lineTo(x,y+6);
880
 
        p->lineTo(x+3,y+6);
 
849
        p->drawLine(x+3,y,x+3,y+3);
 
850
        p->drawLine(x+3,y+3,x,y+3);
 
851
        p->drawLine(x,y+3,x,y+6);
 
852
        p->drawLine(x,y+6,x+3,y+6);
881
853
      break;
882
854
      case 3:
883
855
        p->drawLine(x,y,x+3,y);
884
 
        p->lineTo(x+3,y+6);
885
 
        p->lineTo(x,y+6);
 
856
        p->drawLine(x+3,y,x+3,y+6);
 
857
        p->drawLine(x+3,y+6,x,y+6);
886
858
        p->drawLine(x,y+3,x+3,y+3);
887
859
      break;
888
860
      case 4:
889
861
        p->drawLine(x,y,x,y+3);
890
 
        p->lineTo(x+3,y+3);
 
862
        p->drawLine(x,y+3,x+3,y+3);
891
863
        p->drawLine (x+3,y,x+3,y+6);
892
864
      break;
893
865
      case 5:
894
866
        p->drawLine(x+3,y,x,y);
895
 
        p->lineTo(x,y+3);
896
 
        p->lineTo(x+3,y+3);
897
 
        p->lineTo(x+3,y+6);
898
 
        p->lineTo(x,y+6);
 
867
        p->drawLine(x,y,x,y+3);
 
868
        p->drawLine(x,y+3,x+3,y+3);
 
869
        p->drawLine(x+3,y+3,x+3,y+6);
 
870
        p->drawLine(x+3,y+6,x,y+6);
899
871
      break;
900
872
      case 6:
901
 
        p->drawRect(x,y+3,4,4);
 
873
        p->drawRect(x,y+3,3,3);
902
874
        p->drawLine(x,y+3,x,y);
903
 
        p->lineTo(x+3,y);
 
875
        p->drawLine(x,y,x+3,y);
904
876
      break;
905
877
      case 7:
906
878
        p->drawLine(x,y,x+3,y);
907
 
        p->lineTo(x+3,y+6);
 
879
        p->drawLine(x+3,y,x+3,y+6);
908
880
      break;
909
881
      case 8:
910
 
        p->drawRect(x,y,4,7);
 
882
        p->drawRect(x,y,3,6);
911
883
        p->drawLine(x,y+3,x+3,y+3);
912
884
      break;
913
885
      case 9:
914
 
        p->drawRect(x,y,4,4);
 
886
        p->drawRect(x,y,3,3);
915
887
        p->drawLine(x+3,y+3,x+3,y+6);
916
 
        p->lineTo(x,y+6);
 
888
        p->drawLine(x+3,y+6,x,y+6);
917
889
      break;
918
890
      }
919
891
    } 
925
897
  switch (LCDChar) {
926
898
    case 'L':
927
899
      p->drawLine(x,y,x,y+6);
928
 
      p->lineTo(x+3,y+6);
 
900
      p->drawLine(x,y+6,x+3,y+6);
929
901
    break;
930
902
    case 'O':
931
903
      p->drawRect(x,y,4,7);
932
904
    break;
933
905
    case 'B':
934
906
      p->drawLine(x,y,x,y+6);
935
 
      p->lineTo(x+2,y+6);
 
907
      p->drawLine(x,y+6,x+2,y+6);
936
908
      p->drawLine(x,y,x+2,y);
937
909
      p->drawLine(x,y+3,x+2,y+3);
938
910
      p->drawLine(x+3,y+1,x+3,y+2);
940
912
    break;
941
913
    case 'U':
942
914
      p->drawLine(x,y,x,y+6);
943
 
      p->lineTo(x+3,y+6);
944
 
      p->lineTo(x+3,y);
 
915
      p->drawLine(x,y+6,x+3,y+6);
 
916
      p->drawLine(x+3,y+6,x+3,y);
945
917
    break;
946
918
    case 'C':
947
919
      p->drawLine(x+3,y+1,x+3,y);
948
 
      p->lineTo(x,y);
949
 
      p->lineTo(x,y+6);
950
 
      p->lineTo(x+3,y+6);
951
 
      p->lineTo(x+3,y+5);
 
920
      p->drawLine(x+3,y,x,y);
 
921
      p->drawLine(x,y,x,y+6);
 
922
      p->drawLine(x,y+6,x+3,y+6);
 
923
      p->drawLine(x+3,y+6,x+3,y+5);
952
924
    break;
953
925
    case 'R':
954
926
      p->drawLine(x,y,x,y+6);
972
944
 
973
945
 
974
946
 
975
 
 
976
947
#include "knutdock.moc"