diff --git a/CMakeLists.txt b/CMakeLists.txt index f49ee59236514c0ac3d057f3f37e02ae8c473b8e..06521b5de3dd55f22fed61d971351154f15cae70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.15.40") +set(PIM_VERSION "5.15.41") project(libkdepim VERSION ${PIM_VERSION}) diff --git a/src/libkdepim/CMakeLists.txt b/src/libkdepim/CMakeLists.txt index 0ec3bb4ea7dc958ee249f7cd58935e3de6f2c537..e38c9d7167edd8fec93d5c4f089ba9855cfb9168 100644 --- a/src/libkdepim/CMakeLists.txt +++ b/src/libkdepim/CMakeLists.txt @@ -43,7 +43,6 @@ set(kdepim_LIB_SRCS ${kdepim_widgets_LIB_SRCS} ${kdepim_misc_LIB_SRCS} ${kdepim_multiplyingline_LIB_SRCS} - prefs/kprefsdialog.cpp ) ecm_qt_declare_logging_category(kdepim_LIB_SRCS HEADER libkdepim_debug.h IDENTIFIER LIBKDEPIM_LOG CATEGORY_NAME org.kde.pim.libkdepim DESCRIPTION "libkdepim (libkdepim)" @@ -118,14 +117,6 @@ ecm_generate_headers(libkdepim_Camelcaseprogresswidget_HEADERS RELATIVE progresswidget ) -ecm_generate_headers(libkdepim_Camelcasepref_HEADERS - HEADER_NAMES - KPrefsDialog - REQUIRED_HEADERS libkdepim_pref_HEADERS - PREFIX Libkdepim - RELATIVE prefs - ) - ecm_generate_headers(libkdepim_Camelcasemultiline_HEADERS HEADER_NAMES MultiplyingLine @@ -145,7 +136,6 @@ install(FILES ${libkdepim_Camelcasewidgets_HEADERS} ${libkdepim_Camelcaseprogresswidget_HEADERS} ${libkdepim_Camelcasemisc_HEADERS} - ${libkdepim_Camelcasepref_HEADERS} ${libkdepim_Camelcasemultiline_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/Libkdepim COMPONENT Devel @@ -157,7 +147,6 @@ install(FILES ${libkdepim_progresswidget_HEADERS} ${libkdepim_misc_HEADERS} ${libkdepim_widgets_HEADERS} - ${libkdepim_pref_HEADERS} ${libkdepim_multiline_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/libkdepim COMPONENT Devel diff --git a/src/libkdepim/prefs/kprefsdialog.cpp b/src/libkdepim/prefs/kprefsdialog.cpp deleted file mode 100644 index 3c4cdc19fff2c10a1508a9620af4477f42562139..0000000000000000000000000000000000000000 --- a/src/libkdepim/prefs/kprefsdialog.cpp +++ /dev/null @@ -1,930 +0,0 @@ -/* - This file is part of libkdepim. - - Copyright (c) 2001,2003 Cornelius Schumacher - Copyright (C) 2003-2004 Reinhold Kainhofer - Copyright (C) 2005,2008,2011 Allen Winter - - 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -//krazy:excludeall=tipsandthis - -#include "kprefsdialog.h" - -#include -#include -#include -#include -#include "libkdepim_debug.h" -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace KPIM; - -namespace KPrefsWidFactory { -KPrefsWid *create(KConfigSkeletonItem *item, QWidget *parent) -{ - KConfigSkeleton::ItemBool *boolItem - = dynamic_cast(item); - if (boolItem) { - return new KPrefsWidBool(boolItem, parent); - } - - KConfigSkeleton::ItemString *stringItem - = dynamic_cast(item); - if (stringItem) { - return new KPrefsWidString(stringItem, parent); - } - - KConfigSkeleton::ItemEnum *enumItem - = dynamic_cast(item); - if (enumItem) { - QList choices = enumItem->choices(); - if (choices.isEmpty()) { - qCritical() << "Enum has no choices."; - return nullptr; - } else { - KPrefsWidRadios *radios = new KPrefsWidRadios(enumItem, parent); - QList::ConstIterator it; - int value = 0; - QList::ConstIterator end(choices.constEnd()); - for (it = choices.constBegin(); it != end; ++it) { - radios->addRadio(value++, (*it).label); - } - return radios; - } - } - - KConfigSkeleton::ItemInt *intItem = dynamic_cast(item); - if (intItem) { - return new KPrefsWidInt(intItem, parent); - } - - return nullptr; -} -} // namespace KPrefsWidFactory - -QList KPrefsWid::widgets() const -{ - return QList(); -} - -KPrefsWidBool::KPrefsWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent) - : mItem(item) -{ - mCheck = new QCheckBox(mItem->label(), parent); - connect(mCheck, &QCheckBox::clicked, this, &KPrefsWidBool::changed); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mCheck->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mCheck->setWhatsThis(whatsThis); - } -} - -void KPrefsWidBool::readConfig() -{ - mCheck->setChecked(mItem->value()); -} - -void KPrefsWidBool::writeConfig() -{ - mItem->setValue(mCheck->isChecked()); -} - -QCheckBox *KPrefsWidBool::checkBox() -{ - return mCheck; -} - -QList KPrefsWidBool::widgets() const -{ - QList widgets; - widgets.append(mCheck); - return widgets; -} - -KPrefsWidInt::KPrefsWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mSpin = new QSpinBox(parent); - if (!mItem->minValue().isNull()) { - mSpin->setMinimum(mItem->minValue().toInt()); - } - if (!mItem->maxValue().isNull()) { - mSpin->setMaximum(mItem->maxValue().toInt()); - } - connect(mSpin, qOverload(&QSpinBox::valueChanged), this, &KPrefsWidInt::changed); - mLabel->setBuddy(mSpin); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mLabel->setToolTip(toolTip); - mSpin->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mLabel->setWhatsThis(whatsThis); - mSpin->setWhatsThis(whatsThis); - } -} - -void KPrefsWidInt::readConfig() -{ - mSpin->setValue(mItem->value()); -} - -void KPrefsWidInt::writeConfig() -{ - mItem->setValue(mSpin->value()); -} - -QLabel *KPrefsWidInt::label() const -{ - return mLabel; -} - -QSpinBox *KPrefsWidInt::spinBox() -{ - return mSpin; -} - -QList KPrefsWidInt::widgets() const -{ - QList widgets; - widgets.append(mLabel); - widgets.append(mSpin); - return widgets; -} - -KPrefsWidColor::KPrefsWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent) - : mItem(item) -{ - mButton = new KColorButton(parent); - connect(mButton, &KColorButton::changed, this, &KPrefsWidColor::changed); - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mLabel->setBuddy(mButton); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mButton->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mButton->setWhatsThis(whatsThis); - } -} - -KPrefsWidColor::~KPrefsWidColor() -{ -} - -void KPrefsWidColor::readConfig() -{ - mButton->setColor(mItem->value()); -} - -void KPrefsWidColor::writeConfig() -{ - mItem->setValue(mButton->color()); -} - -QLabel *KPrefsWidColor::label() -{ - return mLabel; -} - -KColorButton *KPrefsWidColor::button() -{ - return mButton; -} - -KPrefsWidFont::KPrefsWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent, const QString &sampleText) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - - mPreview = new QLabel(sampleText, parent); - mPreview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - - mButton = new QPushButton(i18n("Choose..."), parent); - connect(mButton, &QPushButton::clicked, this, &KPIM::KPrefsWidFont::selectFont); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mPreview->setToolTip(toolTip); - mButton->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mPreview->setWhatsThis(whatsThis); - mButton->setWhatsThis(whatsThis); - } -} - -KPrefsWidFont::~KPrefsWidFont() -{ -} - -void KPrefsWidFont::readConfig() -{ - mPreview->setFont(mItem->value()); -} - -void KPrefsWidFont::writeConfig() -{ - mItem->setValue(mPreview->font()); -} - -QLabel *KPrefsWidFont::label() -{ - return mLabel; -} - -QFrame *KPrefsWidFont::preview() -{ - return mPreview; -} - -QPushButton *KPrefsWidFont::button() -{ - return mButton; -} - -void KPrefsWidFont::selectFont() -{ -#ifndef QT_NO_FONTDIALOG - bool ok; - QFont myFont = QFontDialog::getFont(&ok, mPreview->font()); - if (ok) { - mPreview->setFont(myFont); - Q_EMIT changed(); - } -#endif -} - -KPrefsWidTime::KPrefsWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mTimeEdit = new KTimeComboBox(parent); - mLabel->setBuddy(mTimeEdit); - connect(mTimeEdit, &KTimeComboBox::timeEdited, this, &KPrefsWidTime::changed); - connect(mTimeEdit, &KTimeComboBox::timeEntered, this, &KPrefsWidTime::changed); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mTimeEdit->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mTimeEdit->setWhatsThis(whatsThis); - } -} - -void KPrefsWidTime::readConfig() -{ - mTimeEdit->setTime(mItem->value().time()); -} - -void KPrefsWidTime::writeConfig() -{ - // Don't overwrite the date value of the QDateTime, so we can use a - // KPrefsWidTime and a KPrefsWidDate on the same config entry! - QDateTime dt(mItem->value()); - dt.setTime(mTimeEdit->time()); - mItem->setValue(dt); -} - -QLabel *KPrefsWidTime::label() -{ - return mLabel; -} - -KTimeComboBox *KPrefsWidTime::timeEdit() -{ - return mTimeEdit; -} - -KPrefsWidDuration::KPrefsWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mTimeEdit = new QTimeEdit(parent); - mLabel->setBuddy(mTimeEdit); - if (format.isEmpty()) { - mTimeEdit->setDisplayFormat(QStringLiteral("hh:mm:ss")); - } else { - mTimeEdit->setDisplayFormat(format); - } - mTimeEdit->setMinimumTime(QTime(0, 1)); // [1 min] - mTimeEdit->setMaximumTime(QTime(24, 0)); // [24 hr] - connect(mTimeEdit, &QTimeEdit::timeChanged, this, &KPrefsWidDuration::changed); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mTimeEdit->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mTimeEdit->setWhatsThis(whatsThis); - } -} - -void KPrefsWidDuration::readConfig() -{ - mTimeEdit->setTime(mItem->value().time()); -} - -void KPrefsWidDuration::writeConfig() -{ - QDateTime dt(mItem->value()); - dt.setTime(mTimeEdit->time()); - mItem->setValue(dt); -} - -QLabel *KPrefsWidDuration::label() -{ - return mLabel; -} - -QTimeEdit *KPrefsWidDuration::timeEdit() -{ - return mTimeEdit; -} - -KPrefsWidDate::KPrefsWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mDateEdit = new KDateComboBox(parent); - mLabel->setBuddy(mDateEdit); - connect(mDateEdit, &KDateComboBox::dateEdited, this, &KPrefsWidDate::changed); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mDateEdit->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mDateEdit->setWhatsThis(whatsThis); - } -} - -void KPrefsWidDate::readConfig() -{ - if (!mItem->value().date().isValid()) { - mItem->setValue(QDateTime::currentDateTime()); - } - mDateEdit->setDate(mItem->value().date().isValid() - ? mItem->value().date() : QDate::currentDate()); -} - -void KPrefsWidDate::writeConfig() -{ - QDateTime dt(mItem->value()); - dt.setDate(mDateEdit->date()); - mItem->setValue(dt); - if (!mItem->value().date().isValid()) { - mItem->setValue(QDateTime::currentDateTime()); - } -} - -QLabel *KPrefsWidDate::label() -{ - return mLabel; -} - -KDateComboBox *KPrefsWidDate::dateEdit() -{ - return mDateEdit; -} - -KPrefsWidRadios::KPrefsWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent) - : mItem(item) -{ - mBox = new QGroupBox(mItem->label(), parent); - new QVBoxLayout(mBox); - mGroup = new QButtonGroup(parent); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - connect(mGroup, qOverload(&QButtonGroup::buttonClicked), this, &KPrefsWidRadios::changed); -#else - connect(mGroup, qOverload(&QButtonGroup::buttonClicked), this, &KPrefsWidRadios::changed); -#endif -} - -KPrefsWidRadios::~KPrefsWidRadios() -{ -} - -void KPrefsWidRadios::addRadio(int value, const QString &text, const QString &toolTip, const QString &whatsThis) -{ - QRadioButton *r = new QRadioButton(text, mBox); - mBox->layout()->addWidget(r); - mGroup->addButton(r, value); - if (!toolTip.isEmpty()) { - r->setToolTip(toolTip); - } - if (!whatsThis.isEmpty()) { - r->setWhatsThis(whatsThis); - } -} - -QGroupBox *KPrefsWidRadios::groupBox() const -{ - return mBox; -} - -void KPrefsWidRadios::readConfig() -{ - if (!mGroup->button(mItem->value())) { - return; - } - mGroup->button(mItem->value())->setChecked(true); -} - -void KPrefsWidRadios::writeConfig() -{ - mItem->setValue(mGroup->checkedId()); -} - -QList KPrefsWidRadios::widgets() const -{ - QList w; - w.append(mBox); - return w; -} - -KPrefsWidCombo::KPrefsWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent) - : mItem(item) -{ - mLabel = new QLabel(mItem->label(), parent); - mCombo = new KComboBox(parent); - connect(mCombo, qOverload(&KComboBox::activated), this, &KPrefsWidCombo::changed); - mLabel->setBuddy(mCombo); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mLabel->setToolTip(toolTip); - mCombo->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mLabel->setWhatsThis(whatsThis); - mCombo->setWhatsThis(whatsThis); - } -} - -KPrefsWidCombo::~KPrefsWidCombo() -{ -} - -void KPrefsWidCombo::readConfig() -{ - mCombo->setCurrentIndex(mItem->value()); -} - -void KPrefsWidCombo::writeConfig() -{ - mItem->setValue(mCombo->currentIndex()); -} - -QList KPrefsWidCombo::widgets() const -{ - QList w; - w.append(mCombo); - return w; -} - -KComboBox *KPrefsWidCombo::comboBox() -{ - return mCombo; -} - -QLabel *KPrefsWidCombo::label() const -{ - return mLabel; -} - -KPrefsWidString::KPrefsWidString(KConfigSkeleton::ItemString *item, QWidget *parent, KLineEdit::EchoMode echomode) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mEdit = new KLineEdit(parent); - mLabel->setBuddy(mEdit); - connect(mEdit, &KLineEdit::textChanged, this, &KPrefsWidString::changed); - mEdit->setEchoMode(echomode); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mEdit->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mEdit->setWhatsThis(whatsThis); - } -} - -KPrefsWidString::~KPrefsWidString() -{ -} - -void KPrefsWidString::readConfig() -{ - mEdit->setText(mItem->value()); -} - -void KPrefsWidString::writeConfig() -{ - mItem->setValue(mEdit->text()); -} - -QLabel *KPrefsWidString::label() -{ - return mLabel; -} - -KLineEdit *KPrefsWidString::lineEdit() -{ - return mEdit; -} - -QList KPrefsWidString::widgets() const -{ - QList widgets; - widgets.append(mLabel); - widgets.append(mEdit); - return widgets; -} - -KPrefsWidPath::KPrefsWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent, const QString &filter, KFile::Modes mode) - : mItem(item) -{ - mLabel = new QLabel(mItem->label() + QLatin1Char(':'), parent); - mURLRequester = new KUrlRequester(parent); - mLabel->setBuddy(mURLRequester); - mURLRequester->setMode(mode); - mURLRequester->setFilter(filter); - connect(mURLRequester, &KUrlRequester::textChanged, this, &KPrefsWidPath::changed); - QString toolTip = mItem->toolTip(); - if (!toolTip.isEmpty()) { - mURLRequester->setToolTip(toolTip); - } - QString whatsThis = mItem->whatsThis(); - if (!whatsThis.isEmpty()) { - mURLRequester->setWhatsThis(whatsThis); - } -} - -KPrefsWidPath::~KPrefsWidPath() -{ -} - -void KPrefsWidPath::readConfig() -{ - mURLRequester->setUrl(QUrl(mItem->value())); -} - -void KPrefsWidPath::writeConfig() -{ - mItem->setValue(mURLRequester->url().path()); -} - -QLabel *KPrefsWidPath::label() -{ - return mLabel; -} - -KUrlRequester *KPrefsWidPath::urlRequester() -{ - return mURLRequester; -} - -QList KPrefsWidPath::widgets() const -{ - QList widgets; - widgets.append(mLabel); - widgets.append(mURLRequester); - return widgets; -} - -KPrefsWidManager::KPrefsWidManager(KConfigSkeleton *prefs) - : mPrefs(prefs) -{ -} - -KPrefsWidManager::~KPrefsWidManager() -{ - qDeleteAll(mPrefsWids); - mPrefsWids.clear(); -} - -void KPrefsWidManager::addWid(KPrefsWid *wid) -{ - mPrefsWids.append(wid); -} - -KPrefsWidBool *KPrefsWidManager::addWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent) -{ - KPrefsWidBool *w = new KPrefsWidBool(item, parent); - addWid(w); - return w; -} - -KPrefsWidTime *KPrefsWidManager::addWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent) -{ - KPrefsWidTime *w = new KPrefsWidTime(item, parent); - addWid(w); - return w; -} - -KPrefsWidDuration *KPrefsWidManager::addWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent) -{ - KPrefsWidDuration *w = new KPrefsWidDuration(item, format, parent); - addWid(w); - return w; -} - -KPrefsWidDate *KPrefsWidManager::addWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent) -{ - KPrefsWidDate *w = new KPrefsWidDate(item, parent); - addWid(w); - return w; -} - -KPrefsWidColor *KPrefsWidManager::addWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent) -{ - KPrefsWidColor *w = new KPrefsWidColor(item, parent); - addWid(w); - return w; -} - -KPrefsWidRadios *KPrefsWidManager::addWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent) -{ - KPrefsWidRadios *w = new KPrefsWidRadios(item, parent); - QList choices; - choices = item->choices2(); - QList::ConstIterator it; - QList::ConstIterator end(choices.constEnd()); - int value = 0; - for (it = choices.constBegin(); it != end; ++it) { - w->addRadio(value++, (*it).label, (*it).toolTip, (*it).whatsThis); - } - addWid(w); - return w; -} - -KPrefsWidCombo *KPrefsWidManager::addWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent) -{ - KPrefsWidCombo *w = new KPrefsWidCombo(item, parent); - QList choices; - choices = item->choices(); - QList::ConstIterator end(choices.constEnd()); - for (QList::ConstIterator it = choices.constBegin(); it != end; ++it) { - w->comboBox()->addItem((*it).label); - } - addWid(w); - return w; -} - -KPrefsWidString *KPrefsWidManager::addWidString(KConfigSkeleton::ItemString *item, QWidget *parent) -{ - KPrefsWidString *w = new KPrefsWidString(item, parent, KLineEdit::Normal); - addWid(w); - return w; -} - -KPrefsWidPath *KPrefsWidManager::addWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent, const QString &filter, KFile::Modes mode) -{ - KPrefsWidPath *w = new KPrefsWidPath(item, parent, filter, mode); - addWid(w); - return w; -} - -KPrefsWidString *KPrefsWidManager::addWidPassword(KConfigSkeleton::ItemString *item, QWidget *parent) -{ - KPrefsWidString *w = new KPrefsWidString(item, parent, KLineEdit::Password); - addWid(w); - return w; -} - -KPrefsWidFont *KPrefsWidManager::addWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent, const QString &sampleText) -{ - KPrefsWidFont *w = new KPrefsWidFont(item, parent, sampleText); - addWid(w); - return w; -} - -KPrefsWidInt *KPrefsWidManager::addWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent) -{ - KPrefsWidInt *w = new KPrefsWidInt(item, parent); - addWid(w); - return w; -} - -void KPrefsWidManager::setWidDefaults() -{ - bool tmp = mPrefs->useDefaults(true); - readWidConfig(); - mPrefs->useDefaults(tmp); -} - -void KPrefsWidManager::readWidConfig() -{ - QList::Iterator it; - for (it = mPrefsWids.begin(); it != mPrefsWids.end(); ++it) { - (*it)->readConfig(); - } -} - -void KPrefsWidManager::writeWidConfig() -{ - QList::Iterator it; - for (it = mPrefsWids.begin(); it != mPrefsWids.end(); ++it) { - (*it)->writeConfig(); - } - - mPrefs->save(); -} - -KPrefsDialog::KPrefsDialog(KConfigSkeleton *prefs, QWidget *parent, bool modal) - : KPageDialog(parent) - , KPrefsWidManager(prefs) -{ - setFaceType(List); - setWindowTitle(i18nc("@title:window", "Preferences")); - setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults); - button(QDialogButtonBox::Ok)->setDefault(true); - setModal(modal); - connect(button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &KPrefsDialog::slotOk); - connect(button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &KPrefsDialog::slotApply); - connect(button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &KPrefsDialog::slotDefault); - connect(button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &KPrefsDialog::reject); -} - -KPrefsDialog::~KPrefsDialog() -{ -} - -void KPrefsDialog::autoCreate() -{ - KConfigSkeletonItem::List items = prefs()->items(); - - QMap mGroupPages; - QMap mGroupLayouts; - QMap mCurrentRows; - - KConfigSkeletonItem::List::ConstIterator it; - for (it = items.constBegin(); it != items.constEnd(); ++it) { - QString group = (*it)->group(); - - QWidget *page = nullptr; - QGridLayout *layout = nullptr; - int currentRow; - if (!mGroupPages.contains(group)) { - page = new QWidget(this); - addPage(page, group); - layout = new QGridLayout(page); - mGroupPages.insert(group, page); - mGroupLayouts.insert(group, layout); - currentRow = 0; - mCurrentRows.insert(group, currentRow); - } else { - page = mGroupPages[ group ]; - layout = mGroupLayouts[ group ]; - currentRow = mCurrentRows[ group ]; - } - - KPrefsWid *wid = KPrefsWidFactory::create(*it, page); - - if (wid) { - QList widgets = wid->widgets(); - if (widgets.count() == 1) { - layout->addWidget(widgets[ 0 ], currentRow, currentRow, 0, 1); - } else if (widgets.count() == 2) { - layout->addWidget(widgets[ 0 ], currentRow, 0); - layout->addWidget(widgets[ 1 ], currentRow, 1); - } else { - qCritical() << "More widgets than expected:" << widgets.count(); - } - - if ((*it)->isImmutable()) { - QList::Iterator it2; - for (it2 = widgets.begin(); it2 != widgets.end(); ++it2) { - (*it2)->setEnabled(false); - } - } - addWid(wid); - mCurrentRows.insert(group, ++currentRow); - } - } - - readConfig(); -} - -void KPrefsDialog::setDefaults() -{ - setWidDefaults(); -} - -void KPrefsDialog::readConfig() -{ - readWidConfig(); - usrReadConfig(); -} - -void KPrefsDialog::writeConfig() -{ - writeWidConfig(); - usrWriteConfig(); - readConfig(); -} - -void KPrefsDialog::slotApply() -{ - writeConfig(); - - Q_EMIT configChanged(); -} - -void KPrefsDialog::slotOk() -{ - slotApply(); - accept(); -} - -void KPrefsDialog::slotDefault() -{ - if (KMessageBox::warningContinueCancel( - this, - i18n("You are about to set all preferences to default values. " - "All custom modifications will be lost."), - i18n("Setting Default Preferences"), - KGuiItem(i18n("Reset to Defaults"))) == KMessageBox::Continue) { - setDefaults(); - } -} - -KPrefsModule::KPrefsModule(KConfigSkeleton *prefs, QWidget *parent, const QVariantList &args) - : KCModule(parent, args) - , KPrefsWidManager(prefs) -{ - Q_EMIT changed(false); -} - -void KPrefsModule::addWid(KPrefsWid *wid) -{ - KPrefsWidManager::addWid(wid); - connect(wid, &KPrefsWid::changed, this, &KPrefsModule::slotWidChanged); -} - -void KPrefsModule::slotWidChanged() -{ - Q_EMIT changed(true); -} - -void KPrefsModule::load() -{ - readWidConfig(); - usrReadConfig(); - - Q_EMIT changed(false); -} - -void KPrefsModule::save() -{ - writeWidConfig(); - usrWriteConfig(); -} - -void KPrefsModule::defaults() -{ - setWidDefaults(); - - Q_EMIT changed(true); -} diff --git a/src/libkdepim/prefs/kprefsdialog.h b/src/libkdepim/prefs/kprefsdialog.h deleted file mode 100644 index b266b276a31b35b7fd92736330f00f32a9907a28..0000000000000000000000000000000000000000 --- a/src/libkdepim/prefs/kprefsdialog.h +++ /dev/null @@ -1,813 +0,0 @@ -/* - This file is part of libkdepim. - - Copyright (c) 2001-2003 Cornelius Schumacher - Copyright (C) 2003-2004 Reinhold Kainhofer - Copyright (C) 2005,2008,2011 Allen Winter - - 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -#ifndef KDEPIM_KPREFSDIALOG_H -#define KDEPIM_KPREFSDIALOG_H - -#include "kdepim_export.h" - -#include -#include -#include -#include -#include - -#include - -class KColorButton; -class KComboBox; -class KDateComboBox; -class KTimeComboBox; -class KUrlRequester; - -class QCheckBox; -class QLabel; -class QSpinBox; -class QTimeEdit; -class QButtonGroup; -class QGroupBox; - -namespace KPIM { -/** - @short Base class for GUI control elements used by @ref KPrefsDialog. - @author Cornelius Schumacher - @see KPrefsDialog - - This class provides the interface for the GUI control elements used by - KPrefsDialog. The control element consists of a set of widgets for handling - a certain type of configuration information. -*/ -class KDEPIM_EXPORT KPrefsWid : public QObject -{ - Q_OBJECT -public: - /** - This function is called to read value of the setting from the - stored configuration and display it in the widget. - */ - virtual void readConfig() = 0; - /** - This function is called to write the current setting of the widget to the - stored configuration. - */ - virtual void writeConfig() = 0; - - /** - Return a list of widgets used by this control element. - */ - virtual QList widgets() const; - -Q_SIGNALS: - /** - Emitted when widget value has changed. - */ - void changed(); -}; - -/** - @short Widgets for bool settings in @ref KPrefsDialog. - - This class provides a control element for configuring bool values. It is meant - to be used by KPrefsDialog. The user is responsible for the layout management. -*/ -class KDEPIM_EXPORT KPrefsWidBool : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a bool value control element consisting of a QCheckbox. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent = nullptr); - - /** - Return the QCheckbox used by this control element. - */ - QCheckBox *checkBox(); - - void readConfig() override; - void writeConfig() override; - - QList widgets() const override; - -private: - KConfigSkeleton::ItemBool *mItem = nullptr; - - QCheckBox *mCheck = nullptr; -}; - -/** - @short Widgets for int settings in @ref KPrefsDialog. - - This class provides a control element for configuring integer values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidInt : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a integer value control element consisting of a label and a - spinbox. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent = nullptr); - - /** - Return QLabel used by this control element. - */ - QLabel *label() const; - - /** - Return the QSpinBox used by this control element. - */ - QSpinBox *spinBox(); - - void readConfig() override; - void writeConfig() override; - - QList widgets() const override; - -private: - KConfigSkeleton::ItemInt *mItem = nullptr; - - QLabel *mLabel = nullptr; - QSpinBox *mSpin = nullptr; -}; - -/** - @short Widgets for time settings in @ref KPrefsDialog. - - This class provides a control element for configuring time values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidTime : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a time value control element consisting of a label and a spinbox. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); - - /** - Return QLabel used by this widget. - */ - QLabel *label(); - - /** - Return KTimeComboBox used by this widget. - */ - KTimeComboBox *timeEdit(); - - void readConfig() override; - void writeConfig() override; - -private: - KConfigSkeleton::ItemDateTime *mItem = nullptr; - - QLabel *mLabel = nullptr; - KTimeComboBox *mTimeEdit = nullptr; -}; - -/** - @short Widgets for duration settings in @ref KPrefsDialog. - - This class provides a control element for configuring duration values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidDuration : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a duration value control element consisting of a label and a - spinbox. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param format display format. default is "hh:mm:ss" - @param parent Parent widget. - */ - explicit KPrefsWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent = nullptr); - - /** - Return QLabel used by this widget. - */ - QLabel *label(); - /** - Return QSpinBox used by this widget. - */ - QTimeEdit *timeEdit(); - - void readConfig() override; - void writeConfig() override; - -private: - KConfigSkeleton::ItemDateTime *mItem = nullptr; - - QLabel *mLabel = nullptr; - QTimeEdit *mTimeEdit = nullptr; -}; - -/** - @short Widgets for time settings in @ref KPrefsDialog. - - This class provides a control element for configuring date values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidDate : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a time value control element consisting of a label and a date box. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); - - /** - Return QLabel used by this widget. - */ - QLabel *label(); - - /** - Return KDateComboBox used by this widget. - */ - KDateComboBox *dateEdit(); - - void readConfig() override; - void writeConfig() override; - -private: - KConfigSkeleton::ItemDateTime *mItem = nullptr; - - QLabel *mLabel = nullptr; - KDateComboBox *mDateEdit = nullptr; -}; - -/** - @short Widgets for color settings in @ref KPrefsDialog. - - This class provides a control element for configuring color values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidColor : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a color value control element consisting of a test field and a - button for opening a color dialog. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent = nullptr); - - /** - Destruct color setting widget. - */ - ~KPrefsWidColor() override; - - /** - Return QLabel for the button - */ - QLabel *label(); - /** - Return button opening the color dialog. - */ - KColorButton *button(); - - void readConfig() override; - void writeConfig() override; - -private: - KConfigSkeleton::ItemColor *mItem = nullptr; - - QLabel *mLabel = nullptr; - KColorButton *mButton = nullptr; -}; - -/** - @short Widgets for font settings in @ref KPrefsDialog. - - This class provides a control element for configuring font values. It is meant - to be used by KPrefsDialog. The user is responsible for the layout management. -*/ -class KDEPIM_EXPORT KPrefsWidFont : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a font value control element consisting of a test field and a - button for opening a font dialog. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - @param sampleText Sample text for previewing the selected font. - */ - explicit KPrefsWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent = nullptr, const QString &sampleText = QString()); - /** - Destruct font setting widget. - */ - ~KPrefsWidFont() override; - - /** - Return QLabel. - */ - QLabel *label(); - - /** - Return QFrame used as preview field. - */ - QFrame *preview(); - - /** - Return button opening the font dialog. - */ - QPushButton *button(); - - void readConfig() override; - void writeConfig() override; - -protected Q_SLOTS: - void selectFont(); - -private: - KConfigSkeleton::ItemFont *mItem = nullptr; - - QLabel *mLabel = nullptr; - QLabel *mPreview = nullptr; - QPushButton *mButton = nullptr; -}; - -/** - @short Widgets for settings represented by a group of radio buttons in - @ref KPrefsDialog. - - This class provides a control element for configuring selections. It is meant - to be used by KPrefsDialog. The user is responsible for the layout management. - - The setting is interpreted as an int value, corresponding to the position of - the radio button. The position of the button is defined by the sequence of - @ref addRadio() calls, starting with 0. -*/ -class KDEPIM_EXPORT KPrefsWidRadios : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a control element for selection of an option. It consists of a box - with several radio buttons. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); - ~KPrefsWidRadios() override; - - /** - Add a radio button. - - @param value The enum value represented by this radio button. - @param text Text of the button. - @param toolTip ToolTip help for the button. - @param whatsThis What's This help for the button. - */ - void addRadio(int value, const QString &text, const QString &toolTip = QString(), const QString &whatsThis = QString()); - - /** - Return the box widget used by this widget. - */ - QGroupBox *groupBox() const; - - void readConfig() override; - void writeConfig() override; - - QList widgets() const override; - -private: - KConfigSkeleton::ItemEnum *mItem = nullptr; - - QGroupBox *mBox = nullptr; - QButtonGroup *mGroup = nullptr; -}; - -/** - @short Widgets for settings represented by a combo box in - @ref KPrefsDialog. - - This class provides a control element for configuring selections. It is meant - to be used by KPrefsDialog. The user is responsible for the layout management. - - The setting is interpreted as an int value, corresponding to the index in - the combo box. -*/ -class KDEPIM_EXPORT KPrefsWidCombo : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a control element for selection of an option. It consists of a - combo box. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - explicit KPrefsWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent); - ~KPrefsWidCombo() override; - - void readConfig() override; - void writeConfig() override; - - KComboBox *comboBox(); - - QList widgets() const override; - /** - Return QLabel used by this control element. - */ - QLabel *label() const; - -private: - KConfigSkeleton::ItemEnum *mItem = nullptr; - KComboBox *mCombo = nullptr; - QLabel *mLabel = nullptr; -}; - -/** - @short Widgets for string settings in @ref KPrefsDialog. - - This class provides a control element for configuring string values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidString : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a string value control element consisting of a test label and a - line edit. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - @param echomode Describes how a line edit should display its contents. - */ - explicit KPrefsWidString(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr, KLineEdit::EchoMode echomode = KLineEdit::Normal); - /** - Destructor. - */ - ~KPrefsWidString() override; - - /** - Return QLabel used by this widget. - */ - QLabel *label(); - /** - Return KLineEdit used by this widget. - */ - KLineEdit *lineEdit(); - - void readConfig() override; - void writeConfig() override; - - QList widgets() const override; - -private: - KConfigSkeleton::ItemString *mItem = nullptr; - - QLabel *mLabel = nullptr; - KLineEdit *mEdit = nullptr; -}; - -/** - @short Widgets for string settings in @ref KPrefsDialog. - - This class provides a control element for configuring string values. It is - meant to be used by KPrefsDialog. The user is responsible for the layout - management. -*/ -class KDEPIM_EXPORT KPrefsWidPath : public KPrefsWid -{ - Q_OBJECT -public: - /** - Create a string value control element consisting of a test label and a - line edit. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - @param filter URLRequester filter - @param mode Describes how a line edit should display its contents. - */ - explicit KPrefsWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent = nullptr, const QString &filter = QString(), KFile::Modes = KFile::File); - - /** - Destructor. - */ - ~KPrefsWidPath() override; - - /** - Return QLabel used by this widget. - */ - QLabel *label(); - - /** - Return KUrlRequester used by this widget. - */ - KUrlRequester *urlRequester(); - - void readConfig() override; - void writeConfig() override; - - QList widgets() const override; - -private: - KConfigSkeleton::ItemPath *mItem = nullptr; - - QLabel *mLabel = nullptr; - KUrlRequester *mURLRequester = nullptr; -}; - -/** - @short Class for managing KPrefsWid objects. - - This class manages standard configuration widgets provided bz the KPrefsWid - subclasses. It handles creation, loading, saving and default values in a - transparent way. The user has to add the widgets by the corresponding addWid - functions and KPrefsWidManager handles the rest automatically. -*/ -class KDEPIM_EXPORT KPrefsWidManager -{ -public: - /** - Create a KPrefsWidManager object for a KPrefs object. - - @param prefs KPrefs object used to access te configuration. - */ - explicit KPrefsWidManager(KConfigSkeleton *prefs); - - /** - Destructor. - */ - virtual ~KPrefsWidManager(); - - KConfigSkeleton *prefs() const - { - return mPrefs; - } - - /** - Register a custom KPrefsWid object. - */ - virtual void addWid(KPrefsWid *); - - /** - Register a @ref KPrefsWidBool object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidBool *addWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidInt object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidInt *addWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidDate object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidDate *addWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidTime object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidTime *addWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidDuration object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param format display format. default is "hh:mm:ss" - @param parent Parent widget. - */ - KPrefsWidDuration *addWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidColor object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidColor *addWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidRadios object. The choices represented by the - given item object are automatically added as radio buttons. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidRadios *addWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidCombo object. The choices represented by the - given item object are automatically added to the combo box. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidCombo *addWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidString object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidString *addWidString(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr); - - /** - Register a path @ref KPrefsWidPath object. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - @param filter URLRequester filter - @param mode URLRequester mode - */ - KPrefsWidPath *addWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent = nullptr, const QString &filter = QString(), KFile::Modes mode = KFile::File); - - /** - Register a password @ref KPrefsWidString object, with echomode set to KLineEdit::Password. - - @param item The KConfigSkeletonItem representing the preferences entry. - @param parent Parent widget. - */ - KPrefsWidString *addWidPassword(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr); - - /** - Register a @ref KPrefsWidFont object. - - @param item The KConfigSkeletonItem representing the preferences - entry. - @param parent Parent widget. - @param sampleText Sample text for previewing the selected font. - */ - KPrefsWidFont *addWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent = nullptr, const QString &sampleText = QString()); - - /** Set all widgets to default values. */ - void setWidDefaults(); - - /** Read preferences from config file. */ - void readWidConfig(); - - /** Write preferences to config file. */ - void writeWidConfig(); - -private: - KConfigSkeleton *mPrefs = nullptr; - - QList mPrefsWids; -}; - -/** - @short Base class for a preferences dialog. - - 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 KPrefsWid via - KPrefsWidManager. 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 KDEPIM_EXPORT KPrefsDialog : public KPageDialog, public KPrefsWidManager -{ - 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. - */ - explicit KPrefsDialog(KConfigSkeleton *prefs, QWidget *parent = nullptr, bool modal = false); - - /** - Destructor. - */ - virtual ~KPrefsDialog(); - - void autoCreate(); - -public Q_SLOTS: - /** Set all widgets to default values. */ - void setDefaults(); - - /** Read preferences from config file. */ - void readConfig(); - - /** Write preferences to config file. */ - void writeConfig(); - -Q_SIGNALS: - /** Emitted when the a changed configuration has been stored. */ - void configChanged(); - -protected Q_SLOTS: - /** Apply changes to preferences */ - void slotApply(); - - /** 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() - { - } -}; - -class KDEPIM_EXPORT KPrefsModule : public KCModule, public KPrefsWidManager -{ - Q_OBJECT -public: - KPrefsModule(KConfigSkeleton *, QWidget *parent = nullptr, const QVariantList &args = QVariantList()); - - void addWid(KPrefsWid *) override; - - void load() override; - void save() override; - void defaults() override; - -public Q_SLOTS: - void slotWidChanged(); - -protected: - /** Implement this to read custom configuration widgets. */ - virtual void usrReadConfig() - { - } - - /** Implement this to write custom configuration widgets. */ - virtual void usrWriteConfig() - { - } -}; -} - -#endif