-rw-r--r-- | pwmanager/pwmanager/pwm.h | 255 |
1 files changed, 255 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h new file mode 100644 index 0000000..3a79e67 --- a/dev/null +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -0,0 +1,255 @@ | |||
1 | /*************************************************************************** | ||
2 | * * | ||
3 | * copyright (C) 2003, 2004 by Michael Buesch * | ||
4 | * email: mbuesch@freenet.de * | ||
5 | * * | ||
6 | * This program is free software; you can redistribute it and/or modify * | ||
7 | * it under the terms of the GNU General Public License version 2 * | ||
8 | * as published by the Free Software Foundation. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
11 | |||
12 | /*************************************************************************** | ||
13 | * copyright (C) 2004 by Ulf Schenk | ||
14 | * This file is originaly based on version 1.0.1 of pwmanager | ||
15 | * and was modified to run on embedded devices that run microkde | ||
16 | * | ||
17 | * $Id$ | ||
18 | **************************************************************************/ | ||
19 | |||
20 | #ifndef __PWM_H | ||
21 | #define __PWM_H | ||
22 | |||
23 | |||
24 | #include <kpopupmenu.h> | ||
25 | #include <klistview.h> | ||
26 | #include <kmainwindow.h> | ||
27 | |||
28 | #ifndef PWM_EMBEDDED | ||
29 | #include <kwin.h> | ||
30 | #include <kapp.h> | ||
31 | #include <kdeversion.h> | ||
32 | #else | ||
33 | #endif | ||
34 | |||
35 | #include <kaction.h> | ||
36 | |||
37 | |||
38 | #include <qglobal.h> | ||
39 | |||
40 | #include "pwmview.h" | ||
41 | #include "pwmexception.h" | ||
42 | |||
43 | |||
44 | /** timeout for displaying a message on the status-bar (in seconds) */ | ||
45 | #define STATUSBAR_MSG_TIMEOUT5 | ||
46 | |||
47 | |||
48 | class PwMInit; | ||
49 | |||
50 | /** PwM is the base class of the project */ | ||
51 | class PwM : public KMainWindow | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | public: | ||
55 | friend class PwMView; | ||
56 | /** construtor */ | ||
57 | PwM(PwMInit *_init, PwMDoc *doc, | ||
58 | bool virginity = true, | ||
59 | QWidget* parent = 0, const char *name = 0); | ||
60 | /** destructor */ | ||
61 | ~PwM(); | ||
62 | |||
63 | /** copy some text to the global clipboard */ | ||
64 | static void copyToClipboard(const QString &s); | ||
65 | |||
66 | /** returns pointer to the view */ | ||
67 | PwMView * curView() | ||
68 | { return view; } | ||
69 | /** returns pointer to the currently using document. */ | ||
70 | PwMDoc * curDoc() | ||
71 | { return curView()->document(); } | ||
72 | /** open a new doc with the given filename */ | ||
73 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); | ||
74 | /** show a message on the global status bar. | ||
75 | * The message times out after some seconds. | ||
76 | */ | ||
77 | void showStatMsg(const QString &msg); | ||
78 | /** ask the user where to save the doc (if it has not been saved, yet) | ||
79 | * and write the data to disk. | ||
80 | */ | ||
81 | bool save(); | ||
82 | /** ask the user where to save the doc | ||
83 | * and write the data to disk. | ||
84 | */ | ||
85 | bool saveAs(); | ||
86 | /** force quit. Quit this window, always! Don't minimize it */ | ||
87 | bool isForceQuit() | ||
88 | { return forceQuit; } | ||
89 | /** set forceQuit */ | ||
90 | void setForceQuit(bool force) | ||
91 | { forceQuit = force; } | ||
92 | /** force minimize this window */ | ||
93 | bool isForceMinimizeToTray() | ||
94 | { return forceMinimizeToTray; } | ||
95 | /** set forceMinimizeToTray */ | ||
96 | void setForceMinimizeToTray(bool force) | ||
97 | { forceMinimizeToTray = force; } | ||
98 | |||
99 | public slots: | ||
100 | /** file/new triggered */ | ||
101 | void new_slot(); | ||
102 | /** file/open triggered */ | ||
103 | //US ENH | ||
104 | void open_slot(); | ||
105 | void open_slot(QString fn); | ||
106 | /** file/close triggered */ | ||
107 | void close_slot(); | ||
108 | /** file/quit triggered */ | ||
109 | void quitButton_slot(); | ||
110 | /** file/save triggered */ | ||
111 | void save_slot(); | ||
112 | /** file/saveAs triggered */ | ||
113 | void saveAs_slot(); | ||
114 | /** file/export/text triggered */ | ||
115 | void exportToText(); | ||
116 | /** file/export/gpasman triggered */ | ||
117 | void exportToGpasman(); | ||
118 | /** file/export/kwallet triggered */ | ||
119 | void exportToKWallet(); | ||
120 | /** file/import/text triggered */ | ||
121 | bool importFromText(); | ||
122 | /** file/import/gpasman triggered */ | ||
123 | bool importFromGpasman(); | ||
124 | /** file/import/kwallet triggered */ | ||
125 | bool importKWallet(); | ||
126 | /** file/print triggered */ | ||
127 | void print_slot(); | ||
128 | /** manage/add triggered */ | ||
129 | //US ENH : changed code to run with older MOC | ||
130 | void addPwd_slot(); | ||
131 | void addPwd_slot(QString *pw, PwMDoc *_doc); | ||
132 | /** manage/edit triggered */ | ||
133 | //US ENH : changed code to run with older MOC | ||
134 | void editPwd_slot(); | ||
135 | void editPwd_slot(const QString *category); | ||
136 | void editPwd_slot(const QString *category = 0, const int *index = 0, | ||
137 | PwMDoc *_doc = 0); | ||
138 | /** manage/delete triggered */ | ||
139 | void deletePwd_slot(); | ||
140 | /** execute the "Launcher" entry */ | ||
141 | void execLauncher_slot(); | ||
142 | /** open browser with URL entry */ | ||
143 | void goToURL_slot(); | ||
144 | /** manage/changeMasterPwd triggered */ | ||
145 | void changeMasterPwd_slot(); | ||
146 | /** lock current document */ | ||
147 | void lockWnd_slot(); | ||
148 | /** deeplock current document */ | ||
149 | void deepLockWnd_slot(); | ||
150 | /** window/unlock triggered */ | ||
151 | void unlockWnd_slot(); | ||
152 | /** find item */ | ||
153 | void find_slot(); | ||
154 | /** configure clicked */ | ||
155 | void config_slot(); | ||
156 | /** (de)activate the "change master pw" button in the menu-bar */ | ||
157 | void activateMpButton(bool activate = true); | ||
158 | /** generate a new chipcard */ | ||
159 | void genNewCard_slot(); | ||
160 | /** completely erase the current card */ | ||
161 | void eraseCard_slot(); | ||
162 | /** returns the ID number of the current card */ | ||
163 | void readCardId_slot(); | ||
164 | /** make backup image of the current card */ | ||
165 | void makeCardBackup_slot(); | ||
166 | /** write backup image to current card */ | ||
167 | void replayCardBackup_slot(); | ||
168 | |||
169 | protected: | ||
170 | /** is this window virgin? */ | ||
171 | bool isVirgin() | ||
172 | { return virgin; } | ||
173 | /** add/remove virginity */ | ||
174 | void setVirgin(bool v); | ||
175 | /** initialize the menubar */ | ||
176 | void initMenubar(); | ||
177 | /** initialize the toolbar */ | ||
178 | void initToolbar(); | ||
179 | /** initialize the window-metrics */ | ||
180 | void initMetrics(); | ||
181 | /** close-event */ | ||
182 | void closeEvent(QCloseEvent *e); | ||
183 | /** creates a new PwM-ListView and returns it */ | ||
184 | PwMView * makeNewListView(PwMDoc *doc); | ||
185 | /** Window hide-event */ | ||
186 | void hideEvent(QHideEvent *); | ||
187 | /** is this window minimized? */ | ||
188 | bool isMinimized() | ||
189 | { | ||
190 | #ifndef PWM_EMBEDDED | ||
191 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | ||
192 | return KWin::windowInfo(winId()).isMinimized(); | ||
193 | #else // KDE_VERSION | ||
194 | return KWin::info(winId()).isIconified(); | ||
195 | #endif // KDE_VERSION | ||
196 | #else | ||
197 | return false; | ||
198 | #endif | ||
199 | } | ||
200 | /** window got the focus */ | ||
201 | void focusInEvent(QFocusEvent *e); | ||
202 | /** update the caption string */ | ||
203 | void updateCaption(); | ||
204 | #ifdef CONFIG_KWALLETIF | ||
205 | /** check if kwalletemu is enabled and ask the user what to do */ | ||
206 | bool checkAndAskForKWalletEmu(); | ||
207 | #endif // CONFIG_KWALLETIF | ||
208 | |||
209 | protected slots: | ||
210 | /** doc got closed */ | ||
211 | void docClosed(PwMDoc *doc); | ||
212 | |||
213 | signals: | ||
214 | /** window got closed (by user or someone else) */ | ||
215 | void closed(PwM *wnd); | ||
216 | /** window got the focus (was brought to foreground) */ | ||
217 | void gotFocus(PwM *wnd); | ||
218 | /** window lost the focus */ | ||
219 | void lostFocus(PwM *wnd); | ||
220 | |||
221 | protected: | ||
222 | /** pointer to the view active in this KMainWindow */ | ||
223 | PwMView *view; | ||
224 | /** pointer to the init class */ | ||
225 | PwMInit *init; | ||
226 | /** has this window already lost its virginity? | ||
227 | * Means is there an open working document | ||
228 | */ | ||
229 | bool virgin; | ||
230 | /** "file" popup-menu */ | ||
231 | KPopupMenu *filePopup; | ||
232 | |||
233 | /** "manage" popup-menu */ | ||
234 | KPopupMenu *managePopup; | ||
235 | #ifdef CONFIG_KEYCARD | ||
236 | /** "chipcard" popup-menu */ | ||
237 | KPopupMenu *chipcardPopup; | ||
238 | #endif // CONFIG_KEYCARD | ||
239 | /** "view" popup-menu */ | ||
240 | KPopupMenu *viewPopup; | ||
241 | /** "options" popup-menu */ | ||
242 | KPopupMenu *optionsPopup; | ||
243 | /** "help" popup-menu */ | ||
244 | KPopupMenu *helpPopup; | ||
245 | /** "export" popup-menu */ | ||
246 | KPopupMenu *exportPopup; | ||
247 | /** "import" popup-menu */ | ||
248 | KPopupMenu *importPopup; | ||
249 | /** force quit this window? */ | ||
250 | bool forceQuit; | ||
251 | /** force minimize this window to the tray */ | ||
252 | bool forceMinimizeToTray; | ||
253 | }; | ||
254 | |||
255 | #endif | ||