diff --git a/src/plugins/mesonprojectmanager/CMakeLists.txt b/src/plugins/mesonprojectmanager/CMakeLists.txt index 65a023b73d5..63479aea438 100644 --- a/src/plugins/mesonprojectmanager/CMakeLists.txt +++ b/src/plugins/mesonprojectmanager/CMakeLists.txt @@ -28,11 +28,6 @@ add_qtc_plugin(MesonProjectManager settings/tools/kitaspect/mesontoolkitaspect.h settings/tools/toolssettingsaccessor.h settings/tools/toolssettingsaccessor.cpp - settings/general/generalsettingswidget.ui - settings/general/generalsettingswidget.cpp - settings/general/generalsettingswidget.h - settings/general/generalsettingspage.h - settings/general/generalsettingspage.cpp settings/general/settings.h settings/general/settings.cpp exewrappers/mesonwrapper.cpp diff --git a/src/plugins/mesonprojectmanager/mesonpluginconstants.h b/src/plugins/mesonprojectmanager/mesonpluginconstants.h index 7aff7a7b245..02983d87389 100644 --- a/src/plugins/mesonprojectmanager/mesonpluginconstants.h +++ b/src/plugins/mesonprojectmanager/mesonpluginconstants.h @@ -58,12 +58,6 @@ const char NAME_KEY[] = "name"; const char ID_KEY[] = "uuid"; } // namespace ToolsSettings -namespace GeneralSettings { -const char SECTION[] = "MesonProjectManager"; -const char AUTORUN_MESON_KEY[] = "meson.autorun"; -const char VERBOSE_NINJA_KEY[] = "ninja.verbose"; -} // namespace GeneralSettings - namespace Icons { const char MESON[] = ":/mesonproject/icons/meson_logo.png"; const char MESON_BW[] = ":/mesonproject/icons/meson_bw_logo.png"; diff --git a/src/plugins/mesonprojectmanager/mesonprojectmanager.pro b/src/plugins/mesonprojectmanager/mesonprojectmanager.pro index 92a6f8f0a5f..96246c8924e 100644 --- a/src/plugins/mesonprojectmanager/mesonprojectmanager.pro +++ b/src/plugins/mesonprojectmanager/mesonprojectmanager.pro @@ -36,8 +36,6 @@ HEADERS = \ project/mesonprojectparser.h \ project/mesonrunconfiguration.h \ project/ninjabuildstep.h \ - settings/general/generalsettingspage.h \ - settings/general/generalsettingswidget.h \ settings/general/settings.h \ settings/tools/kitaspect/mesontoolkitaspect.h \ settings/tools/kitaspect/ninjatoolkitaspect.h \ @@ -75,8 +73,6 @@ SOURCES = \ project/mesonprojectparser.cpp \ project/mesonrunconfiguration.cpp \ project/ninjabuildstep.cpp \ - settings/general/generalsettingspage.cpp \ - settings/general/generalsettingswidget.cpp \ settings/general/settings.cpp \ settings/tools/kitaspect/mesontoolkitaspect.cpp \ settings/tools/kitaspect/ninjatoolkitaspect.cpp \ @@ -93,7 +89,6 @@ RESOURCES += resources.qrc FORMS += \ project/buildoptions/mesonbuildsettingswidget.ui \ - settings/general/generalsettingswidget.ui \ settings/tools/toolitemsettings.ui \ settings/tools/toolssettingswidget.ui diff --git a/src/plugins/mesonprojectmanager/mesonprojectmanager.qbs b/src/plugins/mesonprojectmanager/mesonprojectmanager.qbs index efcfca832ae..2111c087bfc 100644 --- a/src/plugins/mesonprojectmanager/mesonprojectmanager.qbs +++ b/src/plugins/mesonprojectmanager/mesonprojectmanager.qbs @@ -83,11 +83,6 @@ Project { "project/projecttree/projecttree.cpp", "project/projecttree/projecttree.h", "resources.qrc", - "settings/general/generalsettingspage.cpp", - "settings/general/generalsettingspage.h", - "settings/general/generalsettingswidget.cpp", - "settings/general/generalsettingswidget.h", - "settings/general/generalsettingswidget.ui", "settings/general/settings.cpp", "settings/general/settings.h", "settings/tools/kitaspect/mesontoolkitaspect.cpp", diff --git a/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp b/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp index a83f489acb6..bd2e120d513 100644 --- a/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp +++ b/src/plugins/mesonprojectmanager/mesonprojectplugin.cpp @@ -33,7 +33,7 @@ #include "project/mesonproject.h" #include "project/mesonrunconfiguration.h" #include "project/ninjabuildstep.h" -#include "settings/general/generalsettingspage.h" +#include "settings/general/settings.h" #include "settings/tools/kitaspect/mesontoolkitaspect.h" #include "settings/tools/kitaspect/ninjatoolkitaspect.h" #include "settings/tools/toolssettingsaccessor.h" @@ -84,7 +84,6 @@ private: void saveAll() { m_toolsSettings.saveMesonTools(MesonTools::tools(), ICore::dialogParent()); - m_generalSettingsPage.saveAll(); } }; diff --git a/src/plugins/mesonprojectmanager/project/mesonbuildsystem.cpp b/src/plugins/mesonprojectmanager/project/mesonbuildsystem.cpp index 3506e935389..c0212be0a76 100644 --- a/src/plugins/mesonprojectmanager/project/mesonbuildsystem.cpp +++ b/src/plugins/mesonprojectmanager/project/mesonbuildsystem.cpp @@ -214,7 +214,7 @@ void MesonBuildSystem::init() bool MesonBuildSystem::parseProject() { QTC_ASSERT(buildConfiguration(), return false); - if (!isSetup(buildConfiguration()->buildDirectory()) && Settings::autorunMeson()) + if (!isSetup(buildConfiguration()->buildDirectory()) && Settings::instance()->autorunMeson.value()) return configure(); LEAVE_IF_BUSY(); LOCK(); diff --git a/src/plugins/mesonprojectmanager/project/ninjabuildstep.cpp b/src/plugins/mesonprojectmanager/project/ninjabuildstep.cpp index fffb3aa0126..067e853a59e 100644 --- a/src/plugins/mesonprojectmanager/project/ninjabuildstep.cpp +++ b/src/plugins/mesonprojectmanager/project/ninjabuildstep.cpp @@ -65,8 +65,8 @@ NinjaBuildStep::NinjaBuildStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id setUseEnglishOutput(); connect(target(), &ProjectExplorer::Target::parsingFinished, this, &NinjaBuildStep::update); - connect(Settings::instance(), - &Settings::verboseNinjaChanged, + connect(&Settings::instance()->verboseNinja, + &BaseAspect::changed, this, &NinjaBuildStep::commandChanged); } @@ -152,7 +152,7 @@ Utils::CommandLine NinjaBuildStep::command() }(); if (!m_commandArgs.isEmpty()) cmd.addArgs(m_commandArgs, Utils::CommandLine::RawType::Raw); - if (Settings::verboseNinja()) + if (Settings::instance()->verboseNinja.value()) cmd.addArg("-v"); cmd.addArg(m_targetName); return cmd; diff --git a/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.cpp b/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.cpp deleted file mode 100644 index 0b415cf97f1..00000000000 --- a/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Alexis Jeandet. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "generalsettingspage.h" - -#include "generalsettingswidget.h" -#include "mesonpluginconstants.h" -#include "settings.h" - -namespace MesonProjectManager { -namespace Internal { - -GeneralSettingsPage::GeneralSettingsPage() -{ - setId(Constants::SettingsPage::GENERAL_ID); - setDisplayName(tr("General")); - setDisplayCategory("Meson"); - setCategory(Constants::SettingsPage::CATEGORY); - setCategoryIconPath(Constants::Icons::MESON_BW); - setWidgetCreator([]() { return new GeneralSettingsWidget; }); - Settings::loadAll(); -} - -void GeneralSettingsPage::saveAll() -{ - Settings::saveAll(); -} - -} // namespace Internal -} // namespace MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.h b/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.h deleted file mode 100644 index 30ebe94b849..00000000000 --- a/src/plugins/mesonprojectmanager/settings/general/generalsettingspage.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Alexis Jeandet. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -#include - -namespace MesonProjectManager { -namespace Internal { - -class MesonTools; - -class GeneralSettingsPage final : public Core::IOptionsPage -{ - Q_DECLARE_TR_FUNCTIONS(MesonProjectManager::Internal::GeneralSettingsPage) - -public: - GeneralSettingsPage(); - void saveAll(); -}; - -} // namespace Internal -} // namespace MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.cpp b/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.cpp deleted file mode 100644 index f92659fe5f3..00000000000 --- a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Alexis Jeandet. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "generalsettingswidget.h" - -#include "settings.h" -#include "ui_generalsettingswidget.h" - -namespace MesonProjectManager { -namespace Internal { - -GeneralSettingsWidget::GeneralSettingsWidget() - : Core::IOptionsPageWidget() - , ui(new Ui::GeneralSettingsWidget) -{ - ui->setupUi(this); - ui->autorunChkBox->setChecked(Settings::autorunMeson()); - ui->verboseNinjaChkBox->setChecked(Settings::verboseNinja()); -} - -GeneralSettingsWidget::~GeneralSettingsWidget() -{ - delete ui; -} - -void GeneralSettingsWidget::apply() -{ - Settings::setAutorunMeson(ui->autorunChkBox->isChecked()); - Settings::setVerboseNinja(ui->verboseNinjaChkBox->isChecked()); -} - -} // namespace Internal -} // namespace MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.h b/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.h deleted file mode 100644 index 04cc8adb698..00000000000 --- a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Alexis Jeandet. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -#include -#include -#include - -namespace MesonProjectManager { -namespace Internal { - -namespace Ui { class GeneralSettingsWidget; } - -class GeneralSettingsWidget final : public Core::IOptionsPageWidget -{ - Q_DECLARE_TR_FUNCTIONS(MesonProjectManager::Internal::GeneralSettingsWidget) - void apply() final; - -public: - explicit GeneralSettingsWidget(); - ~GeneralSettingsWidget(); - -private: - Ui::GeneralSettingsWidget *ui; -}; - -} // namespace Internal -} // namespace MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.ui b/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.ui deleted file mode 100644 index 78a3c14d771..00000000000 --- a/src/plugins/mesonprojectmanager/settings/general/generalsettingswidget.ui +++ /dev/null @@ -1,57 +0,0 @@ - - - MesonProjectManager::Internal::GeneralSettingsWidget - - - - 0 - 0 - 625 - 349 - - - - - - - - - - Automatically run Meson when needed. - - - Autorun Meson - - - - - - - Enables verbose mode by default when invoking Ninja. - - - Ninja verbose mode - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/src/plugins/mesonprojectmanager/settings/general/settings.cpp b/src/plugins/mesonprojectmanager/settings/general/settings.cpp index 49151f74465..03a9ed293a4 100644 --- a/src/plugins/mesonprojectmanager/settings/general/settings.cpp +++ b/src/plugins/mesonprojectmanager/settings/general/settings.cpp @@ -25,14 +25,53 @@ #include "settings.h" +#include "mesonpluginconstants.h" + +#include + namespace MesonProjectManager { namespace Internal { -Settings::Settings(QObject *parent) - : QObject(parent) - , m_autorunMeson(true) - , m_verboseNinja(true) -{} +Settings::Settings() +{ + setSettingsGroup("MesonProjectManager"); + setAutoApply(false); + + autorunMeson.setSettingsKey("meson.autorun"); + autorunMeson.setLabelText(tr("Autorun Meson")); + autorunMeson.setToolTip(tr("Automatically run Meson when needed.")); + + verboseNinja.setSettingsKey("meson.autorun"); + verboseNinja.setLabelText(tr("Ninja verbose mode")); + verboseNinja.setToolTip(tr("Enables verbose mode by default when invoking Ninja.")); +} + +Settings *Settings::instance() +{ + static Settings m_settings; + return &m_settings; +} + +GeneralSettingsPage::GeneralSettingsPage() +{ + setId(Constants::SettingsPage::GENERAL_ID); + setDisplayName(tr("General")); + setDisplayCategory("Meson"); + setCategory(Constants::SettingsPage::CATEGORY); + setCategoryIconPath(Constants::Icons::MESON_BW); + setSettings(Settings::instance()); + + setLayouter([](QWidget *widget) { + Settings &s = *Settings::instance(); + using namespace Utils::Layouting; + + Column { + s.autorunMeson, + s.verboseNinja, + Stretch(), + }.attachTo(widget); + }); +} } // namespace Internal } // namespace MesonProjectManager diff --git a/src/plugins/mesonprojectmanager/settings/general/settings.h b/src/plugins/mesonprojectmanager/settings/general/settings.h index e25ff28f583..814cdf42f4d 100644 --- a/src/plugins/mesonprojectmanager/settings/general/settings.h +++ b/src/plugins/mesonprojectmanager/settings/general/settings.h @@ -25,69 +25,32 @@ #pragma once -#include "mesonpluginconstants.h" +#include -#include +#include namespace MesonProjectManager { namespace Internal { -template -void with_group(QSettings *settings, const QString &name, const F &f) +class Settings : public Utils::AspectContainer { - settings->beginGroup(name); - f(); - settings->endGroup(); -}; - -#define ADD_PROPERTY(name, setter, type) \ -private: \ - type m_##name; \ -\ -public: \ - inline static type name() { return instance()->m_##name; } \ - inline static void setter(type value) \ - { \ - instance()->m_##name = value; \ - emit instance()->name##Changed(value); \ - } \ - Q_SIGNAL void name##Changed(type newValue); - -class Settings : public QObject -{ - Q_OBJECT - explicit Settings(QObject *parent = nullptr); + Q_DECLARE_TR_FUNCTIONS(MesonProjectManager::Internal::Settings) public: - inline static Settings *instance() - { - static Settings m_settings; - return &m_settings; - } + Settings(); - ADD_PROPERTY(autorunMeson, setAutorunMeson, bool) - ADD_PROPERTY(verboseNinja, setVerboseNinja, bool) + static Settings *instance(); - static inline void saveAll() - { - using namespace Constants; - auto settings = Core::ICore::settings(QSettings::Scope::UserScope); - with_group(settings, GeneralSettings::SECTION, [settings]() { - settings->setValue(GeneralSettings::AUTORUN_MESON_KEY, Settings::autorunMeson()); - settings->setValue(GeneralSettings::VERBOSE_NINJA_KEY, Settings::verboseNinja()); - }); - } - static inline void loadAll() - { - using namespace Constants; - auto settings = Core::ICore::settings(QSettings::Scope::UserScope); - with_group(settings, GeneralSettings::SECTION, [settings]() { - Settings::setAutorunMeson( - settings->value(GeneralSettings::AUTORUN_MESON_KEY, true).toBool()); - Settings::setVerboseNinja( - settings->value(GeneralSettings::VERBOSE_NINJA_KEY, true).toBool()); - }); - } + Utils::BoolAspect autorunMeson; + Utils::BoolAspect verboseNinja; +}; + +class GeneralSettingsPage final : public Core::IOptionsPage +{ + Q_DECLARE_TR_FUNCTIONS(MesonProjectManager::Internal::GeneralSettingsPage) + +public: + GeneralSettingsPage(); }; } // namespace Internal