]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphingeneral.cpp
Merge remote-tracking branch 'origin/master' into frameworks
[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 <KTabWidget>
23 #include <KDialog>
24 #include <KLocale>
25 #include <KPluginFactory>
26 #include <KPluginLoader>
27 #include <KGlobal>
28
29 #include <settings/general/behaviorsettingspage.h>
30 #include <settings/general/previewssettingspage.h>
31 #include <settings/general/confirmationssettingspage.h>
32
33 #include <QDir>
34 #include <QVBoxLayout>
35
36 K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory, registerPlugin<DolphinGeneralConfigModule>("dolphingeneral");)
37 K_EXPORT_PLUGIN(KCMDolphinGeneralConfigFactory("kcmdolphingeneral"))
38
39 DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args) :
40 KCModule(parent),
41 m_pages()
42 {
43 Q_UNUSED(args);
44
45 KGlobal::locale()->insertCatalog("dolphin");
46
47 setButtons(KCModule::Default | KCModule::Help);
48
49 QVBoxLayout* topLayout = new QVBoxLayout(this);
50 topLayout->setMargin(0);
51 topLayout->setSpacing(KDialog::spacingHint());
52
53 KTabWidget* tabWidget = new KTabWidget(this);
54
55 // initialize 'Behavior' tab
56 BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QDir::homePath(), tabWidget);
57 tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
58 connect(behaviorPage, &BehaviorSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
59
60 // initialize 'Previews' tab
61 PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
62 tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
63 connect(previewsPage, &PreviewsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
64
65 // initialize 'Confirmations' tab
66 ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
67 tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
68 connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
69
70 m_pages.append(behaviorPage);
71 m_pages.append(previewsPage);
72 m_pages.append(confirmationsPage);
73
74 topLayout->addWidget(tabWidget, 0, 0);
75 }
76
77 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
78 {
79 }
80
81 void DolphinGeneralConfigModule::save()
82 {
83 foreach (SettingsPageBase* page, m_pages) {
84 page->applySettings();
85 }
86 }
87
88 void DolphinGeneralConfigModule::defaults()
89 {
90 foreach (SettingsPageBase* page, m_pages) {
91 page->applySettings();
92 }
93 }
94
95 #include "kcmdolphingeneral.moc"