]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphingeneral.cpp
a82cb3858c409609fedb07b468ed34a7a427d39e
[dolphin.git] / src / settings / kcm / kcmdolphingeneral.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com> *
3 * *
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. *
8 * *
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. *
13 * *
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 ***************************************************************************/
19
20 #include "kcmdolphingeneral.h"
21
22 #include "settings/general/behaviorsettingspage.h"
23 #include "settings/general/previewssettingspage.h"
24 #include "settings/general/confirmationssettingspage.h"
25
26 #include <KLocalizedString>
27 #include <KPluginFactory>
28 #include <KPluginLoader>
29 #include <kconfigwidgets_version.h>
30
31 #include <QTabWidget>
32 #include <QVBoxLayout>
33
34 K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory, registerPlugin<DolphinGeneralConfigModule>(QStringLiteral("dolphingeneral"));)
35
36 DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args) :
37 KCModule(parent),
38 m_pages()
39 {
40 Q_UNUSED(args)
41
42 setButtons(KCModule::Default | KCModule::Help);
43
44 QVBoxLayout* topLayout = new QVBoxLayout(this);
45 topLayout->setContentsMargins(0, 0, 0, 0);
46
47 QTabWidget* tabWidget = new QTabWidget(this);
48
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));
54 #else
55 connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
56 #endif
57
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));
63 #else
64 connect(previewsPage, &PreviewsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
65 #endif
66
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));
72 #else
73 connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
74 #endif
75 m_pages.append(behaviorPage);
76 m_pages.append(previewsPage);
77 m_pages.append(confirmationsPage);
78
79 topLayout->addWidget(tabWidget, 0, {});
80 }
81
82 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
83 {
84 }
85
86 void DolphinGeneralConfigModule::save()
87 {
88 foreach (SettingsPageBase* page, m_pages) {
89 page->applySettings();
90 }
91 }
92
93 void DolphinGeneralConfigModule::defaults()
94 {
95 foreach (SettingsPageBase* page, m_pages) {
96 page->applySettings();
97 }
98 }
99
100 #include "kcmdolphingeneral.moc"