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/optional.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -400,6 +401,20 @@ QIcon Kit::icon() const
|
|||||||
return d->m_cachedIcon;
|
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
|
FilePath Kit::iconPath() const
|
||||||
{
|
{
|
||||||
return d->m_iconPath;
|
return d->m_iconPath;
|
||||||
|
@@ -96,7 +96,8 @@ public:
|
|||||||
// all other aspects are equal.
|
// all other aspects are equal.
|
||||||
int weight() const;
|
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;
|
Utils::FilePath iconPath() const;
|
||||||
void setIconPath(const Utils::FilePath &path);
|
void setIconPath(const Utils::FilePath &path);
|
||||||
void setDeviceTypeForIcon(Core::Id deviceType);
|
void setDeviceTypeForIcon(Core::Id deviceType);
|
||||||
|
@@ -72,6 +72,11 @@ void KitChooser::onManageButtonClicked()
|
|||||||
Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this);
|
Core::ICore::showOptionsDialog(Constants::KITS_SETTINGS_PAGE_ID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KitChooser::setShowIcons(bool showIcons)
|
||||||
|
{
|
||||||
|
m_showIcons = showIcons;
|
||||||
|
}
|
||||||
|
|
||||||
void KitChooser::onCurrentIndexChanged()
|
void KitChooser::onCurrentIndexChanged()
|
||||||
{
|
{
|
||||||
const Id id = Id::fromSetting(m_chooser->currentData());
|
const Id id = Id::fromSetting(m_chooser->currentData());
|
||||||
@@ -127,9 +132,12 @@ void KitChooser::populate()
|
|||||||
foreach (Kit *kit, KitManager::sortKits(KitManager::kits())) {
|
foreach (Kit *kit, KitManager::sortKits(KitManager::kits())) {
|
||||||
if (m_kitPredicate(kit)) {
|
if (m_kitPredicate(kit)) {
|
||||||
m_chooser->addItem(kitText(kit), kit->id().toSetting());
|
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) {
|
if (!didActivate && kit->id() == lastKit) {
|
||||||
m_chooser->setCurrentIndex(m_chooser->count() - 1);
|
m_chooser->setCurrentIndex(pos);
|
||||||
didActivate = true;
|
didActivate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ public:
|
|||||||
Core::Id currentKitId() const;
|
Core::Id currentKitId() const;
|
||||||
|
|
||||||
void setKitPredicate(const Kit::Predicate &predicate);
|
void setKitPredicate(const Kit::Predicate &predicate);
|
||||||
|
void setShowIcons(bool showIcons);
|
||||||
|
|
||||||
Kit *currentKit() const;
|
Kit *currentKit() const;
|
||||||
bool hasStartupKit() const { return m_hasStartupKit; }
|
bool hasStartupKit() const { return m_hasStartupKit; }
|
||||||
@@ -78,6 +79,7 @@ private:
|
|||||||
QComboBox *m_chooser;
|
QComboBox *m_chooser;
|
||||||
QPushButton *m_manageButton;
|
QPushButton *m_manageButton;
|
||||||
bool m_hasStartupKit = false;
|
bool m_hasStartupKit = false;
|
||||||
|
bool m_showIcons = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -155,9 +156,15 @@ QString KitManagerConfigWidget::displayName() const
|
|||||||
return m_cachedDisplayName;
|
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()
|
void KitManagerConfigWidget::apply()
|
||||||
@@ -199,16 +206,6 @@ bool KitManagerConfigWidget::isDirty() const
|
|||||||
|| m_isDefaultKit != (KitManager::defaultKit() == m_kit);
|
|| 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
|
QString KitManagerConfigWidget::validityMessage() const
|
||||||
{
|
{
|
||||||
Tasks tmp;
|
Tasks tmp;
|
||||||
|
@@ -52,13 +52,11 @@ public:
|
|||||||
~KitManagerConfigWidget() override;
|
~KitManagerConfigWidget() override;
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
QIcon icon() const;
|
QIcon displayIcon() const;
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
void discard();
|
void discard();
|
||||||
bool isDirty() const;
|
bool isDirty() const;
|
||||||
bool isValid() const;
|
|
||||||
bool hasWarning() const;
|
|
||||||
QString validityMessage() const;
|
QString validityMessage() const;
|
||||||
void addAspectToWorkingCopy(KitAspect *aspect);
|
void addAspectToWorkingCopy(KitAspect *aspect);
|
||||||
void makeStickySubWidgetsReadOnly();
|
void makeStickySubWidgetsReadOnly();
|
||||||
|
@@ -85,15 +85,7 @@ public:
|
|||||||
return baseName;
|
return baseName;
|
||||||
}
|
}
|
||||||
if (role == Qt::DecorationRole) {
|
if (role == Qt::DecorationRole) {
|
||||||
if (!widget->isValid()) {
|
return widget->displayIcon();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
if (role == Qt::ToolTipRole) {
|
if (role == Qt::ToolTipRole) {
|
||||||
return widget->validityMessage();
|
return widget->validityMessage();
|
||||||
|
Reference in New Issue
Block a user