author | ulf69 <ulf69> | 2004-10-19 01:12:41 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-19 01:12:41 (UTC) |
commit | 6fdb13cb4142ecde29fd537ff32a3e8e6cc30b26 (patch) (unidiff) | |
tree | 760ad21fcdc4e2d885c5d875d91629a70ce89843 | |
parent | da724334d46c01ee9d4f04101dab5d048c35c833 (diff) | |
download | kdepimpi-6fdb13cb4142ecde29fd537ff32a3e8e6cc30b26.zip kdepimpi-6fdb13cb4142ecde29fd537ff32a3e8e6cc30b26.tar.gz kdepimpi-6fdb13cb4142ecde29fd537ff32a3e8e6cc30b26.tar.bz2 |
added whats new page
-rw-r--r-- | pwmanager/pwmanager/pwm.cpp | 13 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwm.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp index 57b4432..26a44b1 100644 --- a/pwmanager/pwmanager/pwm.cpp +++ b/pwmanager/pwmanager/pwm.cpp | |||
@@ -1,1364 +1,1373 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 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 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 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 | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <klistview.h> | 21 | #include <klistview.h> |
22 | #include <ktoolbar.h> | 22 | #include <ktoolbar.h> |
23 | #include <kfiledialog.h> | 23 | #include <kfiledialog.h> |
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include <kmessagebox.h> | 25 | #include <kmessagebox.h> |
26 | 26 | ||
27 | #ifndef PWM_EMBEDDED | 27 | #ifndef PWM_EMBEDDED |
28 | #include <kmenubar.h> | 28 | #include <kmenubar.h> |
29 | #include <kstatusbar.h> | 29 | #include <kstatusbar.h> |
30 | #include <dcopclient.h> | 30 | #include <dcopclient.h> |
31 | #include "configwndimpl.h" | 31 | #include "configwndimpl.h" |
32 | #include "configuration.h" | 32 | #include "configuration.h" |
33 | #else | 33 | #else |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <pwmprefs.h> | 36 | #include <pwmprefs.h> |
37 | #include <kpimglobalprefs.h> | 37 | #include <kpimglobalprefs.h> |
38 | #include <kcmconfigs/kcmpwmconfig.h> | 38 | #include <kcmconfigs/kcmpwmconfig.h> |
39 | #include <kcmconfigs/kcmkdepimconfig.h> | 39 | #include <kcmconfigs/kcmkdepimconfig.h> |
40 | #include <kcmultidialog.h> | 40 | #include <kcmultidialog.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
44 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
45 | #include <qspinbox.h> | 45 | #include <qspinbox.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qfileinfo.h> | 47 | #include <qfileinfo.h> |
48 | #include <qclipboard.h> | 48 | #include <qclipboard.h> |
49 | 49 | ||
50 | 50 | ||
51 | #include <stdio.h> | 51 | #include <stdio.h> |
52 | 52 | ||
53 | #include "pwm.h" | 53 | #include "pwm.h" |
54 | #include "pwminit.h" | 54 | #include "pwminit.h" |
55 | #include "pwmprint.h" | 55 | #include "pwmprint.h" |
56 | #include "addentrywndimpl.h" | 56 | #include "addentrywndimpl.h" |
57 | #include "globalstuff.h" | 57 | #include "globalstuff.h" |
58 | #include "findwndimpl.h" | 58 | #include "findwndimpl.h" |
59 | 59 | ||
60 | #ifdef CONFIG_KWALLETIF | 60 | #ifdef CONFIG_KWALLETIF |
61 | # include "kwalletif.h" | 61 | # include "kwalletif.h" |
62 | # include "kwalletemu.h" | 62 | # include "kwalletemu.h" |
63 | #endif | 63 | #endif |
64 | #ifdef CONFIG_KEYCARD | 64 | #ifdef CONFIG_KEYCARD |
65 | # include "pwmkeycard.h" | 65 | # include "pwmkeycard.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | 68 | ||
69 | #define DEFAULT_SIZE (QSize(700, 400)) | 69 | #define DEFAULT_SIZE (QSize(700, 400)) |
70 | 70 | ||
71 | // Button IDs for "file" popup menu | 71 | // Button IDs for "file" popup menu |
72 | enum { | 72 | enum { |
73 | BUTTON_POPUP_FILE_NEW = 0, | 73 | BUTTON_POPUP_FILE_NEW = 0, |
74 | BUTTON_POPUP_FILE_OPEN, | 74 | BUTTON_POPUP_FILE_OPEN, |
75 | BUTTON_POPUP_FILE_CLOSE, | 75 | BUTTON_POPUP_FILE_CLOSE, |
76 | BUTTON_POPUP_FILE_SAVE, | 76 | BUTTON_POPUP_FILE_SAVE, |
77 | BUTTON_POPUP_FILE_SAVEAS, | 77 | BUTTON_POPUP_FILE_SAVEAS, |
78 | BUTTON_POPUP_FILE_EXPORT, | 78 | BUTTON_POPUP_FILE_EXPORT, |
79 | BUTTON_POPUP_FILE_IMPORT, | 79 | BUTTON_POPUP_FILE_IMPORT, |
80 | BUTTON_POPUP_FILE_PRINT, | 80 | BUTTON_POPUP_FILE_PRINT, |
81 | BUTTON_POPUP_FILE_QUIT | 81 | BUTTON_POPUP_FILE_QUIT |
82 | }; | 82 | }; |
83 | // Button IDs for "manage" popup menu | 83 | // Button IDs for "manage" popup menu |
84 | enum { | 84 | enum { |
85 | BUTTON_POPUP_MANAGE_ADD = 0, | 85 | BUTTON_POPUP_MANAGE_ADD = 0, |
86 | BUTTON_POPUP_MANAGE_EDIT, | 86 | BUTTON_POPUP_MANAGE_EDIT, |
87 | BUTTON_POPUP_MANAGE_DEL, | 87 | BUTTON_POPUP_MANAGE_DEL, |
88 | BUTTON_POPUP_MANAGE_CHANGEMP | 88 | BUTTON_POPUP_MANAGE_CHANGEMP |
89 | }; | 89 | }; |
90 | // Button IDs for chipcard popup menu | 90 | // Button IDs for chipcard popup menu |
91 | enum { | 91 | enum { |
92 | #ifdef CONFIG_KEYCARD | 92 | #ifdef CONFIG_KEYCARD |
93 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, | 93 | BUTTON_POPUP_CHIPCARD_GENNEW = 0, |
94 | BUTTON_POPUP_CHIPCARD_DEL, | 94 | BUTTON_POPUP_CHIPCARD_DEL, |
95 | BUTTON_POPUP_CHIPCARD_READID, | 95 | BUTTON_POPUP_CHIPCARD_READID, |
96 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, | 96 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP, |
97 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP | 97 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP |
98 | #else // CONFIG_KEYCARD | 98 | #else // CONFIG_KEYCARD |
99 | BUTTON_POPUP_CHIPCARD_NO = 0 | 99 | BUTTON_POPUP_CHIPCARD_NO = 0 |
100 | #endif // CONFIG_KEYCARD | 100 | #endif // CONFIG_KEYCARD |
101 | }; | 101 | }; |
102 | // Button IDs for "view" popup menu | 102 | // Button IDs for "view" popup menu |
103 | enum { | 103 | enum { |
104 | BUTTON_POPUP_VIEW_FIND = 0, | 104 | BUTTON_POPUP_VIEW_FIND = 0, |
105 | BUTTON_POPUP_VIEW_LOCK, | 105 | BUTTON_POPUP_VIEW_LOCK, |
106 | BUTTON_POPUP_VIEW_DEEPLOCK, | 106 | BUTTON_POPUP_VIEW_DEEPLOCK, |
107 | BUTTON_POPUP_VIEW_UNLOCK | 107 | BUTTON_POPUP_VIEW_UNLOCK |
108 | }; | 108 | }; |
109 | // Button IDs for "options" popup menu | 109 | // Button IDs for "options" popup menu |
110 | enum { | 110 | enum { |
111 | BUTTON_POPUP_OPTIONS_CONFIG = 0 | 111 | BUTTON_POPUP_OPTIONS_CONFIG = 0 |
112 | }; | 112 | }; |
113 | // Button IDs for "export" popup menu (in "file" popup menu) | 113 | // Button IDs for "export" popup menu (in "file" popup menu) |
114 | enum { | 114 | enum { |
115 | BUTTON_POPUP_EXPORT_TEXT = 0, | 115 | BUTTON_POPUP_EXPORT_TEXT = 0, |
116 | BUTTON_POPUP_EXPORT_GPASMAN | 116 | BUTTON_POPUP_EXPORT_GPASMAN |
117 | #ifdef CONFIG_KWALLETIF | 117 | #ifdef CONFIG_KWALLETIF |
118 | ,BUTTON_POPUP_EXPORT_KWALLET | 118 | ,BUTTON_POPUP_EXPORT_KWALLET |
119 | #endif | 119 | #endif |
120 | }; | 120 | }; |
121 | // Button IDs for "import" popup menu (in "file" popup menu) | 121 | // Button IDs for "import" popup menu (in "file" popup menu) |
122 | enum { | 122 | enum { |
123 | BUTTON_POPUP_IMPORT_TEXT = 0, | 123 | BUTTON_POPUP_IMPORT_TEXT = 0, |
124 | BUTTON_POPUP_IMPORT_GPASMAN | 124 | BUTTON_POPUP_IMPORT_GPASMAN |
125 | #ifdef CONFIG_KWALLETIF | 125 | #ifdef CONFIG_KWALLETIF |
126 | ,BUTTON_POPUP_IMPORT_KWALLET | 126 | ,BUTTON_POPUP_IMPORT_KWALLET |
127 | #endif | 127 | #endif |
128 | }; | 128 | }; |
129 | 129 | ||
130 | #ifdef PWM_EMBEDDED | 130 | #ifdef PWM_EMBEDDED |
131 | // Button IDs for "help" popup menu | 131 | // Button IDs for "help" popup menu |
132 | enum { | 132 | enum { |
133 | BUTTON_POPUP_HELP_LICENSE = 0, | 133 | BUTTON_POPUP_HELP_LICENSE = 0, |
134 | BUTTON_POPUP_HELP_FAQ, | 134 | BUTTON_POPUP_HELP_FAQ, |
135 | BUTTON_POPUP_HELP_ABOUT, | 135 | BUTTON_POPUP_HELP_ABOUT, |
136 | BUTTON_POPUP_HELP_SYNC | 136 | BUTTON_POPUP_HELP_SYNC, |
137 | BUTTON_POPUP_HELP_WHATSNEW | ||
137 | }; | 138 | }; |
138 | #endif | 139 | #endif |
139 | 140 | ||
140 | // Button IDs for toolbar | 141 | // Button IDs for toolbar |
141 | enum { | 142 | enum { |
142 | BUTTON_TOOL_NEW = 0, | 143 | BUTTON_TOOL_NEW = 0, |
143 | BUTTON_TOOL_OPEN, | 144 | BUTTON_TOOL_OPEN, |
144 | BUTTON_TOOL_SAVE, | 145 | BUTTON_TOOL_SAVE, |
145 | BUTTON_TOOL_SAVEAS, | 146 | BUTTON_TOOL_SAVEAS, |
146 | BUTTON_TOOL_PRINT, | 147 | BUTTON_TOOL_PRINT, |
147 | BUTTON_TOOL_ADD, | 148 | BUTTON_TOOL_ADD, |
148 | BUTTON_TOOL_EDIT, | 149 | BUTTON_TOOL_EDIT, |
149 | BUTTON_TOOL_DEL, | 150 | BUTTON_TOOL_DEL, |
150 | BUTTON_TOOL_FIND, | 151 | BUTTON_TOOL_FIND, |
151 | BUTTON_TOOL_LOCK, | 152 | BUTTON_TOOL_LOCK, |
152 | BUTTON_TOOL_DEEPLOCK, | 153 | BUTTON_TOOL_DEEPLOCK, |
153 | BUTTON_TOOL_UNLOCK | 154 | BUTTON_TOOL_UNLOCK |
154 | }; | 155 | }; |
155 | 156 | ||
156 | 157 | ||
157 | PwM::PwM(PwMInit *_init, PwMDoc *doc, | 158 | PwM::PwM(PwMInit *_init, PwMDoc *doc, |
158 | bool virginity, | 159 | bool virginity, |
159 | QWidget *parent, const char *name) | 160 | QWidget *parent, const char *name) |
160 | : KMainWindow(parent, "HALLO") | 161 | : KMainWindow(parent, "HALLO") |
161 | , forceQuit (false) | 162 | , forceQuit (false) |
162 | , forceMinimizeToTray (false) | 163 | , forceMinimizeToTray (false) |
163 | { | 164 | { |
164 | init = _init; | 165 | init = _init; |
165 | connect(doc, SIGNAL(docClosed(PwMDoc *)), | 166 | connect(doc, SIGNAL(docClosed(PwMDoc *)), |
166 | this, SLOT(docClosed(PwMDoc *))); | 167 | this, SLOT(docClosed(PwMDoc *))); |
167 | initMenubar(); | 168 | initMenubar(); |
168 | initToolbar(); | 169 | initToolbar(); |
169 | initMetrics(); | 170 | initMetrics(); |
170 | setVirgin(virginity); | 171 | setVirgin(virginity); |
171 | setFocusPolicy(QWidget::WheelFocus); | 172 | setFocusPolicy(QWidget::WheelFocus); |
172 | #ifndef PWM_EMBEDDED | 173 | #ifndef PWM_EMBEDDED |
173 | statusBar()->show(); | 174 | statusBar()->show(); |
174 | #endif | 175 | #endif |
175 | view = makeNewListView(doc); | 176 | view = makeNewListView(doc); |
176 | setCentralWidget(view); | 177 | setCentralWidget(view); |
177 | updateCaption(); | 178 | updateCaption(); |
178 | showStatMsg(i18n("Ready.")); | 179 | showStatMsg(i18n("Ready.")); |
179 | } | 180 | } |
180 | 181 | ||
181 | PwM::~PwM() | 182 | PwM::~PwM() |
182 | { | 183 | { |
183 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), | 184 | disconnect(curDoc(), SIGNAL(docClosed(PwMDoc *)), |
184 | this, SLOT(docClosed(PwMDoc *))); | 185 | this, SLOT(docClosed(PwMDoc *))); |
185 | conf()->confWndMainWndSize(size()); | 186 | conf()->confWndMainWndSize(size()); |
186 | emit closed(this); | 187 | emit closed(this); |
187 | delete view; | 188 | delete view; |
188 | } | 189 | } |
189 | 190 | ||
190 | void PwM::initMenubar() | 191 | void PwM::initMenubar() |
191 | { | 192 | { |
192 | KIconLoader* picons; | 193 | KIconLoader* picons; |
193 | #ifndef PWM_EMBEDDED | 194 | #ifndef PWM_EMBEDDED |
194 | KIconLoader icons; | 195 | KIconLoader icons; |
195 | picons = &icons; | 196 | picons = &icons; |
196 | #else | 197 | #else |
197 | picons = KGlobal::iconLoader(); | 198 | picons = KGlobal::iconLoader(); |
198 | 199 | ||
199 | 200 | ||
200 | syncPopup = new KPopupMenu(this); | 201 | syncPopup = new KPopupMenu(this); |
201 | 202 | ||
202 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); | 203 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::PWMPI, PWMPrefs::instance(), syncPopup); |
203 | syncManager->setBlockSave(false); | 204 | syncManager->setBlockSave(false); |
204 | 205 | ||
205 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 206 | connect ( syncPopup, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
206 | syncManager->fillSyncMenu(); | 207 | syncManager->fillSyncMenu(); |
207 | 208 | ||
208 | #endif | 209 | #endif |
209 | filePopup = new KPopupMenu(this); | 210 | filePopup = new KPopupMenu(this); |
210 | importPopup = new KPopupMenu(filePopup); | 211 | importPopup = new KPopupMenu(filePopup); |
211 | exportPopup = new KPopupMenu(filePopup); | 212 | exportPopup = new KPopupMenu(filePopup); |
212 | managePopup = new KPopupMenu(this); | 213 | managePopup = new KPopupMenu(this); |
213 | #ifdef CONFIG_KEYCARD | 214 | #ifdef CONFIG_KEYCARD |
214 | chipcardPopup = new KPopupMenu(this); | 215 | chipcardPopup = new KPopupMenu(this); |
215 | #endif // CONFIG_KEYCARD | 216 | #endif // CONFIG_KEYCARD |
216 | viewPopup = new KPopupMenu(this); | 217 | viewPopup = new KPopupMenu(this); |
217 | optionsPopup = new KPopupMenu(this); | 218 | optionsPopup = new KPopupMenu(this); |
218 | 219 | ||
219 | // "file" popup menu | 220 | // "file" popup menu |
220 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 221 | filePopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
221 | i18n("&New"), this, | 222 | i18n("&New"), this, |
222 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); | 223 | SLOT(new_slot()), 0, BUTTON_POPUP_FILE_NEW); |
223 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), | 224 | filePopup->insertItem(QIconSet(picons->loadIcon("fileopen", KIcon::Small)), |
224 | i18n("&Open"), this, | 225 | i18n("&Open"), this, |
225 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); | 226 | SLOT(open_slot()), 0, BUTTON_POPUP_FILE_OPEN); |
226 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), | 227 | filePopup->insertItem(QIconSet(picons->loadIcon("fileclose", KIcon::Small)), |
227 | i18n("&Close"), this, | 228 | i18n("&Close"), this, |
228 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); | 229 | SLOT(close_slot()), 0, BUTTON_POPUP_FILE_CLOSE); |
229 | filePopup->insertSeparator(); | 230 | filePopup->insertSeparator(); |
230 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), | 231 | filePopup->insertItem(QIconSet(picons->loadIcon("filesave", KIcon::Small)), |
231 | i18n("&Save"), this, | 232 | i18n("&Save"), this, |
232 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); | 233 | SLOT(save_slot()), 0, BUTTON_POPUP_FILE_SAVE); |
233 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), | 234 | filePopup->insertItem(QIconSet(picons->loadIcon("filesaveas", KIcon::Small)), |
234 | i18n("Save &as..."), | 235 | i18n("Save &as..."), |
235 | this, SLOT(saveAs_slot()), 0, | 236 | this, SLOT(saveAs_slot()), 0, |
236 | BUTTON_POPUP_FILE_SAVEAS); | 237 | BUTTON_POPUP_FILE_SAVEAS); |
237 | filePopup->insertSeparator(); | 238 | filePopup->insertSeparator(); |
238 | // "file/export" popup menu | 239 | // "file/export" popup menu |
239 | exportPopup->insertItem(i18n("&Text-file..."), this, | 240 | exportPopup->insertItem(i18n("&Text-file..."), this, |
240 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); | 241 | SLOT(exportToText()), 0, BUTTON_POPUP_EXPORT_TEXT); |
241 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 242 | exportPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
242 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); | 243 | SLOT(exportToGpasman()), 0, BUTTON_POPUP_EXPORT_GPASMAN); |
243 | #ifdef CONFIG_KWALLETIF | 244 | #ifdef CONFIG_KWALLETIF |
244 | exportPopup->insertItem(i18n("&KWallet..."), this, | 245 | exportPopup->insertItem(i18n("&KWallet..."), this, |
245 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); | 246 | SLOT(exportToKWallet()), 0, BUTTON_POPUP_EXPORT_KWALLET); |
246 | #endif | 247 | #endif |
247 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), | 248 | filePopup->insertItem(QIconSet(picons->loadIcon("fileexport", KIcon::Small)), |
248 | i18n("E&xport"), exportPopup, | 249 | i18n("E&xport"), exportPopup, |
249 | BUTTON_POPUP_FILE_EXPORT); | 250 | BUTTON_POPUP_FILE_EXPORT); |
250 | // "file/import" popup menu | 251 | // "file/import" popup menu |
251 | importPopup->insertItem(i18n("&Text-file..."), this, | 252 | importPopup->insertItem(i18n("&Text-file..."), this, |
252 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); | 253 | SLOT(importFromText()), 0, BUTTON_POPUP_IMPORT_TEXT); |
253 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, | 254 | importPopup->insertItem(i18n("&Gpasman / Kpasman ..."), this, |
254 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); | 255 | SLOT(importFromGpasman()), 0, BUTTON_POPUP_IMPORT_GPASMAN); |
255 | #ifdef CONFIG_KWALLETIF | 256 | #ifdef CONFIG_KWALLETIF |
256 | importPopup->insertItem(i18n("&KWallet..."), this, | 257 | importPopup->insertItem(i18n("&KWallet..."), this, |
257 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); | 258 | SLOT(importKWallet()), 0, BUTTON_POPUP_IMPORT_KWALLET); |
258 | #endif | 259 | #endif |
259 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), | 260 | filePopup->insertItem(QIconSet(picons->loadIcon("fileimport", KIcon::Small)), |
260 | i18n("I&mport"), importPopup, | 261 | i18n("I&mport"), importPopup, |
261 | BUTTON_POPUP_FILE_IMPORT); | 262 | BUTTON_POPUP_FILE_IMPORT); |
262 | filePopup->insertSeparator(); | 263 | filePopup->insertSeparator(); |
263 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), | 264 | filePopup->insertItem(QIconSet(picons->loadIcon("fileprint", KIcon::Small)), |
264 | i18n("&Print..."), this, | 265 | i18n("&Print..."), this, |
265 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); | 266 | SLOT(print_slot()), 0, BUTTON_POPUP_FILE_PRINT); |
266 | filePopup->insertSeparator(); | 267 | filePopup->insertSeparator(); |
267 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), | 268 | filePopup->insertItem(QIconSet(picons->loadIcon("exit", KIcon::Small)), |
268 | i18n("&Quit"), this, | 269 | i18n("&Quit"), this, |
269 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); | 270 | SLOT(quitButton_slot()), 0, BUTTON_POPUP_FILE_QUIT); |
270 | menuBar()->insertItem(i18n("&File"), filePopup); | 271 | menuBar()->insertItem(i18n("&File"), filePopup); |
271 | // "manage" popup menu | 272 | // "manage" popup menu |
272 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), | 273 | managePopup->insertItem(QIconSet(picons->loadIcon("pencil", KIcon::Small)), |
273 | i18n("&Add password"), this, | 274 | i18n("&Add password"), this, |
274 | SLOT(addPwd_slot()), 0, | 275 | SLOT(addPwd_slot()), 0, |
275 | BUTTON_POPUP_MANAGE_ADD); | 276 | BUTTON_POPUP_MANAGE_ADD); |
276 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), | 277 | managePopup->insertItem(QIconSet(picons->loadIcon("edit", KIcon::Small)), |
277 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, | 278 | i18n("&Edit"), this, SLOT(editPwd_slot()), 0, |
278 | BUTTON_POPUP_MANAGE_EDIT); | 279 | BUTTON_POPUP_MANAGE_EDIT); |
279 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 280 | managePopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
280 | i18n("&Delete"), this, SLOT(deletePwd_slot()), | 281 | i18n("&Delete"), this, SLOT(deletePwd_slot()), |
281 | 0, BUTTON_POPUP_MANAGE_DEL); | 282 | 0, BUTTON_POPUP_MANAGE_DEL); |
282 | managePopup->insertSeparator(); | 283 | managePopup->insertSeparator(); |
283 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), | 284 | managePopup->insertItem(QIconSet(picons->loadIcon("rotate", KIcon::Small)), |
284 | i18n("Change &Master Password"), this, | 285 | i18n("Change &Master Password"), this, |
285 | SLOT(changeMasterPwd_slot()), 0, | 286 | SLOT(changeMasterPwd_slot()), 0, |
286 | BUTTON_POPUP_MANAGE_CHANGEMP); | 287 | BUTTON_POPUP_MANAGE_CHANGEMP); |
287 | menuBar()->insertItem(i18n("&Manage"), managePopup); | 288 | menuBar()->insertItem(i18n("&Manage"), managePopup); |
288 | // "chipcard" popup menu | 289 | // "chipcard" popup menu |
289 | #ifdef CONFIG_KEYCARD | 290 | #ifdef CONFIG_KEYCARD |
290 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), | 291 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("filenew", KIcon::Small)), |
291 | i18n("&Generate new key-card"), this, | 292 | i18n("&Generate new key-card"), this, |
292 | SLOT(genNewCard_slot()), 0, | 293 | SLOT(genNewCard_slot()), 0, |
293 | BUTTON_POPUP_CHIPCARD_GENNEW); | 294 | BUTTON_POPUP_CHIPCARD_GENNEW); |
294 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), | 295 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("editdelete", KIcon::Small)), |
295 | i18n("&Erase key-card"), this, | 296 | i18n("&Erase key-card"), this, |
296 | SLOT(eraseCard_slot()), 0, | 297 | SLOT(eraseCard_slot()), 0, |
297 | BUTTON_POPUP_CHIPCARD_DEL); | 298 | BUTTON_POPUP_CHIPCARD_DEL); |
298 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), | 299 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("", KIcon::Small)), |
299 | i18n("Read card-&ID"), this, | 300 | i18n("Read card-&ID"), this, |
300 | SLOT(readCardId_slot()), 0, | 301 | SLOT(readCardId_slot()), 0, |
301 | BUTTON_POPUP_CHIPCARD_READID); | 302 | BUTTON_POPUP_CHIPCARD_READID); |
302 | chipcardPopup->insertSeparator(); | 303 | chipcardPopup->insertSeparator(); |
303 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), | 304 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2rightarrow", KIcon::Small)), |
304 | i18n("&Make card backup-image"), this, | 305 | i18n("&Make card backup-image"), this, |
305 | SLOT(makeCardBackup_slot()), 0, | 306 | SLOT(makeCardBackup_slot()), 0, |
306 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); | 307 | BUTTON_POPUP_CHIPCARD_SAVEBACKUP); |
307 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), | 308 | chipcardPopup->insertItem(QIconSet(picons->loadIcon("2leftarrow", KIcon::Small)), |
308 | i18n("&Replay card backup-image"), this, | 309 | i18n("&Replay card backup-image"), this, |
309 | SLOT(replayCardBackup_slot()), 0, | 310 | SLOT(replayCardBackup_slot()), 0, |
310 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); | 311 | BUTTON_POPUP_CHIPCARD_REPLAYBACKUP); |
311 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); | 312 | menuBar()->insertItem(i18n("&Chipcard manager"), chipcardPopup); |
312 | #endif // CONFIG_KEYCARD | 313 | #endif // CONFIG_KEYCARD |
313 | // "view" popup menu | 314 | // "view" popup menu |
314 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), | 315 | viewPopup->insertItem(QIconSet(picons->loadIcon("find", KIcon::Small)), |
315 | i18n("&Find"), this, | 316 | i18n("&Find"), this, |
316 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); | 317 | SLOT(find_slot()), 0, BUTTON_POPUP_VIEW_FIND); |
317 | viewPopup->insertSeparator(); | 318 | viewPopup->insertSeparator(); |
318 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), | 319 | viewPopup->insertItem(QIconSet(picons->loadIcon("halfencrypted", KIcon::Small)), |
319 | i18n("&Lock all entries"), this, | 320 | i18n("&Lock all entries"), this, |
320 | SLOT(lockWnd_slot()), 0, | 321 | SLOT(lockWnd_slot()), 0, |
321 | BUTTON_POPUP_VIEW_LOCK); | 322 | BUTTON_POPUP_VIEW_LOCK); |
322 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), | 323 | viewPopup->insertItem(QIconSet(picons->loadIcon("encrypted", KIcon::Small)), |
323 | i18n("&Deep-lock all entries"), this, | 324 | i18n("&Deep-lock all entries"), this, |
324 | SLOT(deepLockWnd_slot()), 0, | 325 | SLOT(deepLockWnd_slot()), 0, |
325 | BUTTON_POPUP_VIEW_DEEPLOCK); | 326 | BUTTON_POPUP_VIEW_DEEPLOCK); |
326 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), | 327 | viewPopup->insertItem(QIconSet(picons->loadIcon("decrypted", KIcon::Small)), |
327 | i18n("&Unlock all entries"), this, | 328 | i18n("&Unlock all entries"), this, |
328 | SLOT(unlockWnd_slot()), 0, | 329 | SLOT(unlockWnd_slot()), 0, |
329 | BUTTON_POPUP_VIEW_UNLOCK); | 330 | BUTTON_POPUP_VIEW_UNLOCK); |
330 | menuBar()->insertItem(i18n("&View"), viewPopup); | 331 | menuBar()->insertItem(i18n("&View"), viewPopup); |
331 | // "options" popup menu | 332 | // "options" popup menu |
332 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), | 333 | optionsPopup->insertItem(QIconSet(picons->loadIcon("configure", KIcon::Small)), |
333 | i18n("&Configure..."), this, | 334 | i18n("&Configure..."), this, |
334 | SLOT(config_slot()), | 335 | SLOT(config_slot()), |
335 | BUTTON_POPUP_OPTIONS_CONFIG); | 336 | BUTTON_POPUP_OPTIONS_CONFIG); |
336 | menuBar()->insertItem(i18n("&Options"), optionsPopup); | 337 | menuBar()->insertItem(i18n("&Options"), optionsPopup); |
337 | // "help" popup menu | 338 | // "help" popup menu |
338 | #ifndef PWM_EMBEDDED | 339 | #ifndef PWM_EMBEDDED |
339 | helpPopup = helpMenu(QString::null, false); | 340 | helpPopup = helpMenu(QString::null, false); |
340 | #else | 341 | #else |
341 | menuBar()->insertItem(i18n("&Sync"), syncPopup); | 342 | menuBar()->insertItem(i18n("&Sync"), syncPopup); |
342 | 343 | ||
343 | 344 | ||
344 | 345 | ||
345 | 346 | ||
346 | 347 | ||
347 | helpPopup = new KPopupMenu(this); | 348 | helpPopup = new KPopupMenu(this); |
348 | 349 | ||
349 | 350 | ||
350 | helpPopup->insertItem(i18n("&License"), this, | 351 | helpPopup->insertItem(i18n("&License"), this, |
351 | SLOT(showLicense_slot()), 0, | 352 | SLOT(showLicense_slot()), 0, |
352 | BUTTON_POPUP_HELP_LICENSE); | 353 | BUTTON_POPUP_HELP_LICENSE); |
353 | 354 | ||
354 | helpPopup->insertItem(i18n("&Faq"), this, | 355 | helpPopup->insertItem(i18n("&Faq"), this, |
355 | SLOT(faq_slot()), 0, | 356 | SLOT(faq_slot()), 0, |
356 | BUTTON_POPUP_HELP_FAQ); | 357 | BUTTON_POPUP_HELP_FAQ); |
357 | 358 | ||
358 | helpPopup->insertItem(i18n("&About PwManager"), this, | 359 | helpPopup->insertItem(i18n("&About PwManager"), this, |
359 | SLOT(createAboutData_slot()), 0, | 360 | SLOT(createAboutData_slot()), 0, |
360 | BUTTON_POPUP_HELP_ABOUT); | 361 | BUTTON_POPUP_HELP_ABOUT); |
361 | 362 | ||
362 | helpPopup->insertItem(i18n("&Sync HowTo"), this, | 363 | helpPopup->insertItem(i18n("&Sync HowTo"), this, |
363 | SLOT(syncHowTo_slot()), 0, | 364 | SLOT(syncHowTo_slot()), 0, |
364 | BUTTON_POPUP_HELP_SYNC); | 365 | BUTTON_POPUP_HELP_SYNC); |
365 | 366 | ||
367 | helpPopup->insertItem(i18n("&What's New"), this, | ||
368 | SLOT(whatsnew_slot()), 0, | ||
369 | BUTTON_POPUP_HELP_WHATSNEW); | ||
370 | |||
366 | #endif | 371 | #endif |
367 | menuBar()->insertItem(i18n("&Help"), helpPopup); | 372 | menuBar()->insertItem(i18n("&Help"), helpPopup); |
368 | 373 | ||
369 | } | 374 | } |
370 | 375 | ||
371 | void PwM::initToolbar() | 376 | void PwM::initToolbar() |
372 | { | 377 | { |
373 | KIconLoader* picons; | 378 | KIconLoader* picons; |
374 | #ifndef PWM_EMBEDDED | 379 | #ifndef PWM_EMBEDDED |
375 | KIconLoader icons; | 380 | KIconLoader icons; |
376 | picons = &icons; | 381 | picons = &icons; |
377 | #else | 382 | #else |
378 | picons = KGlobal::iconLoader(); | 383 | picons = KGlobal::iconLoader(); |
379 | #endif | 384 | #endif |
380 | 385 | ||
381 | #ifdef PWM_EMBEDDED | 386 | #ifdef PWM_EMBEDDED |
382 | if ( QApplication::desktop()->width() > 320 ) | 387 | if ( QApplication::desktop()->width() > 320 ) |
383 | #endif | 388 | #endif |
384 | { | 389 | { |
385 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), | 390 | toolBar()->insertButton(picons->loadIcon("filenew", KIcon::Toolbar), |
386 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, | 391 | BUTTON_TOOL_NEW, SIGNAL(clicked(int)), this, |
387 | SLOT(new_slot()), true, i18n("New")); | 392 | SLOT(new_slot()), true, i18n("New")); |
388 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), | 393 | toolBar()->insertButton(picons->loadIcon("fileopen", KIcon::Toolbar), |
389 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, | 394 | BUTTON_TOOL_OPEN, SIGNAL(clicked(int)), this, |
390 | SLOT(open_slot()), true, i18n("Open")); | 395 | SLOT(open_slot()), true, i18n("Open")); |
391 | toolBar()->insertSeparator(); | 396 | toolBar()->insertSeparator(); |
392 | } | 397 | } |
393 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), | 398 | toolBar()->insertButton(picons->loadIcon("filesave", KIcon::Toolbar), |
394 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, | 399 | BUTTON_TOOL_SAVE, SIGNAL(clicked(int)), this, |
395 | SLOT(save_slot()), true, i18n("Save")); | 400 | SLOT(save_slot()), true, i18n("Save")); |
396 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), | 401 | toolBar()->insertButton(picons->loadIcon("filesaveas", KIcon::Toolbar), |
397 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, | 402 | BUTTON_TOOL_SAVEAS, SIGNAL(clicked(int)), this, |
398 | SLOT(saveAs_slot()), true, i18n("Save as")); | 403 | SLOT(saveAs_slot()), true, i18n("Save as")); |
399 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), | 404 | toolBar()->insertButton(picons->loadIcon("fileprint", KIcon::Toolbar), |
400 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, | 405 | BUTTON_TOOL_PRINT, SIGNAL(clicked(int)), this, |
401 | SLOT(print_slot()), true, i18n("Print...")); | 406 | SLOT(print_slot()), true, i18n("Print...")); |
402 | toolBar()->insertSeparator(); | 407 | toolBar()->insertSeparator(); |
403 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), | 408 | toolBar()->insertButton(picons->loadIcon("pencil", KIcon::Toolbar), |
404 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, | 409 | BUTTON_TOOL_ADD, SIGNAL(clicked(int)), this, |
405 | SLOT(addPwd_slot()), true, | 410 | SLOT(addPwd_slot()), true, |
406 | i18n("Add password")); | 411 | i18n("Add password")); |
407 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), | 412 | toolBar()->insertButton(picons->loadIcon("edit", KIcon::Toolbar), |
408 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, | 413 | BUTTON_TOOL_EDIT, SIGNAL(clicked(int)), this, |
409 | SLOT(editPwd_slot()), true, | 414 | SLOT(editPwd_slot()), true, |
410 | i18n("Edit password")); | 415 | i18n("Edit password")); |
411 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), | 416 | toolBar()->insertButton(picons->loadIcon("editdelete", KIcon::Toolbar), |
412 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, | 417 | BUTTON_TOOL_DEL, SIGNAL(clicked(int)), this, |
413 | SLOT(deletePwd_slot()), true, | 418 | SLOT(deletePwd_slot()), true, |
414 | i18n("Delete password")); | 419 | i18n("Delete password")); |
415 | toolBar()->insertSeparator(); | 420 | toolBar()->insertSeparator(); |
416 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), | 421 | toolBar()->insertButton(picons->loadIcon("find", KIcon::Toolbar), |
417 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, | 422 | BUTTON_TOOL_FIND, SIGNAL(clicked(int)), this, |
418 | SLOT(find_slot()), true, i18n("Find entry")); | 423 | SLOT(find_slot()), true, i18n("Find entry")); |
419 | toolBar()->insertSeparator(); | 424 | toolBar()->insertSeparator(); |
420 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), | 425 | toolBar()->insertButton(picons->loadIcon("halfencrypted", KIcon::Toolbar), |
421 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, | 426 | BUTTON_TOOL_LOCK, SIGNAL(clicked(int)), this, |
422 | SLOT(lockWnd_slot()), true, | 427 | SLOT(lockWnd_slot()), true, |
423 | i18n("Lock all entries")); | 428 | i18n("Lock all entries")); |
424 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), | 429 | toolBar()->insertButton(picons->loadIcon("encrypted", KIcon::Toolbar), |
425 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, | 430 | BUTTON_TOOL_DEEPLOCK, SIGNAL(clicked(int)), this, |
426 | SLOT(deepLockWnd_slot()), true, | 431 | SLOT(deepLockWnd_slot()), true, |
427 | i18n("Deep-Lock all entries")); | 432 | i18n("Deep-Lock all entries")); |
428 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), | 433 | toolBar()->insertButton(picons->loadIcon("decrypted", KIcon::Toolbar), |
429 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, | 434 | BUTTON_TOOL_UNLOCK, SIGNAL(clicked(int)), this, |
430 | SLOT(unlockWnd_slot()), true, | 435 | SLOT(unlockWnd_slot()), true, |
431 | i18n("Unlock all entries")); | 436 | i18n("Unlock all entries")); |
432 | } | 437 | } |
433 | 438 | ||
434 | void PwM::initMetrics() | 439 | void PwM::initMetrics() |
435 | { | 440 | { |
436 | QSize s = conf()->confWndMainWndSize(); | 441 | QSize s = conf()->confWndMainWndSize(); |
437 | if (s.isValid()) | 442 | if (s.isValid()) |
438 | resize(s); | 443 | resize(s); |
439 | else | 444 | else |
440 | resize(DEFAULT_SIZE); | 445 | resize(DEFAULT_SIZE); |
441 | } | 446 | } |
442 | 447 | ||
443 | void PwM::updateCaption() | 448 | void PwM::updateCaption() |
444 | { | 449 | { |
445 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); | 450 | setPlainCaption(curDoc()->getTitle() + " - " PROG_NAME " " PACKAGE_VER); |
446 | } | 451 | } |
447 | 452 | ||
448 | void PwM::hideEvent(QHideEvent *) | 453 | void PwM::hideEvent(QHideEvent *) |
449 | { | 454 | { |
450 | if (isMinimized()) { | 455 | if (isMinimized()) { |
451 | if (init->tray()) { | 456 | if (init->tray()) { |
452 | forceMinimizeToTray = true; | 457 | forceMinimizeToTray = true; |
453 | close(); | 458 | close(); |
454 | } | 459 | } |
455 | int mmlock = conf()->confGlobMinimizeLock(); | 460 | int mmlock = conf()->confGlobMinimizeLock(); |
456 | switch (mmlock) { | 461 | switch (mmlock) { |
457 | case 0: // don't lock anything | 462 | case 0: // don't lock anything |
458 | break; | 463 | break; |
459 | case 1: {// normal lock | 464 | case 1: {// normal lock |
460 | curDoc()->lockAll(true); | 465 | curDoc()->lockAll(true); |
461 | break; | 466 | break; |
462 | } case 2: {// deep-lock | 467 | } case 2: {// deep-lock |
463 | curDoc()->deepLock(); | 468 | curDoc()->deepLock(); |
464 | break; | 469 | break; |
465 | } default: | 470 | } default: |
466 | WARN(); | 471 | WARN(); |
467 | } | 472 | } |
468 | } | 473 | } |
469 | } | 474 | } |
470 | 475 | ||
471 | void PwM::setVirgin(bool v) | 476 | void PwM::setVirgin(bool v) |
472 | { | 477 | { |
473 | if (virgin == v) | 478 | if (virgin == v) |
474 | return; | 479 | return; |
475 | virgin = v; | 480 | virgin = v; |
476 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); | 481 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVE, !v); |
477 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); | 482 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_SAVEAS, !v); |
478 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); | 483 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_EXPORT, !v); |
479 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); | 484 | filePopup->setItemEnabled(BUTTON_POPUP_FILE_PRINT, !v); |
480 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); | 485 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_EDIT, !v); |
481 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); | 486 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_DEL, !v); |
482 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); | 487 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, !v); |
483 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); | 488 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_LOCK, !v); |
484 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); | 489 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_DEEPLOCK, !v); |
485 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); | 490 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_UNLOCK, !v); |
486 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); | 491 | viewPopup->setItemEnabled(BUTTON_POPUP_VIEW_FIND, !v); |
487 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); | 492 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVE, !v); |
488 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); | 493 | toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); |
489 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); | 494 | toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); |
490 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); | 495 | toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); |
491 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); | 496 | toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); |
492 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); | 497 | toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); |
493 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); | 498 | toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); |
494 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); | 499 | toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); |
495 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); | 500 | toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); |
496 | } | 501 | } |
497 | 502 | ||
498 | void PwM::new_slot() | 503 | void PwM::new_slot() |
499 | { | 504 | { |
500 | init->createMainWnd(); | 505 | init->createMainWnd(); |
501 | } | 506 | } |
502 | 507 | ||
503 | //US ENH | 508 | //US ENH |
504 | void PwM::open_slot() | 509 | void PwM::open_slot() |
505 | { | 510 | { |
506 | open_slot(""); | 511 | open_slot(""); |
507 | } | 512 | } |
508 | 513 | ||
509 | void PwM::open_slot(QString fn) | 514 | void PwM::open_slot(QString fn) |
510 | { | 515 | { |
511 | openDoc(fn); | 516 | openDoc(fn); |
512 | } | 517 | } |
513 | 518 | ||
514 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) | 519 | PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) |
515 | { | 520 | { |
516 | if (!isVirgin()) { | 521 | if (!isVirgin()) { |
517 | // open the document in a new window. | 522 | // open the document in a new window. |
518 | PwM *newInstance = init->createMainWnd(); | 523 | PwM *newInstance = init->createMainWnd(); |
519 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); | 524 | PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); |
520 | if (!newDoc) { | 525 | if (!newDoc) { |
521 | newInstance->setForceQuit(true); | 526 | newInstance->setForceQuit(true); |
522 | delete_and_null(newInstance); | 527 | delete_and_null(newInstance); |
523 | } | 528 | } |
524 | return newDoc; | 529 | return newDoc; |
525 | } | 530 | } |
526 | 531 | ||
527 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) | 532 | if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) |
528 | return 0; | 533 | return 0; |
529 | showStatMsg(i18n("Successfully opened file.")); | 534 | showStatMsg(i18n("Successfully opened file.")); |
530 | updateCaption(); | 535 | updateCaption(); |
531 | setVirgin(false); | 536 | setVirgin(false); |
532 | return curDoc(); | 537 | return curDoc(); |
533 | } | 538 | } |
534 | 539 | ||
535 | PwMView * PwM::makeNewListView(PwMDoc *doc) | 540 | PwMView * PwM::makeNewListView(PwMDoc *doc) |
536 | { | 541 | { |
537 | PwMView *ret = new PwMView(this, this, doc); | 542 | PwMView *ret = new PwMView(this, this, doc); |
538 | ret->setFont(conf()->confGlobEntryFont()); | 543 | ret->setFont(conf()->confGlobEntryFont()); |
539 | ret->show(); | 544 | ret->show(); |
540 | return ret; | 545 | return ret; |
541 | } | 546 | } |
542 | 547 | ||
543 | void PwM::close_slot() | 548 | void PwM::close_slot() |
544 | { | 549 | { |
545 | close(); | 550 | close(); |
546 | } | 551 | } |
547 | 552 | ||
548 | void PwM::quitButton_slot() | 553 | void PwM::quitButton_slot() |
549 | { | 554 | { |
550 | init->shutdownApp(0); | 555 | init->shutdownApp(0); |
551 | } | 556 | } |
552 | 557 | ||
553 | void PwM::save_slot() | 558 | void PwM::save_slot() |
554 | { | 559 | { |
555 | save(); | 560 | save(); |
556 | } | 561 | } |
557 | 562 | ||
558 | bool PwM::save() | 563 | bool PwM::save() |
559 | { | 564 | { |
560 | if (!curDoc()->saveDocUi(curDoc())) | 565 | if (!curDoc()->saveDocUi(curDoc())) |
561 | return false; | 566 | return false; |
562 | showStatMsg(i18n("Successfully saved data.")); | 567 | showStatMsg(i18n("Successfully saved data.")); |
563 | updateCaption(); | 568 | updateCaption(); |
564 | return true; | 569 | return true; |
565 | } | 570 | } |
566 | 571 | ||
567 | void PwM::saveAs_slot() | 572 | void PwM::saveAs_slot() |
568 | { | 573 | { |
569 | saveAs(); | 574 | saveAs(); |
570 | } | 575 | } |
571 | 576 | ||
572 | bool PwM::saveAs() | 577 | bool PwM::saveAs() |
573 | { | 578 | { |
574 | if (!curDoc()->saveAsDocUi(curDoc())) | 579 | if (!curDoc()->saveAsDocUi(curDoc())) |
575 | return false; | 580 | return false; |
576 | showStatMsg(i18n("Successfully saved data.")); | 581 | showStatMsg(i18n("Successfully saved data.")); |
577 | updateCaption(); | 582 | updateCaption(); |
578 | return true; | 583 | return true; |
579 | } | 584 | } |
580 | 585 | ||
581 | //US ENH : changed code to run with older MOC | 586 | //US ENH : changed code to run with older MOC |
582 | void PwM::addPwd_slot() | 587 | void PwM::addPwd_slot() |
583 | { | 588 | { |
584 | addPwd_slot(0, 0); | 589 | addPwd_slot(0, 0); |
585 | } | 590 | } |
586 | 591 | ||
587 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) | 592 | void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) |
588 | { | 593 | { |
589 | PwMDoc *doc; | 594 | PwMDoc *doc; |
590 | if (_doc) { | 595 | if (_doc) { |
591 | doc = _doc; | 596 | doc = _doc; |
592 | } else { | 597 | } else { |
593 | doc = curDoc(); | 598 | doc = curDoc(); |
594 | } | 599 | } |
595 | PWM_ASSERT(doc); | 600 | PWM_ASSERT(doc); |
596 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 601 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
597 | #ifndef PWM_EMBEDDED | 602 | #ifndef PWM_EMBEDDED |
598 | AddEntryWndImpl w; | 603 | AddEntryWndImpl w; |
599 | #else | 604 | #else |
600 | AddEntryWndImpl w(this, "addentrywndimpl"); | 605 | AddEntryWndImpl w(this, "addentrywndimpl"); |
601 | #endif | 606 | #endif |
602 | 607 | ||
603 | vector<string> catList; | 608 | vector<string> catList; |
604 | doc->getCategoryList(&catList); | 609 | doc->getCategoryList(&catList); |
605 | unsigned i, size = catList.size(); | 610 | unsigned i, size = catList.size(); |
606 | for (i = 0; i < size; ++i) { | 611 | for (i = 0; i < size; ++i) { |
607 | w.addCategory(catList[i].c_str()); | 612 | w.addCategory(catList[i].c_str()); |
608 | } | 613 | } |
609 | w.setCurrCategory(view->getCurrentCategory()); | 614 | w.setCurrCategory(view->getCurrentCategory()); |
610 | if (pw) | 615 | if (pw) |
611 | w.pwLineEdit->setText(*pw); | 616 | w.pwLineEdit->setText(*pw); |
612 | 617 | ||
613 | tryAgain: | 618 | tryAgain: |
614 | if (w.exec() == 1) | 619 | if (w.exec() == 1) |
615 | { | 620 | { |
616 | PwMDataItem d; | 621 | PwMDataItem d; |
617 | 622 | ||
618 | //US BUG: to initialize all values of curEntr with meaningfulldata, | 623 | //US BUG: to initialize all values of curEntr with meaningfulldata, |
619 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. | 624 | // we call clear on it. Reason: Metadata will be uninitialized otherwise. |
620 | // another option would be to create a constructor for PwMDataItem | 625 | // another option would be to create a constructor for PwMDataItem |
621 | d.clear(true); | 626 | d.clear(true); |
622 | 627 | ||
623 | d.desc = w.getDescription().latin1(); | 628 | d.desc = w.getDescription().latin1(); |
624 | d.name = w.getUsername().latin1(); | 629 | d.name = w.getUsername().latin1(); |
625 | d.pw = w.getPassword().latin1(); | 630 | d.pw = w.getPassword().latin1(); |
626 | d.comment = w.getComment().latin1(); | 631 | d.comment = w.getComment().latin1(); |
627 | d.url = w.getUrl().latin1(); | 632 | d.url = w.getUrl().latin1(); |
628 | d.launcher = w.getLauncher().latin1(); | 633 | d.launcher = w.getLauncher().latin1(); |
629 | PwMerror ret = doc->addEntry(w.getCategory(), &d); | 634 | PwMerror ret = doc->addEntry(w.getCategory(), &d); |
630 | if (ret == e_entryExists) { | 635 | if (ret == e_entryExists) { |
631 | KMessageBox::error(this, | 636 | KMessageBox::error(this, |
632 | i18n | 637 | i18n |
633 | ("An entry with this \"Description\",\n" | 638 | ("An entry with this \"Description\",\n" |
634 | "does already exist.\n" | 639 | "does already exist.\n" |
635 | "Please select another description."), | 640 | "Please select another description."), |
636 | i18n("entry already exists.")); | 641 | i18n("entry already exists.")); |
637 | goto tryAgain; | 642 | goto tryAgain; |
638 | } else if (ret == e_maxAllowedEntr) { | 643 | } else if (ret == e_maxAllowedEntr) { |
639 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" | 644 | KMessageBox::error(this, i18n("The maximum possible number of\nentries" |
640 | "has been reached.\nYou can't add more entries."), | 645 | "has been reached.\nYou can't add more entries."), |
641 | i18n("maximum number of entries")); | 646 | i18n("maximum number of entries")); |
642 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 647 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
643 | return; | 648 | return; |
644 | } | 649 | } |
645 | } | 650 | } |
646 | setVirgin(false); | 651 | setVirgin(false); |
647 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 652 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
648 | } | 653 | } |
649 | 654 | ||
650 | //US ENH : changed code to run with older MOC | 655 | //US ENH : changed code to run with older MOC |
651 | void PwM::editPwd_slot() | 656 | void PwM::editPwd_slot() |
652 | { | 657 | { |
653 | editPwd_slot(0,0,0); | 658 | editPwd_slot(0,0,0); |
654 | } | 659 | } |
655 | 660 | ||
656 | void PwM::editPwd_slot(const QString *category) | 661 | void PwM::editPwd_slot(const QString *category) |
657 | { | 662 | { |
658 | editPwd_slot(category, 0, 0); | 663 | editPwd_slot(category, 0, 0); |
659 | } | 664 | } |
660 | 665 | ||
661 | void PwM::editPwd_slot(const QString *category, const int *index, | 666 | void PwM::editPwd_slot(const QString *category, const int *index, |
662 | PwMDoc *_doc) | 667 | PwMDoc *_doc) |
663 | { | 668 | { |
664 | PwMDoc *doc; | 669 | PwMDoc *doc; |
665 | if (_doc) { | 670 | if (_doc) { |
666 | doc = _doc; | 671 | doc = _doc; |
667 | } else { | 672 | } else { |
668 | doc = curDoc(); | 673 | doc = curDoc(); |
669 | } | 674 | } |
670 | PWM_ASSERT(doc); | 675 | PWM_ASSERT(doc); |
671 | if (doc->isDocEmpty()) | 676 | if (doc->isDocEmpty()) |
672 | return; | 677 | return; |
673 | if (doc->isDeepLocked()) | 678 | if (doc->isDeepLocked()) |
674 | return; | 679 | return; |
675 | doc->timer()->getLock(DocTimer::id_autoLockTimer); | 680 | doc->timer()->getLock(DocTimer::id_autoLockTimer); |
676 | unsigned int curEntryIndex; | 681 | unsigned int curEntryIndex; |
677 | if (index) { | 682 | if (index) { |
678 | curEntryIndex = *index; | 683 | curEntryIndex = *index; |
679 | } else { | 684 | } else { |
680 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 685 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
681 | printDebug("couldn't get index. Maybe we have a binary entry here."); | 686 | printDebug("couldn't get index. Maybe we have a binary entry here."); |
682 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 687 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
683 | return; | 688 | return; |
684 | } | 689 | } |
685 | } | 690 | } |
686 | QString curCategory; | 691 | QString curCategory; |
687 | if (category) { | 692 | if (category) { |
688 | curCategory = *category; | 693 | curCategory = *category; |
689 | } else { | 694 | } else { |
690 | curCategory = view->getCurrentCategory(); | 695 | curCategory = view->getCurrentCategory(); |
691 | } | 696 | } |
692 | PwMDataItem currItem; | 697 | PwMDataItem currItem; |
693 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { | 698 | if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { |
694 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 699 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
695 | return; | 700 | return; |
696 | } | 701 | } |
697 | BUG_ON(currItem.binary); | 702 | BUG_ON(currItem.binary); |
698 | 703 | ||
699 | AddEntryWndImpl w; | 704 | AddEntryWndImpl w; |
700 | vector<string> catList; | 705 | vector<string> catList; |
701 | doc->getCategoryList(&catList); | 706 | doc->getCategoryList(&catList); |
702 | unsigned i, size = catList.size(); | 707 | unsigned i, size = catList.size(); |
703 | for (i = 0; i < size; ++i) { | 708 | for (i = 0; i < size; ++i) { |
704 | w.addCategory(catList[i].c_str()); | 709 | w.addCategory(catList[i].c_str()); |
705 | } | 710 | } |
706 | w.setCurrCategory(curCategory); | 711 | w.setCurrCategory(curCategory); |
707 | w.setDescription(currItem.desc.c_str()); | 712 | w.setDescription(currItem.desc.c_str()); |
708 | w.setUsername(currItem.name.c_str()); | 713 | w.setUsername(currItem.name.c_str()); |
709 | w.setPassword(currItem.pw.c_str()); | 714 | w.setPassword(currItem.pw.c_str()); |
710 | w.setUrl(currItem.url.c_str()); | 715 | w.setUrl(currItem.url.c_str()); |
711 | w.setLauncher(currItem.launcher.c_str()); | 716 | w.setLauncher(currItem.launcher.c_str()); |
712 | w.setComment(currItem.comment.c_str()); | 717 | w.setComment(currItem.comment.c_str()); |
713 | if (w.exec() == 1) { | 718 | if (w.exec() == 1) { |
714 | currItem.desc = w.getDescription().latin1(); | 719 | currItem.desc = w.getDescription().latin1(); |
715 | currItem.name = w.getUsername().latin1(); | 720 | currItem.name = w.getUsername().latin1(); |
716 | currItem.pw = w.getPassword().latin1(); | 721 | currItem.pw = w.getPassword().latin1(); |
717 | currItem.comment = w.getComment().latin1(); | 722 | currItem.comment = w.getComment().latin1(); |
718 | currItem.url = w.getUrl().latin1(); | 723 | currItem.url = w.getUrl().latin1(); |
719 | currItem.launcher = w.getLauncher().latin1(); | 724 | currItem.launcher = w.getLauncher().latin1(); |
720 | if (!doc->editEntry(curCategory, w.getCategory(), | 725 | if (!doc->editEntry(curCategory, w.getCategory(), |
721 | curEntryIndex, &currItem)) { | 726 | curEntryIndex, &currItem)) { |
722 | KMessageBox::error(this, | 727 | KMessageBox::error(this, |
723 | i18n("Couldn't edit the entry.\n" | 728 | i18n("Couldn't edit the entry.\n" |
724 | "Maybe you changed the category and " | 729 | "Maybe you changed the category and " |
725 | "this entry is already present in the new " | 730 | "this entry is already present in the new " |
726 | "category?"), | 731 | "category?"), |
727 | i18n("couldn't edit entry.")); | 732 | i18n("couldn't edit entry.")); |
728 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 733 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
729 | return; | 734 | return; |
730 | } | 735 | } |
731 | } | 736 | } |
732 | doc->timer()->putLock(DocTimer::id_autoLockTimer); | 737 | doc->timer()->putLock(DocTimer::id_autoLockTimer); |
733 | } | 738 | } |
734 | 739 | ||
735 | void PwM::deletePwd_slot() | 740 | void PwM::deletePwd_slot() |
736 | { | 741 | { |
737 | PWM_ASSERT(curDoc()); | 742 | PWM_ASSERT(curDoc()); |
738 | if (curDoc()->isDocEmpty()) | 743 | if (curDoc()->isDocEmpty()) |
739 | return; | 744 | return; |
740 | if (curDoc()->isDeepLocked()) | 745 | if (curDoc()->isDeepLocked()) |
741 | return; | 746 | return; |
742 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 747 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
743 | unsigned int curEntryIndex = 0; | 748 | unsigned int curEntryIndex = 0; |
744 | if (!(view->getCurEntryIndex(&curEntryIndex))) { | 749 | if (!(view->getCurEntryIndex(&curEntryIndex))) { |
745 | printDebug("couldn't get index"); | 750 | printDebug("couldn't get index"); |
746 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 751 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
747 | return; | 752 | return; |
748 | } | 753 | } |
749 | 754 | ||
750 | PwMDataItem currItem; | 755 | PwMDataItem currItem; |
751 | QString curCategory = view->getCurrentCategory(); | 756 | QString curCategory = view->getCurrentCategory(); |
752 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { | 757 | if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { |
753 | printDebug("couldn't get entry"); | 758 | printDebug("couldn't get entry"); |
754 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 759 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
755 | return; | 760 | return; |
756 | } | 761 | } |
757 | if (KMessageBox:: | 762 | if (KMessageBox:: |
758 | questionYesNo(this, | 763 | questionYesNo(this, |
759 | i18n | 764 | i18n |
760 | ("Do you really want to delete\nthe selected entry") + | 765 | ("Do you really want to delete\nthe selected entry") + |
761 | " \n\"" + QString(currItem.desc.c_str()) | 766 | " \n\"" + QString(currItem.desc.c_str()) |
762 | + "\" ?", i18n("delete?")) | 767 | + "\" ?", i18n("delete?")) |
763 | == KMessageBox::Yes) { | 768 | == KMessageBox::Yes) { |
764 | 769 | ||
765 | curDoc()->delEntry(curCategory, curEntryIndex); | 770 | curDoc()->delEntry(curCategory, curEntryIndex); |
766 | } | 771 | } |
767 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 772 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
768 | } | 773 | } |
769 | 774 | ||
770 | void PwM::changeMasterPwd_slot() | 775 | void PwM::changeMasterPwd_slot() |
771 | { | 776 | { |
772 | PWM_ASSERT(curDoc()); | 777 | PWM_ASSERT(curDoc()); |
773 | curDoc()->changeCurrentPw(); | 778 | curDoc()->changeCurrentPw(); |
774 | } | 779 | } |
775 | 780 | ||
776 | void PwM::lockWnd_slot() | 781 | void PwM::lockWnd_slot() |
777 | { | 782 | { |
778 | PWM_ASSERT(curDoc()); | 783 | PWM_ASSERT(curDoc()); |
779 | curDoc()->lockAll(true); | 784 | curDoc()->lockAll(true); |
780 | } | 785 | } |
781 | 786 | ||
782 | void PwM::deepLockWnd_slot() | 787 | void PwM::deepLockWnd_slot() |
783 | { | 788 | { |
784 | PWM_ASSERT(curDoc()); | 789 | PWM_ASSERT(curDoc()); |
785 | curDoc()->deepLock(); | 790 | curDoc()->deepLock(); |
786 | } | 791 | } |
787 | 792 | ||
788 | void PwM::unlockWnd_slot() | 793 | void PwM::unlockWnd_slot() |
789 | { | 794 | { |
790 | PWM_ASSERT(curDoc()); | 795 | PWM_ASSERT(curDoc()); |
791 | curDoc()->lockAll(false); | 796 | curDoc()->lockAll(false); |
792 | } | 797 | } |
793 | 798 | ||
794 | void PwM::config_slot() | 799 | void PwM::config_slot() |
795 | { | 800 | { |
796 | int oldStyle = conf()->confWndMainViewStyle(); | 801 | int oldStyle = conf()->confWndMainViewStyle(); |
797 | #ifdef PWM_EMBEDDED | 802 | #ifdef PWM_EMBEDDED |
798 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); | 803 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"pwmconfigdialog", true ); |
799 | 804 | ||
800 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); | 805 | KCMPwmConfig* pwmcfg = new KCMPwmConfig( ConfigureDialog->getNewVBoxPage(i18n( "PwManager")) , "KCMPwmConfig" ); |
801 | ConfigureDialog->addModule(pwmcfg ); | 806 | ConfigureDialog->addModule(pwmcfg ); |
802 | 807 | ||
803 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 808 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
804 | ConfigureDialog->addModule(kdelibcfg ); | 809 | ConfigureDialog->addModule(kdelibcfg ); |
805 | 810 | ||
806 | #ifndef DESKTOP_VERSION | 811 | #ifndef DESKTOP_VERSION |
807 | ConfigureDialog->showMaximized(); | 812 | ConfigureDialog->showMaximized(); |
808 | #endif | 813 | #endif |
809 | if ( ConfigureDialog->exec() ) | 814 | if ( ConfigureDialog->exec() ) |
810 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 815 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
811 | delete ConfigureDialog; | 816 | delete ConfigureDialog; |
812 | 817 | ||
813 | #else //PWM_EMBEDDED | 818 | #else //PWM_EMBEDDED |
814 | // display the configuration window (modal mode) | 819 | // display the configuration window (modal mode) |
815 | if (!conf()->showConfWnd(this)) | 820 | if (!conf()->showConfWnd(this)) |
816 | return; | 821 | return; |
817 | #endif | 822 | #endif |
818 | 823 | ||
819 | int newStyle = conf()->confWndMainViewStyle(); | 824 | int newStyle = conf()->confWndMainViewStyle(); |
820 | // reinitialize tray | 825 | // reinitialize tray |
821 | init->initTray(); | 826 | init->initTray(); |
822 | // reinitialize KWallet emulation | 827 | // reinitialize KWallet emulation |
823 | init->initKWalletEmu(); | 828 | init->initKWalletEmu(); |
824 | 829 | ||
825 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 830 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
826 | const vector<PwMDocList::listItem> *dl = _dl->getList(); | 831 | const vector<PwMDocList::listItem> *dl = _dl->getList(); |
827 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 832 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
828 | end = dl->end(); | 833 | end = dl->end(); |
829 | PwMDoc *doc; | 834 | PwMDoc *doc; |
830 | while (i != end) { | 835 | while (i != end) { |
831 | doc = (*i).doc; | 836 | doc = (*i).doc; |
832 | // unlock-without-mpw timeout | 837 | // unlock-without-mpw timeout |
833 | doc->timer()->start(DocTimer::id_mpwTimer); | 838 | doc->timer()->start(DocTimer::id_mpwTimer); |
834 | // auto-lock timeout | 839 | // auto-lock timeout |
835 | doc->timer()->start(DocTimer::id_autoLockTimer); | 840 | doc->timer()->start(DocTimer::id_autoLockTimer); |
836 | ++i; | 841 | ++i; |
837 | } | 842 | } |
838 | 843 | ||
839 | const QValueList<PwM *> *ml = init->mainWndList(); | 844 | const QValueList<PwM *> *ml = init->mainWndList(); |
840 | #ifndef PWM_EMBEDDED | 845 | #ifndef PWM_EMBEDDED |
841 | QValueList<PwM *>::const_iterator i2 = ml->begin(), | 846 | QValueList<PwM *>::const_iterator i2 = ml->begin(), |
842 | end2 = ml->end(); | 847 | end2 = ml->end(); |
843 | #else | 848 | #else |
844 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), | 849 | QValueList<PwM *>::ConstIterator i2 = ml->begin(), |
845 | end2 = ml->end(); | 850 | end2 = ml->end(); |
846 | #endif | 851 | #endif |
847 | PwM *pwm; | 852 | PwM *pwm; |
848 | while (i2 != end2) { | 853 | while (i2 != end2) { |
849 | pwm = *i2; | 854 | pwm = *i2; |
850 | // reinitialize the window style. | 855 | // reinitialize the window style. |
851 | if (oldStyle != newStyle) | 856 | if (oldStyle != newStyle) |
852 | pwm->curView()->initStyle(newStyle); | 857 | pwm->curView()->initStyle(newStyle); |
853 | // set the new font | 858 | // set the new font |
854 | pwm->curView()->setFont(conf()->confGlobEntryFont()); | 859 | pwm->curView()->setFont(conf()->confGlobEntryFont()); |
855 | ++i2; | 860 | ++i2; |
856 | } | 861 | } |
857 | } | 862 | } |
858 | 863 | ||
859 | void PwM::activateMpButton(bool activate) | 864 | void PwM::activateMpButton(bool activate) |
860 | { | 865 | { |
861 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); | 866 | managePopup->setItemEnabled(BUTTON_POPUP_MANAGE_CHANGEMP, activate); |
862 | } | 867 | } |
863 | 868 | ||
864 | void PwM::closeEvent(QCloseEvent *e) | 869 | void PwM::closeEvent(QCloseEvent *e) |
865 | { | 870 | { |
866 | e->accept(); | 871 | e->accept(); |
867 | } | 872 | } |
868 | 873 | ||
869 | void PwM::docClosed(PwMDoc *doc) | 874 | void PwM::docClosed(PwMDoc *doc) |
870 | { | 875 | { |
871 | PARAM_UNUSED(doc); | 876 | PARAM_UNUSED(doc); |
872 | PWM_ASSERT(doc == curDoc()); | 877 | PWM_ASSERT(doc == curDoc()); |
873 | close(); | 878 | close(); |
874 | } | 879 | } |
875 | 880 | ||
876 | void PwM::find_slot() | 881 | void PwM::find_slot() |
877 | { | 882 | { |
878 | PWM_ASSERT(curDoc()); | 883 | PWM_ASSERT(curDoc()); |
879 | if (curDoc()->isDocEmpty()) | 884 | if (curDoc()->isDocEmpty()) |
880 | return; | 885 | return; |
881 | if (curDoc()->isDeepLocked()) | 886 | if (curDoc()->isDeepLocked()) |
882 | return; | 887 | return; |
883 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 888 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
884 | FindWndImpl findWnd(view); | 889 | FindWndImpl findWnd(view); |
885 | findWnd.exec(); | 890 | findWnd.exec(); |
886 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 891 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
887 | } | 892 | } |
888 | 893 | ||
889 | void PwM::exportToText() | 894 | void PwM::exportToText() |
890 | { | 895 | { |
891 | PWM_ASSERT(curDoc()); | 896 | PWM_ASSERT(curDoc()); |
892 | if (curDoc()->isDocEmpty()) { | 897 | if (curDoc()->isDocEmpty()) { |
893 | KMessageBox::information(this, | 898 | KMessageBox::information(this, |
894 | i18n | 899 | i18n |
895 | ("Sorry, there's nothing to export.\n" | 900 | ("Sorry, there's nothing to export.\n" |
896 | "Please first add some passwords."), | 901 | "Please first add some passwords."), |
897 | i18n("nothing to do")); | 902 | i18n("nothing to do")); |
898 | return; | 903 | return; |
899 | } | 904 | } |
900 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 905 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
901 | QString fn(KFileDialog::getSaveFileName(QString::null, | 906 | QString fn(KFileDialog::getSaveFileName(QString::null, |
902 | i18n("*|plain-text file"), | 907 | i18n("*|plain-text file"), |
903 | this)); | 908 | this)); |
904 | if (fn == "") { | 909 | if (fn == "") { |
905 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 910 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
906 | return; | 911 | return; |
907 | } | 912 | } |
908 | 913 | ||
909 | PwMerror ret = curDoc()->exportToText(&fn); | 914 | PwMerror ret = curDoc()->exportToText(&fn); |
910 | if (ret != e_success) { | 915 | if (ret != e_success) { |
911 | KMessageBox::error(this, | 916 | KMessageBox::error(this, |
912 | i18n("Error: Couldn't write to file.\n" | 917 | i18n("Error: Couldn't write to file.\n" |
913 | "Please check if you have permission to write " | 918 | "Please check if you have permission to write " |
914 | "to the file in that directory."), | 919 | "to the file in that directory."), |
915 | i18n("error while writing")); | 920 | i18n("error while writing")); |
916 | } else | 921 | } else |
917 | showStatMsg(i18n("Successfully exported data.")); | 922 | showStatMsg(i18n("Successfully exported data.")); |
918 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 923 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
919 | } | 924 | } |
920 | 925 | ||
921 | bool PwM::importFromText() | 926 | bool PwM::importFromText() |
922 | { | 927 | { |
923 | if (!isVirgin()) { | 928 | if (!isVirgin()) { |
924 | if (KMessageBox::questionYesNo(this, | 929 | if (KMessageBox::questionYesNo(this, |
925 | i18n("Do you want to import the data " | 930 | i18n("Do you want to import the data " |
926 | "into the current document? (If you " | 931 | "into the current document? (If you " |
927 | "select \"no\", a new document will be " | 932 | "select \"no\", a new document will be " |
928 | "opened.)"), | 933 | "opened.)"), |
929 | i18n("import into this document?")) | 934 | i18n("import into this document?")) |
930 | == KMessageBox::No) { | 935 | == KMessageBox::No) { |
931 | // import the data to a new window. | 936 | // import the data to a new window. |
932 | PwM *newInstance = init->createMainWnd(); | 937 | PwM *newInstance = init->createMainWnd(); |
933 | bool ok = newInstance->importFromText(); | 938 | bool ok = newInstance->importFromText(); |
934 | if (!ok) { | 939 | if (!ok) { |
935 | newInstance->setForceQuit(true); | 940 | newInstance->setForceQuit(true); |
936 | delete_and_null(newInstance); | 941 | delete_and_null(newInstance); |
937 | } | 942 | } |
938 | return ok; | 943 | return ok; |
939 | } | 944 | } |
940 | } | 945 | } |
941 | 946 | ||
942 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 947 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
943 | PwMerror ret; | 948 | PwMerror ret; |
944 | QString path(KFileDialog::getOpenFileName(QString::null, | 949 | QString path(KFileDialog::getOpenFileName(QString::null, |
945 | i18n("*|PWM-exported text file"), | 950 | i18n("*|PWM-exported text file"), |
946 | this)); | 951 | this)); |
947 | if (path == "") | 952 | if (path == "") |
948 | goto cancelImport; | 953 | goto cancelImport; |
949 | 954 | ||
950 | ret = curDoc()->importFromText(&path, 0); | 955 | ret = curDoc()->importFromText(&path, 0); |
951 | if (ret == e_fileFormat) { | 956 | if (ret == e_fileFormat) { |
952 | KMessageBox::error(this, | 957 | KMessageBox::error(this, |
953 | i18n("Could not read file-format.\n" | 958 | i18n("Could not read file-format.\n" |
954 | "This seems to be _not_ a valid file " | 959 | "This seems to be _not_ a valid file " |
955 | "exported by PwM."), | 960 | "exported by PwM."), |
956 | i18n("invalid file-format")); | 961 | i18n("invalid file-format")); |
957 | goto cancelImport; | 962 | goto cancelImport; |
958 | } else if (ret == e_invalidArg) { | 963 | } else if (ret == e_invalidArg) { |
959 | BUG(); | 964 | BUG(); |
960 | goto cancelImport; | 965 | goto cancelImport; |
961 | } else if (ret != e_success) { | 966 | } else if (ret != e_success) { |
962 | KMessageBox::error(this, | 967 | KMessageBox::error(this, |
963 | i18n("Could not import file!\n" | 968 | i18n("Could not import file!\n" |
964 | "Do you have permission to read this file? " | 969 | "Do you have permission to read this file? " |
965 | "Do you have enough free memory?"), | 970 | "Do you have enough free memory?"), |
966 | i18n("import failed")); | 971 | i18n("import failed")); |
967 | goto cancelImport; | 972 | goto cancelImport; |
968 | } | 973 | } |
969 | setVirgin(false); | 974 | setVirgin(false); |
970 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 975 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
971 | return true; | 976 | return true; |
972 | 977 | ||
973 | cancelImport: | 978 | cancelImport: |
974 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 979 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
975 | return false; | 980 | return false; |
976 | } | 981 | } |
977 | 982 | ||
978 | void PwM::exportToGpasman() | 983 | void PwM::exportToGpasman() |
979 | { | 984 | { |
980 | PWM_ASSERT(curDoc()); | 985 | PWM_ASSERT(curDoc()); |
981 | if (curDoc()->isDocEmpty()) { | 986 | if (curDoc()->isDocEmpty()) { |
982 | KMessageBox::information(this, | 987 | KMessageBox::information(this, |
983 | i18n | 988 | i18n |
984 | ("Sorry, there's nothing to export.\n" | 989 | ("Sorry, there's nothing to export.\n" |
985 | "Please first add some passwords."), | 990 | "Please first add some passwords."), |
986 | i18n("nothing to do")); | 991 | i18n("nothing to do")); |
987 | return; | 992 | return; |
988 | } | 993 | } |
989 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 994 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
990 | QString fn(KFileDialog::getSaveFileName(QString::null, | 995 | QString fn(KFileDialog::getSaveFileName(QString::null, |
991 | i18n("*|Gpasman or Kpasman file"), | 996 | i18n("*|Gpasman or Kpasman file"), |
992 | this)); | 997 | this)); |
993 | if (fn == "") { | 998 | if (fn == "") { |
994 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 999 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
995 | return; | 1000 | return; |
996 | } | 1001 | } |
997 | 1002 | ||
998 | PwMerror ret = curDoc()->exportToGpasman(&fn); | 1003 | PwMerror ret = curDoc()->exportToGpasman(&fn); |
999 | if (ret != e_success) { | 1004 | if (ret != e_success) { |
1000 | if (ret == e_noPw) { | 1005 | if (ret == e_noPw) { |
1001 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1006 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1002 | return; | 1007 | return; |
1003 | } | 1008 | } |
1004 | KMessageBox::error(this, | 1009 | KMessageBox::error(this, |
1005 | i18n("Error: Couldn't write to file.\n" | 1010 | i18n("Error: Couldn't write to file.\n" |
1006 | "Please check if you have permission to write " | 1011 | "Please check if you have permission to write " |
1007 | "to the file in that directory."), | 1012 | "to the file in that directory."), |
1008 | i18n("error while writing")); | 1013 | i18n("error while writing")); |
1009 | } else | 1014 | } else |
1010 | showStatMsg(i18n("Successfully exported data.")); | 1015 | showStatMsg(i18n("Successfully exported data.")); |
1011 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1016 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1012 | } | 1017 | } |
1013 | 1018 | ||
1014 | void PwM::exportToKWallet() | 1019 | void PwM::exportToKWallet() |
1015 | { | 1020 | { |
1016 | #ifdef CONFIG_KWALLETIF | 1021 | #ifdef CONFIG_KWALLETIF |
1017 | if (!checkAndAskForKWalletEmu()) | 1022 | if (!checkAndAskForKWalletEmu()) |
1018 | return; | 1023 | return; |
1019 | PWM_ASSERT(curDoc()); | 1024 | PWM_ASSERT(curDoc()); |
1020 | if (curDoc()->isDocEmpty()) { | 1025 | if (curDoc()->isDocEmpty()) { |
1021 | KMessageBox::information(this, | 1026 | KMessageBox::information(this, |
1022 | i18n | 1027 | i18n |
1023 | ("Sorry, there's nothing to export.\n" | 1028 | ("Sorry, there's nothing to export.\n" |
1024 | "Please first add some passwords."), | 1029 | "Please first add some passwords."), |
1025 | i18n("nothing to do")); | 1030 | i18n("nothing to do")); |
1026 | init->initKWalletEmu(); | 1031 | init->initKWalletEmu(); |
1027 | return; | 1032 | return; |
1028 | } | 1033 | } |
1029 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1034 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1030 | KWalletIf walletIf(this); | 1035 | KWalletIf walletIf(this); |
1031 | if (walletIf.kwalletExport(curDoc())) { | 1036 | if (walletIf.kwalletExport(curDoc())) { |
1032 | KMessageBox::information(this, | 1037 | KMessageBox::information(this, |
1033 | i18n("Successfully exported the data of the current " | 1038 | i18n("Successfully exported the data of the current " |
1034 | "document to KWallet."), | 1039 | "document to KWallet."), |
1035 | i18n("Successfully exported data.")); | 1040 | i18n("Successfully exported data.")); |
1036 | showStatMsg(i18n("Successfully exported data.")); | 1041 | showStatMsg(i18n("Successfully exported data.")); |
1037 | } | 1042 | } |
1038 | init->initKWalletEmu(); | 1043 | init->initKWalletEmu(); |
1039 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1044 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1040 | #endif // CONFIG_KWALLETIF | 1045 | #endif // CONFIG_KWALLETIF |
1041 | } | 1046 | } |
1042 | 1047 | ||
1043 | bool PwM::importFromGpasman() | 1048 | bool PwM::importFromGpasman() |
1044 | { | 1049 | { |
1045 | if (!isVirgin()) { | 1050 | if (!isVirgin()) { |
1046 | if (KMessageBox::questionYesNo(this, | 1051 | if (KMessageBox::questionYesNo(this, |
1047 | i18n("Do you want to import the data " | 1052 | i18n("Do you want to import the data " |
1048 | "into the current document? (If you " | 1053 | "into the current document? (If you " |
1049 | "select \"no\", a new document will be " | 1054 | "select \"no\", a new document will be " |
1050 | "opened.)"), | 1055 | "opened.)"), |
1051 | i18n("import into this document?")) | 1056 | i18n("import into this document?")) |
1052 | == KMessageBox::No) { | 1057 | == KMessageBox::No) { |
1053 | // import the data to a new window. | 1058 | // import the data to a new window. |
1054 | PwM *newInstance = init->createMainWnd(); | 1059 | PwM *newInstance = init->createMainWnd(); |
1055 | bool ok = newInstance->importFromGpasman(); | 1060 | bool ok = newInstance->importFromGpasman(); |
1056 | if (!ok) { | 1061 | if (!ok) { |
1057 | newInstance->setForceQuit(true); | 1062 | newInstance->setForceQuit(true); |
1058 | delete_and_null(newInstance); | 1063 | delete_and_null(newInstance); |
1059 | } | 1064 | } |
1060 | return ok; | 1065 | return ok; |
1061 | } | 1066 | } |
1062 | } | 1067 | } |
1063 | 1068 | ||
1064 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1069 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1065 | PwMerror ret; | 1070 | PwMerror ret; |
1066 | QString path(KFileDialog::getOpenFileName(QString::null, | 1071 | QString path(KFileDialog::getOpenFileName(QString::null, |
1067 | i18n("*|Gpasman or Kpasman file"), this)); | 1072 | i18n("*|Gpasman or Kpasman file"), this)); |
1068 | if (path == "") | 1073 | if (path == "") |
1069 | goto cancelImport; | 1074 | goto cancelImport; |
1070 | ret = curDoc()->importFromGpasman(&path); | 1075 | ret = curDoc()->importFromGpasman(&path); |
1071 | if (ret == e_wrongPw) { | 1076 | if (ret == e_wrongPw) { |
1072 | if (KMessageBox::questionYesNo(this, | 1077 | if (KMessageBox::questionYesNo(this, |
1073 | i18n | 1078 | i18n |
1074 | ("This is probably the wrong master-password" | 1079 | ("This is probably the wrong master-password" |
1075 | "you have typed in.\n" | 1080 | "you have typed in.\n" |
1076 | "There is no real way to determine the " | 1081 | "There is no real way to determine the " |
1077 | "correctness of the password in the Gpasman " | 1082 | "correctness of the password in the Gpasman " |
1078 | "file-format. But I think this " | 1083 | "file-format. But I think this " |
1079 | "password ist wrong.\n" | 1084 | "password ist wrong.\n" |
1080 | "Do you want to continue nevertheless?"), | 1085 | "Do you want to continue nevertheless?"), |
1081 | i18n("password error")) | 1086 | i18n("password error")) |
1082 | == KMessageBox::No) { | 1087 | == KMessageBox::No) { |
1083 | goto cancelImport; | 1088 | goto cancelImport; |
1084 | } | 1089 | } |
1085 | } else if (ret != e_success) { | 1090 | } else if (ret != e_success) { |
1086 | KMessageBox::error(this, | 1091 | KMessageBox::error(this, |
1087 | i18n("Could not import file!\n" | 1092 | i18n("Could not import file!\n" |
1088 | "Do you have permission to read this file?"), | 1093 | "Do you have permission to read this file?"), |
1089 | i18n("import failed")); | 1094 | i18n("import failed")); |
1090 | goto cancelImport; | 1095 | goto cancelImport; |
1091 | } | 1096 | } |
1092 | setVirgin(false); | 1097 | setVirgin(false); |
1093 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1098 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1094 | return true; | 1099 | return true; |
1095 | 1100 | ||
1096 | cancelImport: | 1101 | cancelImport: |
1097 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1102 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1098 | return false; | 1103 | return false; |
1099 | } | 1104 | } |
1100 | 1105 | ||
1101 | #ifdef CONFIG_KWALLETIF | 1106 | #ifdef CONFIG_KWALLETIF |
1102 | bool PwM::checkAndAskForKWalletEmu() | 1107 | bool PwM::checkAndAskForKWalletEmu() |
1103 | { | 1108 | { |
1104 | if (init->kwalletEmu()) { | 1109 | if (init->kwalletEmu()) { |
1105 | /* KWallet emulation is enabled. We can't import/export | 1110 | /* KWallet emulation is enabled. We can't import/export |
1106 | * data from/to it, while emulation is active. | 1111 | * data from/to it, while emulation is active. |
1107 | */ | 1112 | */ |
1108 | if (KMessageBox::questionYesNo(this, | 1113 | if (KMessageBox::questionYesNo(this, |
1109 | i18n("KWallet emulation is enabled.\n" | 1114 | i18n("KWallet emulation is enabled.\n" |
1110 | "You can't import or export data from/to " | 1115 | "You can't import or export data from/to " |
1111 | "the original KWallet, while the emulation " | 1116 | "the original KWallet, while the emulation " |
1112 | "is active.\n" | 1117 | "is active.\n" |
1113 | "Do you want to tempoarly disable the KWallet emulation?"), | 1118 | "Do you want to tempoarly disable the KWallet emulation?"), |
1114 | i18n("Tempoarly disable KWallet emulation?")) | 1119 | i18n("Tempoarly disable KWallet emulation?")) |
1115 | == KMessageBox::Yes) { | 1120 | == KMessageBox::Yes) { |
1116 | init->initKWalletEmu(true); | 1121 | init->initKWalletEmu(true); |
1117 | PWM_ASSERT(!init->kwalletEmu()); | 1122 | PWM_ASSERT(!init->kwalletEmu()); |
1118 | return true; | 1123 | return true; |
1119 | } | 1124 | } |
1120 | return false; | 1125 | return false; |
1121 | } | 1126 | } |
1122 | return true; | 1127 | return true; |
1123 | } | 1128 | } |
1124 | #endif // CONFIG_KWALLETIF | 1129 | #endif // CONFIG_KWALLETIF |
1125 | 1130 | ||
1126 | bool PwM::importKWallet() | 1131 | bool PwM::importKWallet() |
1127 | { | 1132 | { |
1128 | #ifdef CONFIG_KWALLETIF | 1133 | #ifdef CONFIG_KWALLETIF |
1129 | if (!checkAndAskForKWalletEmu()) | 1134 | if (!checkAndAskForKWalletEmu()) |
1130 | return false; | 1135 | return false; |
1131 | KWalletIf walletIf(this); | 1136 | KWalletIf walletIf(this); |
1132 | if (!isVirgin()) { | 1137 | if (!isVirgin()) { |
1133 | if (KMessageBox::questionYesNo(this, | 1138 | if (KMessageBox::questionYesNo(this, |
1134 | i18n("Do you want to import the data " | 1139 | i18n("Do you want to import the data " |
1135 | "into the current document? (If you " | 1140 | "into the current document? (If you " |
1136 | "select \"no\", a new document will be " | 1141 | "select \"no\", a new document will be " |
1137 | "opened.)"), | 1142 | "opened.)"), |
1138 | i18n("import into this document?")) | 1143 | i18n("import into this document?")) |
1139 | == KMessageBox::No) { | 1144 | == KMessageBox::No) { |
1140 | // import the data to a new window. | 1145 | // import the data to a new window. |
1141 | PwM *newInstance = init->createMainWnd(); | 1146 | PwM *newInstance = init->createMainWnd(); |
1142 | bool ok = newInstance->importKWallet(); | 1147 | bool ok = newInstance->importKWallet(); |
1143 | if (!ok) { | 1148 | if (!ok) { |
1144 | newInstance->setForceQuit(true); | 1149 | newInstance->setForceQuit(true); |
1145 | delete_and_null(newInstance); | 1150 | delete_and_null(newInstance); |
1146 | goto exit_fail; | 1151 | goto exit_fail; |
1147 | } else { | 1152 | } else { |
1148 | goto exit_ok; | 1153 | goto exit_ok; |
1149 | } | 1154 | } |
1150 | } | 1155 | } |
1151 | } | 1156 | } |
1152 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1157 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1153 | if (!walletIf.kwalletImport(curDoc())) { | 1158 | if (!walletIf.kwalletImport(curDoc())) { |
1154 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1159 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1155 | showStatMsg(i18n("KWallet import failed")); | 1160 | showStatMsg(i18n("KWallet import failed")); |
1156 | goto exit_fail; | 1161 | goto exit_fail; |
1157 | } | 1162 | } |
1158 | KMessageBox::information(this, | 1163 | KMessageBox::information(this, |
1159 | i18n("Successfully imported the KWallet data " | 1164 | i18n("Successfully imported the KWallet data " |
1160 | "into the current document."), | 1165 | "into the current document."), |
1161 | i18n("successfully imported")); | 1166 | i18n("successfully imported")); |
1162 | showStatMsg(i18n("successfully imported")); | 1167 | showStatMsg(i18n("successfully imported")); |
1163 | setVirgin(false); | 1168 | setVirgin(false); |
1164 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1169 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1165 | 1170 | ||
1166 | exit_ok: | 1171 | exit_ok: |
1167 | init->initKWalletEmu(); | 1172 | init->initKWalletEmu(); |
1168 | return true; | 1173 | return true; |
1169 | 1174 | ||
1170 | exit_fail: | 1175 | exit_fail: |
1171 | init->initKWalletEmu(); | 1176 | init->initKWalletEmu(); |
1172 | #endif // CONFIG_KWALLETIF | 1177 | #endif // CONFIG_KWALLETIF |
1173 | return false; | 1178 | return false; |
1174 | } | 1179 | } |
1175 | 1180 | ||
1176 | void PwM::print_slot() | 1181 | void PwM::print_slot() |
1177 | { | 1182 | { |
1178 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); | 1183 | curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); |
1179 | #ifndef PWM_EMBEDDED | 1184 | #ifndef PWM_EMBEDDED |
1180 | PwMPrint p(curDoc(), this); | 1185 | PwMPrint p(curDoc(), this); |
1181 | p.printNow(); | 1186 | p.printNow(); |
1182 | #else | 1187 | #else |
1183 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); | 1188 | qDebug("PwM::print_slot , PRINTING IS NOT IMPLEMENTED"); |
1184 | #endif | 1189 | #endif |
1185 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); | 1190 | curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); |
1186 | } | 1191 | } |
1187 | 1192 | ||
1188 | void PwM::genNewCard_slot() | 1193 | void PwM::genNewCard_slot() |
1189 | { | 1194 | { |
1190 | #ifdef CONFIG_KEYCARD | 1195 | #ifdef CONFIG_KEYCARD |
1191 | init->keycard()->genNewCard(); | 1196 | init->keycard()->genNewCard(); |
1192 | #endif | 1197 | #endif |
1193 | } | 1198 | } |
1194 | 1199 | ||
1195 | void PwM::eraseCard_slot() | 1200 | void PwM::eraseCard_slot() |
1196 | { | 1201 | { |
1197 | #ifdef CONFIG_KEYCARD | 1202 | #ifdef CONFIG_KEYCARD |
1198 | init->keycard()->eraseCard(); | 1203 | init->keycard()->eraseCard(); |
1199 | #endif | 1204 | #endif |
1200 | } | 1205 | } |
1201 | 1206 | ||
1202 | void PwM::readCardId_slot() | 1207 | void PwM::readCardId_slot() |
1203 | { | 1208 | { |
1204 | #ifdef CONFIG_KEYCARD | 1209 | #ifdef CONFIG_KEYCARD |
1205 | init->keycard()->displayKey(); | 1210 | init->keycard()->displayKey(); |
1206 | #endif | 1211 | #endif |
1207 | } | 1212 | } |
1208 | 1213 | ||
1209 | void PwM::makeCardBackup_slot() | 1214 | void PwM::makeCardBackup_slot() |
1210 | { | 1215 | { |
1211 | #ifdef CONFIG_KEYCARD | 1216 | #ifdef CONFIG_KEYCARD |
1212 | init->keycard()->makeBackupImage(); | 1217 | init->keycard()->makeBackupImage(); |
1213 | #endif | 1218 | #endif |
1214 | } | 1219 | } |
1215 | 1220 | ||
1216 | void PwM::replayCardBackup_slot() | 1221 | void PwM::replayCardBackup_slot() |
1217 | { | 1222 | { |
1218 | #ifdef CONFIG_KEYCARD | 1223 | #ifdef CONFIG_KEYCARD |
1219 | init->keycard()->replayBackupImage(); | 1224 | init->keycard()->replayBackupImage(); |
1220 | #endif | 1225 | #endif |
1221 | } | 1226 | } |
1222 | 1227 | ||
1223 | void PwM::execLauncher_slot() | 1228 | void PwM::execLauncher_slot() |
1224 | { | 1229 | { |
1225 | PWM_ASSERT(curDoc()); | 1230 | PWM_ASSERT(curDoc()); |
1226 | if (curDoc()->isDeepLocked()) | 1231 | if (curDoc()->isDeepLocked()) |
1227 | return; | 1232 | return; |
1228 | unsigned int curEntryIndex; | 1233 | unsigned int curEntryIndex; |
1229 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1234 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1230 | return; | 1235 | return; |
1231 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), | 1236 | bool ret = curDoc()->execLauncher(view->getCurrentCategory(), |
1232 | curEntryIndex); | 1237 | curEntryIndex); |
1233 | if (ret) | 1238 | if (ret) |
1234 | showStatMsg(i18n("Executed the \"Launcher\".")); | 1239 | showStatMsg(i18n("Executed the \"Launcher\".")); |
1235 | else | 1240 | else |
1236 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); | 1241 | showStatMsg(i18n("ERROR: Couldn't execute the \"Launcher\"!")); |
1237 | } | 1242 | } |
1238 | 1243 | ||
1239 | void PwM::goToURL_slot() | 1244 | void PwM::goToURL_slot() |
1240 | { | 1245 | { |
1241 | PWM_ASSERT(curDoc()); | 1246 | PWM_ASSERT(curDoc()); |
1242 | if (curDoc()->isDeepLocked()) | 1247 | if (curDoc()->isDeepLocked()) |
1243 | return; | 1248 | return; |
1244 | unsigned int curEntryIndex; | 1249 | unsigned int curEntryIndex; |
1245 | if (!view->getCurEntryIndex(&curEntryIndex)) | 1250 | if (!view->getCurEntryIndex(&curEntryIndex)) |
1246 | return; | 1251 | return; |
1247 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), | 1252 | bool ret = curDoc()->goToURL(view->getCurrentCategory(), |
1248 | curEntryIndex); | 1253 | curEntryIndex); |
1249 | if (ret) | 1254 | if (ret) |
1250 | showStatMsg(i18n("started browser with current URL.")); | 1255 | showStatMsg(i18n("started browser with current URL.")); |
1251 | else | 1256 | else |
1252 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); | 1257 | showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); |
1253 | } | 1258 | } |
1254 | 1259 | ||
1255 | void PwM::copyToClipboard(const QString &s) | 1260 | void PwM::copyToClipboard(const QString &s) |
1256 | { | 1261 | { |
1257 | QClipboard *cb = QApplication::clipboard(); | 1262 | QClipboard *cb = QApplication::clipboard(); |
1258 | #ifndef PWM_EMBEDDED | 1263 | #ifndef PWM_EMBEDDED |
1259 | if (cb->supportsSelection()) | 1264 | if (cb->supportsSelection()) |
1260 | cb->setText(s, QClipboard::Selection); | 1265 | cb->setText(s, QClipboard::Selection); |
1261 | cb->setText(s, QClipboard::Clipboard); | 1266 | cb->setText(s, QClipboard::Clipboard); |
1262 | #else | 1267 | #else |
1263 | cb->setText(s); | 1268 | cb->setText(s); |
1264 | 1269 | ||
1265 | #endif | 1270 | #endif |
1266 | 1271 | ||
1267 | } | 1272 | } |
1268 | 1273 | ||
1269 | void PwM::showStatMsg(const QString &msg) | 1274 | void PwM::showStatMsg(const QString &msg) |
1270 | { | 1275 | { |
1271 | #ifndef PWM_EMBEDDED | 1276 | #ifndef PWM_EMBEDDED |
1272 | KStatusBar *statBar = statusBar(); | 1277 | KStatusBar *statBar = statusBar(); |
1273 | statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); | 1278 | statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000); |
1274 | #else | 1279 | #else |
1275 | qDebug("Statusbar : %s",msg.latin1()); | 1280 | qDebug("Statusbar : %s",msg.latin1()); |
1276 | #endif | 1281 | #endif |
1277 | } | 1282 | } |
1278 | 1283 | ||
1279 | void PwM::focusInEvent(QFocusEvent *e) | 1284 | void PwM::focusInEvent(QFocusEvent *e) |
1280 | { | 1285 | { |
1281 | if (e->gotFocus()) { | 1286 | if (e->gotFocus()) { |
1282 | emit gotFocus(this); | 1287 | emit gotFocus(this); |
1283 | } else if (e->lostFocus()) { | 1288 | } else if (e->lostFocus()) { |
1284 | emit lostFocus(this); | 1289 | emit lostFocus(this); |
1285 | } | 1290 | } |
1286 | } | 1291 | } |
1287 | 1292 | ||
1288 | 1293 | ||
1289 | #ifdef PWM_EMBEDDED | 1294 | #ifdef PWM_EMBEDDED |
1290 | 1295 | ||
1296 | void PwM::whatsnew_slot() | ||
1297 | { | ||
1298 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | ||
1299 | } | ||
1300 | |||
1291 | void PwM::showLicense_slot() | 1301 | void PwM::showLicense_slot() |
1292 | { | 1302 | { |
1293 | KApplication::showLicence(); | 1303 | KApplication::showLicence(); |
1294 | } | 1304 | } |
1295 | 1305 | ||
1296 | void PwM::faq_slot() | 1306 | void PwM::faq_slot() |
1297 | { | 1307 | { |
1298 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); | 1308 | KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); |
1299 | } | 1309 | } |
1300 | 1310 | ||
1301 | void PwM::syncHowTo_slot() | 1311 | void PwM::syncHowTo_slot() |
1302 | { | 1312 | { |
1303 | qDebug("PwM::syncHowTo_slot"); | ||
1304 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1313 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1305 | } | 1314 | } |
1306 | 1315 | ||
1307 | 1316 | ||
1308 | void PwM::createAboutData_slot() | 1317 | void PwM::createAboutData_slot() |
1309 | { | 1318 | { |
1310 | QString version; | 1319 | QString version; |
1311 | #include <../version> | 1320 | #include <../version> |
1312 | QMessageBox::about( this, "About PwManager/Pi", | 1321 | QMessageBox::about( this, "About PwManager/Pi", |
1313 | "PwManager/Platform-independent\n" | 1322 | "PwManager/Platform-independent\n" |
1314 | "(PWM/Pi) " +version + " - " + | 1323 | "(PWM/Pi) " +version + " - " + |
1315 | #ifdef DESKTOP_VERSION | 1324 | #ifdef DESKTOP_VERSION |
1316 | "Desktop Edition\n" | 1325 | "Desktop Edition\n" |
1317 | #else | 1326 | #else |
1318 | "PDA-Edition\n" | 1327 | "PDA-Edition\n" |
1319 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 1328 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
1320 | #endif | 1329 | #endif |
1321 | 1330 | ||
1322 | "(c) 2004 Ulf Schenk\n" | 1331 | "(c) 2004 Ulf Schenk\n" |
1323 | "(c) 2004 Lutz Rogowski\n" | 1332 | "(c) 2004 Lutz Rogowski\n" |
1324 | "(c) 1997-2004, The KDE PIM Team\n" | 1333 | "(c) 1997-2004, The KDE PIM Team\n" |
1325 | 1334 | ||
1326 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" | 1335 | "(c) Michael Buesch - main programming\nand current maintainer\nmbuesch@freenet.de\n" |
1327 | "Matt Scifo - mscifo@o1.com\n" | 1336 | "Matt Scifo - mscifo@o1.com\n" |
1328 | "Elias Probst - elias.probst@gmx.de\n" | 1337 | "Elias Probst - elias.probst@gmx.de\n" |
1329 | "George Staikos - staikos@kde.org\n" | 1338 | "George Staikos - staikos@kde.org\n" |
1330 | "Matthew Palmer - mjp16@uow.edu.au\n" | 1339 | "Matthew Palmer - mjp16@uow.edu.au\n" |
1331 | "Olivier Sessink - gpasman@nl.linux.org\n" | 1340 | "Olivier Sessink - gpasman@nl.linux.org\n" |
1332 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" | 1341 | "The libgcrypt developers -\nBlowfish and SHA1 algorithms\nftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/\n" |
1333 | "Troy Engel - tengel@sonic.net\n" | 1342 | "Troy Engel - tengel@sonic.net\n" |
1334 | "Wickey - wickey@gmx.at\n" | 1343 | "Wickey - wickey@gmx.at\n" |
1335 | "Ian MacGregor - original documentation author.\n" | 1344 | "Ian MacGregor - original documentation author.\n" |
1336 | ); | 1345 | ); |
1337 | } | 1346 | } |
1338 | 1347 | ||
1339 | 1348 | ||
1340 | //this are the overwritten callbackmethods from the syncinterface | 1349 | //this are the overwritten callbackmethods from the syncinterface |
1341 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) | 1350 | bool PwM::sync(KSyncManager* manager, QString filename, int mode) |
1342 | { | 1351 | { |
1343 | PWM_ASSERT(curDoc()); | 1352 | PWM_ASSERT(curDoc()); |
1344 | 1353 | ||
1345 | bool ret = curDoc()->sync(manager, filename, mode); | 1354 | bool ret = curDoc()->sync(manager, filename, mode); |
1346 | 1355 | ||
1347 | qDebug("PwM::sync save now: ret=%i", ret); | 1356 | qDebug("PwM::sync save now: ret=%i", ret); |
1348 | 1357 | ||
1349 | if (ret == true) { | 1358 | if (ret == true) { |
1350 | //US BUG: what can we call here to update the view of the current doc? | 1359 | //US BUG: what can we call here to update the view of the current doc? |
1351 | //mViewManager->refreshView(); | 1360 | //mViewManager->refreshView(); |
1352 | 1361 | ||
1353 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. | 1362 | //US curDoc()->sync sets the dirtyFlag in case the sync was successfull. |
1354 | save(); | 1363 | save(); |
1355 | } | 1364 | } |
1356 | 1365 | ||
1357 | return ret; | 1366 | return ret; |
1358 | } | 1367 | } |
1359 | #endif | 1368 | #endif |
1360 | 1369 | ||
1361 | 1370 | ||
1362 | #ifndef PWM_EMBEDDED | 1371 | #ifndef PWM_EMBEDDED |
1363 | #include "pwm.moc" | 1372 | #include "pwm.moc" |
1364 | #endif | 1373 | #endif |
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h index 6ed9d34..fe1f7a1 100644 --- a/pwmanager/pwmanager/pwm.h +++ b/pwmanager/pwmanager/pwm.h | |||
@@ -1,291 +1,292 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 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 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 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 | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #ifndef __PWM_H | 20 | #ifndef __PWM_H |
21 | #define __PWM_H | 21 | #define __PWM_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <kpopupmenu.h> | 24 | #include <kpopupmenu.h> |
25 | #include <klistview.h> | 25 | #include <klistview.h> |
26 | #include <kmainwindow.h> | 26 | #include <kmainwindow.h> |
27 | 27 | ||
28 | #ifndef PWM_EMBEDDED | 28 | #ifndef PWM_EMBEDDED |
29 | #include <kwin.h> | 29 | #include <kwin.h> |
30 | #include <kapp.h> | 30 | #include <kapp.h> |
31 | #include <kdeversion.h> | 31 | #include <kdeversion.h> |
32 | #else | 32 | #else |
33 | #include <ksyncmanager.h> | 33 | #include <ksyncmanager.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <kaction.h> | 36 | #include <kaction.h> |
37 | 37 | ||
38 | #include <qglobal.h> | 38 | #include <qglobal.h> |
39 | 39 | ||
40 | #include "pwmview.h" | 40 | #include "pwmview.h" |
41 | #include "pwmexception.h" | 41 | #include "pwmexception.h" |
42 | 42 | ||
43 | 43 | ||
44 | /** timeout for displaying a message on the status-bar (in seconds) */ | 44 | /** timeout for displaying a message on the status-bar (in seconds) */ |
45 | #define STATUSBAR_MSG_TIMEOUT5 | 45 | #define STATUSBAR_MSG_TIMEOUT5 |
46 | 46 | ||
47 | 47 | ||
48 | class PwMInit; | 48 | class PwMInit; |
49 | class KSyncManager; | 49 | class KSyncManager; |
50 | 50 | ||
51 | /** PwM is the base class of the project */ | 51 | /** PwM is the base class of the project */ |
52 | #ifndef PWM_EMBEDDED | 52 | #ifndef PWM_EMBEDDED |
53 | //MOC_SKIP_BEGIN | 53 | //MOC_SKIP_BEGIN |
54 | class PwM : public KMainWindow | 54 | class PwM : public KMainWindow |
55 | //MOC_SKIP_END | 55 | //MOC_SKIP_END |
56 | #else | 56 | #else |
57 | class PwM : public KMainWindow, public KSyncInterface | 57 | class PwM : public KMainWindow, public KSyncInterface |
58 | #endif | 58 | #endif |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | public: | 61 | public: |
62 | friend class PwMView; | 62 | friend class PwMView; |
63 | /** construtor */ | 63 | /** construtor */ |
64 | PwM(PwMInit *_init, PwMDoc *doc, | 64 | PwM(PwMInit *_init, PwMDoc *doc, |
65 | bool virginity = true, | 65 | bool virginity = true, |
66 | QWidget* parent = 0, const char *name = 0); | 66 | QWidget* parent = 0, const char *name = 0); |
67 | /** destructor */ | 67 | /** destructor */ |
68 | ~PwM(); | 68 | ~PwM(); |
69 | 69 | ||
70 | /** copy some text to the global clipboard */ | 70 | /** copy some text to the global clipboard */ |
71 | static void copyToClipboard(const QString &s); | 71 | static void copyToClipboard(const QString &s); |
72 | 72 | ||
73 | /** returns pointer to the view */ | 73 | /** returns pointer to the view */ |
74 | PwMView * curView() | 74 | PwMView * curView() |
75 | { return view; } | 75 | { return view; } |
76 | /** returns pointer to the currently using document. */ | 76 | /** returns pointer to the currently using document. */ |
77 | PwMDoc * curDoc() | 77 | PwMDoc * curDoc() |
78 | { return curView()->document(); } | 78 | { return curView()->document(); } |
79 | /** open a new doc with the given filename */ | 79 | /** open a new doc with the given filename */ |
80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); | 80 | PwMDoc * openDoc(QString filename, bool openDeepLocked = false); |
81 | /** show a message on the global status bar. | 81 | /** show a message on the global status bar. |
82 | * The message times out after some seconds. | 82 | * The message times out after some seconds. |
83 | */ | 83 | */ |
84 | void showStatMsg(const QString &msg); | 84 | void showStatMsg(const QString &msg); |
85 | /** ask the user where to save the doc (if it has not been saved, yet) | 85 | /** ask the user where to save the doc (if it has not been saved, yet) |
86 | * and write the data to disk. | 86 | * and write the data to disk. |
87 | */ | 87 | */ |
88 | bool save(); | 88 | bool save(); |
89 | /** ask the user where to save the doc | 89 | /** ask the user where to save the doc |
90 | * and write the data to disk. | 90 | * and write the data to disk. |
91 | */ | 91 | */ |
92 | bool saveAs(); | 92 | bool saveAs(); |
93 | /** force quit. Quit this window, always! Don't minimize it */ | 93 | /** force quit. Quit this window, always! Don't minimize it */ |
94 | bool isForceQuit() | 94 | bool isForceQuit() |
95 | { return forceQuit; } | 95 | { return forceQuit; } |
96 | /** set forceQuit */ | 96 | /** set forceQuit */ |
97 | void setForceQuit(bool force) | 97 | void setForceQuit(bool force) |
98 | { forceQuit = force; } | 98 | { forceQuit = force; } |
99 | /** force minimize this window */ | 99 | /** force minimize this window */ |
100 | bool isForceMinimizeToTray() | 100 | bool isForceMinimizeToTray() |
101 | { return forceMinimizeToTray; } | 101 | { return forceMinimizeToTray; } |
102 | /** set forceMinimizeToTray */ | 102 | /** set forceMinimizeToTray */ |
103 | void setForceMinimizeToTray(bool force) | 103 | void setForceMinimizeToTray(bool force) |
104 | { forceMinimizeToTray = force; } | 104 | { forceMinimizeToTray = force; } |
105 | 105 | ||
106 | public slots: | 106 | public slots: |
107 | /** file/new triggered */ | 107 | /** file/new triggered */ |
108 | void new_slot(); | 108 | void new_slot(); |
109 | /** file/open triggered */ | 109 | /** file/open triggered */ |
110 | //US ENH | 110 | //US ENH |
111 | void open_slot(); | 111 | void open_slot(); |
112 | void open_slot(QString fn); | 112 | void open_slot(QString fn); |
113 | /** file/close triggered */ | 113 | /** file/close triggered */ |
114 | void close_slot(); | 114 | void close_slot(); |
115 | /** file/quit triggered */ | 115 | /** file/quit triggered */ |
116 | void quitButton_slot(); | 116 | void quitButton_slot(); |
117 | /** file/save triggered */ | 117 | /** file/save triggered */ |
118 | void save_slot(); | 118 | void save_slot(); |
119 | /** file/saveAs triggered */ | 119 | /** file/saveAs triggered */ |
120 | void saveAs_slot(); | 120 | void saveAs_slot(); |
121 | /** file/export/text triggered */ | 121 | /** file/export/text triggered */ |
122 | void exportToText(); | 122 | void exportToText(); |
123 | /** file/export/gpasman triggered */ | 123 | /** file/export/gpasman triggered */ |
124 | void exportToGpasman(); | 124 | void exportToGpasman(); |
125 | /** file/export/kwallet triggered */ | 125 | /** file/export/kwallet triggered */ |
126 | void exportToKWallet(); | 126 | void exportToKWallet(); |
127 | /** file/import/text triggered */ | 127 | /** file/import/text triggered */ |
128 | bool importFromText(); | 128 | bool importFromText(); |
129 | /** file/import/gpasman triggered */ | 129 | /** file/import/gpasman triggered */ |
130 | bool importFromGpasman(); | 130 | bool importFromGpasman(); |
131 | /** file/import/kwallet triggered */ | 131 | /** file/import/kwallet triggered */ |
132 | bool importKWallet(); | 132 | bool importKWallet(); |
133 | /** file/print triggered */ | 133 | /** file/print triggered */ |
134 | void print_slot(); | 134 | void print_slot(); |
135 | /** manage/add triggered */ | 135 | /** manage/add triggered */ |
136 | //US ENH : changed code to run with older MOC | 136 | //US ENH : changed code to run with older MOC |
137 | void addPwd_slot(); | 137 | void addPwd_slot(); |
138 | void addPwd_slot(QString *pw, PwMDoc *_doc); | 138 | void addPwd_slot(QString *pw, PwMDoc *_doc); |
139 | /** manage/edit triggered */ | 139 | /** manage/edit triggered */ |
140 | //US ENH : changed code to run with older MOC | 140 | //US ENH : changed code to run with older MOC |
141 | void editPwd_slot(); | 141 | void editPwd_slot(); |
142 | void editPwd_slot(const QString *category); | 142 | void editPwd_slot(const QString *category); |
143 | void editPwd_slot(const QString *category = 0, const int *index = 0, | 143 | void editPwd_slot(const QString *category = 0, const int *index = 0, |
144 | PwMDoc *_doc = 0); | 144 | PwMDoc *_doc = 0); |
145 | /** manage/delete triggered */ | 145 | /** manage/delete triggered */ |
146 | void deletePwd_slot(); | 146 | void deletePwd_slot(); |
147 | /** execute the "Launcher" entry */ | 147 | /** execute the "Launcher" entry */ |
148 | void execLauncher_slot(); | 148 | void execLauncher_slot(); |
149 | /** open browser with URL entry */ | 149 | /** open browser with URL entry */ |
150 | void goToURL_slot(); | 150 | void goToURL_slot(); |
151 | /** manage/changeMasterPwd triggered */ | 151 | /** manage/changeMasterPwd triggered */ |
152 | void changeMasterPwd_slot(); | 152 | void changeMasterPwd_slot(); |
153 | /** lock current document */ | 153 | /** lock current document */ |
154 | void lockWnd_slot(); | 154 | void lockWnd_slot(); |
155 | /** deeplock current document */ | 155 | /** deeplock current document */ |
156 | void deepLockWnd_slot(); | 156 | void deepLockWnd_slot(); |
157 | /** window/unlock triggered */ | 157 | /** window/unlock triggered */ |
158 | void unlockWnd_slot(); | 158 | void unlockWnd_slot(); |
159 | /** find item */ | 159 | /** find item */ |
160 | void find_slot(); | 160 | void find_slot(); |
161 | /** configure clicked */ | 161 | /** configure clicked */ |
162 | void config_slot(); | 162 | void config_slot(); |
163 | /** (de)activate the "change master pw" button in the menu-bar */ | 163 | /** (de)activate the "change master pw" button in the menu-bar */ |
164 | void activateMpButton(bool activate = true); | 164 | void activateMpButton(bool activate = true); |
165 | /** generate a new chipcard */ | 165 | /** generate a new chipcard */ |
166 | void genNewCard_slot(); | 166 | void genNewCard_slot(); |
167 | /** completely erase the current card */ | 167 | /** completely erase the current card */ |
168 | void eraseCard_slot(); | 168 | void eraseCard_slot(); |
169 | /** returns the ID number of the current card */ | 169 | /** returns the ID number of the current card */ |
170 | void readCardId_slot(); | 170 | void readCardId_slot(); |
171 | /** make backup image of the current card */ | 171 | /** make backup image of the current card */ |
172 | void makeCardBackup_slot(); | 172 | void makeCardBackup_slot(); |
173 | /** write backup image to current card */ | 173 | /** write backup image to current card */ |
174 | void replayCardBackup_slot(); | 174 | void replayCardBackup_slot(); |
175 | 175 | ||
176 | #ifdef PWM_EMBEDDED | 176 | #ifdef PWM_EMBEDDED |
177 | void whatsnew_slot(); | ||
177 | void showLicense_slot(); | 178 | void showLicense_slot(); |
178 | void faq_slot(); | 179 | void faq_slot(); |
179 | void createAboutData_slot(); | 180 | void createAboutData_slot(); |
180 | void syncHowTo_slot(); | 181 | void syncHowTo_slot(); |
181 | #endif | 182 | #endif |
182 | 183 | ||
183 | protected: | 184 | protected: |
184 | /** is this window virgin? */ | 185 | /** is this window virgin? */ |
185 | bool isVirgin() | 186 | bool isVirgin() |
186 | { return virgin; } | 187 | { return virgin; } |
187 | /** add/remove virginity */ | 188 | /** add/remove virginity */ |
188 | void setVirgin(bool v); | 189 | void setVirgin(bool v); |
189 | /** initialize the menubar */ | 190 | /** initialize the menubar */ |
190 | void initMenubar(); | 191 | void initMenubar(); |
191 | /** initialize the toolbar */ | 192 | /** initialize the toolbar */ |
192 | void initToolbar(); | 193 | void initToolbar(); |
193 | /** initialize the window-metrics */ | 194 | /** initialize the window-metrics */ |
194 | void initMetrics(); | 195 | void initMetrics(); |
195 | /** close-event */ | 196 | /** close-event */ |
196 | void closeEvent(QCloseEvent *e); | 197 | void closeEvent(QCloseEvent *e); |
197 | /** creates a new PwM-ListView and returns it */ | 198 | /** creates a new PwM-ListView and returns it */ |
198 | PwMView * makeNewListView(PwMDoc *doc); | 199 | PwMView * makeNewListView(PwMDoc *doc); |
199 | /** Window hide-event */ | 200 | /** Window hide-event */ |
200 | void hideEvent(QHideEvent *); | 201 | void hideEvent(QHideEvent *); |
201 | /** is this window minimized? */ | 202 | /** is this window minimized? */ |
202 | bool isMinimized() | 203 | bool isMinimized() |
203 | { | 204 | { |
204 | #ifndef PWM_EMBEDDED | 205 | #ifndef PWM_EMBEDDED |
205 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) | 206 | #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) |
206 | return KWin::windowInfo(winId()).isMinimized(); | 207 | return KWin::windowInfo(winId()).isMinimized(); |
207 | #else // KDE_VERSION | 208 | #else // KDE_VERSION |
208 | return KWin::info(winId()).isIconified(); | 209 | return KWin::info(winId()).isIconified(); |
209 | #endif // KDE_VERSION | 210 | #endif // KDE_VERSION |
210 | #else | 211 | #else |
211 | return false; | 212 | return false; |
212 | #endif | 213 | #endif |
213 | } | 214 | } |
214 | /** window got the focus */ | 215 | /** window got the focus */ |
215 | void focusInEvent(QFocusEvent *e); | 216 | void focusInEvent(QFocusEvent *e); |
216 | /** update the caption string */ | 217 | /** update the caption string */ |
217 | void updateCaption(); | 218 | void updateCaption(); |
218 | #ifdef CONFIG_KWALLETIF | 219 | #ifdef CONFIG_KWALLETIF |
219 | /** check if kwalletemu is enabled and ask the user what to do */ | 220 | /** check if kwalletemu is enabled and ask the user what to do */ |
220 | bool checkAndAskForKWalletEmu(); | 221 | bool checkAndAskForKWalletEmu(); |
221 | #endif // CONFIG_KWALLETIF | 222 | #endif // CONFIG_KWALLETIF |
222 | 223 | ||
223 | protected slots: | 224 | protected slots: |
224 | /** doc got closed */ | 225 | /** doc got closed */ |
225 | void docClosed(PwMDoc *doc); | 226 | void docClosed(PwMDoc *doc); |
226 | 227 | ||
227 | signals: | 228 | signals: |
228 | /** window got closed (by user or someone else) */ | 229 | /** window got closed (by user or someone else) */ |
229 | void closed(PwM *wnd); | 230 | void closed(PwM *wnd); |
230 | /** window got the focus (was brought to foreground) */ | 231 | /** window got the focus (was brought to foreground) */ |
231 | void gotFocus(PwM *wnd); | 232 | void gotFocus(PwM *wnd); |
232 | /** window lost the focus */ | 233 | /** window lost the focus */ |
233 | void lostFocus(PwM *wnd); | 234 | void lostFocus(PwM *wnd); |
234 | 235 | ||
235 | protected: | 236 | protected: |
236 | /** pointer to the view active in this KMainWindow */ | 237 | /** pointer to the view active in this KMainWindow */ |
237 | PwMView *view; | 238 | PwMView *view; |
238 | /** pointer to the init class */ | 239 | /** pointer to the init class */ |
239 | PwMInit *init; | 240 | PwMInit *init; |
240 | /** has this window already lost its virginity? | 241 | /** has this window already lost its virginity? |
241 | * Means is there an open working document | 242 | * Means is there an open working document |
242 | */ | 243 | */ |
243 | bool virgin; | 244 | bool virgin; |
244 | /** "file" popup-menu */ | 245 | /** "file" popup-menu */ |
245 | KPopupMenu *filePopup; | 246 | KPopupMenu *filePopup; |
246 | 247 | ||
247 | /** "manage" popup-menu */ | 248 | /** "manage" popup-menu */ |
248 | KPopupMenu *managePopup; | 249 | KPopupMenu *managePopup; |
249 | #ifdef CONFIG_KEYCARD | 250 | #ifdef CONFIG_KEYCARD |
250 | /** "chipcard" popup-menu */ | 251 | /** "chipcard" popup-menu */ |
251 | KPopupMenu *chipcardPopup; | 252 | KPopupMenu *chipcardPopup; |
252 | #endif // CONFIG_KEYCARD | 253 | #endif // CONFIG_KEYCARD |
253 | /** "view" popup-menu */ | 254 | /** "view" popup-menu */ |
254 | KPopupMenu *viewPopup; | 255 | KPopupMenu *viewPopup; |
255 | /** "options" popup-menu */ | 256 | /** "options" popup-menu */ |
256 | KPopupMenu *optionsPopup; | 257 | KPopupMenu *optionsPopup; |
257 | /** "help" popup-menu */ | 258 | /** "help" popup-menu */ |
258 | KPopupMenu *helpPopup; | 259 | KPopupMenu *helpPopup; |
259 | /** "export" popup-menu */ | 260 | /** "export" popup-menu */ |
260 | KPopupMenu *exportPopup; | 261 | KPopupMenu *exportPopup; |
261 | /** "import" popup-menu */ | 262 | /** "import" popup-menu */ |
262 | KPopupMenu *importPopup; | 263 | KPopupMenu *importPopup; |
263 | /** force quit this window? */ | 264 | /** force quit this window? */ |
264 | bool forceQuit; | 265 | bool forceQuit; |
265 | /** force minimize this window to the tray */ | 266 | /** force minimize this window to the tray */ |
266 | bool forceMinimizeToTray; | 267 | bool forceMinimizeToTray; |
267 | 268 | ||
268 | 269 | ||
269 | 270 | ||
270 | 271 | ||
271 | private: | 272 | private: |
272 | #ifdef PWM_EMBEDDED | 273 | #ifdef PWM_EMBEDDED |
273 | //this are the overwritten callbackmethods from the syncinterface | 274 | //this are the overwritten callbackmethods from the syncinterface |
274 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 275 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
275 | 276 | ||
276 | // LR ******************************* | 277 | // LR ******************************* |
277 | // sync stuff! | 278 | // sync stuff! |
278 | QPopupMenu *syncPopup; | 279 | QPopupMenu *syncPopup; |
279 | KSyncManager* syncManager; | 280 | KSyncManager* syncManager; |
280 | #endif | 281 | #endif |
281 | 282 | ||
282 | 283 | ||
283 | 284 | ||
284 | 285 | ||
285 | 286 | ||
286 | 287 | ||
287 | 288 | ||
288 | 289 | ||
289 | }; | 290 | }; |
290 | 291 | ||
291 | #endif | 292 | #endif |