1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "kcmdolphingeneral.h"
22 #include "settings/general/behaviorsettingspage.h"
23 #include "settings/general/previewssettingspage.h"
24 #include "settings/general/confirmationssettingspage.h"
26 #include <KLocalizedString>
27 #include <KPluginFactory>
28 #include <KPluginLoader>
29 #include <kconfigwidgets_version.h>
32 #include <QVBoxLayout>
34 K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory
, registerPlugin
<DolphinGeneralConfigModule
>(QStringLiteral("dolphingeneral"));)
36 DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget
* parent
, const QVariantList
& args
) :
42 setButtons(KCModule::Default
| KCModule::Help
);
44 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
45 topLayout
->setContentsMargins(0, 0, 0, 0);
47 QTabWidget
* tabWidget
= new QTabWidget(this);
49 // initialize 'Behavior' tab
50 BehaviorSettingsPage
* behaviorPage
= new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget
);
51 tabWidget
->addTab(behaviorPage
, i18nc("@title:tab Behavior settings", "Behavior"));
52 #if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
53 connect(behaviorPage
, &BehaviorSettingsPage::changed
, this, QOverload
<>::of(&DolphinGeneralConfigModule::changed
));
55 connect(behaviorPage
, &BehaviorSettingsPage::changed
, this, &DolphinGeneralConfigModule::markAsChanged
);
58 // initialize 'Previews' tab
59 PreviewsSettingsPage
* previewsPage
= new PreviewsSettingsPage(tabWidget
);
60 tabWidget
->addTab(previewsPage
, i18nc("@title:tab Previews settings", "Previews"));
61 #if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
62 connect(previewsPage
, &PreviewsSettingsPage::changed
, this, QOverload
<>::of(&DolphinGeneralConfigModule::changed
));
64 connect(previewsPage
, &PreviewsSettingsPage::changed
, this, &DolphinGeneralConfigModule::markAsChanged
);
67 // initialize 'Confirmations' tab
68 ConfirmationsSettingsPage
* confirmationsPage
= new ConfirmationsSettingsPage(tabWidget
);
69 tabWidget
->addTab(confirmationsPage
, i18nc("@title:tab Confirmations settings", "Confirmations"));
70 #if KCONFIGWIDGETS_VERSION < QT_VERSION_CHECK(5, 64, 0)
71 connect(confirmationsPage
, &ConfirmationsSettingsPage::changed
, this, QOverload
<>::of(&DolphinGeneralConfigModule::changed
));
73 connect(confirmationsPage
, &ConfirmationsSettingsPage::changed
, this, &DolphinGeneralConfigModule::markAsChanged
);
75 m_pages
.append(behaviorPage
);
76 m_pages
.append(previewsPage
);
77 m_pages
.append(confirmationsPage
);
79 topLayout
->addWidget(tabWidget
, 0, {});
82 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
86 void DolphinGeneralConfigModule::save()
88 foreach (SettingsPageBase
* page
, m_pages
) {
89 page
->applySettings();
93 void DolphinGeneralConfigModule::defaults()
95 foreach (SettingsPageBase
* page
, m_pages
) {
96 page
->applySettings();
100 #include "kcmdolphingeneral.moc"