Commit 58c326cb authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 9ceb9cd7
......@@ -344,13 +344,20 @@ void CMakeConfigurationKitConfigWidget::editConfigurationChanges()
"separated from the variable value by \"=\".<br>"
"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(buttons);
connect(buttons, &QDialogButtonBox::accepted, m_dialog, &QDialog::accept);
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::rejected, this, &CMakeConfigurationKitConfigWidget::closeChangesDialog);
connect(buttons->button(QDialogButtonBox::Apply), &QAbstractButton::clicked,
......
......@@ -314,15 +314,22 @@ void CMakeConfigurationKitInformation::fromStringList(Kit *k, const QStringList
setConfiguration(k, result);
}
QVariant CMakeConfigurationKitInformation::defaultValue(const Kit *k) const
CMakeConfig CMakeConfigurationKitInformation::defaultConfiguration(const Kit *k)
{
Q_UNUSED(k);
// FIXME: Convert preload scripts
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
{
Q_UNUSED(k);
// FIXME: Convert preload scripts
CMakeConfig config = defaultConfiguration(k);
const QStringList tmp
= Utils::transform(config, [](const CMakeConfigItem &i) { return i.toString(); });
return tmp;
......
......@@ -84,6 +84,8 @@ public:
static QStringList toStringList(const ProjectExplorer::Kit *k);
static void fromStringList(ProjectExplorer::Kit *k, const QStringList &in);
static CMakeConfig defaultConfiguration(const ProjectExplorer::Kit *k);
// KitInformation interface
QVariant defaultValue(const ProjectExplorer::Kit *k) const override;
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment