Fix various context menu actions from project managers

The correct pattern is this: The actions in the build menu are supposed
to be for the startup project. They should use the global context and be
manually hidden/shown if the startup project changes.

This fixes a crash on assigning keyboard shortcut to the edit files
context menu action.

The slot connected assumed that the action could only be triggered via
the context menu. By using ProjectTree;:currentProject() the code now
works even if the project tree is not actually focused.

It also fixes that the "Run CMake" action was shown even in the build menu,
even though a non cmake project was the startup project.

Change-Id: I0bb8086d8b1078b4c71c3b5ba9d7f8596757e724
Task-number: QTCREATORBUG-14728
Task-number: QTCREATORBUG-14768
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Daniel Teske
2015-07-14 13:10:18 +02:00
parent 513c4e0a89
commit cea36f1376
4 changed files with 18 additions and 24 deletions

View File

@@ -58,10 +58,6 @@ using namespace ProjectExplorer;
namespace GenericProjectManager {
namespace Internal {
GenericProjectPlugin::GenericProjectPlugin()
: m_contextMenuProject(0)
{ }
bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage)
{
Q_UNUSED(errorMessage)
@@ -85,15 +81,14 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage
connect(editFilesAction, &QAction::triggered, this, &GenericProjectPlugin::editFiles);
connect(ProjectTree::instance(), &ProjectTree::aboutToShowContextMenu,
[this] (Project *project, Node *) { m_contextMenuProject = project; });
return true;
}
void GenericProjectPlugin::editFiles()
{
GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject);
auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject());
if (!genericProject)
return;
SelectableFilesDialogEditFiles sfd(genericProject->projectFilePath().toFileInfo().path(), genericProject->files(),
ICore::mainWindow());
if (sfd.exec() == QDialog::Accepted)