forked from qt-creator/qt-creator
CMakePM: Display CMake kit mismatch values in Settings page
updateFromKit() is now called on parsingFinished and the configuration values that differ from the ones in the Kit's CMake configuration will be displayed in red. The "Initial Configuration" page will display the mismatches between kit's CMake configuration and initial parameters. The "Current Configuration" page will display the mismatches between the initial parameters and the current CMake parameters. The Tooltip is displayed with a bit of more space between values for more readability. Change-Id: I6ebfa71951cf979ab08f097befed2d43b74e4d6e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -353,6 +353,8 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
m_showProgressTimer.start();
|
m_showProgressTimer.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_configModel->setMacroExpander(m_buildConfiguration->macroExpander());
|
||||||
|
|
||||||
if (bc->buildSystem()->isParsing())
|
if (bc->buildSystem()->isParsing())
|
||||||
m_showProgressTimer.start();
|
m_showProgressTimer.start();
|
||||||
else {
|
else {
|
||||||
@@ -368,6 +370,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
m_configModel->setInitialParametersConfiguration(
|
m_configModel->setInitialParametersConfiguration(
|
||||||
m_buildConfiguration->initialCMakeConfiguration());
|
m_buildConfiguration->initialCMakeConfiguration());
|
||||||
m_buildConfiguration->filterConfigArgumentsFromAdditionalCMakeArguments();
|
m_buildConfiguration->filterConfigArgumentsFromAdditionalCMakeArguments();
|
||||||
|
updateFromKit();
|
||||||
m_configView->expandAll();
|
m_configView->expandAll();
|
||||||
m_configView->setEnabled(true);
|
m_configView->setEnabled(true);
|
||||||
stretcher->stretch();
|
stretcher->stretch();
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "configmodel.h"
|
#include "configmodel.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
@@ -315,34 +316,37 @@ void ConfigModel::setConfiguration(const QList<ConfigModel::InternalDataItem> &c
|
|||||||
generateTree();
|
generateTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::MacroExpander *ConfigModel::macroExpander() const
|
||||||
|
{
|
||||||
|
return m_macroExpander;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::setMacroExpander(Utils::MacroExpander *newExpander)
|
||||||
|
{
|
||||||
|
m_macroExpander = newExpander;
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigModel::generateTree()
|
void ConfigModel::generateTree()
|
||||||
{
|
{
|
||||||
|
QHash<QString, InternalDataItem> initialHash;
|
||||||
|
for (const InternalDataItem &di : m_configuration)
|
||||||
|
if (di.isInitial)
|
||||||
|
initialHash.insert(di.key, di);
|
||||||
|
|
||||||
auto root = new Utils::TreeItem;
|
auto root = new Utils::TreeItem;
|
||||||
for (InternalDataItem &di : m_configuration)
|
for (InternalDataItem &di : m_configuration) {
|
||||||
|
auto it = initialHash.find(di.key);
|
||||||
|
if (it != initialHash.end())
|
||||||
|
di.initialValue = macroExpander()->expand(it->value);
|
||||||
|
|
||||||
root->appendChild(new Internal::ConfigModelTreeItem(&di));
|
root->appendChild(new Internal::ConfigModelTreeItem(&di));
|
||||||
|
}
|
||||||
setRootItem(root);
|
setRootItem(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigModel::InternalDataItem::InternalDataItem(const ConfigModel::DataItem &item) : DataItem(item)
|
ConfigModel::InternalDataItem::InternalDataItem(const ConfigModel::DataItem &item) : DataItem(item)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QString ConfigModel::InternalDataItem::toolTip() const
|
|
||||||
{
|
|
||||||
QString desc = description;
|
|
||||||
if (isAdvanced)
|
|
||||||
desc += QCoreApplication::translate("CMakeProjectManager::ConfigModel", " (ADVANCED)");
|
|
||||||
QStringList tooltip(desc);
|
|
||||||
if (inCMakeCache) {
|
|
||||||
if (value != newValue)
|
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Current CMake: %1").arg(value);
|
|
||||||
} else {
|
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Not in CMakeCache.txt").arg(value);
|
|
||||||
}
|
|
||||||
if (!kitValue.isEmpty())
|
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager::ConfigModel", "Current kit: %1").arg(kitValue);
|
|
||||||
return tooltip.join("<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConfigModel::InternalDataItem::currentValue() const
|
QString ConfigModel::InternalDataItem::currentValue() const
|
||||||
{
|
{
|
||||||
if (isUnset)
|
if (isUnset)
|
||||||
@@ -414,9 +418,15 @@ QVariant ConfigModelTreeItem::data(int column, int role) const
|
|||||||
font.setStrikeOut((!dataItem->inCMakeCache && !dataItem->isUserNew) || dataItem->isUnset);
|
font.setStrikeOut((!dataItem->inCMakeCache && !dataItem->isUserNew) || dataItem->isUnset);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
case Qt::ForegroundRole:
|
case Qt::ForegroundRole: {
|
||||||
return Utils::creatorTheme()->color((!dataItem->kitValue.isNull() && dataItem->kitValue != value)
|
bool mismatch = false;
|
||||||
? Utils::Theme::TextColorHighlight : Utils::Theme::TextColorNormal);
|
if (dataItem->isInitial)
|
||||||
|
mismatch = !dataItem->kitValue.isEmpty() && dataItem->kitValue != value;
|
||||||
|
else
|
||||||
|
mismatch = !dataItem->initialValue.isEmpty() && dataItem->initialValue != value;
|
||||||
|
return Utils::creatorTheme()->color(mismatch ? Utils::Theme::TextColorHighlight
|
||||||
|
: Utils::Theme::TextColorNormal);
|
||||||
|
}
|
||||||
case Qt::ToolTipRole: {
|
case Qt::ToolTipRole: {
|
||||||
return toolTip();
|
return toolTip();
|
||||||
}
|
}
|
||||||
@@ -492,16 +502,36 @@ Qt::ItemFlags ConfigModelTreeItem::flags(int column) const
|
|||||||
QString ConfigModelTreeItem::toolTip() const
|
QString ConfigModelTreeItem::toolTip() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dataItem, return QString());
|
QTC_ASSERT(dataItem, return QString());
|
||||||
QStringList tooltip(dataItem->description);
|
QStringList tooltip;
|
||||||
if (!dataItem->kitValue.isEmpty())
|
if (!dataItem->description.isEmpty())
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Value requested by kit: %1").arg(dataItem->kitValue);
|
tooltip << dataItem->description;
|
||||||
if (dataItem->inCMakeCache) {
|
|
||||||
|
if (dataItem->isInitial) {
|
||||||
|
if (!dataItem->kitValue.isEmpty())
|
||||||
|
tooltip << QCoreApplication::translate("CMakeProjectManager", "<p>Kit: <b>%1</b></p>")
|
||||||
|
.arg(dataItem->kitValue);
|
||||||
|
|
||||||
if (dataItem->value != dataItem->newValue)
|
if (dataItem->value != dataItem->newValue)
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Current CMake: %1").arg(dataItem->value);
|
tooltip << QCoreApplication::translate("CMakeProjectManager",
|
||||||
} else {
|
"<p>Initial Configuration: <b>%1</b></p>")
|
||||||
tooltip << QCoreApplication::translate("CMakeProjectManager", "Not in CMakeCache.txt");
|
.arg(dataItem->value);
|
||||||
|
} else {
|
||||||
|
if (!dataItem->initialValue.isEmpty())
|
||||||
|
tooltip << QCoreApplication::translate("CMakeProjectManager",
|
||||||
|
"<p>Initial Configuration: <b>%1</b></p>")
|
||||||
|
.arg(dataItem->initialValue);
|
||||||
|
|
||||||
|
if (dataItem->inCMakeCache) {
|
||||||
|
if (dataItem->value != dataItem->newValue)
|
||||||
|
tooltip << QCoreApplication::translate("CMakeProjectManager",
|
||||||
|
"<p>Current Configuration: <b>%1</b></p>")
|
||||||
|
.arg(dataItem->value);
|
||||||
|
} else {
|
||||||
|
tooltip << QCoreApplication::translate("CMakeProjectManager",
|
||||||
|
"<p>Not in CMakeCache.txt</p>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tooltip.join("<br>");
|
return tooltip.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigModelTreeItem::currentValue() const
|
QString ConfigModelTreeItem::currentValue() const
|
||||||
|
@@ -162,6 +162,8 @@ public:
|
|||||||
|
|
||||||
QList<DataItem> configurationForCMake() const;
|
QList<DataItem> configurationForCMake() const;
|
||||||
|
|
||||||
|
Utils::MacroExpander *macroExpander() const;
|
||||||
|
void setMacroExpander(Utils::MacroExpander *newExpander);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class InternalDataItem : public DataItem
|
class InternalDataItem : public DataItem
|
||||||
@@ -170,13 +172,13 @@ private:
|
|||||||
InternalDataItem(const DataItem &item);
|
InternalDataItem(const DataItem &item);
|
||||||
InternalDataItem(const InternalDataItem &item) = default;
|
InternalDataItem(const InternalDataItem &item) = default;
|
||||||
|
|
||||||
QString toolTip() const;
|
|
||||||
QString currentValue() const;
|
QString currentValue() const;
|
||||||
|
|
||||||
bool isUserChanged = false;
|
bool isUserChanged = false;
|
||||||
bool isUserNew = false;
|
bool isUserNew = false;
|
||||||
QString newValue;
|
QString newValue;
|
||||||
QString kitValue;
|
QString kitValue;
|
||||||
|
QString initialValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void generateTree();
|
void generateTree();
|
||||||
@@ -184,6 +186,7 @@ private:
|
|||||||
void setConfiguration(const QList<InternalDataItem> &config);
|
void setConfiguration(const QList<InternalDataItem> &config);
|
||||||
QList<InternalDataItem> m_configuration;
|
QList<InternalDataItem> m_configuration;
|
||||||
KitConfiguration m_kitConfiguration;
|
KitConfiguration m_kitConfiguration;
|
||||||
|
Utils::MacroExpander *m_macroExpander = nullptr;
|
||||||
|
|
||||||
friend class Internal::ConfigModelTreeItem;
|
friend class Internal::ConfigModelTreeItem;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user