forked from qt-creator/qt-creator
QbsProjectManager: Let users reset the path to qbs
Also, don't store it if it wasn't changed from the default. Change-Id: Ia0f2e2b7e8f65c1fa32e111be499461fb2dda1d5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -13,11 +13,13 @@
|
|||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/process.h>
|
#include <utils/process.h>
|
||||||
|
#include <utils/qtcsettings.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -52,12 +54,17 @@ static bool operator!=(const QbsSettingsData &s1, const QbsSettingsData &s2)
|
|||||||
|
|
||||||
FilePath QbsSettings::qbsExecutableFilePath()
|
FilePath QbsSettings::qbsExecutableFilePath()
|
||||||
{
|
{
|
||||||
const QString fileName = HostOsInfo::withExecutableSuffix("qbs");
|
|
||||||
FilePath candidate = instance().m_settings.qbsExecutableFilePath;
|
FilePath candidate = instance().m_settings.qbsExecutableFilePath;
|
||||||
if (!candidate.exists()) {
|
if (!candidate.exists())
|
||||||
candidate = FilePath::fromString(QCoreApplication::applicationDirPath())
|
candidate = defaultQbsExecutableFilePath();
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
|
||||||
|
FilePath QbsSettings::defaultQbsExecutableFilePath()
|
||||||
|
{
|
||||||
|
const QString fileName = HostOsInfo::withExecutableSuffix("qbs");
|
||||||
|
FilePath candidate = FilePath::fromString(QCoreApplication::applicationDirPath())
|
||||||
.pathAppended(fileName);
|
.pathAppended(fileName);
|
||||||
}
|
|
||||||
if (!candidate.exists())
|
if (!candidate.exists())
|
||||||
candidate = Environment::systemEnvironment().searchInPath(fileName);
|
candidate = Environment::systemEnvironment().searchInPath(fileName);
|
||||||
return candidate;
|
return candidate;
|
||||||
@@ -136,7 +143,8 @@ void QbsSettings::loadSettings()
|
|||||||
void QbsSettings::storeSettings() const
|
void QbsSettings::storeSettings() const
|
||||||
{
|
{
|
||||||
QSettings * const s = Core::ICore::settings();
|
QSettings * const s = Core::ICore::settings();
|
||||||
s->setValue(QBS_EXE_KEY, m_settings.qbsExecutableFilePath.toString());
|
QtcSettings::setValueWithDefault(s, QBS_EXE_KEY, m_settings.qbsExecutableFilePath.toString(),
|
||||||
|
defaultQbsExecutableFilePath().toString());
|
||||||
s->setValue(QBS_DEFAULT_INSTALL_DIR_KEY, m_settings.defaultInstallDirTemplate);
|
s->setValue(QBS_DEFAULT_INSTALL_DIR_KEY, m_settings.defaultInstallDirTemplate);
|
||||||
s->setValue(USE_CREATOR_SETTINGS_KEY, m_settings.useCreatorSettings);
|
s->setValue(USE_CREATOR_SETTINGS_KEY, m_settings.useCreatorSettings);
|
||||||
}
|
}
|
||||||
@@ -148,6 +156,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_qbsExePathChooser.setExpectedKind(PathChooser::ExistingCommand);
|
m_qbsExePathChooser.setExpectedKind(PathChooser::ExistingCommand);
|
||||||
m_qbsExePathChooser.setFilePath(QbsSettings::qbsExecutableFilePath());
|
m_qbsExePathChooser.setFilePath(QbsSettings::qbsExecutableFilePath());
|
||||||
|
m_resetQbsExeButton.setText(Tr::tr("Reset"));
|
||||||
m_defaultInstallDirLineEdit.setText(QbsSettings::defaultInstallDirTemplate());
|
m_defaultInstallDirLineEdit.setText(QbsSettings::defaultInstallDirTemplate());
|
||||||
m_versionLabel.setText(getQbsVersionString());
|
m_versionLabel.setText(getQbsVersionString());
|
||||||
//: %1 == "Qt Creator" or "Qt Design Studio"
|
//: %1 == "Qt Creator" or "Qt Design Studio"
|
||||||
@@ -157,13 +166,19 @@ public:
|
|||||||
|
|
||||||
const auto layout = new QFormLayout(this);
|
const auto layout = new QFormLayout(this);
|
||||||
layout->addRow(&m_settingsDirCheckBox);
|
layout->addRow(&m_settingsDirCheckBox);
|
||||||
layout->addRow(Tr::tr("Path to qbs executable:"), &m_qbsExePathChooser);
|
const auto qbsExeLayout = new QHBoxLayout;
|
||||||
|
qbsExeLayout->addWidget(&m_qbsExePathChooser);
|
||||||
|
qbsExeLayout->addWidget(&m_resetQbsExeButton);
|
||||||
|
layout->addRow(Tr::tr("Path to qbs executable:"), qbsExeLayout);
|
||||||
layout->addRow(Tr::tr("Default installation directory:"), &m_defaultInstallDirLineEdit);
|
layout->addRow(Tr::tr("Default installation directory:"), &m_defaultInstallDirLineEdit);
|
||||||
layout->addRow(Tr::tr("Qbs version:"), &m_versionLabel);
|
layout->addRow(Tr::tr("Qbs version:"), &m_versionLabel);
|
||||||
|
|
||||||
connect(&m_qbsExePathChooser, &PathChooser::textChanged, [this] {
|
connect(&m_qbsExePathChooser, &PathChooser::textChanged, [this] {
|
||||||
m_versionLabel.setText(getQbsVersionString());
|
m_versionLabel.setText(getQbsVersionString());
|
||||||
});
|
});
|
||||||
|
connect(&m_resetQbsExeButton, &QPushButton::clicked, [this] {
|
||||||
|
m_qbsExePathChooser.setFilePath(QbsSettings::defaultQbsExecutableFilePath());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply() final
|
void apply() final
|
||||||
@@ -185,6 +200,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PathChooser m_qbsExePathChooser;
|
PathChooser m_qbsExePathChooser;
|
||||||
|
QPushButton m_resetQbsExeButton;
|
||||||
QLabel m_versionLabel;
|
QLabel m_versionLabel;
|
||||||
QCheckBox m_settingsDirCheckBox;
|
QCheckBox m_settingsDirCheckBox;
|
||||||
FancyLineEdit m_defaultInstallDirLineEdit;
|
FancyLineEdit m_defaultInstallDirLineEdit;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
static QbsSettings &instance();
|
static QbsSettings &instance();
|
||||||
|
|
||||||
static Utils::FilePath qbsExecutableFilePath();
|
static Utils::FilePath qbsExecutableFilePath();
|
||||||
|
static Utils::FilePath defaultQbsExecutableFilePath();
|
||||||
static Utils::FilePath qbsConfigFilePath();
|
static Utils::FilePath qbsConfigFilePath();
|
||||||
static bool hasQbsExecutable();
|
static bool hasQbsExecutable();
|
||||||
static QString defaultInstallDirTemplate();
|
static QString defaultInstallDirTemplate();
|
||||||
|
|||||||
Reference in New Issue
Block a user