Diffstat (limited to 'pwmanager/pwmanager/pwmprefs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.cpp | 299 |
1 files changed, 299 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 | |||
33 | PWMPrefs *PWMPrefs::sInstance = 0; | ||
34 | static KStaticDeleter<PWMPrefs> staticDeleter; | ||
35 | |||
36 | PWMPrefs::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 | |||
66 | PWMPrefs::~PWMPrefs() | ||
67 | { | ||
68 | } | ||
69 | |||
70 | PWMPrefs *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. | ||
86 | KConfig* PWMPrefs::getConfig() | ||
87 | { | ||
88 | return config(); | ||
89 | } | ||
90 | |||
91 | /******************************************************************* | ||
92 | * functions for reading the configuration settings | ||
93 | *******************************************************************/ | ||
94 | |||
95 | QString PWMPrefs::confGlobAutoStart() | ||
96 | { | ||
97 | return mAutoStart; | ||
98 | } | ||
99 | |||
100 | QString PWMPrefs::confGlobBrowserCommand() | ||
101 | { | ||
102 | return mBrowserCommand; | ||
103 | } | ||
104 | |||
105 | QString PWMPrefs::confGlobXtermCommand() | ||
106 | { | ||
107 | return mXTermCommand; | ||
108 | } | ||
109 | |||
110 | QFont PWMPrefs::confGlobEntryFont() | ||
111 | { | ||
112 | return mEntryFont; | ||
113 | } | ||
114 | |||
115 | int PWMPrefs::confGlobPwTimeout() | ||
116 | { | ||
117 | return mPwTimeout; | ||
118 | } | ||
119 | |||
120 | int PWMPrefs::confGlobLockTimeout() | ||
121 | { | ||
122 | return mLockTimeout; | ||
123 | } | ||
124 | |||
125 | int PWMPrefs::confGlobCompression() | ||
126 | { | ||
127 | return mCompression; | ||
128 | } | ||
129 | |||
130 | int PWMPrefs::confGlobFilePermissions() | ||
131 | { | ||
132 | return mFilePermissions; | ||
133 | } | ||
134 | |||
135 | int PWMPrefs::confGlobMinimizeLock() | ||
136 | { | ||
137 | return mMinimizeLock; | ||
138 | } | ||
139 | |||
140 | bool PWMPrefs::confGlobUnlockOnOpen() | ||
141 | { | ||
142 | return mUnlockOnOpen; | ||
143 | } | ||
144 | |||
145 | bool PWMPrefs::confGlobTray() | ||
146 | { | ||
147 | return mTray; | ||
148 | } | ||
149 | |||
150 | bool PWMPrefs::confGlobMakeFileBackup() | ||
151 | { | ||
152 | return mMakeFileBackup; | ||
153 | } | ||
154 | |||
155 | bool PWMPrefs::confGlobAutostartDeepLocked() | ||
156 | { | ||
157 | return mAutostartDeeplocked; | ||
158 | } | ||
159 | |||
160 | bool PWMPrefs::confGlobAutoDeepLock() | ||
161 | { | ||
162 | return mAutoDeeplock; | ||
163 | } | ||
164 | |||
165 | bool PWMPrefs::confGlobKwalletEmu() | ||
166 | { | ||
167 | return mKWalletEmu; | ||
168 | } | ||
169 | |||
170 | bool PWMPrefs::confGlobNewEntrLockStat() | ||
171 | { | ||
172 | return mNewEntrLockStat; | ||
173 | } | ||
174 | |||
175 | QSize PWMPrefs::confWndMainWndSize() | ||
176 | { | ||
177 | return mMainWndSize; | ||
178 | } | ||
179 | |||
180 | int PWMPrefs::confWndMainViewStyle() | ||
181 | { | ||
182 | return mMainViewStyle; | ||
183 | } | ||
184 | |||
185 | bool PWMPrefs::confWndAutoMinimizeOnStart() | ||
186 | { | ||
187 | return mAutoMinimizeOnStart; | ||
188 | } | ||
189 | |||
190 | bool PWMPrefs::confWndClose() | ||
191 | { | ||
192 | return mClose; | ||
193 | } | ||
194 | |||
195 | /******************************************************************* | ||
196 | * functions for writing the configuration settings | ||
197 | *******************************************************************/ | ||
198 | |||
199 | void PWMPrefs::confGlobAutoStart(const QString &e) | ||
200 | { | ||
201 | mAutoStart = e; | ||
202 | } | ||
203 | |||
204 | void PWMPrefs::confGlobBrowserCommand(const QString &e) | ||
205 | { | ||
206 | mBrowserCommand = e; | ||
207 | } | ||
208 | |||
209 | void PWMPrefs::confGlobXtermCommand(const QString &e) | ||
210 | { | ||
211 | mXTermCommand = e; | ||
212 | } | ||
213 | |||
214 | void PWMPrefs::confGlobEntryFont(const QFont &e) | ||
215 | { | ||
216 | mEntryFont = e; | ||
217 | } | ||
218 | |||
219 | void PWMPrefs::confGlobPwTimeout(int e) | ||
220 | { | ||
221 | mPwTimeout = e; | ||
222 | } | ||
223 | |||
224 | void PWMPrefs::confGlobLockTimeout(int e) | ||
225 | { | ||
226 | mLockTimeout = e; | ||
227 | } | ||
228 | |||
229 | void PWMPrefs::confGlobCompression(int e) | ||
230 | { | ||
231 | mCompression = e; | ||
232 | } | ||
233 | |||
234 | void PWMPrefs::confGlobFilePermissions(int e) | ||
235 | { | ||
236 | mFilePermissions = e; | ||
237 | } | ||
238 | |||
239 | void PWMPrefs::confGlobMinimizeLock(int e) | ||
240 | { | ||
241 | mMinimizeLock = e; | ||
242 | } | ||
243 | |||
244 | void PWMPrefs::confGlobUnlockOnOpen(bool e) | ||
245 | { | ||
246 | mUnlockOnOpen = e; | ||
247 | } | ||
248 | |||
249 | void PWMPrefs::confGlobTray(bool e) | ||
250 | { | ||
251 | mTray = e; | ||
252 | } | ||
253 | |||
254 | void PWMPrefs::confGlobMakeFileBackup(bool e) | ||
255 | { | ||
256 | mMakeFileBackup = e; | ||
257 | } | ||
258 | |||
259 | void PWMPrefs::confGlobAutostartDeepLocked(bool e) | ||
260 | { | ||
261 | mAutostartDeeplocked = e; | ||
262 | } | ||
263 | |||
264 | void PWMPrefs::confGlobAutoDeepLock(bool e) | ||
265 | { | ||
266 | mAutoDeeplock = e; | ||
267 | } | ||
268 | |||
269 | void PWMPrefs::confGlobKwalletEmu(bool e) | ||
270 | { | ||
271 | mKWalletEmu = e; | ||
272 | } | ||
273 | |||
274 | void PWMPrefs::confGlobNewEntrLockStat(bool e) | ||
275 | { | ||
276 | mNewEntrLockStat = e; | ||
277 | } | ||
278 | |||
279 | void PWMPrefs::confWndMainWndSize(const QSize &e) | ||
280 | { | ||
281 | mMainWndSize = e; | ||
282 | } | ||
283 | |||
284 | void PWMPrefs::confWndMainViewStyle(int e) | ||
285 | { | ||
286 | mMainViewStyle = e; | ||
287 | } | ||
288 | |||
289 | void PWMPrefs::confWndAutoMinimizeOnStart(bool e) | ||
290 | { | ||
291 | mAutoMinimizeOnStart = e; | ||
292 | } | ||
293 | |||
294 | void PWMPrefs::confWndClose(bool e) | ||
295 | { | ||
296 | mClose = e; | ||
297 | } | ||
298 | |||
299 | |||