forked from qt-creator/qt-creator
Vcpkg: Use new PagedSettings
Change-Id: I75d1b61a05efa630db080a2750d214636c02b5d9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -17,7 +17,7 @@ class VcpkgPluginPrivate
|
||||
{
|
||||
public:
|
||||
VcpkgManifestEditorFactory manifestEditorFactory;
|
||||
VcpkgSettingsPage settingsPage;
|
||||
VcpkgSettings settings;
|
||||
};
|
||||
|
||||
VcpkgPlugin::~VcpkgPlugin()
|
||||
|
||||
@@ -19,10 +19,48 @@
|
||||
|
||||
namespace Vcpkg::Internal {
|
||||
|
||||
static VcpkgSettings *theSettings = nullptr;
|
||||
|
||||
VcpkgSettings *VcpkgSettings::instance()
|
||||
{
|
||||
return theSettings;
|
||||
}
|
||||
|
||||
VcpkgSettings::VcpkgSettings()
|
||||
{
|
||||
theSettings = this;
|
||||
|
||||
setSettingsGroup("Vcpkg");
|
||||
|
||||
setId(Constants::TOOLSSETTINGSPAGE_ID);
|
||||
setDisplayName("Vcpkg");
|
||||
setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);
|
||||
|
||||
setLayouter([this](QWidget *widget) {
|
||||
using namespace Layouting;
|
||||
auto websiteButton = new QToolButton;
|
||||
websiteButton->setIcon(Utils::Icons::ONLINE.icon());
|
||||
websiteButton->setToolTip(Constants::WEBSITE_URL);
|
||||
|
||||
// clang-format off
|
||||
using namespace Layouting;
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Vcpkg installation")),
|
||||
Form {
|
||||
Utils::PathChooser::label(),
|
||||
Span{ 2, Row{ vcpkgRoot, websiteButton} },
|
||||
},
|
||||
},
|
||||
st,
|
||||
}.attachTo(widget);
|
||||
// clang-format on
|
||||
|
||||
connect(websiteButton, &QAbstractButton::clicked, [] {
|
||||
QDesktopServices::openUrl(QUrl::fromUserInput(Constants::WEBSITE_URL));
|
||||
});
|
||||
});
|
||||
|
||||
registerAspect(&vcpkgRoot);
|
||||
vcpkgRoot.setSettingsKey("VcpkgRoot");
|
||||
vcpkgRoot.setDisplayStyle(Utils::StringAspect::PathChooserDisplay);
|
||||
@@ -32,52 +70,9 @@ VcpkgSettings::VcpkgSettings()
|
||||
readSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
VcpkgSettings *VcpkgSettings::instance()
|
||||
{
|
||||
static VcpkgSettings s;
|
||||
return &s;
|
||||
}
|
||||
|
||||
bool VcpkgSettings::vcpkgRootValid() const
|
||||
{
|
||||
return (vcpkgRoot.filePath() / "vcpkg").withExecutableSuffix().isExecutableFile();
|
||||
}
|
||||
|
||||
class VcpkgSettingsPageWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
VcpkgSettingsPageWidget()
|
||||
{
|
||||
auto websiteButton = new QToolButton;
|
||||
websiteButton->setIcon(Utils::Icons::ONLINE.icon());
|
||||
websiteButton->setToolTip(Constants::WEBSITE_URL);
|
||||
|
||||
using namespace Layouting;
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Vcpkg installation")),
|
||||
Form {
|
||||
Utils::PathChooser::label(),
|
||||
Span{ 2, Row{ VcpkgSettings::instance()->vcpkgRoot, websiteButton} },
|
||||
},
|
||||
},
|
||||
st,
|
||||
}.attachTo(this);
|
||||
|
||||
connect(websiteButton, &QAbstractButton::clicked, [] {
|
||||
QDesktopServices::openUrl(QUrl::fromUserInput(Constants::WEBSITE_URL));
|
||||
});
|
||||
|
||||
setOnApply([] { VcpkgSettings::instance()->writeSettings(Core::ICore::settings()); });
|
||||
}
|
||||
};
|
||||
|
||||
VcpkgSettingsPage::VcpkgSettingsPage()
|
||||
{
|
||||
setId(Constants::TOOLSSETTINGSPAGE_ID);
|
||||
setDisplayName("Vcpkg");
|
||||
setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);
|
||||
setWidgetCreator([] { return new VcpkgSettingsPageWidget; });
|
||||
}
|
||||
|
||||
} // namespace Vcpkg::Internal
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <utils/aspects.h>
|
||||
|
||||
namespace Vcpkg::Internal {
|
||||
|
||||
class VcpkgSettings : public Utils::AspectContainer
|
||||
class VcpkgSettings : public Core::PagedSettings
|
||||
{
|
||||
public:
|
||||
VcpkgSettings();
|
||||
@@ -19,10 +18,4 @@ public:
|
||||
Utils::StringAspect vcpkgRoot;
|
||||
};
|
||||
|
||||
class VcpkgSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
VcpkgSettingsPage();
|
||||
};
|
||||
|
||||
} // namespace Vcpkg::Internal
|
||||
|
||||
Reference in New Issue
Block a user