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