diff options
author | hjk <hjk@theqtcompany.com> | 2016-09-16 13:27:22 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2016-09-19 12:43:15 +0000 |
commit | b259939755fa6037db1af7053f8cf9493ef8eb23 (patch) | |
tree | d40453011a6ec166fd40c2a23bda1f0a932bf40e /src/plugins/projectexplorer/targetsettingspanel.cpp | |
parent | 8c76f08ce4630ee6fd21a5e738ca1e01da84d6da (diff) |
ProjectWindow: Make kit activation easier
Add a [+] icon for inactive kit entries, add a "Click to activate" to
the tool tip, and allow single click activation.
Change-Id: I1219eb54b4e3a077ef133afaf71134bb35e14fb7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/targetsettingspanel.cpp')
-rw-r--r-- | src/plugins/projectexplorer/targetsettingspanel.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 320127cfff..64e03b9d77 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -52,6 +52,7 @@ #include <extensionsystem/pluginmanager.h> #include <utils/algorithm.h> +#include <utils/basetreeview.h> #include <utils/qtcassert.h> #include <utils/treemodel.h> #include <utils/utilsicons.h> @@ -333,9 +334,7 @@ public: Qt::ItemFlags flags(int column) const override { Q_UNUSED(column) - if (isEnabled()) - return Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - return Qt::ItemIsSelectable; + return Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } QVariant data(int column, int role) const override @@ -348,6 +347,8 @@ public: } case Qt::DecorationRole: { + if (!isEnabled()) + return Utils::Icons::PLUS.icon(); Kit *k = KitManager::find(m_kitId); QTC_ASSERT(k, return QVariant()); if (!k->isValid()) @@ -357,6 +358,11 @@ public: break; } + case Qt::TextColorRole: { + if (!isEnabled()) + return Utils::creatorTheme()->color(Theme::TextColorDisabled); + } + case Qt::FontRole: { QFont font = parent()->data(column, role).value<QFont>(); if (TargetItem *targetItem = parent()->currentTargetItem()) @@ -369,7 +375,11 @@ public: case Qt::ToolTipRole: { Kit *k = KitManager::find(m_kitId); QTC_ASSERT(k, return QVariant()); - return k->toHtml(); + QString toolTip; + if (!isEnabled()) + toolTip = "<h3>" + tr("Click to activate:") + "</h3>"; + toolTip += k->toHtml(); + return toolTip; } case PanelWidgetRole: @@ -396,6 +406,17 @@ public: return true; } + if (role == BaseTreeView::ItemClickedRole) { + if (!isEnabled()) { + Kit *k = KitManager::find(m_kitId); + Target *t = m_project->createTarget(k); + m_project->addTarget(t); + QTC_ASSERT(!data.isValid(), return false); + SessionManager::setActiveTarget(m_project, target(), SetActive::Cascade); + return true; + } + } + if (role == ItemActivatedFromBelowRole) { // I.e. 'Build' and 'Run' items were present and user clicked on them. int child = children().indexOf(data.value<TreeItem *>()); |