summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-21 19:45:21 (UTC)
committer ulf69 <ulf69>2004-09-21 19:45:21 (UTC)
commit427906b75a4672531f2b7d86b2a4a27427f5d4a4 (patch) (unidiff)
treefc877f34069dd836b024a2d5b90b513dfb88ecc0
parenta6a6544fc57542752fecc3763e0d35e6a38040ac (diff)
downloadkdepimpi-427906b75a4672531f2b7d86b2a4a27427f5d4a4.zip
kdepimpi-427906b75a4672531f2b7d86b2a4a27427f5d4a4.tar.gz
kdepimpi-427906b75a4672531f2b7d86b2a4a27427f5d4a4.tar.bz2
initial revision
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmprefs.cpp299
-rw-r--r--pwmanager/pwmanager/pwmprefs.h146
2 files changed, 445 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/pwmprefs.cpp b/pwmanager/pwmanager/pwmprefs.cpp
new file mode 100644
index 0000000..5779ecc
--- a/dev/null
+++ b/pwmanager/pwmanager/pwmprefs.cpp
@@ -0,0 +1,299 @@
1/*
2 This file is part of PwManager/Pi
3 Copyright (c) 2004 Ulf Schenk
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22
23 $Id$
24*/
25
26
27#include <kconfig.h>
28#include <klocale.h>
29#include <kstaticdeleter.h>
30
31#include "pwmprefs.h"
32
33PWMPrefs *PWMPrefs::sInstance = 0;
34static KStaticDeleter<PWMPrefs> staticDeleter;
35
36PWMPrefs::PWMPrefs()
37 : KPimPrefs("pwmanagerrc")
38{
39 KPrefs::setCurrentGroup( "Global" );
40
41 addItemString( "autoStart", &mAutoStart, "" );
42 addItemString( "browserCommand", &mBrowserCommand, "" );
43 addItemString( "xtermCommand", &mXTermCommand, CONF_DEFAULT_XTERMCOMMAND);
44 addItemFont( "entryFont", &mEntryFont);
45 addItemInt( "pwTimeout", &mPwTimeout, CONF_DEFAULT_PWTIMEOUT );
46 addItemInt( "lockTimeout", &mLockTimeout, CONF_DEFAULT_LOCKTIMEOUT );
47 addItemInt( "compression", &mCompression, CONF_DEFAULT_COMPRESSION );
48 addItemInt( "filePermissions", &mFilePermissions, CONF_DEFAULT_FILEPERMISSIONS );
49 addItemInt( "minimizeLock", &mMinimizeLock, CONF_DEFAULT_MINIMIZELOCK );
50 addItemBool( "unlockOnOpen", &mUnlockOnOpen, CONF_DEFAULT_UNLOCKONOPEN );
51 addItemBool( "tray", &mTray, CONF_DEFAULT_TRAY );
52 addItemBool( "makeFileBackup", &mMakeFileBackup, CONF_DEFAULT_MAKEFILEBACKUP );
53 addItemBool( "autostartDeepLocked", &mAutostartDeeplocked, CONF_DEFAULT_AUTOSTART_DEEPL );
54 addItemBool( "autoDeepLock", &mAutoDeeplock, CONF_DEFAULT_AUTODEEPLOCK );
55 addItemBool( "kwalletEmu", &mKWalletEmu, CONF_DEFAULT_KWALLETEMU );
56 addItemBool( "newEntrLockStat", &mNewEntrLockStat, CONF_DEFAULT_NEWENTRLOCKSTAT );
57
58 KPrefs::setCurrentGroup( "Wnd" );
59
60 addItemSize( "MainWndSize", &mMainWndSize);
61 addItemInt( "MainViewStyle", &mMainViewStyle, CONF_DEFAULT_MAINVIEWSTYLE );
62 addItemBool( "autoMinimizeOnStart", &mAutoMinimizeOnStart, CONF_DEFAULT_AUTOMINIMIZE );
63 addItemBool( "close", &mClose, CONF_DEFAULT_WNDCLOSE );
64}
65
66PWMPrefs::~PWMPrefs()
67{
68}
69
70PWMPrefs *PWMPrefs::instance()
71{
72 if ( !sInstance ) {
73#ifdef PWM_EMBEDDED
74 sInstance = staticDeleter.setObject( new PWMPrefs() );
75#else //PWM_EMBEDDED
76 //US the following line has changed ???. Why
77 staticDeleter.setObject( sInstance, new PWMPrefs() );
78#endif //KAB_EMBEDDED
79 sInstance->readConfig();
80 }
81
82 return sInstance;
83}
84
85 // US introduce a nonconst way to return the config object.
86KConfig* PWMPrefs::getConfig()
87{
88 return config();
89}
90
91/*******************************************************************
92 * functions for reading the configuration settings
93 *******************************************************************/
94
95QString PWMPrefs::confGlobAutoStart()
96{
97 return mAutoStart;
98}
99
100QString PWMPrefs::confGlobBrowserCommand()
101{
102 return mBrowserCommand;
103}
104
105QString PWMPrefs::confGlobXtermCommand()
106{
107 return mXTermCommand;
108}
109
110QFont PWMPrefs::confGlobEntryFont()
111{
112 return mEntryFont;
113}
114
115int PWMPrefs::confGlobPwTimeout()
116{
117 return mPwTimeout;
118}
119
120int PWMPrefs::confGlobLockTimeout()
121{
122 return mLockTimeout;
123}
124
125int PWMPrefs::confGlobCompression()
126{
127 return mCompression;
128}
129
130int PWMPrefs::confGlobFilePermissions()
131{
132 return mFilePermissions;
133}
134
135int PWMPrefs::confGlobMinimizeLock()
136{
137 return mMinimizeLock;
138}
139
140bool PWMPrefs::confGlobUnlockOnOpen()
141{
142 return mUnlockOnOpen;
143}
144
145bool PWMPrefs::confGlobTray()
146{
147 return mTray;
148}
149
150bool PWMPrefs::confGlobMakeFileBackup()
151{
152 return mMakeFileBackup;
153}
154
155bool PWMPrefs::confGlobAutostartDeepLocked()
156{
157 return mAutostartDeeplocked;
158}
159
160bool PWMPrefs::confGlobAutoDeepLock()
161{
162 return mAutoDeeplock;
163}
164
165bool PWMPrefs::confGlobKwalletEmu()
166{
167 return mKWalletEmu;
168}
169
170bool PWMPrefs::confGlobNewEntrLockStat()
171{
172 return mNewEntrLockStat;
173}
174
175QSize PWMPrefs::confWndMainWndSize()
176{
177 return mMainWndSize;
178}
179
180int PWMPrefs::confWndMainViewStyle()
181{
182 return mMainViewStyle;
183}
184
185bool PWMPrefs::confWndAutoMinimizeOnStart()
186{
187 return mAutoMinimizeOnStart;
188}
189
190bool PWMPrefs::confWndClose()
191{
192 return mClose;
193}
194
195/*******************************************************************
196 * functions for writing the configuration settings
197 *******************************************************************/
198
199void PWMPrefs::confGlobAutoStart(const QString &e)
200{
201 mAutoStart = e;
202}
203
204void PWMPrefs::confGlobBrowserCommand(const QString &e)
205{
206 mBrowserCommand = e;
207}
208
209void PWMPrefs::confGlobXtermCommand(const QString &e)
210{
211 mXTermCommand = e;
212}
213
214void PWMPrefs::confGlobEntryFont(const QFont &e)
215{
216 mEntryFont = e;
217}
218
219void PWMPrefs::confGlobPwTimeout(int e)
220{
221 mPwTimeout = e;
222}
223
224void PWMPrefs::confGlobLockTimeout(int e)
225{
226 mLockTimeout = e;
227}
228
229void PWMPrefs::confGlobCompression(int e)
230{
231 mCompression = e;
232}
233
234void PWMPrefs::confGlobFilePermissions(int e)
235{
236 mFilePermissions = e;
237}
238
239void PWMPrefs::confGlobMinimizeLock(int e)
240{
241 mMinimizeLock = e;
242}
243
244void PWMPrefs::confGlobUnlockOnOpen(bool e)
245{
246 mUnlockOnOpen = e;
247}
248
249void PWMPrefs::confGlobTray(bool e)
250{
251 mTray = e;
252}
253
254void PWMPrefs::confGlobMakeFileBackup(bool e)
255{
256 mMakeFileBackup = e;
257}
258
259void PWMPrefs::confGlobAutostartDeepLocked(bool e)
260{
261 mAutostartDeeplocked = e;
262}
263
264void PWMPrefs::confGlobAutoDeepLock(bool e)
265{
266 mAutoDeeplock = e;
267}
268
269void PWMPrefs::confGlobKwalletEmu(bool e)
270{
271 mKWalletEmu = e;
272}
273
274void PWMPrefs::confGlobNewEntrLockStat(bool e)
275{
276 mNewEntrLockStat = e;
277}
278
279void PWMPrefs::confWndMainWndSize(const QSize &e)
280{
281 mMainWndSize = e;
282}
283
284void PWMPrefs::confWndMainViewStyle(int e)
285{
286 mMainViewStyle = e;
287}
288
289void PWMPrefs::confWndAutoMinimizeOnStart(bool e)
290{
291 mAutoMinimizeOnStart = e;
292}
293
294void PWMPrefs::confWndClose(bool e)
295{
296 mClose = e;
297}
298
299
diff --git a/pwmanager/pwmanager/pwmprefs.h b/pwmanager/pwmanager/pwmprefs.h
new file mode 100644
index 0000000..bf7d8b1
--- a/dev/null
+++ b/pwmanager/pwmanager/pwmprefs.h
@@ -0,0 +1,146 @@
1/*
2 This file is part of PwManager/Pi
3 Copyright (c) 2004 Ulf Schenk
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22
23 $Id$
24*/
25
26#ifndef PWMPREFS_H
27#define PWMPREFS_H
28
29#include <qstringlist.h>
30#include <qsize.h>
31
32#include <kpimprefs.h>
33
34class KConfig;
35
36#define conf() PWMPrefs::instance()
37
38
39 #define CONF_DEFAULT_PWTIMEOUT 10/* 10 sec */
40 #define CONF_DEFAULT_LOCKTIMEOUT 0/* 0 == disable */
41 #define CONF_DEFAULT_TRAY true
42 #define CONF_DEFAULT_UNLOCKONOPENfalse
43 #define CONF_DEFAULT_MAINVIEWSTYLE0
44 #define CONF_DEFAULT_COMPRESSION 0x01/* gzip */
45 #define CONF_DEFAULT_AUTOMINIMIZEfalse
46 #define CONF_DEFAULT_BROWSERCOMMAND""
47 #define CONF_DEFAULT_XTERMCOMMAND"konsole -e"
48 #define CONF_DEFAULT_FILEPERMISSIONS0600
49 #define CONF_DEFAULT_MAKEFILEBACKUPfalse
50 #define CONF_DEFAULT_AUTOSTART_DEEPLtrue
51 #define CONF_DEFAULT_AUTODEEPLOCKtrue
52 #define CONF_DEFAULT_KWALLETEMU true
53 #define CONF_DEFAULT_MINIMIZELOCK 2/* deep-lock */
54 #define CONF_DEFAULT_NEWENTRLOCKSTAT true/* locked */
55 #define CONF_DEFAULT_WNDCLOSE true/* don't minimize to tray */
56
57class PWMPrefs : public KPimPrefs
58{
59 public:
60 virtual ~PWMPrefs();
61
62 static PWMPrefs *instance();
63
64public:
65 /* functions for reading the configuration settings */
66 /* GLOBAL */
67 QString confGlobAutoStart();
68 QString confGlobBrowserCommand();
69 QString confGlobXtermCommand();
70 QFont confGlobEntryFont();
71 int confGlobPwTimeout();
72 int confGlobLockTimeout();
73 int confGlobCompression();
74 int confGlobFilePermissions();
75 int confGlobMinimizeLock();
76 bool confGlobUnlockOnOpen();
77 bool confGlobTray();
78 bool confGlobMakeFileBackup();
79 bool confGlobAutostartDeepLocked();
80 bool confGlobAutoDeepLock();
81 bool confGlobKwalletEmu();
82 bool confGlobNewEntrLockStat();
83 /* WND */
84 QSize confWndMainWndSize();
85 int confWndMainViewStyle();
86 bool confWndAutoMinimizeOnStart();
87 bool confWndClose();
88
89public:
90 /* functions for writing the configuration settings */
91 /* GLOBAL */
92 void confGlobAutoStart(const QString &e);
93 void confGlobBrowserCommand(const QString &e);
94 void confGlobXtermCommand(const QString &e);
95 void confGlobEntryFont(const QFont &e);
96 void confGlobPwTimeout(int e);
97 void confGlobLockTimeout(int e);
98 void confGlobCompression(int e);
99 void confGlobFilePermissions(int e);
100 void confGlobMinimizeLock(int e);
101 void confGlobUnlockOnOpen(bool e);
102 void confGlobTray(bool e);
103 void confGlobMakeFileBackup(bool e);
104 void confGlobAutostartDeepLocked(bool e);
105 void confGlobAutoDeepLock(bool e);
106 void confGlobKwalletEmu(bool e);
107 void confGlobNewEntrLockStat(bool e);
108 /* WND */
109 void confWndMainWndSize(const QSize &e);
110 void confWndMainViewStyle(int e);
111 void confWndAutoMinimizeOnStart(bool e);
112 void confWndClose(bool e);
113
114
115
116 QString mAutoStart;
117 QString mBrowserCommand;
118 QString mXTermCommand;
119 QFont mEntryFont;
120 int mPwTimeout;
121 int mLockTimeout;
122 int mCompression;
123 int mFilePermissions;
124 int mMinimizeLock;
125 bool mUnlockOnOpen;
126 bool mTray;
127 bool mMakeFileBackup;
128 bool mAutostartDeeplocked;
129 bool mAutoDeeplock;
130 bool mKWalletEmu;
131 bool mNewEntrLockStat;
132 QSize mMainWndSize;
133 int mMainViewStyle;
134 bool mAutoMinimizeOnStart;
135 bool mClose;
136
137 // US introduce a nonconst way to return the config object.
138 KConfig* getConfig();
139
140 private:
141 PWMPrefs();
142
143 static PWMPrefs *sInstance;
144};
145
146#endif