Commit b2318036 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove kprefsdialog

parent 7c8da268
Pipeline #27382 passed with stage
in 12 minutes and 41 seconds
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.15.40")
set(PIM_VERSION "5.15.41")
project(libkdepim VERSION ${PIM_VERSION})
......
......@@ -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
......
/*
This file is part of libkdepim.
Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
Copyright (C) 2005,2008,2011 Allen Winter <winter@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., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
//krazy:excludeall=tipsandthis
#include "kprefsdialog.h"
#include <KColorButton>
#include <KComboBox>
#include <KConfigSkeleton>
#include <KDateComboBox>
#include "libkdepim_debug.h"
#include <QFontDialog>
#include <KLineEdit>
#include <KLocalizedString>
#include <KMessageBox>
#include <KTimeComboBox>
#include <KUrlRequester>
#include <QUrl>
#include <QFont>
#include <QFrame>
#include <QCheckBox>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QTimeEdit>
#include <QButtonGroup>
#include <QGroupBox>
using namespace KPIM;
namespace KPrefsWidFactory {
KPrefsWid *create(KConfigSkeletonItem *item, QWidget *parent)
{
KConfigSkeleton::ItemBool *boolItem
= dynamic_cast<KConfigSkeleton::ItemBool *>(item);
if (boolItem) {
return new KPrefsWidBool(boolItem, parent);
}
KConfigSkeleton::ItemString *stringItem
= dynamic_cast<KConfigSkeleton::ItemString *>(item);
if (stringItem) {
return new KPrefsWidString(stringItem, parent);
}
KConfigSkeleton::ItemEnum *enumItem
= dynamic_cast<KConfigSkeleton::ItemEnum *>(item);
if (enumItem) {
QList<KConfigSkeleton::ItemEnum::Choice> choices = enumItem->choices();
if (choices.isEmpty()) {
qCritical() << "Enum has no choices.";
return nullptr;
} else {
KPrefsWidRadios *radios = new KPrefsWidRadios(enumItem, parent);
QList<KConfigSkeleton::ItemEnum::Choice>::ConstIterator it;
int value = 0;
QList<KConfigSkeleton::ItemEnum::Choice>::ConstIterator end(choices.constEnd());
for (it = choices.constBegin(); it != end; ++it) {
radios->addRadio(value++, (*it).label);
}
return radios;
}
}
KConfigSkeleton::ItemInt *intItem = dynamic_cast<KConfigSkeleton::ItemInt *>(item);
if (intItem) {
return new KPrefsWidInt(intItem, parent);
}
return nullptr;
}
} // namespace KPrefsWidFactory
QList<QWidget *> KPrefsWid::widgets() const
{
return QList<QWidget *>();
}
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<QWidget *> KPrefsWidBool::widgets() const
{
QList<QWidget *> 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<int>(&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<QWidget *> KPrefsWidInt::widgets() const
{
QList<QWidget *> 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<int>(&QButtonGroup::buttonClicked), this, &KPrefsWidRadios::changed);
#else
connect(mGroup, qOverload<QAbstractButton *>(&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<QWidget *> KPrefsWidRadios::widgets() const
{
QList<QWidget *> 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<int>(&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<QWidget *> KPrefsWidCombo::widgets() const
{
QList<QWidget *> 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()
{