forked from qt-creator/qt-creator
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:
@@ -44,6 +44,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
|
#include <utils/basetreeview.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
@@ -430,7 +431,7 @@ public:
|
|||||||
// SelectorTree
|
// SelectorTree
|
||||||
//
|
//
|
||||||
|
|
||||||
class SelectorTree : public NavigationTreeView
|
class SelectorTree : public BaseTreeView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectorTree()
|
SelectorTree()
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/basetreeview.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
@@ -333,9 +334,7 @@ public:
|
|||||||
Qt::ItemFlags flags(int column) const override
|
Qt::ItemFlags flags(int column) const override
|
||||||
{
|
{
|
||||||
Q_UNUSED(column)
|
Q_UNUSED(column)
|
||||||
if (isEnabled())
|
return Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
return Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
|
||||||
return Qt::ItemIsSelectable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(int column, int role) const override
|
QVariant data(int column, int role) const override
|
||||||
@@ -348,6 +347,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
|
if (!isEnabled())
|
||||||
|
return Utils::Icons::PLUS.icon();
|
||||||
Kit *k = KitManager::find(m_kitId);
|
Kit *k = KitManager::find(m_kitId);
|
||||||
QTC_ASSERT(k, return QVariant());
|
QTC_ASSERT(k, return QVariant());
|
||||||
if (!k->isValid())
|
if (!k->isValid())
|
||||||
@@ -357,6 +358,11 @@ public:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Qt::TextColorRole: {
|
||||||
|
if (!isEnabled())
|
||||||
|
return Utils::creatorTheme()->color(Theme::TextColorDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::FontRole: {
|
case Qt::FontRole: {
|
||||||
QFont font = parent()->data(column, role).value<QFont>();
|
QFont font = parent()->data(column, role).value<QFont>();
|
||||||
if (TargetItem *targetItem = parent()->currentTargetItem())
|
if (TargetItem *targetItem = parent()->currentTargetItem())
|
||||||
@@ -369,7 +375,11 @@ public:
|
|||||||
case Qt::ToolTipRole: {
|
case Qt::ToolTipRole: {
|
||||||
Kit *k = KitManager::find(m_kitId);
|
Kit *k = KitManager::find(m_kitId);
|
||||||
QTC_ASSERT(k, return QVariant());
|
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:
|
case PanelWidgetRole:
|
||||||
@@ -396,6 +406,17 @@ public:
|
|||||||
return true;
|
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) {
|
if (role == ItemActivatedFromBelowRole) {
|
||||||
// I.e. 'Build' and 'Run' items were present and user clicked on them.
|
// I.e. 'Build' and 'Run' items were present and user clicked on them.
|
||||||
int child = children().indexOf(data.value<TreeItem *>());
|
int child = children().indexOf(data.value<TreeItem *>());
|
||||||
|
|||||||
Reference in New Issue
Block a user