]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphingeneral.cpp
39eccff76fab0ab3df20bef6b0293c2978160afc
[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, args),
38 m_pages()
39 {
40 setButtons(KCModule::Default | KCModule::Help);
41
42 QVBoxLayout* topLayout = new QVBoxLayout(this);
43 topLayout->setContentsMargins(0, 0, 0, 0);
44
45 QTabWidget* tabWidget = new QTabWidget(this);
46
47 // initialize 'Behavior' tab
48 BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget);
49 tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
50 connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
51
52 // initialize 'Previews' tab
53 PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
54 tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
55 connect(previewsPage, &PreviewsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
56
57 // initialize 'Confirmations' tab
58 ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
59 tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
60 connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
61 m_pages.append(behaviorPage);
62 m_pages.append(previewsPage);
63 m_pages.append(confirmationsPage);
64
65 topLayout->addWidget(tabWidget, 0, {});
66 }
67
68 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
69 {
70 }
71
72 void DolphinGeneralConfigModule::save()
73 {
74 for (SettingsPageBase* page : qAsConst(m_pages)) {
75 page->applySettings();
76 }
77 }
78
79 void DolphinGeneralConfigModule::defaults()
80 {
81 for (SettingsPageBase* page : qAsConst(m_pages)) {
82 page->applySettings();
83 }
84 }
85
86 #include "kcmdolphingeneral.moc"