]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/kcm/kcmdolphingeneral.cpp
Port to Qt6
[dolphin.git] / src / settings / kcm / kcmdolphingeneral.cpp
1 /*
2 * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "kcmdolphingeneral.h"
8
9 #include "settings/general/behaviorsettingspage.h"
10 #include "settings/general/confirmationssettingspage.h"
11 #include "settings/general/previewssettingspage.h"
12
13 #include <KLocalizedString>
14 #include <KPluginFactory>
15 #include <kconfigwidgets_version.h>
16
17 #include <QTabWidget>
18 #include <QVBoxLayout>
19
20 K_PLUGIN_CLASS_WITH_JSON(DolphinGeneralConfigModule, "kcmdolphingeneral.json")
21
22 DolphinGeneralConfigModule::DolphinGeneralConfigModule(QObject *parent, const KPluginMetaData &data)
23 : KCModule(qobject_cast<QWidget *>(parent), data)
24 , m_pages()
25 {
26 setButtons(KCModule::Default | KCModule::Help | KCModule::Apply);
27
28 const auto parentWidget = qobject_cast<QWidget *>(parent);
29 QVBoxLayout *topLayout = new QVBoxLayout(parentWidget);
30 topLayout->setContentsMargins(0, 0, 0, 0);
31
32 QTabWidget *tabWidget = new QTabWidget(parentWidget);
33
34 // initialize 'Behavior' tab
35 BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget);
36 tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
37 connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
38
39 // initialize 'Previews' tab
40 PreviewsSettingsPage *previewsPage = new PreviewsSettingsPage(tabWidget);
41 tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
42 connect(previewsPage, &PreviewsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
43
44 // initialize 'Confirmations' tab
45 ConfirmationsSettingsPage *confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
46 tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
47 connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
48 m_pages.append(behaviorPage);
49 m_pages.append(previewsPage);
50 m_pages.append(confirmationsPage);
51
52 topLayout->addWidget(tabWidget, 0, {});
53 }
54
55 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
56 {
57 }
58
59 void DolphinGeneralConfigModule::save()
60 {
61 for (SettingsPageBase *page : qAsConst(m_pages)) {
62 page->applySettings();
63 }
64 }
65
66 void DolphinGeneralConfigModule::defaults()
67 {
68 for (SettingsPageBase *page : qAsConst(m_pages)) {
69 page->applySettings();
70 }
71 }
72
73 #include "kcmdolphingeneral.moc"