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

« back to all changes in this revision

Viewing changes to src/knutdock.h

  • 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
                          knutdock.h  -  description
 
3
                             -------------------
 
4
    begin                : �t zari 23 2003
 
5
    copyright            : (C) 2003 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
#ifndef KNUTDOCK_H
 
19
#define KNUTDOCK_H
 
20
 
 
21
#include "knutupsdata.h"
 
22
#include "knutvardata.h"
 
23
#include "knutconst.h"
 
24
 
 
25
 
 
26
#include <ksystemtray.h>
 
27
#include <kpopupmenu.h>
 
28
 
 
29
#include <qobject.h>
 
30
 
 
31
 
 
32
class QString;
 
33
class QPixmap;
 
34
class QColor;
 
35
 
 
36
/**
 
37
 * This class makes icons in dock.
 
38
 * Tato trida zajistuje vytvoreni icony v docku.
 
39
 *
 
40
 * @author Daniel Prynych
 
41
 * @short Dock's icons
 
42
 * @version 0.3
 
43
  */
 
44
class KNutDock : public KSystemTray  {
 
45
  Q_OBJECT
 
46
  public:
 
47
 
 
48
  enum KNTDconst { DefaultToolTipFlags = 0x398};
 
49
 
 
50
 
 
51
  enum upsConnection {
 
52
   idle, // ups isn't connected
 
53
   connecting, // ups is connecting
 
54
   ok, // ups is connected
 
55
   error // error of connecting
 
56
   };
 
57
 
 
58
  enum eTypeOfIcons { pictureKI = 0, generalKI};
 
59
 
 
60
 
 
61
  enum toolTipItems {
 
62
   TTMFR = 0x8, // 8,    // FRM
 
63
   TTModel = 0x10, // 16,    // Model
 
64
   TTSerial = 0x20, // 32,    // Serial
 
65
   TTFirm = 0x40, //64,    // Firmware Revision
 
66
   TTRun = 0x80,// 128,    // Runtime
 
67
   TTCharge = 0x100, // 256,    // Charge
 
68
   TTLoad = 0x200 // 512    // Load
 
69
   };
 
70
 
 
71
 
 
72
 
 
73
 
 
74
/**
 
75
 * Constructor - makes icon in dockbar.
 
76
 * Konstruktor - vytvori iconu v docku.
 
77
 *
 
78
 * @param  tActiveUpsInfo odkaz na structuru upsInfo
 
79
 * @param  tActiveUpsInfo pointer to structure upsInfo
 
80
 * @param  tSettingData  odkaz na strukturu typu SettingDataDef
 
81
 * @param  tSettingData  pointer to structure type of SettingDataDef
 
82
 * @param  tUpsRecord odkaz na instanci tridy tActiveUpsInfo
 
83
 * @param  tUpsRecord pointer to class tActiveUpsInfo
 
84
 * @since  0.2
 
85
 */
 
86
    KNutDock(struct upsInfo* tActiveUpsInfo, SettingDataDef* tSettingData, KNutUpsData* tUpsRecords);
 
87
 
 
88
/**
 
89
 * Destruktor.
 
90
 *
 
91
 * @since  0.1.2
 
92
 **/
 
93
    ~KNutDock();
 
94
 
 
95
 
 
96
/**
 
97
 * Nastavi zakladni nastaveni pro dock.
 
98
 * Sets basic setting for dock.
 
99
 *
 
100
 * @since  0.1
 
101
 **/
 
102
 void clearDockValues(void);
 
103
 
 
104
 
 
105
/**
 
106
 * Vytvori menu (seznam) UPS.
 
107
 * Makes menu (list) of UPS.
 
108
 *
 
109
 * @since  0.1
 
110
 **/
 
111
  void changeUps(void);
 
112
 
 
113
 
 
114
/**
 
115
 * Zmeni styl/typ icon
 
116
 * Changes style/type of icon
 
117
 *
 
118
 * @since  0.1
 
119
 **/
 
120
  void changeKIcon (void);
 
121
 
 
122
/**
 
123
 * Zmeni pozadi icony v kickeru
 
124
 * Changes background of icon in kicker
 
125
 *
 
126
 * @since  0.2
 
127
 **/
 
128
  void changeKIBColor(void);
 
129
 
 
130
 
 
131
/**
 
132
 * Zmeni prvky v tooltip-u
 
133
 * Changes items in toolTip
 
134
 *
 
135
 * @since  0.1
 
136
 **/
 
137
 void changeToolTip(void);
 
138
 
 
139
/**
 
140
 * Provede nove zpracovani dat a jejich nakresli iconu docku, interni repaint je volan vzdy.
 
141
 * Tato funkce take vola funkci ToolTip.
 
142
 * Makes new processing of data and paints icons of dock, internal repaint is colled always.
 
143
 * This function calls function ToolTips too.
 
144
 * @param always Kdyz je true prorovede vykresleni vzdy, kde je false provede vykresleni jen kdyz je zmenena nejaka hodnota UPS.
 
145
 * @param always When param is true, icon is made always, is one is false icon is makeing when same UPS's value is changed.
 
146
 *
 
147
 * @since  0.4
 
148
 **/
 
149
  void repaintDock ( const bool always = false);
 
150
 
 
151
 
 
152
 
 
153
/**
 
154
 * Nastavi v Menu oznaceni pro aktivni UPS.
 
155
 * Sets mark for active UPS in menu.
 
156
 *
 
157
 * @since  0.1
 
158
 **/
 
159
  void setNewUPS(void);
 
160
 
 
161
 
 
162
 
 
163
 
 
164
 signals:
 
165
/**This signal is emited when end of application was selected in menu.
 
166
 * Tento signal je vyslan pokud bylo vybrano v menu ukonceni aplikace.
 
167
 * 
 
168
 *
 
169
 * @since  0.1
 
170
 **/
 
171
  void endApplication(void);
 
172
 
 
173
/**
 
174
 * Tento signal je vyslan pokud bylo vybrano v menu minimalizace aplikace.
 
175
 * Tento signal is emited when minimize application was selected in menu.
 
176
 * 
 
177
 *
 
178
 * @since  0.1
 
179
 **/
 
180
  void minimize(void);
 
181
 
 
182
/**
 
183
 * Tento signal je vyslan pokud bylo vybrano v menu polozka preferences.
 
184
 * This signal is emited when item preferences was selected in menu.
 
185
 *
 
186
 * @since  0.1
 
187
 **/
 
188
  void preferences(void);
 
189
 
 
190
 
 
191
 
 
192
/**
 
193
 * Tento signal je vyslan pokud byla vybrana activace hlavniho okna (Main Window).
 
194
 *
 
195
 * @since  0.1
 
196
 **/
 
197
  void activeMainWindow(void);
 
198
 
 
199
 
 
200
/**
 
201
 * Tento signal je vyslan pokud bylo vybrano zobrazeni promennych;
 
202
 * This signal is emited when showing values was selected.
 
203
 *
 
204
 * @since  0.1
 
205
 **/
 
206
  void printUPSVars(void);
 
207
 
 
208
/**
 
209
 * Tento signal je vyslan pokud bylo vybrano provedeni okamziteho prikazu;
 
210
 * This signal is emited when running instant command was selected.
 
211
 *
 
212
 * @since  0.1
 
213
 **/
 
214
  void instComms(void);
 
215
 
 
216
/**
 
217
 * Tento signal je vyslan pokud bylo vybrana zmena RW promennych.
 
218
 * This signal is emited when change of RW values was selected.
 
219
 *
 
220
 * @since  0.1
 
221
 **/
 
222
  void RWVars(void);
 
223
 
 
224
/**
 
225
 * Tento signal je vyslan pokud bylo vybrana zmena RW promennych.
 
226
 * This signal is emited when refresh connection was selected
 
227
 *
 
228
 * @since  0.1
 
229
 **/
 
230
  void makeRefreshConnection(void);
 
231
 
 
232
 
 
233
/**
 
234
 * Tento signal je vyslan pokud je vybrana nova UPS;
 
235
 * This signal is emited when new UPS is selected
 
236
 *
 
237
 * @since  0.1
 
238
 **/
 
239
  void UPSChanged(QString name);
 
240
 
 
241
 
 
242
  protected slots:
 
243
 
 
244
  virtual void mousePressEvent(QMouseEvent *e);
 
245
 
 
246
/**
 
247
 * @internal
 
248
 * Vola proceduru KAboutApplication, zobrazi informace o teto aplikaci a KDE.
 
249
 * Calls procedure KAboutApplication, shows informations about this application and KDE.
 
250
 *
 
251
 * @since  0.1
 
252
 **/
 
253
  void slotShowMyAbout();
 
254
  void slotExitApplication (void);
 
255
 
 
256
/**
 
257
 * @internal
 
258
 * Vysle signal minimize.
 
259
 * Sends signal minimize.
 
260
 *
 
261
 * @since  0.1
 
262
 **/
 
263
  void slotMinimize (void);
 
264
 
 
265
 
 
266
/**
 
267
 * @internal
 
268
 * Vysle signal peferences.
 
269
 * Sends signal preferences.
 
270
 *
 
271
 * @since  0.1
 
272
 **/
 
273
  void slotPreferences (void);
 
274
 
 
275
/**
 
276
 * @internal
 
277
 * Vysle signal printUPSVars.
 
278
 * Sends signal printUPSVars.
 
279
 *
 
280
 * @since  0.1
 
281
 **/
 
282
  void slotPrintUPSVars(void);
 
283
 
 
284
/**
 
285
 * @internal
 
286
 * Vysle signal instComms.
 
287
 * Sends signal instComms.
 
288
 *
 
289
 * @since  0.1
 
290
 **/
 
291
  void slotInstComms(void);
 
292
 
 
293
 
 
294
/**
 
295
 * @internal
 
296
 * Vysle signal RWVars.
 
297
 * Sends signal RWVars.
 
298
 *
 
299
 * @since  0.1
 
300
 **/
 
301
  void slotRWVars(void);
 
302
 
 
303
/**
 
304
 * @internal
 
305
 * Vysle signal upsName
 
306
 * Sends signal upsName.
 
307
 *
 
308
 * @since  0.1
 
309
 **/
 
310
  void slotUpsName(int i);
 
311
 
 
312
/**
 
313
 * @internal
 
314
 * Vysle signal makeRefreshConnection
 
315
 * Sends signal makeRefreshConnection.
 
316
 *
 
317
 * @since  0.1
 
318
 **/
 
319
  void slotRefreshConnection(void);
 
320
 
 
321
 
 
322
  protected:
 
323
/**
 
324
 * @internal
 
325
 * Nastavi vse pro vykresleni zakladni ikony.
 
326
 * Tato ikona je kreslena dokud neni navazano spojeni
 
327
 * Sets all for painting of basic icon.
 
328
 * This icon is painted
 
329
 *
 
330
 * @since  0.2
 
331
 **/
 
332
  void initImage(void);
 
333
 
 
334
 
 
335
 
 
336
/**
 
337
 * @internal
 
338
 * Sets tooltip.
 
339
 * Nastavi ToolTip.
 
340
 *
 
341
 * @since  0.1
 
342
 **/
 
343
    void toolTip (int runtime, int status, int batteryCharge, int upsLoad );
 
344
 
 
345
 
 
346
/**
 
347
 * @internal
 
348
 * Vytvori a hlavni menu panelu.
 
349
 * Makes a main menu of panel
 
350
 *
 
351
 * @since  0.1
 
352
 **/
 
353
    void createMainMenu(void);
 
354
 
 
355
/**
 
356
 * @internal
 
357
 * Vytvori a podmenu pro seznam UPS-ek.
 
358
 * Makes a  submenu for list ig UPSes.
 
359
 *
 
360
 * @since  0.1
 
361
 **/
 
362
    void createUpsMenu(void);
 
363
 
 
364
/**
 
365
 * @internal
 
366
 * Paints a numbers.
 
367
 * Vykresli cisla.
 
368
 * @param number je hodnota cisla.
 
369
 * @param x je leva souradnice cisla
 
370
 * @param y je horni souradnice cisla
 
371
 * @param p je ukazatel na painter
 
372
 *
 
373
 * @since  0.2
 
374
 **/
 
375
    void paintNumbers (int numbers, int x, int y, QPainter* p ); //x,y levy horni roh cisla 1
 
376
 
 
377
/**
 
378
 * @internal
 
379
 * Paints a number
 
380
 * Vykresli cislici.
 
381
 * @param number je hodnota cislice.
 
382
 * @param x je leva souradnice cislice
 
383
 * @param y je horni souradnice cislice
 
384
 * @param p je ukazatel na painter
 
385
 *
 
386
 * @since  0.1
 
387
 **/
 
388
    void paintNumber (int x, int y, int number, QPainter *p);
 
389
 
 
390
/**
 
391
 * @internal
 
392
 * Paints a char.
 
393
 * Vykresli znak.
 
394
 * @param x je leva souradnice cislice
 
395
 * @param y je horni souradnice cislice
 
396
 * @param p je ukazatel na painter
 
397
 * @param char je vykreslovany znak.
 
398
 *
 
399
 * @since  0.1
 
400
 **/
 
401
    void paintChar (int x, int y, char LCDChar, QPainter *p);
 
402
 
 
403
 
 
404
/**
 
405
 * @internal
 
406
 * Vykresli pomlcku.
 
407
 * @param x je leva souradnice pomlcky
 
408
 * @param y je horni souradnice pomlcky
 
409
 * @param p je ukazatel na painter
 
410
 *
 
411
 * @since  0.1
 
412
 **/
 
413
    void paintDash (int x, int y, QPainter *p);
 
414
 
 
415
 
 
416
/**
 
417
 * @internal
 
418
 * Paints runtime layer.
 
419
 * Vykresli vrstvu runtime.
 
420
 *
 
421
 * @since  0.1
 
422
 **/
 
423
    void paintRuntime (int runtime, int status);
 
424
 
 
425
/**
 
426
 * @internal
 
427
 * Paints layer for UPS Load
 
428
 * Vykresli vrstvu pro UPS Load.
 
429
 *
 
430
 * @since  0.2
 
431
 **/
 
432
    void paintLoad (int load );
 
433
 
 
434
/**
 
435
 * @internal
 
436
 * Paints layer for Battery Charge, only for type general.
 
437
 * Vykresli vrstvu pro Battery Charge.
 
438
 *
 
439
 * @since  0.2
 
440
 **/
 
441
    void paintCharge (int charge );
 
442
 
 
443
/**
 
444
 * @internal
 
445
 * Paints layer for UPS Status, only for type general
 
446
 * Vykresli vrstvu pro UPS Status.
 
447
 *
 
448
 * @since  0.2
 
449
 **/
 
450
    void paintStatus (int status );
 
451
 
 
452
 
 
453
    void paintEvent (QPaintEvent *);
 
454
 
 
455
/**
 
456
 * @internal
 
457
 * Paints green point into main layer, only for type picture.
 
458
 * Vykresli do hlavni vrstvy zeleny bod.
 
459
 * Ma vyznam jen pro typ picture.
 
460
 *
 
461
 * @since  0.3
 
462
 **/
 
463
    void paintErrorPoint ( QPainter& paint );
 
464
 
 
465
/**
 
466
 * @internal
 
467
 * Paints red point into main layer, only for type picture.
 
468
 * Vykresli do hlavni vrstvy cerveny bod.
 
469
 * Ma vyznam jen pro typ picture.
 
470
 *
 
471
 * @since  0.3
 
472
 **/
 
473
    void paintOKPoint ( QPainter& paint );
 
474
 
 
475
/**
 
476
 * @internal
 
477
 * Clean internal variables this class.
 
478
 * Vycisti interni promene teto tridy.
 
479
 *
 
480
 * @since  0.1
 
481
 **/
 
482
  void clearValues(void);
 
483
 
 
484
 
 
485
    KNutUpsData* m_upsRecords;
 
486
    SettingDataDef* m_settingData;  // v teto strukture jsou ulozeny promene ktere nastavuji konfiguraci
 
487
    struct upsInfo* m_activeUpsInfo; // values for selected ups
 
488
 
 
489
    QPixmap m_mainPix;
 
490
    QPixmap m_errorPix;
 
491
    QPixmap m_connectPix;
 
492
    QPixmap m_upsPix;
 
493
    QPixmap m_battPix;
 
494
 
 
495
    QPixmap m_mainLayer1;
 
496
 
 
497
    QColor backgroundColor;
 
498
 
 
499
    KPopupMenu* m_menu;
 
500
    KPopupMenu* m_upsServerMenu;
 
501
 
 
502
    QPixmap *m_statusLayer;
 
503
    QPixmap *m_runtimeLayer;
 
504
    QPixmap *m_loadLayer;
 
505
    QPixmap *m_chargeLayer;
 
506
    QPixmap *m_mainLayer;
 
507
 
 
508
    int m_runtimeValue;
 
509
    int m_upsLoadValue;
 
510
    int m_batteryChargeValue;
 
511
    int m_statusValue;
 
512
    int m_statusBatValue;
 
513
    int m_statusWarningValue;
 
514
 
 
515
 
 
516
    upsConnection m_dataOk; // selects one from four type of icons's view //idle, connecting, connected, error
 
517
    upsConnection m_dataOkOld;
 
518
 
 
519
    int m_typeOfIcon;
 
520
    QColor m_myBGColor;
 
521
    unsigned int m_toolTipFlags;
 
522
 
 
523
};
 
524
 
 
525
#endif