~ubuntu-branches/ubuntu/utopic/knutclient/utopic

« back to all changes in this revision

Viewing changes to src/knutfrontpanel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Quette
  • Date: 2008-06-19 11:09:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080619110950-izi2q2vd0dhwlpym
Tags: 0.9.4-1
* New upstream release
* Merge back Ubuntu changes
* debian/knutclient.menu: update section to fix lintian warnings
* debian/watch: update the pattern for matching new releases (Closes: #471247)
* debian/control:
  - move Homepage to the field and update the URL
  - update Standards-Version to 3.8.0
  - update debhelper Build-Depends to 5.0.51
  - add automake and autoconf to Build-Depends
  - update NUT URL
* debian/rules:
  - fix lintian warning debian-rules-ignores-make-clean-error
  - add a commented call to dh_icons

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          knutfrontpanel.cpp  -  description
 
3
                             -------------------
 
4
    begin                : Tue Aug 21 2001
 
5
    copyright            : (C) 2001 by Daniel Prynych
 
6
    email                : Daniel.Prynych@alo.cz
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
 
 
19
#include "knutfrontpanel.h"
 
20
#include "knutvardata.h"
 
21
#include "knutnet.h"
 
22
 
 
23
#include <klocale.h>
 
24
#include <kapp.h>
 
25
 
 
26
#include <qtooltip.h>
 
27
#include <qstring.h>
 
28
#include <qpaintdevice.h>
 
29
#include <qlayout.h>
 
30
#include <qlcdnumber.h>
 
31
//#include <qframe.h>
 
32
#include <qlabel.h>
 
33
#include <qcolor.h>
 
34
#include <qfont.h>
 
35
#include <qpalette.h>
 
36
#include <qgroupbox.h>
 
37
 
 
38
#include <math.h>
 
39
 
 
40
KNutFrontPanel::KNutFrontPanel( QPalette* const paletteIn, QWidget *parent, const unsigned int flags, QFont* const panelFonts, const char *name) : QFrame( parent, name ), m_panelFlags(flags) {
 
41
 
 
42
  m_myPalette = paletteIn->copy(); // makes deep copy of palette
 
43
  m_upsOkColor = Qt::green;
 
44
  m_upsErrorColor = Qt::red;
 
45
  m_upsBackColor = Qt::white; //backgroundColor();
 
46
  m_helpColor = Qt::black;
 
47
  m_typeOfLCDColor=true;
 
48
  m_LCDNumber1 = 0;
 
49
 
 
50
 
 
51
  setFrameStyle( QFrame::Box | QFrame::Raised );
 
52
  setLineWidth( 2 );
 
53
 
 
54
  if (panelFonts == 0) {
 
55
    m_panelFont =kapp->font(); // sets font - system font
 
56
    m_panelBoldFont = kapp->font();
 
57
    }
 
58
  else {
 
59
    m_panelFont = *panelFonts; // sets font / our selected font
 
60
    m_panelBoldFont = *panelFonts; // change later
 
61
    }
 
62
  m_panelBoldFont.setBold (TRUE);
 
63
  m_panelFont.setBold (FALSE); // sets no bold
 
64
 
 
65
  m_mainLayout = new QVBoxLayout(this);
 
66
  m_mainLayout->setMargin ( 10 );
 
67
  m_mainLayout->setSpacing ( 10 );
 
68
 
 
69
  // layer for bulbs
 
70
 
 
71
  m_bulbsGroupBox = new QGroupBox(this);
 
72
  m_mainLayout->addWidget(m_bulbsGroupBox);
 
73
  m_bulbsGroupBox->setFrameStyle( QFrame::Panel + QFrame::Raised);
 
74
//  m_bulbsGroupBox->setFrameStyle( QFrame::Panel + QFrame::Sunken);
 
75
  m_bulbsGroupBox->setLineWidth(2);
 
76
  QVBoxLayout* bulbsLayout = new QVBoxLayout(m_bulbsGroupBox);
 
77
  bulbsLayout->setMargin( 5 );
 
78
 
 
79
 
 
80
  m_textLabel1 = new QLabel( i18n("UPS On line"),m_bulbsGroupBox);
 
81
  m_frameOL = new KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
82
  m_frameOL->setMaximumSize(30,30);
 
83
  m_frameOL->setMinimumSize(25,25);
 
84
  QToolTip::add(m_textLabel1,m_textLabel1->text());
 
85
 
 
86
  QHBoxLayout* OLLayout = new QHBoxLayout(bulbsLayout);
 
87
  OLLayout->addWidget(m_textLabel1);
 
88
  OLLayout->addSpacing(10); 
 
89
  OLLayout->addWidget(m_frameOL);
 
90
  OLLayout->setMargin (3);
 
91
  OLLayout->setStretchFactor(m_textLabel1,20);
 
92
  OLLayout->setStretchFactor(m_frameOL,5);
 
93
 
 
94
 
 
95
  m_textLabel2 = new QLabel( i18n("UPS On battery"), m_bulbsGroupBox);
 
96
  m_frameOB = new KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
97
  m_frameOB->setMaximumSize(30,30);
 
98
  m_frameOB->setMinimumSize(25,25);
 
99
  QToolTip::add(m_textLabel2,m_textLabel2->text());
 
100
 
 
101
  QHBoxLayout* OBLayout = new QHBoxLayout(bulbsLayout);
 
102
  OBLayout->addWidget(m_textLabel2);
 
103
  OBLayout->addSpacing(10); 
 
104
  OBLayout->addWidget(m_frameOB);
 
105
  OBLayout->setMargin (3);
 
106
  OBLayout->setStretchFactor(m_textLabel2,20);
 
107
  OBLayout->setStretchFactor(m_frameOB,5);
 
108
 
 
109
 
 
110
  m_textLabel3 = new QLabel( i18n("UPS Overload"), m_bulbsGroupBox);
 
111
  m_frameOVER = new  KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
112
  m_frameOVER->setMaximumSize(30,30);
 
113
  m_frameOVER->setMinimumSize(25,25);
 
114
  QToolTip::add(m_textLabel3,m_textLabel3->text());
 
115
 
 
116
  m_OLayout = new QHBoxLayout(bulbsLayout);
 
117
  m_OLayout->addWidget(m_textLabel3);
 
118
  m_OLayout->addSpacing(10); 
 
119
  m_OLayout->addWidget(m_frameOVER);
 
120
  m_OLayout->setMargin (3);
 
121
  m_OLayout->setStretchFactor(m_textLabel3,20);
 
122
  m_OLayout->setStretchFactor(m_frameOVER,5);
 
123
 
 
124
  m_textLabel4 = new QLabel( i18n("UPS Battery low"), m_bulbsGroupBox);
 
125
  m_frameLB = new  KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
126
  m_frameLB->setMaximumSize(30,30);
 
127
  m_frameLB->setMinimumSize(25,25);
 
128
  QToolTip::add(m_textLabel4,m_textLabel4->text());
 
129
 
 
130
  m_LBLayout = new QHBoxLayout(bulbsLayout);
 
131
  m_LBLayout->addWidget(m_textLabel4);
 
132
  m_LBLayout->addSpacing(10); 
 
133
  m_LBLayout->addWidget(m_frameLB);
 
134
  m_LBLayout->setMargin (3);
 
135
  m_LBLayout->setStretchFactor(m_textLabel4,20);
 
136
  m_LBLayout->setStretchFactor(m_frameLB,5);
 
137
 
 
138
  m_textLabel5 = new QLabel( i18n("Replace battery"), m_bulbsGroupBox);
 
139
  m_frameRB = new  KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
140
  m_frameRB->setMaximumSize(30,30);
 
141
  m_frameRB->setMinimumSize(25,25);
 
142
  QToolTip::add(m_textLabel5,m_textLabel5->text());
 
143
 
 
144
  m_RBLayout = new QHBoxLayout(bulbsLayout);
 
145
  m_RBLayout->addWidget(m_textLabel5);
 
146
  m_RBLayout->addSpacing(10); 
 
147
  m_RBLayout->addWidget(m_frameRB);
 
148
  m_RBLayout->setMargin (3);
 
149
  m_RBLayout->setStretchFactor(m_textLabel5,20);
 
150
  m_RBLayout->setStretchFactor(m_frameRB,5);
 
151
 
 
152
  m_textLabel6 = new QLabel( i18n("UPS calibration"), m_bulbsGroupBox);
 
153
  m_frameCAL = new  KLed (m_upsBackColor,KLed::Off,KLed::Sunken,KLed::Circular,m_bulbsGroupBox);
 
154
  m_frameCAL->setMaximumSize(30,30);
 
155
  m_frameCAL->setMinimumSize(25,25);
 
156
  QToolTip::add(m_textLabel6,m_textLabel6->text());
 
157
 
 
158
  m_CALLayout = new QHBoxLayout(bulbsLayout);
 
159
  m_CALLayout->addWidget(m_textLabel6);
 
160
  m_CALLayout->addSpacing(10); 
 
161
  m_CALLayout->addWidget(m_frameCAL);
 
162
  m_CALLayout->setMargin (3);
 
163
  m_CALLayout->setStretchFactor(m_textLabel6,20);
 
164
  m_CALLayout->setStretchFactor(m_frameCAL,5);
 
165
 
 
166
 
 
167
  m_messGroupBox = new QGroupBox(this);
 
168
  m_mainLayout->addWidget(m_messGroupBox);
 
169
  m_messGroupBox->setFrameStyle( QFrame::Panel + QFrame::Raised);
 
170
//  m_messGroupBox->setFrameStyle( QFrame::Panel + QFrame::Sunken);
 
171
  m_messGroupBox->setLineWidth(2);
 
172
  QVBoxLayout* messLayout = new QVBoxLayout(m_messGroupBox);
 
173
  messLayout->setMargin( 3 );
 
174
 
 
175
 
 
176
  m_textLabel7 = new QLabel( "", m_messGroupBox);
 
177
  QToolTip::add(m_textLabel7,m_textLabel7->text());
 
178
  m_manufacModelLayout = new QHBoxLayout(messLayout);
 
179
  m_manufacModelLayout->addWidget(m_textLabel7);
 
180
  m_manufacModelLayout->setMargin ( 3 );
 
181
 
 
182
  m_textLabelManufac = new QLabel( i18n("Manufac. : "), m_messGroupBox);
 
183
  m_textLabel8 = new QLabel( "", m_messGroupBox);
 
184
  QToolTip::add(m_textLabelManufac,m_textLabelManufac->text());
 
185
 
 
186
  m_manufacLayout = new QHBoxLayout(messLayout);
 
187
  m_manufacLayout->addWidget(m_textLabelManufac);
 
188
  m_manufacLayout->addWidget(m_textLabel8);
 
189
  m_manufacLayout->addStretch(20);
 
190
  m_manufacLayout->setMargin ( 3 );
 
191
 
 
192
  m_textLabelName = new QLabel( i18n("Name")+" : ", m_messGroupBox);
 
193
  m_textLabel9 = new QLabel( "", m_messGroupBox);
 
194
  QToolTip::add(m_textLabelName,m_textLabelName->text());
 
195
 
 
196
  m_nameLayout = new QHBoxLayout(messLayout);
 
197
  m_nameLayout->addWidget(m_textLabelName);
 
198
  m_nameLayout->addWidget(m_textLabel9);
 
199
  m_nameLayout->addStretch(20);
 
200
  m_nameLayout->setMargin ( 3 );
 
201
 
 
202
  m_textLabelSerial = new QLabel( i18n("Serial : "), m_messGroupBox);
 
203
  m_textLabel10 = new QLabel( "", m_messGroupBox);
 
204
  QToolTip::add(m_textLabelSerial,m_textLabelSerial->text());
 
205
 
 
206
  m_serialLayout = new QHBoxLayout(messLayout);
 
207
  m_serialLayout->addWidget(m_textLabelSerial);
 
208
  m_serialLayout->addWidget(m_textLabel10);
 
209
  m_serialLayout->addStretch(20);
 
210
  m_serialLayout->setMargin ( 3 );
 
211
 
 
212
  m_textLabelFirm = new QLabel( i18n("Firm. rev. : "), m_messGroupBox);
 
213
  m_textLabel11 = new QLabel( "", m_messGroupBox);
 
214
  QToolTip::add(m_textLabelFirm,m_textLabelFirm->text());
 
215
 
 
216
  m_firmLayout = new QHBoxLayout(messLayout);
 
217
  m_firmLayout->addWidget(m_textLabelFirm);
 
218
  m_firmLayout->addWidget(m_textLabel11);
 
219
  m_firmLayout->addStretch(20);
 
220
  m_firmLayout->setMargin ( 3 );
 
221
  
 
222
  
 
223
  m_valGroupBox = new QGroupBox(this);
 
224
  m_mainLayout->addWidget(m_valGroupBox);
 
225
  m_valGroupBox->setFrameStyle( QFrame::Panel + QFrame::Raised);
 
226
//  m_bulbsGroupBox->setFrameStyle( QFrame::Panel + QFrame::Sunken);
 
227
  m_valGroupBox->setLineWidth(2);
 
228
  QVBoxLayout* valLayout = new QVBoxLayout(m_valGroupBox);
 
229
  valLayout->setMargin( 3 );
 
230
 
 
231
  
 
232
  
 
233
  m_textLabelRun = new QLabel( i18n("Runtime")+" : ", m_valGroupBox);
 
234
  QToolTip::add(m_textLabelRun,m_textLabelRun->text());
 
235
 
 
236
  m_LCDNumber1 = new QLCDNumber (5,m_valGroupBox);
 
237
  m_LCDNumber1->setSegmentStyle (QLCDNumber::Flat);
 
238
  m_LCDNumber1->setFrameStyle( QFrame::NoFrame );
 
239
  m_LCDNumber1->setMinimumSize(50,20);
 
240
 
 
241
  m_runLayout = new QHBoxLayout(valLayout);
 
242
  m_runLayout->addWidget(m_textLabelRun);
 
243
  m_runLayout->addStretch(20);
 
244
  m_runLayout->addWidget(m_LCDNumber1);
 
245
  m_runLayout->setMargin ( 5 );
 
246
 
 
247
  m_mainLayout->addStretch(20);
 
248
  m_mainLayout->addSpacing(5);
 
249
 
 
250
  setAllPalettes();
 
251
 
 
252
  changePanelFont();
 
253
  paintPanel ();
 
254
 
 
255
  }
 
256
 
 
257
KNutFrontPanel::~KNutFrontPanel(){
 
258
  }
 
259
 
 
260
 
 
261
//************************************************************
 
262
 
 
263
void KNutFrontPanel::paintPanel( void ) {
 
264
 
 
265
  if (m_panelFlags & PBOnLine) {
 
266
    m_textLabel1->show();
 
267
    m_frameOL->show();
 
268
    }
 
269
  else {
 
270
    m_textLabel1->hide();
 
271
    m_frameOL->hide();
 
272
    }
 
273
 
 
274
  if (m_panelFlags & PBOnBatt) {
 
275
    m_textLabel2->show();
 
276
    m_frameOB->show();
 
277
    }
 
278
  else {
 
279
    m_textLabel2->hide();
 
280
    m_frameOB->hide();
 
281
    }
 
282
 
 
283
  if (m_panelFlags & PBOver) {
 
284
    m_OLayout->setMargin ( 3 );
 
285
    m_textLabel3->show();
 
286
    m_frameOVER->show();
 
287
    }
 
288
  else {
 
289
    m_textLabel3->hide();
 
290
    m_frameOVER->hide();
 
291
    m_OLayout->setMargin ( 0 );
 
292
    }
 
293
 
 
294
  if (m_panelFlags & PBBattLow) {
 
295
    m_textLabel4->show();
 
296
    m_frameLB->show();
 
297
    m_LBLayout->setMargin ( 3 );
 
298
    }
 
299
  else {
 
300
    m_textLabel4->hide();
 
301
    m_frameLB->hide();
 
302
    m_LBLayout->setMargin ( 0 );
 
303
    }
 
304
 
 
305
  if (m_panelFlags & PBRepBatt) {
 
306
    m_textLabel5->show();
 
307
    m_frameRB->show();
 
308
    m_RBLayout->setMargin ( 3 );
 
309
    }
 
310
  else {
 
311
    m_textLabel5->hide();
 
312
    m_frameRB->hide();
 
313
    m_RBLayout->setMargin ( 0 );
 
314
    }
 
315
 
 
316
  if (m_panelFlags & PBCal) {
 
317
    m_textLabel6->show();
 
318
    m_frameCAL->show();
 
319
    m_CALLayout->setMargin ( 3 );
 
320
    }
 
321
  else {
 
322
    m_textLabel6->hide();
 
323
    m_frameCAL->hide();
 
324
    m_CALLayout->setMargin ( 0 );
 
325
    }
 
326
 
 
327
  if (m_panelFlags & PBMFRMod) {
 
328
    m_textLabel7->show();
 
329
    m_manufacModelLayout->setMargin ( 5 );
 
330
    }
 
331
  else {
 
332
    m_textLabel7->hide();
 
333
    m_manufacModelLayout->setMargin ( 0 );
 
334
    }
 
335
 
 
336
 
 
337
  if (m_panelFlags & PBMFR) {
 
338
    m_textLabel8->show();
 
339
    m_textLabelManufac->show();
 
340
    m_manufacLayout->setMargin ( 5 );
 
341
    }
 
342
  else {
 
343
    m_textLabel8->hide();
 
344
    m_textLabelManufac->hide();
 
345
    m_manufacLayout->setMargin ( 0 );
 
346
    }
 
347
 
 
348
  if (m_panelFlags & PBModel) {
 
349
    m_textLabel9->show();
 
350
    m_textLabelName->show();
 
351
    m_nameLayout->setMargin ( 5 );
 
352
    }
 
353
  else {
 
354
    m_textLabel9->hide();
 
355
    m_textLabelName->hide();
 
356
    m_nameLayout->setMargin ( 0 );
 
357
    }
 
358
 
 
359
  if (m_panelFlags & PBSerial) {
 
360
    m_textLabel10->show();
 
361
    m_textLabelSerial->show();
 
362
    m_serialLayout->setMargin ( 5 );
 
363
    }
 
364
  else {
 
365
    m_textLabel10->hide();
 
366
    m_textLabelSerial->hide();
 
367
    m_serialLayout->setMargin ( 0 );
 
368
    }
 
369
 
 
370
  if (m_panelFlags & PBFirm) {
 
371
    m_textLabel11->show();
 
372
    m_textLabelFirm->show();
 
373
    m_firmLayout->setMargin ( 5 );
 
374
    }
 
375
  else {
 
376
    m_textLabel11->hide();
 
377
    m_textLabelFirm->hide();
 
378
    m_firmLayout->setMargin ( 0 );
 
379
    }
 
380
 
 
381
if ( (m_panelFlags & PBMFRMod) || (m_panelFlags & PBMFR) || (m_panelFlags & PBModel) || (m_panelFlags & PBSerial) ||(m_panelFlags & PBFirm))    
 
382
   m_messGroupBox->show();
 
383
else
 
384
  m_messGroupBox->hide();
 
385
      
 
386
  if (m_panelFlags & PBRun) {
 
387
//    LCDNumber1->show();
 
388
//    textLabelRun->show();
 
389
//    runLayout->setMargin ( 5 );
 
390
    m_valGroupBox->show();
 
391
    }
 
392
  else {
 
393
//    LCDNumber1->hide();
 
394
//    textLabelRun->hide();
 
395
//    runLayout->setMargin ( 0 );
 
396
    m_valGroupBox->hide();
 
397
    }
 
398
  }
 
399
 
 
400
 
 
401
int KNutFrontPanel::getPanelHeight( void) { return 0; }  ///// correct !!!!!!!!
 
402
 
 
403
unsigned int KNutFrontPanel::getPanelFlags( void) { return m_panelFlags; }
 
404
 
 
405
void KNutFrontPanel::setPanelFlags(const int upsPanelFlags) { m_panelFlags = upsPanelFlags; }
 
406
 
 
407
void KNutFrontPanel::setAllNameUps(const QString panelUpsAllName ){
 
408
  m_textLabel7->setText(panelUpsAllName);
 
409
  QToolTip::remove(m_textLabel7);
 
410
  QToolTip::add(m_textLabel7,panelUpsAllName);
 
411
  }
 
412
 
 
413
void KNutFrontPanel::setMFRUps(const QString panelUpsFRM ){
 
414
  m_textLabel8->setText(panelUpsFRM);
 
415
  QToolTip::remove(m_textLabelManufac);
 
416
  QToolTip::add(m_textLabelManufac,m_textLabelManufac->text()+panelUpsFRM);
 
417
  }
 
418
 
 
419
void KNutFrontPanel::setNameUps(const QString panelUpsName ){
 
420
  m_textLabel9->setText(panelUpsName);
 
421
  QToolTip::remove(m_textLabelName);
 
422
  QToolTip::add(m_textLabelName,m_textLabelName->text()+panelUpsName);
 
423
  }
 
424
 
 
425
void KNutFrontPanel::setSerialUps(const QString panelUpsSerial ){
 
426
  m_textLabel10->setText(panelUpsSerial);
 
427
  QToolTip::remove(m_textLabelSerial);
 
428
  QToolTip::add(m_textLabelSerial,m_textLabelSerial->text()+panelUpsSerial);
 
429
  }
 
430
 
 
431
void KNutFrontPanel::setFirmRevUps(const QString upsPanelFormRev ){
 
432
  m_textLabel11->setText(upsPanelFormRev);
 
433
  QToolTip::remove(m_textLabelFirm);
 
434
  QToolTip::add(m_textLabelFirm,m_textLabelFirm->text()+upsPanelFormRev);
 
435
  }
 
436
 
 
437
 
 
438
void KNutFrontPanel::cleanPanel(void) {
 
439
  m_textLabel7->setText("");
 
440
  m_textLabel8->setText("");
 
441
  m_textLabel9->setText("");
 
442
  m_textLabel10->setText("");
 
443
  m_textLabel11->setText("");
 
444
 
 
445
  m_frameOL->setColor(m_upsBackColor);
 
446
  m_frameOL->off();
 
447
  m_frameOB->setColor(m_upsBackColor);
 
448
  m_frameOB->off();
 
449
  m_frameOVER->setColor(m_upsBackColor);
 
450
  m_frameOVER->off();
 
451
  m_frameLB->setColor(m_upsBackColor);
 
452
  m_frameLB->off();
 
453
  m_frameRB->setColor(m_upsBackColor);
 
454
  m_frameRB->off();
 
455
  m_frameCAL->setColor(m_upsBackColor);
 
456
  m_frameCAL->off();
 
457
 
 
458
  m_LCDNumber1->display("-:--");
 
459
  m_LCDNumber1->setPalette (palette());
 
460
  }
 
461
 
 
462
void KNutFrontPanel::setRuntime(const int runtime) {
 
463
  QString runtimeString;
 
464
 
 
465
  if (runtime != knc::numberVarError) {
 
466
    int min = (int)floor(runtime/60);
 
467
    int sec = runtime - (min*60);
 
468
    runtimeString=QString("%1:%2").arg(min,2).arg(sec,2);
 
469
    if (runtimeString[3] == ' ') runtimeString[3]='0';
 
470
    }
 
471
  else runtimeString="-:--";  
 
472
 
 
473
  m_LCDNumber1->display(runtimeString);
 
474
  }
 
475
 
 
476
  
 
477
 
 
478
void KNutFrontPanel::setPanel(const int panelBulbs) {
 
479
//  OFF                 - 1 ups je vypnuta
 
480
//  OL                  - 2 ups je bezi na sit
 
481
//  OB                  - 4 ups bezi na baterie
 
482
//  LB                  - 8 baterie je vybyta (pokud je zaroven OB dojde k shutdownu)
 
483
//  CAL                 - 16 je spustena calibrace
 
484
//  OVER                - 128 ups je pretizena
 
485
//  RB                  - 256 ups pozaduje vymenu baterie
 
486
 
 
487
 
 
488
  if (!(panelBulbs < 0)) {
 
489
    // ups online /na sit
 
490
    if (panelBulbs & KNutNet::OL) {
 
491
      m_frameOL->setColor(m_upsOkColor);
 
492
      m_frameOL->on();
 
493
      m_LCDNumber1->setPalette (m_LCDPaletteOk);
 
494
      m_typeOfLCDColor=true;
 
495
      }
 
496
    else {
 
497
      m_frameOL->setColor(m_upsBackColor);
 
498
      m_frameOL->off();
 
499
      }
 
500
 
 
501
    // ups ofline /na baterie
 
502
    if (panelBulbs & KNutNet::OB) {
 
503
      m_frameOB->setColor(m_upsErrorColor);
 
504
      m_frameOB->on();
 
505
      m_LCDNumber1->setPalette (m_LCDPaletteErr);
 
506
      m_typeOfLCDColor=false;
 
507
      }
 
508
    else {
 
509
      m_frameOB->setColor(m_upsBackColor);
 
510
      m_frameOB->off();
 
511
      }
 
512
 
 
513
    if (panelBulbs & KNutNet::LB) {
 
514
      m_frameLB->setColor(m_upsErrorColor);
 
515
      m_frameLB->on();
 
516
      }
 
517
    else {
 
518
      m_frameLB->setColor(m_upsBackColor);
 
519
      m_frameLB->off();
 
520
      }
 
521
 
 
522
    if (panelBulbs & KNutNet::OVER) {
 
523
      m_frameOVER->setColor(m_upsErrorColor);
 
524
      m_frameOVER->on();
 
525
      }
 
526
    else {
 
527
      m_frameOVER->setColor(m_upsBackColor);
 
528
      m_frameOVER->off();
 
529
      }
 
530
 
 
531
    if (panelBulbs & KNutNet::RB) {
 
532
      m_frameRB->setColor(m_upsErrorColor);
 
533
      m_frameRB->on();
 
534
      }
 
535
    else {
 
536
      m_frameRB->setColor(m_upsBackColor);
 
537
      m_frameRB->off();
 
538
      }
 
539
 
 
540
    if (panelBulbs & KNutNet::CAL) {
 
541
      m_frameCAL->setColor(m_upsErrorColor);
 
542
      m_frameCAL->on();
 
543
      }
 
544
    else {
 
545
      m_frameCAL->setColor(m_upsBackColor);
 
546
      m_frameCAL->off();
 
547
      }
 
548
    }
 
549
  }
 
550
 
 
551
  
 
552
/*********************************************************************************************/
 
553
/*                                                                                           */
 
554
/*                         PUBLIC SLOTS                                                      */
 
555
/*                                                                                           */
 
556
/*********************************************************************************************/
 
557
  
 
558
  
 
559
void KNutFrontPanel::slotSetPanelFont(QFont newPanelFont) {
 
560
 
 
561
  m_panelFont = newPanelFont; // nastavime font
 
562
  m_panelBoldFont = newPanelFont; // pozdeji zmenime
 
563
 
 
564
  m_panelBoldFont.setBold (TRUE);
 
565
  m_panelFont.setBold (FALSE); // Zrusime bold u panelu
 
566
 
 
567
  changePanelFont(); // zmeni pismo
 
568
  paintPanel();
 
569
  }
 
570
 
 
571
  
 
572
/*********************************************************************************************/
 
573
/*                                                                                           */
 
574
/*                         PRIVATE FUNCTIONS                                                 */
 
575
/*                                                                                           */
 
576
/*********************************************************************************************/
 
577
  
 
578
  
 
579
void KNutFrontPanel::setLCDPalette (void) {
 
580
  m_LCDPaletteOk = m_myPalette;
 
581
  m_LCDPaletteErr = m_myPalette;
 
582
  //Nastavime barvu pro OK system je online
 
583
  QColorGroup activeColorGroup = m_LCDPaletteOk.active();
 
584
  activeColorGroup.setColor( QColorGroup::Foreground, green);
 
585
 
 
586
  m_LCDPaletteOk.setActive(activeColorGroup);
 
587
  m_LCDPaletteOk.setInactive(activeColorGroup);
 
588
 
 
589
  //Nastavime Barvu pro Error - System neni online
 
590
  activeColorGroup = m_LCDPaletteErr.active();
 
591
  activeColorGroup.setColor( QColorGroup::Foreground, red);
 
592
  m_LCDPaletteErr.setActive(activeColorGroup);
 
593
  m_LCDPaletteErr.setInactive(activeColorGroup);
 
594
  }
 
595
 
 
596
void KNutFrontPanel::setPalette (const QPalette & p){
 
597
 
 
598
  m_myPalette = p;
 
599
  setAllPalettes();
 
600
  }
 
601
 
 
602
      
 
603
void KNutFrontPanel::setAllPalettes (void){
 
604
  QColor myColor;
 
605
 
 
606
  QFrame::setPalette (m_myPalette);
 
607
  //QColorGroup myColorGroup = myPalette.active();
 
608
  
 
609
//  LCDPaletteOk = myPalette;
 
610
//  LCDPaletteErr = myPalette;
 
611
 
 
612
  setLCDPalette();
 
613
  
 
614
  m_bulbsPalette = m_myPalette;
 
615
 
 
616
  m_frameOL->setPalette(m_bulbsPalette);
 
617
 
 
618
  // we must correct feature of KLed, KLed repaint background when color of item (function KLed::setColor()) is changed only
 
619
  // when we change palette backround only, KLed ignore this change
 
620
    
 
621
  myColor = m_frameOL->color();
 
622
  m_frameOL->setColor(m_helpColor); // black is neutral (unprofitable) color for us 
 
623
  m_frameOL->setColor(myColor); 
 
624
 
 
625
  myColor = m_frameOB->color();
 
626
  m_frameOB->setColor(m_helpColor);
 
627
  m_frameOB->setColor(myColor);
 
628
  
 
629
  myColor = m_frameLB->color();
 
630
  m_frameLB->setColor(m_helpColor);
 
631
  m_frameLB->setColor(myColor);
 
632
 
 
633
  myColor = m_frameOVER->color();
 
634
  m_frameOVER->setColor(m_helpColor);
 
635
  m_frameOVER->setColor(myColor);
 
636
 
 
637
  myColor = m_frameRB->color();
 
638
  m_frameRB->setColor(m_helpColor);
 
639
  m_frameRB->setColor(myColor);
 
640
 
 
641
  myColor = m_frameCAL->color();
 
642
  m_frameCAL->setColor(m_helpColor);
 
643
  m_frameCAL->setColor(myColor);
 
644
        
 
645
  
 
646
  if (m_LCDNumber1) {
 
647
    if (m_typeOfLCDColor)
 
648
      m_LCDNumber1->setPalette (m_LCDPaletteOk);
 
649
    else
 
650
      m_LCDNumber1->setPalette (m_LCDPaletteErr);
 
651
    }
 
652
  }
 
653
 
 
654
void KNutFrontPanel::changePanelFont (void) {
 
655
  m_textLabel1->setFont(m_panelFont);
 
656
  m_textLabel2->setFont(m_panelFont);
 
657
  m_textLabel3->setFont(m_panelFont);
 
658
  m_textLabel4->setFont(m_panelFont);
 
659
  m_textLabel5->setFont(m_panelFont);
 
660
  m_textLabel6->setFont(m_panelFont);
 
661
 
 
662
  m_textLabelManufac->setFont(m_panelFont);
 
663
  m_textLabelName->setFont (m_panelFont);
 
664
  m_textLabelSerial->setFont (m_panelFont);
 
665
  m_textLabelFirm->setFont (m_panelFont);
 
666
  m_textLabelRun->setFont (m_panelFont);
 
667
  m_textLabel7->setFont (m_panelBoldFont);
 
668
  m_textLabel8->setFont (m_panelBoldFont);
 
669
  m_textLabel9->setFont (m_panelBoldFont);
 
670
  m_textLabel10->setFont (m_panelBoldFont);
 
671
  m_textLabel11->setFont (m_panelBoldFont);
 
672
  m_textLabelRun->setFont (m_panelFont);
 
673
  }
 
674
 
 
675
  
 
676
#include "knutfrontpanel.moc"