forked from qt-creator/qt-creator
CMake: Add a reset button to the CMake Configuration edit in Kits
Add a reset button to the CMake configuration edit dialog that is available in the kits configuration panel. It restores the default value for the kit. Change-Id: I89921e2c86cbf8d9658a32fe5fa51dc2f903ff00 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -344,13 +344,20 @@ void CMakeConfigurationKitConfigWidget::editConfigurationChanges()
|
|||||||
"separated from the variable value by \"=\".<br>"
|
"separated from the variable value by \"=\".<br>"
|
||||||
"You may provide a type hint by adding \":TYPE\" before the \"=\"."));
|
"You may provide a type hint by adding \":TYPE\" before the \"=\"."));
|
||||||
|
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Apply|QDialogButtonBox::Cancel);
|
auto buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Apply
|
||||||
|
|QDialogButtonBox::Reset|QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
layout->addWidget(m_editor);
|
layout->addWidget(m_editor);
|
||||||
layout->addWidget(buttons);
|
layout->addWidget(buttons);
|
||||||
|
|
||||||
connect(buttons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
|
connect(buttons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
|
||||||
connect(buttons, &QDialogButtonBox::rejected, m_dialog, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, m_dialog, &QDialog::reject);
|
||||||
|
connect(buttons, &QDialogButtonBox::clicked, m_dialog, [buttons, this](QAbstractButton *button) {
|
||||||
|
if (button != buttons->button(QDialogButtonBox::Reset))
|
||||||
|
return;
|
||||||
|
CMakeConfigurationKitInformation::setConfiguration(kit(),
|
||||||
|
CMakeConfigurationKitInformation::defaultConfiguration(kit()));
|
||||||
|
});
|
||||||
connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitConfigWidget::acceptChangesDialog);
|
connect(m_dialog, &QDialog::accepted, this, &CMakeConfigurationKitConfigWidget::acceptChangesDialog);
|
||||||
connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitConfigWidget::closeChangesDialog);
|
connect(m_dialog, &QDialog::rejected, this, &CMakeConfigurationKitConfigWidget::closeChangesDialog);
|
||||||
connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
|
connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
|
||||||
|
@@ -314,15 +314,22 @@ void CMakeConfigurationKitInformation::fromStringList(Kit *k, const QStringList
|
|||||||
setConfiguration(k, result);
|
setConfiguration(k, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMakeConfig CMakeConfigurationKitInformation::defaultConfiguration(const Kit *k)
|
||||||
|
{
|
||||||
|
Q_UNUSED(k);
|
||||||
|
CMakeConfig config;
|
||||||
|
config << CMakeConfigItem(CMAKE_QMAKE_KEY, "%{Qt:qmakeExecutable}");
|
||||||
|
config << CMakeConfigItem(CMAKE_TOOLCHAIN_KEY, "%{Compiler:Executable}");
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
|
QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(k);
|
Q_UNUSED(k);
|
||||||
|
|
||||||
// FIXME: Convert preload scripts
|
// FIXME: Convert preload scripts
|
||||||
CMakeConfig config;
|
CMakeConfig config = defaultConfiguration(k);
|
||||||
config << CMakeConfigItem(CMAKE_QMAKE_KEY, "%{Qt:qmakeExecutable}");
|
|
||||||
config << CMakeConfigItem(CMAKE_TOOLCHAIN_KEY, "%{Compiler:Executable}");
|
|
||||||
|
|
||||||
const QStringList tmp
|
const QStringList tmp
|
||||||
= Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); });
|
= Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); });
|
||||||
return tmp;
|
return tmp;
|
||||||
|
@@ -84,6 +84,8 @@ public:
|
|||||||
static QStringList toStringList(const ProjectExplorer::Kit *k);
|
static QStringList toStringList(const ProjectExplorer::Kit *k);
|
||||||
static void fromStringList(ProjectExplorer::Kit *k, const QStringList &in);
|
static void fromStringList(ProjectExplorer::Kit *k, const QStringList &in);
|
||||||
|
|
||||||
|
static CMakeConfig defaultConfiguration(const ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
// KitInformation interface
|
// KitInformation interface
|
||||||
QVariant defaultValue(const ProjectExplorer::Kit *k) const override;
|
QVariant defaultValue(const ProjectExplorer::Kit *k) const override;
|
||||||
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override;
|
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override;
|
||||||
|
Reference in New Issue
Block a user