diff --git a/interfaces/configpage.cpp b/interfaces/configpage.cpp index f94f0a4dc7..30f1ed0de0 100644 --- a/interfaces/configpage.cpp +++ b/interfaces/configpage.cpp @@ -1,154 +1,154 @@ /* * This file is part of KDevelop * Copyright 2014 Alex Richardson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "configpage.h" #include #include #include using namespace KDevelop; ConfigPage::ConfigPage(KCoreConfigSkeleton* config, QWidget* parent) : KTextEditor::ConfigPage(parent), m_configSkeleton(config) { if (m_configSkeleton) { m_configManager.reset(new KConfigDialogManager(parent, m_configSkeleton)); connect(m_configManager.data(), &KConfigDialogManager::widgetModified, this, &ConfigPage::changed); // m_configManager->addWidget(this) must be called from the config dialog, // since the widget tree is not complete yet when calling this constructor } } ConfigPage::~ConfigPage() { } void ConfigPage::apply() { Q_ASSERT(m_configManager); // if null, this method must be overriden m_configManager->updateSettings(); m_configManager->updateWidgets(); } void ConfigPage::defaults() { Q_ASSERT(m_configManager); // if null, this method must be overriden m_configManager->updateWidgetsDefault(); } void ConfigPage::reset() { Q_ASSERT(m_configManager); // if null, this method must be overriden m_configManager->updateWidgets(); } void ConfigPage::initConfigManager() { if (m_configManager) { m_configManager->addWidget(this); m_configManager->updateWidgets(); } } QList ConfigPage::childPages() { return {}; } -KTextEditorConfigPageWrapper::KTextEditorConfigPageWrapper(KTextEditor::ConfigPage* page, QWidget* parent) +KTextEditorConfigPageAdapter::KTextEditorConfigPageAdapter(KTextEditor::ConfigPage* page, QWidget* parent) : ConfigPage(nullptr, parent), m_page(page) { page->setParent(this); QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(page); this->setLayout(layout); } -KTextEditorConfigPageWrapper::~KTextEditorConfigPageWrapper() +KTextEditorConfigPageAdapter::~KTextEditorConfigPageAdapter() { } -void KTextEditorConfigPageWrapper::apply() +void KTextEditorConfigPageAdapter::apply() { m_page->apply(); } -void KTextEditorConfigPageWrapper::defaults() +void KTextEditorConfigPageAdapter::defaults() { m_page->defaults(); } -void KTextEditorConfigPageWrapper::reset() +void KTextEditorConfigPageAdapter::reset() { m_page->reset(); } -QString KTextEditorConfigPageWrapper::fullName() const +QString KTextEditorConfigPageAdapter::fullName() const { return m_page->fullName(); } -QIcon KTextEditorConfigPageWrapper::icon() const +QIcon KTextEditorConfigPageAdapter::icon() const { return m_page->icon(); } -QString KTextEditorConfigPageWrapper::name() const +QString KTextEditorConfigPageAdapter::name() const { return m_page->name(); } EditorConfigPage::EditorConfigPage(QWidget* parent) : ConfigPage(nullptr, parent) { qDebug("Editor config page created"); setObjectName("editorconfig"); } EditorConfigPage::~EditorConfigPage() { qDebug("Editor config page deleted"); } QString EditorConfigPage::name() const { return i18n("Editor"); } QIcon EditorConfigPage::icon() const { return QIcon::fromTheme(QStringLiteral("accessories-text-editor")); } QString EditorConfigPage::fullName() const { return i18n("Configure Text editor"); } QList EditorConfigPage::childPages() { QList ret; auto editor = KTextEditor::Editor::instance(); for (int i = 0; i < editor->configPages(); ++i) { - ret.append(new KTextEditorConfigPageWrapper(editor->configPage(i, this), this)); + ret.append(new KTextEditorConfigPageAdapter(editor->configPage(i, this), this)); } return ret; }; diff --git a/interfaces/configpage.h b/interfaces/configpage.h index 8e459a6aca..068f6db2a1 100644 --- a/interfaces/configpage.h +++ b/interfaces/configpage.h @@ -1,115 +1,115 @@ /* * This file is part of KDevelop * Copyright 2014 Alex Richardson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KDEVELOP_CONFIGPAGE_H #define KDEVELOP_CONFIGPAGE_H #include #include #include #include #include "interfacesexport.h" namespace KDevelop { class KDEVPLATFORMINTERFACES_EXPORT ConfigPage : public KTextEditor::ConfigPage { Q_OBJECT public: /** * Create a new config page * @param config the config skeleton that is used to store the preferences. If you don't use * a K(Core)ConfigSkeleton to save the settings you can also pass null here. * However this means that you will have to manually implement the apply(), defaults() and reset() slots */ explicit ConfigPage(KCoreConfigSkeleton* config = nullptr, QWidget* parent = nullptr); virtual ~ConfigPage(); /** * Get any subpages of the current page. * @return By default returns an empty list */ virtual QList childPages(); public Q_SLOTS: virtual void apply() override; virtual void defaults() override; virtual void reset() override; public: /** * Initializes the KConfigDialogManager. * Must be called explicitly since not all child widgets are available at the end of the constructor. * This is handled automatically by KDevelop::ConfigDialog, subclasses don't need to call this. */ void initConfigManager(); KCoreConfigSkeleton* configSkeleton() { return m_configSkeleton; } private: QScopedPointer m_configManager; KCoreConfigSkeleton* m_configSkeleton; }; -class KDEVPLATFORMINTERFACES_EXPORT KTextEditorConfigPageWrapper : public ConfigPage +class KDEVPLATFORMINTERFACES_EXPORT KTextEditorConfigPageAdapter : public ConfigPage { Q_OBJECT public: - explicit KTextEditorConfigPageWrapper(KTextEditor::ConfigPage* page, QWidget* parent = nullptr); - virtual ~KTextEditorConfigPageWrapper(); + explicit KTextEditorConfigPageAdapter(KTextEditor::ConfigPage* page, QWidget* parent = nullptr); + virtual ~KTextEditorConfigPageAdapter(); virtual QString name() const override; virtual QIcon icon() const override; virtual QString fullName() const override; public Q_SLOTS: virtual void apply() override; virtual void defaults() override; virtual void reset() override; private: KTextEditor::ConfigPage* m_page; }; class KDEVPLATFORMINTERFACES_EXPORT EditorConfigPage : public ConfigPage { Q_OBJECT public: EditorConfigPage(QWidget* parent); virtual ~EditorConfigPage(); virtual QString name() const override; virtual QIcon icon() const override; virtual QString fullName() const override; virtual QList childPages() override; public Q_SLOTS: virtual void apply() override {}; virtual void reset() override {}; virtual void defaults() override {}; }; } #endif // KDEVELOP_CONFIGPAGE_H