forked from qt-creator/qt-creator
CompilationDatabase: Use ActionBuilder
Change-Id: I0469a25370592f62391d79fa1b8cc0f34ea362e7 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -48,21 +48,21 @@ class CompilationDatabaseProjectManagerPlugin final : public ExtensionSystem::IP
|
|||||||
ProjectManager::registerProjectType<CompilationDatabaseProject>(
|
ProjectManager::registerProjectType<CompilationDatabaseProject>(
|
||||||
Constants::COMPILATIONDATABASEMIMETYPE);
|
Constants::COMPILATIONDATABASEMIMETYPE);
|
||||||
|
|
||||||
Command *cmd = ActionManager::registerAction(&m_changeRootAction, CHANGEROOTDIR);
|
|
||||||
|
|
||||||
ActionContainer *mprojectContextMenu = ActionManager::actionContainer(
|
ActionContainer *mprojectContextMenu = ActionManager::actionContainer(
|
||||||
ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
||||||
mprojectContextMenu->addSeparator(ProjectExplorer::Constants::G_PROJECT_TREE);
|
mprojectContextMenu->addSeparator(ProjectExplorer::Constants::G_PROJECT_TREE);
|
||||||
mprojectContextMenu->addAction(cmd, ProjectExplorer::Constants::G_PROJECT_TREE);
|
|
||||||
|
|
||||||
connect(&m_changeRootAction, &QAction::triggered,
|
QAction *changeRootAction = nullptr;
|
||||||
ProjectTree::instance(), &ProjectTree::changeProjectRootDirectory);
|
ActionBuilder(this, CHANGEROOTDIR)
|
||||||
|
.setText(Tr::tr("Change Root Directory"))
|
||||||
|
.bindContextAction(&changeRootAction)
|
||||||
|
.addToContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT)
|
||||||
|
.addOnTriggered(ProjectTree::instance(), &ProjectTree::changeProjectRootDirectory);
|
||||||
|
|
||||||
const auto onProjectChanged = [this] {
|
const auto onProjectChanged = [changeRootAction] {
|
||||||
const auto currentProject = qobject_cast<CompilationDatabaseProject *>(
|
const auto currentProject = qobject_cast<CompilationDatabaseProject *>(
|
||||||
ProjectTree::currentProject());
|
ProjectTree::currentProject());
|
||||||
|
changeRootAction->setEnabled(currentProject);
|
||||||
m_changeRootAction.setEnabled(currentProject);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged,
|
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged,
|
||||||
@@ -75,8 +75,6 @@ class CompilationDatabaseProjectManagerPlugin final : public ExtensionSystem::IP
|
|||||||
addTest<CompilationDatabaseTests>();
|
addTest<CompilationDatabaseTests>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction m_changeRootAction{Tr::tr("Change Root Directory")};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // CompilationDatabaseProjectManager::Internal
|
} // CompilationDatabaseProjectManager::Internal
|
||||||
|
Reference in New Issue
Block a user