From b2f5ed78e187fe57308549dde306563c7a9520e3 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 25 Nov 2019 10:09:21 +0100 Subject: ClangTools: Add "go to project settings" toolbar button With the introduction of the "Analyze Current File" action the widget to configure the diagnostic config was moved to the project panel (Project mode > Project Settings > Clang Tools). As not too many users are aware of the project settings there and navigating there involves more user interation now (mode switch, looking for the "Clang Tools" item), add a toolbar button as a shortcut. Change-Id: I4c864045ef41ff501d925d3175ce604def213f29 Reviewed-by: hjk Reviewed-by: Leena Miettinen Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectwindow.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/plugins/projectexplorer/projectwindow.cpp') diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index dfa20793e3..d72f7812ff 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -84,6 +84,8 @@ public: Qt::ItemFlags flags(int column) const override; bool setData(int column, const QVariant &, int role) override; + ProjectPanelFactory *factory() const { return m_factory; } + protected: ProjectPanelFactory *m_factory = nullptr; QPointer m_project; @@ -281,6 +283,13 @@ public: return activeItem ? activeItem->index() : QModelIndex(); } + TreeItem *itemForProjectPanel(Core::Id panelId) + { + return m_miscItem->findChildAtLevel(1, [panelId](const TreeItem *item){ + return static_cast(item)->factory()->id() == panelId; + }); + } + private: int m_currentChildIndex = 0; // Start with Build & Run. Project *m_project = nullptr; @@ -497,6 +506,14 @@ public: item->setData(0, QVariant(), ItemActivatedDirectlyRole); } + void activateProjectPanel(Core::Id panelId) + { + if (ProjectItem *projectItem = m_projectsModel.rootItem()->childAt(0)) { + if (TreeItem *item = projectItem->itemForProjectPanel(panelId)) + itemActivated(item->index()); + } + } + void openContextMenu(const QPoint &pos) { QMenu menu; @@ -606,6 +623,11 @@ ProjectWindow::ProjectWindow() setContextMenuPolicy(Qt::CustomContextMenu); } +void ProjectWindow::activateProjectPanel(Core::Id panelId) +{ + d->activateProjectPanel(panelId); +} + ProjectWindow::~ProjectWindow() = default; QSize SelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -- cgit v1.2.3