]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/settings/kcm/kcmdolphingeneral.cpp
Port to Qt6
[dolphin.git] / src / settings / kcm / kcmdolphingeneral.cpp
index 26cb580f026e5a51ef17b0a2ec863b7c32bab0e6..417979d234d868c8e8f476dbbb1d402957130ae9 100644 (file)
@@ -1,76 +1,55 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "kcmdolphingeneral.h"
 
-#include <KTabWidget>
-#include <KDialog>
-#include <KLocale>
-#include <KPluginFactory>
-#include <KPluginLoader>
+#include "settings/general/behaviorsettingspage.h"
+#include "settings/general/confirmationssettingspage.h"
+#include "settings/general/previewssettingspage.h"
 
-#include <settings/general/behaviorsettingspage.h>
-#include <settings/general/previewssettingspage.h>
-#include <settings/general/confirmationssettingspage.h>
+#include <KLocalizedString>
+#include <KPluginFactory>
+#include <kconfigwidgets_version.h>
 
-#include <QDir>
+#include <QTabWidget>
 #include <QVBoxLayout>
 
-K_PLUGIN_FACTORY(KCMDolphinGeneralConfigFactory, registerPlugin<DolphinGeneralConfigModule>("dolphingeneral");)
-K_EXPORT_PLUGIN(KCMDolphinGeneralConfigFactory("kcmdolphingeneral"))
+K_PLUGIN_CLASS_WITH_JSON(DolphinGeneralConfigModule, "kcmdolphingeneral.json")
 
-DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args) :
-    KCModule(KCMDolphinGeneralConfigFactory::componentData(), parent),
-    m_pages()
+DolphinGeneralConfigModule::DolphinGeneralConfigModule(QObject *parent, const KPluginMetaData &data)
+    : KCModule(qobject_cast<QWidget *>(parent), data)
+    m_pages()
 {
-    Q_UNUSED(args);
-
-    KGlobal::locale()->insertCatalog("dolphin");
+    setButtons(KCModule::Default | KCModule::Help | KCModule::Apply);
 
-    setButtons(KCModule::Default | KCModule::Help);
+    const auto parentWidget = qobject_cast<QWidget *>(parent);
+    QVBoxLayout *topLayout = new QVBoxLayout(parentWidget);
+    topLayout->setContentsMargins(0, 0, 0, 0);
 
-    QVBoxLayout* topLayout = new QVBoxLayout(this);
-    topLayout->setMargin(0);
-    topLayout->setSpacing(KDialog::spacingHint());
-
-    KTabWidget* tabWidget = new KTabWidget(this);
+    QTabWidget *tabWidget = new QTabWidget(parentWidget);
 
     // initialize 'Behavior' tab
-    BehaviorSettingsPage* behaviorPage = new BehaviorSettingsPage(QDir::homePath(), tabWidget);
+    BehaviorSettingsPage *behaviorPage = new BehaviorSettingsPage(QUrl::fromLocalFile(QDir::homePath()), tabWidget);
     tabWidget->addTab(behaviorPage, i18nc("@title:tab Behavior settings", "Behavior"));
-    connect(behaviorPage, SIGNAL(changed()), this, SLOT(changed()));
+    connect(behaviorPage, &BehaviorSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
 
     // initialize 'Previews' tab
-    PreviewsSettingsPagepreviewsPage = new PreviewsSettingsPage(tabWidget);
+    PreviewsSettingsPage *previewsPage = new PreviewsSettingsPage(tabWidget);
     tabWidget->addTab(previewsPage, i18nc("@title:tab Previews settings", "Previews"));
-    connect(previewsPage, SIGNAL(changed()), this, SLOT(changed()));
+    connect(previewsPage, &PreviewsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
 
     // initialize 'Confirmations' tab
-    ConfirmationsSettingsPage* confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
-    tabWidget->addTab(confirmationsPage,  i18nc("@title:tab Confirmations settings", "Confirmations"));
-    connect(confirmationsPage, SIGNAL(changed()), this, SLOT(changed()));
-
+    ConfirmationsSettingsPage *confirmationsPage = new ConfirmationsSettingsPage(tabWidget);
+    tabWidget->addTab(confirmationsPage, i18nc("@title:tab Confirmations settings", "Confirmations"));
+    connect(confirmationsPage, &ConfirmationsSettingsPage::changed, this, &DolphinGeneralConfigModule::markAsChanged);
     m_pages.append(behaviorPage);
     m_pages.append(previewsPage);
     m_pages.append(confirmationsPage);
 
-    topLayout->addWidget(tabWidget, 0, 0);
+    topLayout->addWidget(tabWidget, 0, {});
 }
 
 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
@@ -79,14 +58,14 @@ DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
 
 void DolphinGeneralConfigModule::save()
 {
-    foreach (SettingsPageBase* page, m_pages) {
+    for (SettingsPageBase *page : qAsConst(m_pages)) {
         page->applySettings();
     }
 }
 
 void DolphinGeneralConfigModule::defaults()
 {
-    foreach (SettingsPageBase* page, m_pages) {
+    for (SettingsPageBase *page : qAsConst(m_pages)) {
         page->applySettings();
     }
 }