QmlProject: Disable or hide qmlproject related actions

Generate CMake Build files is only relevant for .qmlprojects
and should only be enabled for those.

Export as latest Project Format is only relevant for QDS and should be
hidden in Qt Creator.

Task-number: QTCREATORBUG-27935
Change-Id: Iac6ca6927443a92dfb501f76c855fd641aaf10da
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2022-07-20 10:36:44 +02:00
parent 2984934af9
commit e1b0ba2473
2 changed files with 9 additions and 5 deletions

View File

@@ -90,11 +90,14 @@ void generateMenuEntry(QObject *parent)
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.CreateCMakeLists");
menu->addAction(cmd, Core::Constants::G_FILE_EXPORT);
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
action->setEnabled(false);
QObject::connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged, [action]() {
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
});
&ProjectExplorer::SessionManager::startupProjectChanged,
[action]() {
auto qmlProject = qobject_cast<QmlProject *>(
ProjectExplorer::SessionManager::startupProject());
action->setEnabled(qmlProject != nullptr);
});
}
void onGenerateCmakeLists()

View File

@@ -379,7 +379,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
}
GenerateCmake::generateMenuEntry(this);
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
if (QmlProject::isQtDesignStudio())
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
return true;
}