forked from qt-creator/qt-creator
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 <hjk@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -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<Project> 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<const MiscSettingsPanelItem *>(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
|
||||
|
||||
Reference in New Issue
Block a user