]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphingeneral.cpp
port to QPushButton
[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 <KLocalizedString>
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 //KF5 port: remove this line and define TRANSLATION_DOMAIN in CMakeLists.txt instead
46 //KLocale::global()->insertCatalog("dolphin");
47
48 setButtons(KCModule::Default | KCModule::Help);
49
50 QVBoxLayout* topLayout = new QVBoxLayout(this);
51 topLayout->setMargin(0);
52 topLayout->setSpacing(KDialog::spacingHint());
53
54 KTabWidget* tabWidget = new KTabWidget(this);
55
56 // initialize 'Behavior' tab
57 BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QDir::homePath(), tabWidget);
58 tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
59 connect(behaviorPage, &BehaviorSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
60
61 // initialize 'Previews' tab
62 PreviewsSettingsPage* previewsPage = new PreviewsSettingsPage(tabWidget);
63 tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
64 connect(previewsPage, &PreviewsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
65
66 // initialize 'Confirmations' tab
67 ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
68 tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
69 connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, static_cast<void(DolphinGeneralConfigModule::*)()>(&DolphinGeneralConfigModule::changed));
70
71 m_pages.append(behaviorPage);
72 m_pages.append(previewsPage);
73 m_pages.append(confirmationsPage);
74
75 topLayout->addWidget(tabWidget, 0, 0);
76 }
77
78 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
79 {
80 }
81
82 void DolphinGeneralConfigModule::save()
83 {
84 foreach (SettingsPageBase* page, m_pages) {
85 page->applySettings();
86 }
87 }
88
89 void DolphinGeneralConfigModule::defaults()
90 {
91 foreach (SettingsPageBase* page, m_pages) {
92 page->applySettings();
93 }
94 }
95
96 #include "kcmdolphingeneral.moc"