forked from qt-creator/qt-creator
ProjectExplorer: Let the KitChooser optionally show icons
There are cases in the debugger where it's more convenient or with the current state of Abi matching even needed to use non-matching kits. Still, visual hints are helpful. Change-Id: I66ca89cbd1664f43864873e3b4d81a9c8e1b36fa Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <utils/optional.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
@@ -400,6 +401,20 @@ QIcon Kit::icon() const
|
||||
return d->m_cachedIcon;
|
||||
}
|
||||
|
||||
QIcon Kit::displayIcon() const
|
||||
{
|
||||
QIcon result = icon();
|
||||
if (hasWarning()) {
|
||||
static const QIcon warningIcon(Utils::Icons::WARNING.icon());
|
||||
result = warningIcon;
|
||||
}
|
||||
if (!isValid()) {
|
||||
static const QIcon errorIcon(Utils::Icons::CRITICAL.icon());
|
||||
result = errorIcon;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
FilePath Kit::iconPath() const
|
||||
{
|
||||
return d->m_iconPath;
|
||||
|
@@ -96,7 +96,8 @@ public:
|
||||
// all other aspects are equal.
|
||||
int weight() const;
|
||||
|
||||
QIcon icon() const;
|
||||
QIcon icon() const; // Raw device icon, independent of warning or error.
|
||||
QIcon displayIcon() const; // Error or warning or device icon.
|
||||
Utils::FilePath iconPath() const;
|
||||
void setIconPath(const Utils::FilePath &path);
|
||||
void setDeviceTypeForIcon(Core::Id deviceType);
|
||||
|
@@ -72,6 +72,11 @@ void KitChooser::onManageButtonClicked()
|
||||
Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this);
|
||||
}
|
||||
|
||||
void KitChooser::setShowIcons(bool showIcons)
|
||||
{
|
||||
m_showIcons = showIcons;
|
||||
}
|
||||
|
||||
void KitChooser::onCurrentIndexChanged()
|
||||
{
|
||||
const Id id = Id::fromSetting(m_chooser->currentData());
|
||||
@@ -127,9 +132,12 @@ void KitChooser::populate()
|
||||
foreach (Kit *kit, KitManager::sortKits(KitManager::kits())) {
|
||||
if (m_kitPredicate(kit)) {
|
||||
m_chooser->addItem(kitText(kit), kit->id().toSetting());
|
||||
m_chooser->setItemData(m_chooser->count() - 1, kitToolTip(kit), Qt::ToolTipRole);
|
||||
const int pos = m_chooser->count() - 1;
|
||||
m_chooser->setItemData(pos, kitToolTip(kit), Qt::ToolTipRole);
|
||||
if (m_showIcons)
|
||||
m_chooser->setItemData(pos, kit->displayIcon(), Qt::DecorationRole);
|
||||
if (!didActivate && kit->id() == lastKit) {
|
||||
m_chooser->setCurrentIndex(m_chooser->count() - 1);
|
||||
m_chooser->setCurrentIndex(pos);
|
||||
didActivate = true;
|
||||
}
|
||||
}
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
Core::Id currentKitId() const;
|
||||
|
||||
void setKitPredicate(const Kit::Predicate &predicate);
|
||||
void setShowIcons(bool showIcons);
|
||||
|
||||
Kit *currentKit() const;
|
||||
bool hasStartupKit() const { return m_hasStartupKit; }
|
||||
@@ -78,6 +79,7 @@ private:
|
||||
QComboBox *m_chooser;
|
||||
QPushButton *m_manageButton;
|
||||
bool m_hasStartupKit = false;
|
||||
bool m_showIcons = false;
|
||||
};
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QRegularExpression>
|
||||
@@ -155,9 +156,15 @@ QString KitManagerConfigWidget::displayName() const
|
||||
return m_cachedDisplayName;
|
||||
}
|
||||
|
||||
QIcon KitManagerConfigWidget::icon() const
|
||||
QIcon KitManagerConfigWidget::displayIcon() const
|
||||
{
|
||||
return m_modifiedKit->icon();
|
||||
// Special case: Extra warning if there are no errors but name is not unique.
|
||||
if (m_modifiedKit->isValid() && !m_hasUniqueName) {
|
||||
static const QIcon warningIcon(Utils::Icons::WARNING.icon());
|
||||
return warningIcon;
|
||||
}
|
||||
|
||||
return m_modifiedKit->displayIcon();
|
||||
}
|
||||
|
||||
void KitManagerConfigWidget::apply()
|
||||
@@ -199,16 +206,6 @@ bool KitManagerConfigWidget::isDirty() const
|
||||
|| m_isDefaultKit != (KitManager::defaultKit() == m_kit);
|
||||
}
|
||||
|
||||
bool KitManagerConfigWidget::isValid() const
|
||||
{
|
||||
return m_modifiedKit->isValid();
|
||||
}
|
||||
|
||||
bool KitManagerConfigWidget::hasWarning() const
|
||||
{
|
||||
return m_modifiedKit->hasWarning() || !m_hasUniqueName;
|
||||
}
|
||||
|
||||
QString KitManagerConfigWidget::validityMessage() const
|
||||
{
|
||||
Tasks tmp;
|
||||
|
@@ -52,13 +52,11 @@ public:
|
||||
~KitManagerConfigWidget() override;
|
||||
|
||||
QString displayName() const;
|
||||
QIcon icon() const;
|
||||
QIcon displayIcon() const;
|
||||
|
||||
void apply();
|
||||
void discard();
|
||||
bool isDirty() const;
|
||||
bool isValid() const;
|
||||
bool hasWarning() const;
|
||||
QString validityMessage() const;
|
||||
void addAspectToWorkingCopy(KitAspect *aspect);
|
||||
void makeStickySubWidgetsReadOnly();
|
||||
|
@@ -85,15 +85,7 @@ public:
|
||||
return baseName;
|
||||
}
|
||||
if (role == Qt::DecorationRole) {
|
||||
if (!widget->isValid()) {
|
||||
static const QIcon errorIcon(Utils::Icons::CRITICAL.icon());
|
||||
return errorIcon;
|
||||
}
|
||||
if (widget->hasWarning()) {
|
||||
static const QIcon warningIcon(Utils::Icons::WARNING.icon());
|
||||
return warningIcon;
|
||||
}
|
||||
return widget->icon();
|
||||
return widget->displayIcon();
|
||||
}
|
||||
if (role == Qt::ToolTipRole) {
|
||||
return widget->validityMessage();
|
||||
|
Reference in New Issue
Block a user