1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
/***************************************************************************
knutmainwindow.h - description
-------------------
begin : Po cen 16 2003
copyright : (C) 2003 by Daniel Prynych
email : Daniel@prynych.cz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KNUTMAINWINDOW_H
#define KNUTMAINWINDOW_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "knutprefdlg.h"
#include "knutupsdata.h"
#include "knutvardata.h"
#include "knutfrontpanel.h"
#include "knutnet.h"
#include "knutanalog.h"
#include "knutpanelmeter.h"
#include <kapp.h>
#include <kmainwindow.h>
#include <kaction.h>
//#include <kprogress.h>
#include <tqwidget.h>
#include <tqdatetime.h>
//#include <tqprogressbar.h>
class TQString;
class TQStringList;
class TQLabel;
class TQPalette;
class TQSplitter;
class KProgress;
//class TQProgressBar;
/**
* Trida slouzi pro zobrazeni okna s informacemi o UPS.
* Class is used for view window with informations about UPS
*
* @author Daniel Prynych
* @short Hlavni okno
* @version 0.2.3
*/
class KNutMainWindow : public KMainWindow {
Q_OBJECT
public:
/**
* Constructor - makes main window.
* Konstruktor - vytvori hlavni okno.
*
* @param tListKNutEvent pointer on TQStringList contain text information about events (drop connection, switch ..)
* @param tActiveUpsInfo pointer on data about active UPS
* @param tSettingData pointer on basic data of program (background color, intercircle, pointers...,fonts..)
* @param tAnalogRecords pointer in class which works with data about UPS
* @param tListKNutEvent ukazatel na TQStringList obsahuje textove udaje o udalostech (ztrata spojeni, prepnuti atd.)
* @param tActiveUpsInfo ukazatel na data o aktivni UPS
* @param tSettingData ukazatel na zakladni data programu (barvy pozadi, mezikruzi, rucicky ... ,fonty atd )
* @param tAnalogRecords ukazatel na tridu ktera pracuje s daty o upsekach
*
* @since 0.3.1
**/
KNutMainWindow(TQStringList* tListKNutEvent, KNutVarData::upsInfoDef* tActiveUpsInfo, KNutVarData::SettingDataDef* tSettingData, KNutUpsData* tUpsRecords, KNutVarData* tAnalogRecords, TQWidget* parent=0,const char *name=0);
/**
* Destructor
*
* @since 0.1.1
**/
~KNutMainWindow();
/**
* Repaints information of main panel.
* Prekresli informace hlavniho panelu.
*
* @since 0.1.2
**/
void repaintPanel(void);
/**
* Repaints analog panels based on their status.
* Prekresli analogove panely na zaklade jejich stavu.
* @param run = TRUE makes immediately repaint of panel
*
* @since 0.3.1
**/
void repaintAnalogs ( bool run = true);
/**
* Da prikaz k prekresleni analogovych panelu, hlavniho panelu a nastavi jejich hodnoty na
* zaklade XFer hodnot.
* Give command to repaint analog panels, main panel and sets their values based on XFer values
* @param run = TRUE makes immediately repaint of analog panels
*
* @since 0.3.1
**/
void showUpsData (void);
/**
* Adds other line into list of events and shows them on bottom part of panel.
* Prida dalsi radku do seznamu udalosti a zobrazi je v dolni casti panelu.
*
* @param text text of event.
* @param name name of UPS, name which is list of UPSes.
* @param text udava text udalosti.
* @param name udava jmeno UPS-ky tak jak je vedena v seznamu UPS-ek tohoto programu
*
* @since 0.1
**/
void addComboStatusItem (const TQString text, const TQString name = TQString());
/**
* Rebuilds main panel based on value changeSetting.
* This value generates config windies
* Prestavi hlavni panel na zaklade hodnoty changeSetting.
* Tuto hodnotu generuje konfiguracni okno.
*
* @param changeSetting tell which setting was changed.
* @param changeSetting udava jake nastaveni bylo zmeneno.
*
* @since 0.1.2
**/
void setConfig (unsigned int changeSetting);
/**
* Sets ComboBox (for name of UPS)
* Nastavi ComboBox (pro jmeno UPSky).
*
* ¶m name je jmeno UPSky ktere bude nastavena.
* ¶m name is name of ups which will be set.
*
* @since 0.1
**/
void setCombo(TQString name);
/**
* Nastavi vsechny panely na nulovo hodnotu
* Sets all pannels to zero value
*
* @since 0.2
**/
void zeroingPanels (void);
/**
* Cleans front panel and panel meter (includes analog panels) .
*
* @since 0.1
**/
void cleanPanels (void);
/**
* Sets and shows connect progress bar.
* Nastavi a zobrazi connect progress bar.
*
* ¶m is count of parts of progress bar.
* ¶m je pocet casti progres baru.
*
* @since 0.1
**/
void startConnectPB ( const int count );
/**
* Hide connect progress bar.
* Schova connect progress bar.
*
* @since 0.1
**/
void hideConnectPB ( void );
/**
* Sets amount of progress for connect progress bar.
* Nastavi delku vyplne pro connect progresbar.
*
* ¶m is amount of progress.
* ¶m je delka vyplne.
*
* @since 0.1
**/
void setProgressConnectPB ( const int progress );
signals:
/**
* This signal is emited when other UPS was selected.
* Tento signal je vyslan pokud byla vybrana jina UPS-ka.
*
* @since 0.1
**/
void UPSChanged (TQString);
/**
* This signal is emited when request for viewing preferences window was ordered from menu.
* Tento signal je vyslan pokud byl z menu zadan pozadavek na zobrazeni okna
* pro nastaveni programu (preference).
*
* @since 0.1
**/
void preferenceUps (void);
/**
* This signal is emited, when in menu was odered requirement for viewing list of values .
* Tento signal je vyslan, pokud byl z menu zadan pozadavek na zobrazeni seznamu promennych.
*
* @since 0.1
**/
void showUPSVars (void);
/**
* Tento signal je vyslan pokud byl z menu zadan pozadavek na zmenu RW promennych.
* This signal is emited when request for change RW varianles was orederd from menu.
*
* @since 0.1
**/
void makeRWVars(void);
/**
* Tento signal je vyslan pokud byl z menu vybran pozadavek na obnovu spojeni.
* This signal is emited when request for refreshing connection was selected from menu.
*
* @since 0.1
**/
void makeRefreshConnection(void);
/**
* This signal is emited when request for making instant commands was selected from menu.
* Tento signal je vyslan pokud byl z menu zadan pozadavek na provedeni okamzitych prikazu.
*
* @since 0.1
**/
void makeInstComms(void);
/**
* This signal is emited whem we need save configuration of program.
* Tento signal je vyslan pokud potrebujeme ulozit konfiguraci programuss.
*
* @since 0.1
**/
void saveConf(void);
/**
* This signal is emited whem request for ending all application was selected from menu.
* Tento signal je vyslan pokud byl z menu zadan pozadavek na ukonceni cele aplikace.
*
* @since 0.1
**/
void endApplication();
protected:
void closeEvent( TQCloseEvent *e );
private slots:
void slotDescription(void);
void slotShowToolBar(void);
void slotShowStatusBar(void);
void slotPreferencesUps(void);
void slotPrintUPSVars(void);
void slotInstComms(void);
void slotRWVars(void);
void slotChangeRWVars ( TQString );
void slotCloseKnutClient (void);
void slotChangeUPS (const TQString &name);
void slotConfigureKeys(void);
void slotRefreshConnection(void);
/************** private common functions ************************/
private:
void activeConfiguration (void);
int activeMainCombo (void);
void hideUpsData (void);
/************ init functions ********************/
void initVars ( void );
void initAction ( void );
void initStatusBar ( void );
void initToolBar ( void );
void initStatusBarMessage ( void );
/************** private vars **************************/
// Nazvy promenych UPS cislovany jsou od 0 do 10 "NONE", "UTILITY", "BATTPCT", "UPSTEMP", "ACFREQ", "LOADPCT", "AMBTEMP", "AMBHUMID", "BATTVOLT", "OUTVOLT", "CURRENT"
TQStringList* m_listKNutEvent;
KNutVarData::upsInfoDef* m_activeUpsInfo; // values for selected ups / hodnoty pro vybrane ups
KNutVarData::SettingDataDef* m_settingData; // v teto strukture jsou ulozeny promene ktere nastavuji konfiguraci
KNutUpsData* m_upsRecords;
KNutVarData* m_analogRecords;
KAction *m_quit;
KAction *m_preferencesUps;
KToggleAction *m_descriptionAction;
TQLabel* m_area; // main arrea, on its will server main panel and analog panels
// hlavni plocha na ni umistime panel a analogove ukazatele
TQSplitter* m_mainSplit;
KNutFrontPanel* m_frontPanel;
// nactene hodnoty promenych UPS, tyto promene se ctou jen jednou
// readly values of UPS's variables, these varieables is read only once
TQString m_manufacturer, m_upsModel, m_serial, m_firmrev;
bool m_existLowHighXfer;
float m_lowXfer, m_highXfer;
TQPalette m_mainPalette, m_areaPalette, m_mPanelPalette, m_aPanelPalette;
// Combo a pomocne struktury pro dolni radku
// Combo and help structures for bottom line.
KComboBox *m_infoCombo;
KNutPanelMeter* m_panelMeter;
KProgress* m_connectProggresBar;
TQString m_progressFormatString;
};
#endif
|