CMake: Use new PagedSettings

More compact.

Change-Id: Ie800e52b98d23e1acd1deba9d6b6e5f778c016bb
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-05-10 13:51:34 +02:00
parent 699b804181
commit 72e30b69c5
3 changed files with 31 additions and 43 deletions

View File

@@ -23,7 +23,6 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectmanager.h>
@@ -74,7 +73,7 @@ public:
};
CMakeSettingsPage settingsPage;
CMakeSpecificSettingsPage specificSettings;
CMakeSpecificSettings specificSettings;
CMakeManager manager;
CMakeBuildStepFactory buildStepFactory;
@@ -146,7 +145,6 @@ CMakeProjectPlugin::~CMakeProjectPlugin()
void CMakeProjectPlugin::initialize()
{
d = new CMakeProjectPluginPrivate;
CMakeSpecificSettings::instance()->readSettings(ICore::settings());
const Context projectContext{CMakeProjectManager::Constants::CMAKE_PROJECT_ID};

View File

@@ -15,8 +15,36 @@ using namespace Utils;
namespace CMakeProjectManager::Internal {
static CMakeSpecificSettings *theSettings;
CMakeSpecificSettings *CMakeSpecificSettings::instance()
{
return theSettings;
}
CMakeSpecificSettings::CMakeSpecificSettings()
{
theSettings = this;
setId(Constants::Settings::GENERAL_ID);
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
setDisplayCategory("CMake");
setCategory(Constants::Settings::CATEGORY);
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
setSettings(this);
setLayouter([this](QWidget *widget) {
using namespace Layouting;
Column {
autorunCMake,
packageManagerAutoSetup,
askBeforeReConfigureInitialParams,
showSourceSubFolders,
showAdvancedOptionsByDefault,
st
}.attachTo(widget);
});
// TODO: fixup of QTCREATORBUG-26289 , remove in Qt Creator 7 or so
Core::ICore::settings()->remove("CMakeSpecificSettings/NinjaPath");
@@ -61,38 +89,8 @@ CMakeSpecificSettings::CMakeSpecificSettings()
showAdvancedOptionsByDefault.setDefaultValue(false);
showAdvancedOptionsByDefault.setLabelText(
::CMakeProjectManager::Tr::tr("Show advanced options by default"));
}
CMakeSpecificSettings *CMakeSpecificSettings::instance()
{
static CMakeSpecificSettings theSettings;
return &theSettings;
}
// CMakeSpecificSettingsPage
CMakeSpecificSettingsPage::CMakeSpecificSettingsPage()
{
CMakeSpecificSettings *settings = CMakeSpecificSettings::instance();
setId(Constants::Settings::GENERAL_ID);
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
setDisplayCategory("CMake");
setCategory(Constants::Settings::CATEGORY);
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
setSettings(settings);
setLayouter([settings](QWidget *widget) {
CMakeSpecificSettings &s = *settings;
using namespace Layouting;
Column {
s.autorunCMake,
s.packageManagerAutoSetup,
s.askBeforeReConfigureInitialParams,
s.showSourceSubFolders,
s.showAdvancedOptionsByDefault,
st
}.attachTo(widget);
});
readSettings(Core::ICore::settings());
}
} // CMakeProjectManager::Internal

View File

@@ -5,11 +5,9 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <utils/aspects.h>
namespace CMakeProjectManager::Internal {
class CMakeSpecificSettings final : public Utils::AspectContainer
class CMakeSpecificSettings final : public Core::PagedSettings
{
public:
CMakeSpecificSettings();
@@ -24,10 +22,4 @@ public:
Utils::BoolAspect showAdvancedOptionsByDefault;
};
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
{
public:
CMakeSpecificSettingsPage();
};
} // CMakeProjectManager::Internal