forked from qt-creator/qt-creator
Meson: Aspectify general settings
This follows suit which what is currently happening in other plugins. Change-Id: I5fb75e23d7d6add632cd07c732131b4f9793d345 Reviewed-by: Alexis Jeandet <alexis.jeandet@member.fsf.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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 <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
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
|
||||
@@ -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
|
||||
@@ -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 <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTabWidget>
|
||||
#include <QWidget>
|
||||
|
||||
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
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MesonProjectManager::Internal::GeneralSettingsWidget</class>
|
||||
<widget class="QWidget" name="MesonProjectManager::Internal::GeneralSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>625</width>
|
||||
<height>349</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autorunChkBox">
|
||||
<property name="toolTip">
|
||||
<string>Automatically run Meson when needed.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Autorun Meson</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="verboseNinjaChkBox">
|
||||
<property name="toolTip">
|
||||
<string>Enables verbose mode by default when invoking Ninja.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ninja verbose mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -25,14 +25,53 @@
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -25,69 +25,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mesonpluginconstants.h"
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/aspects.h>
|
||||
|
||||
namespace MesonProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
template<class F>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user