CMakePM: Add "Appy Kit/Initial Configuration Value" context menu entry

Now the "Initial Configuration" and "Current Configuration" displays
in red the mismatches between kit / initial value and respectively
initial and current configuration values.

By having a "Apply Kit / Initial Configuration Value" context menu
entry the user can resolve the mismatches if needed.

Change-Id: I2e272821c3ba396cd8a6b7c81e1437cb3fd4bbad
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2022-01-28 18:16:23 +01:00
parent dc825e11bd
commit 9c8f46a173
3 changed files with 66 additions and 0 deletions

View File

@@ -895,6 +895,30 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
if ((action = createForceAction(ConfigModel::DataItem::STRING, idx)))
menu->addAction(action);
menu->addSeparator();
auto applyKitOrInitialValue = new QAction(isInitialConfiguration()
? tr("Apply Kit Value")
: tr("Apply Initial Configuration Value"),
this);
menu->addAction(applyKitOrInitialValue);
connect(applyKitOrInitialValue, &QAction::triggered, this, [this] {
const QModelIndexList selectedIndexes = m_configView->selectionModel()->selectedIndexes();
const QModelIndexList validIndexes = Utils::filtered(selectedIndexes, [](const QModelIndex &index) {
return index.isValid() && index.flags().testFlag(Qt::ItemIsSelectable);
});
for (const QModelIndex &index : validIndexes) {
if (isInitialConfiguration())
m_configModel->applyKitValue(mapToSource(m_configView, index));
else
m_configModel->applyInitialValue(mapToSource(m_configView, index));
}
});
menu->addSeparator();
auto copy = new QAction(tr("Copy"), this);
menu->addAction(copy);
connect(copy, &QAction::triggered, this, [this] {