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>
This commit is contained in:
hjk
2016-09-16 13:27:22 +02:00
committed by hjk
parent 8c76f08ce4
commit b259939755
2 changed files with 27 additions and 5 deletions

View File

@@ -44,6 +44,7 @@
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
#include <utils/treemodel.h>
#include <utils/basetreeview.h>
#include <QApplication>
#include <QComboBox>
@@ -430,7 +431,7 @@ public:
// SelectorTree
//
class SelectorTree : public NavigationTreeView
class SelectorTree : public BaseTreeView
{
public:
SelectorTree()

View File

@@ -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;
}
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 *>());