summaryrefslogtreecommitdiffabout
path: root/microkde
Side-by-side diff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/kprefs.cpp50
-rw-r--r--microkde/kdecore/kprefs.h15
-rw-r--r--microkde/kutils/kcmultidialog.cpp20
-rw-r--r--microkde/kutils/kcmultidialog.h5
4 files changed, 87 insertions, 3 deletions
diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp
index f5e5e5a..71050e7 100644
--- a/microkde/kdecore/kprefs.cpp
+++ b/microkde/kdecore/kprefs.cpp
@@ -28,96 +28,111 @@
#include <kdebug.h>
#include "kprefs.h"
class KPrefsItemBool : public KPrefsItem {
public:
KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true);
virtual ~KPrefsItemBool() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
bool *mReference;
bool mDefault;
};
class KPrefsItemInt : public KPrefsItem {
public:
KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
virtual ~KPrefsItemInt() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
int *mReference;
int mDefault;
};
class KPrefsItemColor : public KPrefsItem {
public:
KPrefsItemColor(const QString &group,const QString &name,QColor *,
const QColor &defaultValue=QColor(128,128,128));
virtual ~KPrefsItemColor() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
QColor *mReference;
QColor mDefault;
};
+class KPrefsItemSize : public KPrefsItem {
+ public:
+ KPrefsItemSize(const QString &group,const QString &name,QSize *,
+ const QSize &defaultValue=QSize());
+ ~KPrefsItemSize() {}
+
+ void setDefault();
+ void readConfig(KConfig *);
+ void writeConfig(KConfig *);
+
+ private:
+ QSize *mReference;
+ QSize mDefault;
+};
+
class KPrefsItemFont : public KPrefsItem {
public:
KPrefsItemFont(const QString &group,const QString &name,QFont *,
const QFont &defaultValue=QFont("helvetica",12));
virtual ~KPrefsItemFont() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
QFont *mReference;
QFont mDefault;
};
class KPrefsItemString : public KPrefsItem {
public:
KPrefsItemString(const QString &group,const QString &name,QString *,
const QString &defaultValue="", bool isPassword=false);
virtual ~KPrefsItemString() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
QString *mReference;
QString mDefault;
bool mPassword;
};
class KPrefsItemStringList : public KPrefsItem {
public:
KPrefsItemStringList(const QString &group,const QString &name,QStringList *,
const QStringList &defaultValue=QStringList());
virtual ~KPrefsItemStringList() {}
void setDefault();
void readConfig(KConfig *);
void writeConfig(KConfig *);
private:
QStringList *mReference;
QStringList mDefault;
};
@@ -174,96 +189,123 @@ KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name,
mDefault = defaultValue;
}
void KPrefsItemInt::setDefault()
{
*mReference = mDefault;
}
void KPrefsItemInt::writeConfig(KConfig *config)
{
config->setGroup(mGroup);
config->writeEntry(mName,*mReference);
}
void KPrefsItemInt::readConfig(KConfig *config)
{
config->setGroup(mGroup);
*mReference = config->readNumEntry(mName,mDefault);
}
KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name,
QColor *reference,const QColor &defaultValue) :
KPrefsItem(group,name)
{
mReference = reference;
mDefault = defaultValue;
}
void KPrefsItemColor::setDefault()
{
*mReference = mDefault;
}
void KPrefsItemColor::writeConfig(KConfig *config)
{
config->setGroup(mGroup);
config->writeEntry(mName,*mReference);
}
void KPrefsItemColor::readConfig(KConfig *config)
{
config->setGroup(mGroup);
*mReference = config->readColorEntry(mName,&mDefault);
}
+KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name,
+ QSize *reference,const QSize &defaultValue) :
+ KPrefsItem(group,name)
+{
+ mReference = reference;
+ mDefault = defaultValue;
+}
+
+void KPrefsItemSize::setDefault()
+{
+ *mReference = mDefault;
+}
+
+void KPrefsItemSize::writeConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ config->writeEntry(mName,*mReference);
+}
+
+void KPrefsItemSize::readConfig(KConfig *config)
+{
+ config->setGroup(mGroup);
+ *mReference = config->readSizeEntry(mName,&mDefault);
+
+}
+
+
KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name,
QFont *reference,const QFont &defaultValue) :
KPrefsItem(group,name)
{
mReference = reference;
mDefault = defaultValue;
}
void KPrefsItemFont::setDefault()
{
*mReference = mDefault;
}
void KPrefsItemFont::writeConfig(KConfig *config)
{
config->setGroup(mGroup);
config->writeEntry(mName,*mReference);
}
void KPrefsItemFont::readConfig(KConfig *config)
{
config->setGroup(mGroup);
*mReference = config->readFontEntry(mName,&mDefault);
}
QString endecryptStr( const QString &aStr )
{
QString result;
uint i;
for ( i = 0; i < aStr.length(); i++)
result += (aStr.at(i).unicode() < 0x20) ?
aStr.at(i) :
QChar(0x1001F - aStr.at(i).unicode());
return result;
}
KPrefsItemString::KPrefsItemString(const QString &group,const QString &name,
QString *reference,const QString &defaultValue,
bool isPassword) :
KPrefsItem(group,name)
{
mReference = reference;
mDefault = defaultValue;
mPassword = isPassword;
}
@@ -355,109 +397,115 @@ KPrefs::KPrefs(const QString &configname)
//qDebug("KPrefs::KPrefs %s",configname.latin1() );
mConfig = new KConfig(locateLocal("config",configname));
} else {
mConfig = KGlobal::config();
}
mItems.setAutoDelete(true);
// Set default group
if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group");
}
KPrefs::~KPrefs()
{
if (mConfig != KGlobal::config()) {
delete mConfig;
}
}
void KPrefs::setCurrentGroup(const QString &group)
{
if (mCurrentGroup) delete mCurrentGroup;
mCurrentGroup = new QString(group);
}
KConfig *KPrefs::config() const
{
return mConfig;
}
void KPrefs::setDefaults()
{
KPrefsItem *item;
for(item = mItems.first();item;item = mItems.next()) {
item->setDefault();
}
usrSetDefaults();
}
void KPrefs::readConfig()
{
KPrefsItem *item;
for(item = mItems.first();item;item = mItems.next()) {
item->readConfig(mConfig);
}
usrReadConfig();
+ //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1());
}
void KPrefs::writeConfig()
{
KPrefsItem *item;
for(item = mItems.first();item;item = mItems.next()) {
item->writeConfig(mConfig);
}
usrWriteConfig();
-
+ //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1());
mConfig->sync();
}
void KPrefs::addItem(KPrefsItem *item)
{
mItems.append(item);
}
void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue)
{
addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue));
}
void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue)
{
addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue));
}
void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue)
{
addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue));
}
void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue)
{
addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue));
}
+void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue)
+{
+ addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue));
+}
+
void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue)
{
addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false));
}
void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue)
{
addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true));
}
void KPrefs::addItemStringList(const QString &key,QStringList *reference,
const QStringList &defaultValue)
{
addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue));
}
void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference,
const QValueList<int> &defaultValue)
{
addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue));
}
diff --git a/microkde/kdecore/kprefs.h b/microkde/kdecore/kprefs.h
index 7014bb8..95d2724 100644
--- a/microkde/kdecore/kprefs.h
+++ b/microkde/kdecore/kprefs.h
@@ -1,74 +1,75 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _KPREFS_H
#define _KPREFS_H
// $Id$
#include <qptrlist.h>
#include <qcolor.h>
#include <qfont.h>
+#include <qsize.h>
#include <qstringlist.h>
class KConfig;
/**
@short Class for storing a preferences setting
@author Cornelius Schumacher
@see KPref
This class represents one preferences setting as used by @ref KPrefs.
Subclasses of KPrefsItem implement storage functions for a certain type of
setting. Normally you don't have to use this class directly. Use the special
addItem() functions of KPrefs instead. If you subclass this class you will
have to register instances with the function KPrefs::addItem().
*/
class KPrefsItem {
public:
/**
Constructor.
@param group Config file group.
@param name Config file key.
*/
KPrefsItem(const QString &group,const QString &name) :
mGroup(group),mName(name) {}
/**
Destructor.
*/
virtual ~KPrefsItem() {}
/**
This function is called by @ref KPrefs to set this setting to its default
value.
*/
virtual void setDefault() = 0;
/**
This function is called by @ref KPrefs to read the value for this setting
from a config file.
value.
*/
virtual void readConfig(KConfig *) = 0;
/**
This function is called by @ref KPrefs to write the value of this setting
to a config file.
*/
virtual void writeConfig(KConfig *) = 0;
protected:
@@ -162,96 +163,110 @@ class KPrefs {
/**
Set the config file group for subsequent addItem() calls. It is valid
until setCurrentGroup() is called with a new argument. Call this before
you add any items. The default value is "No Group".
*/
static void setCurrentGroup(const QString &group);
/**
Register a custom @ref KPrefsItem.
*/
void addItem(KPrefsItem *);
/**
Register an item of type bool.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemBool(const QString &key,bool *reference,
bool defaultValue=false);
/**
Register an item of type int.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemInt(const QString &key,int *reference,
int defaultValue=0);
/**
Register an item of type QColor.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemColor(const QString &key,QColor *reference,
const QColor &defaultValue=QColor(128,128,128));
+
+ /**
+ Register an item of type QSize.
+
+ @param key Key used in config file.
+ @param reference Pointer to the variable, which is set by readConfig()
+ and setDefaults() calls and read by writeConfig() calls.
+ @param defaultValue Default value, which is used by setDefaults() and
+ when the config file does not yet contain the key of
+ this item.
+ */
+ void addItemSize(const QString &key,QSize *reference,
+ const QSize &defaultValue=QSize());
+
/**
Register an item of type QFont.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemFont(const QString &key,QFont *reference,
const QFont &defaultValue=QFont("helvetica",12));
/**
Register an item of type QString.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemString(const QString &key,QString *reference,
const QString &defaultValue="");
/**
Register a password item of type QString. The string value is written
encrypted to the config file. Note that the current encryption scheme
is very weak.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
void addItemPassword(const QString &key,QString *reference,
const QString &defaultValue="");
/**
Register an item of type QStringList.
@param key Key used in config file.
@param reference Pointer to the variable, which is set by readConfig()
and setDefaults() calls and read by writeConfig() calls.
@param defaultValue Default value, which is used by setDefaults() and
when the config file does not yet contain the key of
this item.
*/
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index e7aa9d1..c4ccede 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -22,97 +22,97 @@
#include <qhbox.h>
#include <qvbox.h>
#include <qcursor.h>
#include <qlayout.h>
#include <klocale.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kmessagebox.h>
//US #include <klibloader.h>
#include <krun.h>
#include <kprocess.h>
#include "kcmultidialog.h"
//US #include "kcmultidialog.moc"
//US #include "kcmoduleloader.h"
KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
: KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
parent, name, modal, true), d(0L)
{
enableButton(Apply, false);
//connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
_baseGroup = baseGroup;
mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
setMainWidget(mMainWidget );
#ifdef DESKTOP_VERSION
resize(640,480);
#else
resize(640,480);
setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
//showMaximized();
#endif
}
KCMultiDialog::~KCMultiDialog()
{
//US moduleDict.setAutoDelete(true);
}
void KCMultiDialog::slotDefault()
{
- int curPageIndex = mMainWidget->activePageIndex();
+ int curPageIndex = activePageIndex();
QPtrListIterator<KCModule> it(modules);
for (; it.current(); ++it)
{
if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
{
(*it)->defaults();
clientChanged(true);
return;
}
}
}
void KCMultiDialog::accept()
{
slotOk();
}
void KCMultiDialog::slotApply()
{
qDebug("KCMultiDialog::slotApply clicked");
QPtrListIterator<KCModule> it(modules);
for (; it.current(); ++it)
(*it)->save();
clientChanged(false);
emit applyClicked();
}
void KCMultiDialog::slotOk()
{
qDebug("KCMultiDialog::slotOk clicked");
QPtrListIterator<KCModule> it(modules);
for (; it.current(); ++it)
(*it)->save();
QDialog::accept();
emit okClicked();
}
void KCMultiDialog::slotHelp()
{
/*US
KURL url( KURL("help:/"), _docPath );
@@ -162,48 +162,66 @@ void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename,
{
modules.append(module);
connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
//US
module->load();
}
void KCMultiDialog::slotAboutToShow(QWidget *page)
{
/*US
LoadInfo *loadInfo = moduleDict[page];
if (!loadInfo)
return;
QApplication::setOverrideCursor(Qt::WaitCursor);
moduleDict.remove(page);
KCModuleInfo info(loadInfo->path, _baseGroup);
KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
if (!module)
{
QApplication::restoreOverrideCursor();
KCModuleLoader::showLastLoaderError(this);
delete loadInfo;
return;
}
module->reparent(page,0,QPoint(0,0),true);
connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
//setHelp( docpath, QString::null );
_docPath = info.docPath();
modules.append(module);
//KCGlobal::repairAccels( topLevelWidget() );
delete loadInfo;
QApplication::restoreOverrideCursor();
*/
qDebug("KCMultiDialog::slotAboutToShow not implemented");
}
+
+
+bool KCMultiDialog::showPage( int index )
+{
+ return(mMainWidget->showPage(index) );
+}
+
+
+int KCMultiDialog::activePageIndex() const
+{
+ return( mMainWidget->activePageIndex() );
+}
+
+
+int KCMultiDialog::pageIndex( QWidget *widget ) const
+{
+ return( mMainWidget->pageIndex( widget) );
+}
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
index 768faea..66412ac 100644
--- a/microkde/kutils/kcmultidialog.h
+++ b/microkde/kutils/kcmultidialog.h
@@ -28,101 +28,104 @@
#include <kdialogbase.h>
#include <kjanuswidget.h>
#include <kcmodule.h>
/**
* A class that offers a @ref KDialogBase containing arbitrary KControl Modules
*
* @short A method that offers a @ref KDialogBase containing arbitrary
* KControl Modules.
*
* @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
* @since 3.2
*/
class KCMultiDialog : public KDialogBase
{
Q_OBJECT
public:
/**
* Constructs a new KCMultiDialog
*
* @param parent The parent Widget
* @param name The widget name
* @param baseGroup The baseGroup, if you want to call a module out of
* kcontrol, just keep "settings"
* @param modal If you pass true here, the dialog will be modal
**/
KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"),
QWidget *parent=0, const char *name=0,
bool modal=false);
/**
* Destructor
**/
virtual ~KCMultiDialog();
/**
* Add a module.
*
* @param module Specify the name of the module that is to be added
* to the list of modules the dialog will show.
*
* @param withfallback Try harder to load the module. Might result
* in the module appearing outside the dialog.
**/
//US void addModule(const QString& module, bool withfallback=true);
-//US special method for microkde. We dop noty want to load everything dynamically.
+//US special method for microkde. We do not want to load everything dynamically.
void addModule(KCModule* module );//, const QString& modulename, const QString& iconname);
QVBox* getNewVBoxPage(const QString & modulename) ;
+ bool showPage( int index );
+ int activePageIndex() const;
+ int pageIndex( QWidget *widget ) const;
protected slots:
/**
* This slot is called when the user presses the "Default" Button
* You can reimplement it if needed.
*
* @note Make sure you call the original implementation!
**/
virtual void slotDefault();
/**
* This slot is called when the user presses the "Apply" Button
* You can reimplement it if needed
*
* @note Make sure you call the original implementation!
**/
virtual void slotApply();
/**
* This slot is called when the user presses the "OK" Button
* You can reimplement it if needed
*
* @note Make sure you call the original implementation!
**/
virtual void slotOk();
/**
* This slot is called when the user presses the "Help" Button
* You can reimplement it if needed
*
* @note Make sure you call the original implementation!
**/
virtual void slotHelp();
void accept();
private slots:
void slotAboutToShow(QWidget *);
void clientChanged(bool state);
private:
/*US
struct LoadInfo {
LoadInfo(const QString &_path, bool _withfallback)
: path(_path), withfallback(_withfallback)
{ }