summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show 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 @@
+/*
+ This file is part of PwManager/Pi
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+ $Id$
+*/
+
+
+#include <kconfig.h>
+#include <klocale.h>
+#include <kstaticdeleter.h>
+
+#include "pwmprefs.h"
+
+PWMPrefs *PWMPrefs::sInstance = 0;
+static KStaticDeleter<PWMPrefs> staticDeleter;
+
+PWMPrefs::PWMPrefs()
+ : KPimPrefs("pwmanagerrc")
+{
+ KPrefs::setCurrentGroup( "Global" );
+
+ addItemString( "autoStart", &mAutoStart, "" );
+ addItemString( "browserCommand", &mBrowserCommand, "" );
+ addItemString( "xtermCommand", &mXTermCommand, CONF_DEFAULT_XTERMCOMMAND);
+ addItemFont( "entryFont", &mEntryFont);
+ addItemInt( "pwTimeout", &mPwTimeout, CONF_DEFAULT_PWTIMEOUT );
+ addItemInt( "lockTimeout", &mLockTimeout, CONF_DEFAULT_LOCKTIMEOUT );
+ addItemInt( "compression", &mCompression, CONF_DEFAULT_COMPRESSION );
+ addItemInt( "filePermissions", &mFilePermissions, CONF_DEFAULT_FILEPERMISSIONS );
+ addItemInt( "minimizeLock", &mMinimizeLock, CONF_DEFAULT_MINIMIZELOCK );
+ addItemBool( "unlockOnOpen", &mUnlockOnOpen, CONF_DEFAULT_UNLOCKONOPEN );
+ addItemBool( "tray", &mTray, CONF_DEFAULT_TRAY );
+ addItemBool( "makeFileBackup", &mMakeFileBackup, CONF_DEFAULT_MAKEFILEBACKUP );
+ addItemBool( "autostartDeepLocked", &mAutostartDeeplocked, CONF_DEFAULT_AUTOSTART_DEEPL );
+ addItemBool( "autoDeepLock", &mAutoDeeplock, CONF_DEFAULT_AUTODEEPLOCK );
+ addItemBool( "kwalletEmu", &mKWalletEmu, CONF_DEFAULT_KWALLETEMU );
+ addItemBool( "newEntrLockStat", &mNewEntrLockStat, CONF_DEFAULT_NEWENTRLOCKSTAT );
+
+ KPrefs::setCurrentGroup( "Wnd" );
+
+ addItemSize( "MainWndSize", &mMainWndSize);
+ addItemInt( "MainViewStyle", &mMainViewStyle, CONF_DEFAULT_MAINVIEWSTYLE );
+ addItemBool( "autoMinimizeOnStart", &mAutoMinimizeOnStart, CONF_DEFAULT_AUTOMINIMIZE );
+ addItemBool( "close", &mClose, CONF_DEFAULT_WNDCLOSE );
+}
+
+PWMPrefs::~PWMPrefs()
+{
+}
+
+PWMPrefs *PWMPrefs::instance()
+{
+ if ( !sInstance ) {
+#ifdef PWM_EMBEDDED
+ sInstance = staticDeleter.setObject( new PWMPrefs() );
+#else //PWM_EMBEDDED
+ //US the following line has changed ???. Why
+ staticDeleter.setObject( sInstance, new PWMPrefs() );
+#endif //KAB_EMBEDDED
+ sInstance->readConfig();
+ }
+
+ return sInstance;
+}
+
+ // US introduce a nonconst way to return the config object.
+KConfig* PWMPrefs::getConfig()
+{
+ return config();
+}
+
+/*******************************************************************
+ * functions for reading the configuration settings
+ *******************************************************************/
+
+QString PWMPrefs::confGlobAutoStart()
+{
+ return mAutoStart;
+}
+
+QString PWMPrefs::confGlobBrowserCommand()
+{
+ return mBrowserCommand;
+}
+
+QString PWMPrefs::confGlobXtermCommand()
+{
+ return mXTermCommand;
+}
+
+QFont PWMPrefs::confGlobEntryFont()
+{
+ return mEntryFont;
+}
+
+int PWMPrefs::confGlobPwTimeout()
+{
+ return mPwTimeout;
+}
+
+int PWMPrefs::confGlobLockTimeout()
+{
+ return mLockTimeout;
+}
+
+int PWMPrefs::confGlobCompression()
+{
+ return mCompression;
+}
+
+int PWMPrefs::confGlobFilePermissions()
+{
+ return mFilePermissions;
+}
+
+int PWMPrefs::confGlobMinimizeLock()
+{
+ return mMinimizeLock;
+}
+
+bool PWMPrefs::confGlobUnlockOnOpen()
+{
+ return mUnlockOnOpen;
+}
+
+bool PWMPrefs::confGlobTray()
+{
+ return mTray;
+}
+
+bool PWMPrefs::confGlobMakeFileBackup()
+{
+ return mMakeFileBackup;
+}
+
+bool PWMPrefs::confGlobAutostartDeepLocked()
+{
+ return mAutostartDeeplocked;
+}
+
+bool PWMPrefs::confGlobAutoDeepLock()
+{
+ return mAutoDeeplock;
+}
+
+bool PWMPrefs::confGlobKwalletEmu()
+{
+ return mKWalletEmu;
+}
+
+bool PWMPrefs::confGlobNewEntrLockStat()
+{
+ return mNewEntrLockStat;
+}
+
+QSize PWMPrefs::confWndMainWndSize()
+{
+ return mMainWndSize;
+}
+
+int PWMPrefs::confWndMainViewStyle()
+{
+ return mMainViewStyle;
+}
+
+bool PWMPrefs::confWndAutoMinimizeOnStart()
+{
+ return mAutoMinimizeOnStart;
+}
+
+bool PWMPrefs::confWndClose()
+{
+ return mClose;
+}
+
+/*******************************************************************
+ * functions for writing the configuration settings
+ *******************************************************************/
+
+void PWMPrefs::confGlobAutoStart(const QString &e)
+{
+ mAutoStart = e;
+}
+
+void PWMPrefs::confGlobBrowserCommand(const QString &e)
+{
+ mBrowserCommand = e;
+}
+
+void PWMPrefs::confGlobXtermCommand(const QString &e)
+{
+ mXTermCommand = e;
+}
+
+void PWMPrefs::confGlobEntryFont(const QFont &e)
+{
+ mEntryFont = e;
+}
+
+void PWMPrefs::confGlobPwTimeout(int e)
+{
+ mPwTimeout = e;
+}
+
+void PWMPrefs::confGlobLockTimeout(int e)
+{
+ mLockTimeout = e;
+}
+
+void PWMPrefs::confGlobCompression(int e)
+{
+ mCompression = e;
+}
+
+void PWMPrefs::confGlobFilePermissions(int e)
+{
+ mFilePermissions = e;
+}
+
+void PWMPrefs::confGlobMinimizeLock(int e)
+{
+ mMinimizeLock = e;
+}
+
+void PWMPrefs::confGlobUnlockOnOpen(bool e)
+{
+ mUnlockOnOpen = e;
+}
+
+void PWMPrefs::confGlobTray(bool e)
+{
+ mTray = e;
+}
+
+void PWMPrefs::confGlobMakeFileBackup(bool e)
+{
+ mMakeFileBackup = e;
+}
+
+void PWMPrefs::confGlobAutostartDeepLocked(bool e)
+{
+ mAutostartDeeplocked = e;
+}
+
+void PWMPrefs::confGlobAutoDeepLock(bool e)
+{
+ mAutoDeeplock = e;
+}
+
+void PWMPrefs::confGlobKwalletEmu(bool e)
+{
+ mKWalletEmu = e;
+}
+
+void PWMPrefs::confGlobNewEntrLockStat(bool e)
+{
+ mNewEntrLockStat = e;
+}
+
+void PWMPrefs::confWndMainWndSize(const QSize &e)
+{
+ mMainWndSize = e;
+}
+
+void PWMPrefs::confWndMainViewStyle(int e)
+{
+ mMainViewStyle = e;
+}
+
+void PWMPrefs::confWndAutoMinimizeOnStart(bool e)
+{
+ mAutoMinimizeOnStart = e;
+}
+
+void PWMPrefs::confWndClose(bool e)
+{
+ mClose = e;
+}
+
+
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 @@
+/*
+ This file is part of PwManager/Pi
+ Copyright (c) 2004 Ulf Schenk
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ As a special exception, permission is given to link this program
+ with any edition of Qt, and distribute the resulting executable,
+ without including the source code for Qt in the source distribution.
+
+ $Id$
+*/
+
+#ifndef PWMPREFS_H
+#define PWMPREFS_H
+
+#include <qstringlist.h>
+#include <qsize.h>
+
+#include <kpimprefs.h>
+
+class KConfig;
+
+#define conf() PWMPrefs::instance()
+
+
+#define CONF_DEFAULT_PWTIMEOUT 10 /* 10 sec */
+#define CONF_DEFAULT_LOCKTIMEOUT 0 /* 0 == disable */
+#define CONF_DEFAULT_TRAY true
+#define CONF_DEFAULT_UNLOCKONOPEN false
+#define CONF_DEFAULT_MAINVIEWSTYLE 0
+#define CONF_DEFAULT_COMPRESSION 0x01 /* gzip */
+#define CONF_DEFAULT_AUTOMINIMIZE false
+#define CONF_DEFAULT_BROWSERCOMMAND ""
+#define CONF_DEFAULT_XTERMCOMMAND "konsole -e"
+#define CONF_DEFAULT_FILEPERMISSIONS 0600
+#define CONF_DEFAULT_MAKEFILEBACKUP false
+#define CONF_DEFAULT_AUTOSTART_DEEPL true
+#define CONF_DEFAULT_AUTODEEPLOCK true
+#define CONF_DEFAULT_KWALLETEMU true
+#define CONF_DEFAULT_MINIMIZELOCK 2 /* deep-lock */
+#define CONF_DEFAULT_NEWENTRLOCKSTAT true /* locked */
+#define CONF_DEFAULT_WNDCLOSE true /* don't minimize to tray */
+
+class PWMPrefs : public KPimPrefs
+{
+ public:
+ virtual ~PWMPrefs();
+
+ static PWMPrefs *instance();
+
+public:
+ /* functions for reading the configuration settings */
+ /* GLOBAL */
+ QString confGlobAutoStart();
+ QString confGlobBrowserCommand();
+ QString confGlobXtermCommand();
+ QFont confGlobEntryFont();
+ int confGlobPwTimeout();
+ int confGlobLockTimeout();
+ int confGlobCompression();
+ int confGlobFilePermissions();
+ int confGlobMinimizeLock();
+ bool confGlobUnlockOnOpen();
+ bool confGlobTray();
+ bool confGlobMakeFileBackup();
+ bool confGlobAutostartDeepLocked();
+ bool confGlobAutoDeepLock();
+ bool confGlobKwalletEmu();
+ bool confGlobNewEntrLockStat();
+ /* WND */
+ QSize confWndMainWndSize();
+ int confWndMainViewStyle();
+ bool confWndAutoMinimizeOnStart();
+ bool confWndClose();
+
+public:
+ /* functions for writing the configuration settings */
+ /* GLOBAL */
+ void confGlobAutoStart(const QString &e);
+ void confGlobBrowserCommand(const QString &e);
+ void confGlobXtermCommand(const QString &e);
+ void confGlobEntryFont(const QFont &e);
+ void confGlobPwTimeout(int e);
+ void confGlobLockTimeout(int e);
+ void confGlobCompression(int e);
+ void confGlobFilePermissions(int e);
+ void confGlobMinimizeLock(int e);
+ void confGlobUnlockOnOpen(bool e);
+ void confGlobTray(bool e);
+ void confGlobMakeFileBackup(bool e);
+ void confGlobAutostartDeepLocked(bool e);
+ void confGlobAutoDeepLock(bool e);
+ void confGlobKwalletEmu(bool e);
+ void confGlobNewEntrLockStat(bool e);
+ /* WND */
+ void confWndMainWndSize(const QSize &e);
+ void confWndMainViewStyle(int e);
+ void confWndAutoMinimizeOnStart(bool e);
+ void confWndClose(bool e);
+
+
+
+ QString mAutoStart;
+ QString mBrowserCommand;
+ QString mXTermCommand;
+ QFont mEntryFont;
+ int mPwTimeout;
+ int mLockTimeout;
+ int mCompression;
+ int mFilePermissions;
+ int mMinimizeLock;
+ bool mUnlockOnOpen;
+ bool mTray;
+ bool mMakeFileBackup;
+ bool mAutostartDeeplocked;
+ bool mAutoDeeplock;
+ bool mKWalletEmu;
+ bool mNewEntrLockStat;
+ QSize mMainWndSize;
+ int mMainViewStyle;
+ bool mAutoMinimizeOnStart;
+ bool mClose;
+
+ // US introduce a nonconst way to return the config object.
+ KConfig* getConfig();
+
+ private:
+ PWMPrefs();
+
+ static PWMPrefs *sInstance;
+};
+
+#endif