diff --git a/interfaces/configpage.h b/interfaces/configpage.h --- a/interfaces/configpage.h +++ b/interfaces/configpage.h @@ -64,7 +64,8 @@ enum ConfigPageType { DefaultConfigPage, - LanguageConfigPage ///< A config page that contains language specific settings. This page is appended as a child page to the "Language support" config page. + LanguageConfigPage, ///< A config page that contains language specific settings. This page is appended as a child page to the "Language support" config page. + AnalyzerConfigPage ///< A config page that contains settings for some analyzer. This page is appended as a child page to the "Analyzers" config page. }; /** diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -80,7 +80,7 @@ settings/bgpreferences.cpp settings/templateconfig.cpp settings/templatepage.cpp - + settings/analyzerspreferences.cpp ) if(APPLE) diff --git a/shell/settings/analyzerspreferences.h b/shell/settings/analyzerspreferences.h new file mode 100644 --- /dev/null +++ b/shell/settings/analyzerspreferences.h @@ -0,0 +1,48 @@ +/* This file is part of KDevelop + * + * Copyright 2016 Anton Anikin + * + * 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. + */ + +#ifndef KDEVPLATFORM_ANALYZERS_PREFERENCES_H +#define KDEVPLATFORM_ANALYZERS_PREFERENCES_H + +#include + +namespace KDevelop +{ + +class AnalyzersPreferences : public ConfigPage +{ + Q_OBJECT +public: + explicit AnalyzersPreferences(QWidget* parent); + ~AnalyzersPreferences() override; + + QString name() const override; + QIcon icon() const override; + QString fullName() const override; + +public Q_SLOTS: + void apply() override; + void defaults() override; + void reset() override; +}; + +} + +#endif diff --git a/shell/settings/analyzerspreferences.cpp b/shell/settings/analyzerspreferences.cpp new file mode 100644 --- /dev/null +++ b/shell/settings/analyzerspreferences.cpp @@ -0,0 +1,64 @@ +/* This file is part of KDevelop +* +* Copyright 2016 Anton Anikin +* +* 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. +*/ + +#include "analyzerspreferences.h" + +#include + +namespace KDevelop +{ + +AnalyzersPreferences::AnalyzersPreferences(QWidget* parent) + : ConfigPage(nullptr, nullptr, parent) +{ +} + +AnalyzersPreferences::~AnalyzersPreferences() +{ +} + +QString AnalyzersPreferences::name() const +{ + return i18n("Analyzers"); +} + +QIcon AnalyzersPreferences::icon() const +{ + return QIcon::fromTheme(QStringLiteral("dialog-ok")); +} + +QString AnalyzersPreferences::fullName() const +{ + return i18n("Configure Analyzers"); +} + +void AnalyzersPreferences::apply() +{ +} + +void AnalyzersPreferences::defaults() +{ +} + +void AnalyzersPreferences::reset() +{ +} + +} diff --git a/shell/settings/pluginpreferences.cpp b/shell/settings/pluginpreferences.cpp --- a/shell/settings/pluginpreferences.cpp +++ b/shell/settings/pluginpreferences.cpp @@ -52,6 +52,7 @@ { "Language Support", i18nc("@title:group", "Language Support") }, { "Debugging", i18nc("@title:group", "Debugging") }, { "Testing", i18nc("@title:group", "Testing") }, + { "Analyzers", i18nc("@title:group", "Analyzers") }, { "Other", i18nc("@title:group", "Other") } }; foreach (const KPluginMetaData& info, Core::self()->pluginControllerInternal()->allPluginInfos()) { diff --git a/shell/uicontroller.cpp b/shell/uicontroller.cpp --- a/shell/uicontroller.cpp +++ b/shell/uicontroller.cpp @@ -60,6 +60,7 @@ #include "settings/sourceformattersettings.h" #include "settings/uipreferences.h" #include "settings/templateconfig.h" +#include "settings/analyzerspreferences.h" namespace KDevelop { @@ -491,39 +492,50 @@ void UiController::showSettingsDialog() { - auto editorConfigPage = new EditorConfigPage(activeMainWindow()); - auto languageConfigPage = new LanguagePreferences(activeMainWindow()); + auto parent = activeMainWindow(); + + auto editorConfigPage = new EditorConfigPage(parent); + auto languageConfigPage = new LanguagePreferences(parent); + auto analyzersPreferences = new AnalyzersPreferences(parent); auto configPages = QVector { - new UiPreferences(activeMainWindow()), - new PluginPreferences(activeMainWindow()), - new SourceFormatterSettings(activeMainWindow()), - new ProjectPreferences(activeMainWindow()), - new EnvironmentPreferences(QString(), activeMainWindow()), - new BGPreferences(activeMainWindow()), - new TemplateConfig(activeMainWindow()), + new UiPreferences(parent), + new PluginPreferences(parent), + new SourceFormatterSettings(parent), + new ProjectPreferences(parent), + new EnvironmentPreferences(QString(), parent), + new TemplateConfig(parent), editorConfigPage }; - ConfigDialog cfgDlg(configPages, activeMainWindow()); + ConfigDialog cfgDlg(configPages, parent); auto addPluginPages = [&](IPlugin* plugin) { for (int i = 0, numPages = plugin->configPages(); i < numPages; ++i) { auto page = plugin->configPage(i, &cfgDlg); - if(page && page->configPageType() == ConfigPage::LanguageConfigPage){ + if (!page) + continue; + + if (page->configPageType() == ConfigPage::LanguageConfigPage) { cfgDlg.addSubConfigPage(languageConfigPage, page); + } else if (page->configPageType() == ConfigPage::AnalyzerConfigPage) { + cfgDlg.addSubConfigPage(analyzersPreferences, page); } else { // insert them before the editor config page cfgDlg.addConfigPage(page, editorConfigPage); } } }; - cfgDlg.addConfigPage(languageConfigPage, configPages[5]); + cfgDlg.addConfigPage(analyzersPreferences, configPages[5]); + + cfgDlg.addConfigPage(languageConfigPage, analyzersPreferences); + cfgDlg.addSubConfigPage(languageConfigPage, new BGPreferences(parent)); foreach (IPlugin* plugin, ICore::self()->pluginController()->loadedPlugins()) { addPluginPages(plugin); } + // TODO: only load settings if a UI related page was changed? connect(&cfgDlg, &ConfigDialog::configSaved, activeSublimeWindow(), &Sublime::MainWindow::loadSettings); // make sure that pages get added whenever a new plugin is loaded (probably from the plugin selection dialog)