Commit fd827e41 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Dolphin: Cleanup kcms

Summary: Refactor forearch, adjust formatting, remove unnecessary version checks.

Test Plan: Compiles

Reviewers: #dolphin, ngraham, elvisangelaccio, meven

Reviewed By: #dolphin, ngraham

Subscribers: kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D29377
parent ddcca5fb
......@@ -33,12 +33,10 @@
K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory, registerPlugin<DolphinGeneralConfigModule>(QStringLiteral("dolphingeneral"));)
DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args) :
KCModule(parent),
DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget *parent, const QVariantList &args) :
KCModule(parent, args),
m_pages()
{
Q_UNUSED(args)
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
......@@ -49,29 +47,17 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QV
// initialize 'Behavior' tab
BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget);
tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
connect(behaviorPage, &BehaviorSettingsPage::changed, this, QOverload<>::of(&DolphinGeneralConfigModule::changed));
#else
connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
#endif
// initialize 'Previews' tab
PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
connect(previewsPage, &PreviewsSettingsPage::changed, this, QOverload<>::of(&DolphinGeneralConfigModule::changed));
#else
connect(previewsPage, &PreviewsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
#endif
// initialize 'Confirmations' tab
ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, QOverload<>::of(&DolphinGeneralConfigModule::changed));
#else
connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
#endif
m_pages.append(behaviorPage);
m_pages.append(previewsPage);
m_pages.append(confirmationsPage);
......@@ -85,14 +71,14 @@ DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
void DolphinGeneralConfigModule::save()
{
foreach (SettingsPageBase* page, m_pages) {
for (SettingsPageBase* page : qAsConst(m_pages)) {
page->applySettings();
}
}
void DolphinGeneralConfigModule::defaults()
{
foreach (SettingsPageBase* page, m_pages) {
for (SettingsPageBase* page : qAsConst(m_pages)) {
page->applySettings();
}
}
......
......@@ -34,7 +34,7 @@ class DolphinGeneralConfigModule : public KCModule
Q_OBJECT
public:
DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args);
DolphinGeneralConfigModule(QWidget *parent, const QVariantList &args);
~DolphinGeneralConfigModule() override;
void save() override;
......
......@@ -29,23 +29,17 @@
K_PLUGIN_FACTORY(KCMDolphinNavigationConfigFactory, registerPlugin<DolphinNavigationConfigModule>(QStringLiteral("dolphinnavigation"));)
DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args) :
KCModule(parent),
DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args) :
KCModule(parent, args),
m_navigation(nullptr)
{
Q_UNUSED(args)
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
m_navigation = new NavigationSettingsPage(this);
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
connect(m_navigation, &NavigationSettingsPage::changed, this, QOverload<>::of(&DolphinNavigationConfigModule::changed));
#else
connect(m_navigation, &NavigationSettingsPage::changed, this, &DolphinNavigationConfigModule::markAsChanged);
#endif
topLayout->addWidget(m_navigation, 0, {});
}
......
......@@ -32,14 +32,14 @@ class DolphinNavigationConfigModule : public KCModule
Q_OBJECT
public:
DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args);
DolphinNavigationConfigModule(QWidget *parent, const QVariantList &args);
~DolphinNavigationConfigModule() override;
void save() override;
void defaults() override;
private:
NavigationSettingsPage* m_navigation;
NavigationSettingsPage *m_navigation;
};
#endif
......@@ -30,22 +30,16 @@
K_PLUGIN_FACTORY(KCMDolphinServicesConfigFactory, registerPlugin<DolphinServicesConfigModule>(QStringLiteral("dolphinservices"));)
DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const QVariantList& args) :
KCModule(parent),
KCModule(parent, args),
m_services(nullptr)
{
Q_UNUSED(args)
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setContentsMargins(0, 0, 0, 0);
m_services = new ServicesSettingsPage(this);
#if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
connect(m_services, &ServicesSettingsPage::changed, this, QOverload<>::of(&DolphinServicesConfigModule::changed));
#else
connect(m_services, &ServicesSettingsPage::changed, this, &DolphinServicesConfigModule::markAsChanged);
#endif
topLayout->addWidget(m_services, 0, {});
}
......
......@@ -39,7 +39,7 @@ public:
void defaults() override;
private:
ServicesSettingsPage* m_services;
ServicesSettingsPage *m_services;
};
#endif
......@@ -33,12 +33,10 @@
K_PLUGIN_FACTORY(KCMDolphinViewModesConfigFactory, registerPlugin<DolphinViewModesConfigModule>(QStringLiteral("dolphinviewmodes"));)
DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args) :
KCModule(parent),
DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget *parent, const QVariantList &args) :
KCModule(parent, args),
m_tabs()
{
Q_UNUSED(args)
setButtons(KCModule::Default | KCModule::Help);
QVBoxLayout* topLayout = new QVBoxLayout(this);
......@@ -74,7 +72,7 @@ DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
void DolphinViewModesConfigModule::save()
{
foreach (ViewSettingsTab* tab, m_tabs) {
for (ViewSettingsTab *tab : qAsConst(m_tabs)) {
tab->applySettings();
}
reparseConfiguration();
......@@ -82,7 +80,7 @@ void DolphinViewModesConfigModule::save()
void DolphinViewModesConfigModule::defaults()
{
foreach (ViewSettingsTab* tab, m_tabs) {
for (ViewSettingsTab *tab : qAsConst(m_tabs)) {
tab->restoreDefaultSettings();
}
reparseConfiguration();
......@@ -90,13 +88,15 @@ void DolphinViewModesConfigModule::defaults()
void DolphinViewModesConfigModule::reparseConfiguration()
{
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KonqMain"), QStringLiteral("org.kde.Konqueror.Main"), QStringLiteral("reparseConfiguration"));
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KonqMain"),
QStringLiteral("org.kde.Konqueror.Main"),
QStringLiteral("reparseConfiguration"));
QDBusConnection::sessionBus().send(message);
}
void DolphinViewModesConfigModule::viewModeChanged()
{
emit changed(true);
emit markAsChanged();
}
#include "kcmdolphinviewmodes.moc"
......@@ -32,7 +32,7 @@ class DolphinViewModesConfigModule : public KCModule
Q_OBJECT
public:
DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args);
DolphinViewModesConfigModule(QWidget *parent, const QVariantList &args);
~DolphinViewModesConfigModule() override;
void save() override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment