forked from qt-creator/qt-creator
QmlDesigner: Add new menu for export actions
Task-number: QDS-8092 Change-Id: If83ea84fded27485c50865e49d8d184fecc6d454 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -182,7 +182,8 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
||||
const Core::Context projectContext(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
// ToDo: move this to QtCreator and add tr to the string then
|
||||
auto action = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"Generate QRC Resource File"), parent);
|
||||
"Generate QRC Resource File..."),
|
||||
parent);
|
||||
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
||||
// todo make it more intelligent when it gets enabled
|
||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||
@@ -331,7 +332,8 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
||||
|
||||
// ToDo: move this to QtCreator and add tr to the string then
|
||||
auto rccAction = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||
"Generate Deployable Package"), parent);
|
||||
"Generate Deployable Package..."),
|
||||
parent);
|
||||
rccAction->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||
&ProjectExplorer::SessionManager::startupProjectChanged, [rccAction]() {
|
||||
@@ -340,7 +342,7 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
||||
|
||||
Core::Command *cmd2 = Core::ActionManager::registerAction(rccAction,
|
||||
"QmlProject.CreateRCCResource");
|
||||
QObject::connect(rccAction, &QAction::triggered, [] () {
|
||||
QObject::connect(rccAction, &QAction::triggered, []() {
|
||||
auto currentProject = ProjectExplorer::SessionManager::startupProject();
|
||||
QTC_ASSERT(currentProject, return);
|
||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
||||
@@ -558,8 +560,11 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
||||
"Successfully generated deployable package\n %1")
|
||||
.arg(resourceFileName.toString()));
|
||||
});
|
||||
menu->addAction(cmd, Core::Constants::G_FILE_EXPORT);
|
||||
menu->addAction(cmd2, Core::Constants::G_FILE_EXPORT);
|
||||
|
||||
Core::ActionContainer *exportMenu = Core::ActionManager::actionContainer(
|
||||
QmlProjectManager::Constants::EXPORT_MENU);
|
||||
exportMenu->addAction(cmd, QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
||||
exportMenu->addAction(cmd2, QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -38,16 +40,16 @@
|
||||
namespace QmlDesigner {
|
||||
|
||||
ShortCutManager::ShortCutManager()
|
||||
: QObject(),
|
||||
m_exportAsImageAction(tr("Export as &Image...")),
|
||||
m_undoAction(tr("&Undo")),
|
||||
m_redoAction(tr("&Redo")),
|
||||
m_deleteAction(tr("Delete")),
|
||||
m_cutAction(tr("Cu&t")),
|
||||
m_copyAction(tr("&Copy")),
|
||||
m_pasteAction(tr("&Paste")),
|
||||
m_selectAllAction(tr("Select &All")),
|
||||
m_escapeAction(this)
|
||||
: QObject()
|
||||
, m_exportAsImageAction(tr("Export as Image..."))
|
||||
, m_undoAction(tr("&Undo"))
|
||||
, m_redoAction(tr("&Redo"))
|
||||
, m_deleteAction(tr("Delete"))
|
||||
, m_cutAction(tr("Cu&t"))
|
||||
, m_copyAction(tr("&Copy"))
|
||||
, m_pasteAction(tr("&Paste"))
|
||||
, m_selectAllAction(tr("Select &All"))
|
||||
, m_escapeAction(this)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -101,7 +103,11 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
||||
connect(&m_exportAsImageAction, &QAction::triggered, [] {
|
||||
QmlDesignerPlugin::instance()->viewManager().exportAsImage();
|
||||
});
|
||||
fileMenu->addAction(command, Core::Constants::G_FILE_SAVE);
|
||||
|
||||
Core::ActionContainer *exportMenu = Core::ActionManager::actionContainer(
|
||||
QmlProjectManager::Constants::EXPORT_MENU);
|
||||
|
||||
exportMenu->addAction(command, QmlProjectManager::Constants::G_EXPORT_CONVERT);
|
||||
|
||||
//Close Editor
|
||||
Core::ActionManager::registerAction(&m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
||||
|
@@ -13,6 +13,8 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
#include <QRegularExpression>
|
||||
@@ -24,7 +26,7 @@ namespace QmlProjectManager {
|
||||
namespace GenerateCmake {
|
||||
|
||||
const QString MENU_ITEM_CONVERT = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
||||
"Export as Latest Project Format");
|
||||
"Export as Latest Project Format...");
|
||||
const QString ERROR_TITLE = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
||||
"Creating Project");
|
||||
const QString SUCCESS_TITLE = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
||||
@@ -36,12 +38,12 @@ const QString SUCCESS_TEXT = QCoreApplication::translate("QmlDesigner::CmakeProj
|
||||
|
||||
void CmakeProjectConverter::generateMenuEntry(QObject *parent)
|
||||
{
|
||||
Core::ActionContainer *menu =
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||
Core::ActionContainer *exportMenu = Core::ActionManager::actionContainer(
|
||||
QmlProjectManager::Constants::EXPORT_MENU);
|
||||
auto action = new QAction(MENU_ITEM_CONVERT, parent);
|
||||
QObject::connect(action, &QAction::triggered, CmakeProjectConverter::onConvertProject);
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.ConvertToCmakeProject");
|
||||
menu->addAction(cmd, Core::Constants::G_FILE_EXPORT);
|
||||
exportMenu->addAction(cmd, QmlProjectManager::Constants::G_EXPORT_CONVERT);
|
||||
|
||||
action->setEnabled(isProjectConvertable(ProjectExplorer::SessionManager::startupProject()));
|
||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||
|
@@ -14,18 +14,19 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmlprojectmanager/qmlmainfileaspect.h>
|
||||
#include <qmlprojectmanager/qmlproject.h>
|
||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||
#include <qmlprojectmanager/qmlmainfileaspect.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QtConcurrent>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <QtConcurrent>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace QmlProjectManager::GenerateCmake::Constants;
|
||||
@@ -56,16 +57,27 @@ enum ProjectDirectoryError {
|
||||
};
|
||||
|
||||
const QString MENU_ITEM_GENERATE = QCoreApplication::translate("QmlDesigner::GenerateCmake",
|
||||
"Generate CMake Build Files");
|
||||
"Generate CMake Build Files...");
|
||||
|
||||
void generateMenuEntry(QObject *parent)
|
||||
{
|
||||
Core::ActionContainer *menu =
|
||||
Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||
|
||||
Core::ActionContainer *exportMenu = Core::ActionManager::createMenu(
|
||||
QmlProjectManager::Constants::EXPORT_MENU);
|
||||
|
||||
exportMenu->menu()->setTitle(
|
||||
QCoreApplication::translate("QmlDesigner::GenerateCmake", "Export Project"));
|
||||
menu->addMenu(exportMenu, Core::Constants::G_FILE_EXPORT);
|
||||
|
||||
exportMenu->appendGroup(QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
||||
exportMenu->appendGroup(QmlProjectManager::Constants::G_EXPORT_CONVERT);
|
||||
exportMenu->addSeparator(QmlProjectManager::Constants::G_EXPORT_CONVERT);
|
||||
|
||||
auto action = new QAction(MENU_ITEM_GENERATE, parent);
|
||||
QObject::connect(action, &QAction::triggered, GenerateCmake::onGenerateCmakeLists);
|
||||
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.CreateCMakeLists");
|
||||
menu->addAction(cmd, Core::Constants::G_FILE_EXPORT);
|
||||
exportMenu->addAction(cmd, QmlProjectManager::Constants::G_EXPORT_GENERATE);
|
||||
|
||||
action->setEnabled(false);
|
||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||
|
@@ -16,5 +16,9 @@ const char USE_MULTILANGUAGE_KEY[] = "QmlProjectManager.QmlRunConfiguration.UseM
|
||||
const char LAST_USED_LANGUAGE[] = "QmlProjectManager.QmlRunConfiguration.LastUsedLanguage";
|
||||
const char USER_ENVIRONMENT_CHANGES_KEY[] = "QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges";
|
||||
|
||||
const char EXPORT_MENU[] = "QmlDesigner.ExportMenu";
|
||||
const char G_EXPORT_GENERATE[] = "QmlDesigner.Group.GenerateProject";
|
||||
const char G_EXPORT_CONVERT[] = "QmlDesigner.Group.ConvertProject";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlProjectManager
|
||||
|
Reference in New Issue
Block a user