summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kprefsdialog.cpp30
-rw-r--r--libkdepim/kprefsdialog.h26
2 files changed, 56 insertions, 0 deletions
diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp
index b6ae775..6dc741d 100644
--- a/libkdepim/kprefsdialog.cpp
+++ b/libkdepim/kprefsdialog.cpp
@@ -1,183 +1,185 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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 <qlayout.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qbuttongroup.h>
#include <qlineedit.h>
#include <qfont.h>
#include <qslider.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qspinbox.h>
#include <qdatetime.h>
#include <qframe.h>
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <kcolorbutton.h>
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
+#include <kglobalsettings.h>
#include <kfontdialog.h>
#include <kmessagebox.h>
#include <kcolordialog.h>
#include <kiconloader.h>
#include "kprefs.h"
+#include "kpimglobalprefs.h"
#include "kprefsdialog.h"
//#include "kprefsdialog.moc"
KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference,
QWidget *parent)
{
mReference = reference;
mCheck = new QCheckBox(text,parent);
}
void KPrefsDialogWidBool::readConfig()
{
mCheck->setChecked(*mReference);
}
void KPrefsDialogWidBool::writeConfig()
{
*mReference = mCheck->isChecked();
}
QCheckBox *KPrefsDialogWidBool::checkBox()
{
return mCheck;
}
KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference,
QWidget *parent)
{
mReference = reference;
mButton = new KColorButton(parent);
mLabel = new QLabel(mButton, text, parent);
mButton->setColor( *mReference );
mButton->setColor( Qt::red );
}
KPrefsDialogWidColor::~KPrefsDialogWidColor()
{
// kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl;
}
void KPrefsDialogWidColor::readConfig()
{
mButton->setColor(*mReference);
}
void KPrefsDialogWidColor::writeConfig()
{
*mReference = mButton->color();
}
QLabel *KPrefsDialogWidColor::label()
{
return mLabel;
}
KColorButton *KPrefsDialogWidColor::button()
{
return mButton;
}
KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText,
QFont *reference,QWidget *parent)
{
mReference = reference;
mLabel = new QLabel(labelText, parent);
mPreview = new QLabel(sampleText,parent);
mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken);
mButton = new QPushButton(i18n("Choose..."), parent);
connect(mButton,SIGNAL(clicked()),SLOT(selectFont()));
mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 );
mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 );
}
KPrefsDialogWidFont::~KPrefsDialogWidFont()
{
}
void KPrefsDialogWidFont::readConfig()
{
mPreview->setFont(*mReference);
}
void KPrefsDialogWidFont::writeConfig()
{
*mReference = mPreview->font();
}
QLabel *KPrefsDialogWidFont::label()
{
return mLabel;
}
QLabel *KPrefsDialogWidFont::preview()
{
return mPreview;
}
QPushButton *KPrefsDialogWidFont::button()
{
return mButton;
}
void KPrefsDialogWidFont::selectFont()
{
QFont myFont(mPreview->font());
bool ok;
myFont = KFontDialog::getFont(myFont, ok);
if ( ok ) {
mPreview->setFont(myFont);
}
}
KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference,
QWidget *parent)
{
mReference = reference;
mLabel = new QLabel(text,parent);
mSpin = new QSpinBox(0,23,1,parent);
@@ -283,128 +285,156 @@ KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal)
mPrefsWids.setAutoDelete(true);
connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault()));
//connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault()));
//connect(this,SIGNAL(cancelClicked()),SLOT(reject()));
}
KPrefsDialog::~KPrefsDialog()
{
}
void KPrefsDialog::addWid(KPrefsDialogWid *wid)
{
mPrefsWids.append(wid);
}
KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent)
{
KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent);
addWid(w);
return w;
}
KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent)
{
KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent);
addWid(w);
return w;
}
KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent)
{
KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent);
addWid(w);
return w;
}
KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent)
{
KPrefsDialogWidRadios *w = new KPrefsDialogWidRadios(text,reference,parent);
addWid(w);
return w;
}
KPrefsDialogWidString *KPrefsDialog::addWidString(const QString &text,QString *reference,QWidget *parent)
{
KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent);
addWid(w);
return w;
}
KPrefsDialogWidString *KPrefsDialog::addWidPassword(const QString &text,QString *reference,QWidget *parent)
{
KPrefsDialogWidString *w = new KPrefsDialogWidString(text,reference,parent,QLineEdit::Password);
addWid(w);
return w;
}
KPrefsDialogWidFont *KPrefsDialog::addWidFont(const QString &sampleText,const QString &buttonText,
QFont *reference,QWidget *parent)
{
KPrefsDialogWidFont *w = new KPrefsDialogWidFont(sampleText,buttonText,reference,parent);
addWid(w);
return w;
}
void KPrefsDialog::setDefaults()
{
mPrefs->setDefaults();
readConfig();
}
void KPrefsDialog::readConfig()
{
// kdDebug(5300) << "KPrefsDialog::readConfig()" << endl;
KPrefsDialogWid *wid;
for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
wid->readConfig();
}
usrReadConfig();
}
void KPrefsDialog::writeConfig()
{
// kdDebug(5300) << "KPrefsDialog::writeConfig()" << endl;
KPrefsDialogWid *wid;
for(wid = mPrefsWids.first();wid;wid=mPrefsWids.next()) {
wid->writeConfig();
}
usrWriteConfig();
// kdDebug(5300) << "KPrefsDialog::writeConfig() now writing..." << endl;
mPrefs->writeConfig();
// kdDebug(5300) << "KPrefsDialog::writeConfig() done" << endl;
}
void KPrefsDialog::slotApply()
{
writeConfig();
emit configChanged();
}
void KPrefsDialog::slotOk()
{
slotApply();
QDialog::accept();
}
void KPrefsDialog::accept()
{
slotOk();
}
void KPrefsDialog::slotDefault()
{
if (KMessageBox::warningContinueCancel(this,
i18n("You are about to set all\npreferences to default values.\nAll "
"custom modifications will be lost."),i18n("Setting Default Preferences"),
i18n("Continue"))
== KMessageBox::Continue) setDefaults();
}
+
+KPimPrefsGlobalDialog::KPimPrefsGlobalDialog(QWidget *parent,char *name,bool modal): KPrefsDialog( KPimGlobalPrefs::instance() ,parent, name, modal )
+{
+ setFont( KGlobalSettings::generalMaxFont() );
+ kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), this, "KPrefsGlobalDialog" );
+ setMainWidget( kdelibcfg );
+ setCaption( i18n("KDE-Pim Global Settings"));
+ kdelibcfg->readConfig();
+#ifndef DESKTOP_VERSION
+ if ( QApplication::desktop()->height() <= 480 )
+ hideButtons();
+ showMaximized();
+#endif
+}
+void KPimPrefsGlobalDialog::showTZconfig()
+{
+ kdelibcfg->showTimeZoneTab() ;
+}
+void KPimPrefsGlobalDialog::usrReadConfig()
+{
+ kdelibcfg->readConfig();
+}
+
+void KPimPrefsGlobalDialog::usrWriteConfig()
+{
+ kdelibcfg->writeConfig();
+}
+
diff --git a/libkdepim/kprefsdialog.h b/libkdepim/kprefsdialog.h
index efcb86a..52ec809 100644
--- a/libkdepim/kprefsdialog.h
+++ b/libkdepim/kprefsdialog.h
@@ -317,129 +317,155 @@ class KPrefsDialogWidString : public KPrefsDialogWid
This class provides the framework for a preferences dialog. You have to
subclass it and add the code to create the actual configuration widgets and
do the layout management.
KPrefsDialog provides functions to add subclasses of @ref KPrefsDialogWid. For
these widgets the reading, writing and setting to default values is handled
automatically. Custom widgets have to be handled in the functions @ref
usrReadConfig() and @ref usrWriteConfig().
*/
class KPrefsDialog : public KDialogBase
{
Q_OBJECT
public:
/**
Create a KPrefsDialog for a KPrefs object.
@param prefs KPrefs object used to access te configuration.
@param parent Parent widget.
@param name Widget name.
@param modal true, if dialog has to be modal, false for non-modal.
*/
KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false);
/**
Destructor.
*/
virtual ~KPrefsDialog();
/**
Register a custom KPrefsDialogWid object.
*/
void addWid(KPrefsDialogWid *);
/**
Register a @ref KPrefsDialogWidBool object.
@param text Text of bool widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
/**
Register a @ref KPrefsDialogWidTime object.
@param text Text of time widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
/**
Register a @ref KPrefsDialogWidColor object.
@param text Text of color widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
/**
Register a @ref KPrefsDialogWidRadios object.
@param text Text of radio button box widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
/**
Register a @ref KPrefsDialogWidString object.
@param text Text of string widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
/**
Register a password @ref KPrefsDialogWidString object, with echomode set to QLineEdit::Password.
@param text Text of string widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
/**
Register a @ref KPrefsDialogWidFont object.
@param sampleText Sample text of font widget.
@param buttonText Button text of font widget.
@param reference Reference to variable storing the setting.
@param parent Parent widget.
*/
KPrefsDialogWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
QFont *reference,QWidget *parent);
public slots:
/** Set all widgets to default values. */
void setDefaults();
/** Read preferences from config file. */
void readConfig();
/** Write preferences to config file. */
void writeConfig();
signals:
/** Emitted when the a changed configuration has been stored. */
void configChanged();
protected slots:
/** Apply changes to preferences */
void slotApply();
void accept();
/** Accept changes to preferences and close dialog */
void slotOk();
/** Set preferences to default values */
void slotDefault();
protected:
/** Implement this to read custom configuration widgets. */
virtual void usrReadConfig() {}
/** Implement this to write custom configuration widgets. */
virtual void usrWriteConfig() {}
private:
KPrefs *mPrefs;
QPtrList<KPrefsDialogWid> mPrefsWids;
};
+
+#include "kcmconfigs/kdepimconfigwidget.h"
+class KPimPrefsGlobalDialog : public KPrefsDialog
+{
+ Q_OBJECT
+ public:
+ KPimPrefsGlobalDialog(QWidget *parent=0,char *name=0,bool modal=true);
+ /**
+ Destructor.
+ */
+ void showTZconfig();
+
+ public slots:
+
+ signals:
+ protected slots:
+
+ protected:
+ void usrReadConfig();
+ virtual void usrWriteConfig() ;
+
+ private:
+ KDEPIMConfigWidget* kdelibcfg;
+
+};
+
#endif