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);
|
const Core::Context projectContext(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||||
// ToDo: move this to QtCreator and add tr to the string then
|
// ToDo: move this to QtCreator and add tr to the string then
|
||||||
auto action = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
auto action = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
"Generate QRC Resource File"), parent);
|
"Generate QRC Resource File..."),
|
||||||
|
parent);
|
||||||
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
||||||
// todo make it more intelligent when it gets enabled
|
// todo make it more intelligent when it gets enabled
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
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
|
// ToDo: move this to QtCreator and add tr to the string then
|
||||||
auto rccAction = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
auto rccAction = new QAction(QCoreApplication::translate("QmlDesigner::GenerateResource",
|
||||||
"Generate Deployable Package"), parent);
|
"Generate Deployable Package..."),
|
||||||
|
parent);
|
||||||
rccAction->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
rccAction->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||||
&ProjectExplorer::SessionManager::startupProjectChanged, [rccAction]() {
|
&ProjectExplorer::SessionManager::startupProjectChanged, [rccAction]() {
|
||||||
@@ -340,7 +342,7 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
|||||||
|
|
||||||
Core::Command *cmd2 = Core::ActionManager::registerAction(rccAction,
|
Core::Command *cmd2 = Core::ActionManager::registerAction(rccAction,
|
||||||
"QmlProject.CreateRCCResource");
|
"QmlProject.CreateRCCResource");
|
||||||
QObject::connect(rccAction, &QAction::triggered, [] () {
|
QObject::connect(rccAction, &QAction::triggered, []() {
|
||||||
auto currentProject = ProjectExplorer::SessionManager::startupProject();
|
auto currentProject = ProjectExplorer::SessionManager::startupProject();
|
||||||
QTC_ASSERT(currentProject, return);
|
QTC_ASSERT(currentProject, return);
|
||||||
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
const FilePath projectPath = currentProject->projectFilePath().parentDir();
|
||||||
@@ -558,8 +560,11 @@ void GenerateResource::generateMenuEntry(QObject *parent)
|
|||||||
"Successfully generated deployable package\n %1")
|
"Successfully generated deployable package\n %1")
|
||||||
.arg(resourceFileName.toString()));
|
.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
|
} // namespace QmlDesigner
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <qmljseditor/qmljseditorconstants.h>
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
|
|
||||||
|
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -38,16 +40,16 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
ShortCutManager::ShortCutManager()
|
ShortCutManager::ShortCutManager()
|
||||||
: QObject(),
|
: QObject()
|
||||||
m_exportAsImageAction(tr("Export as &Image...")),
|
, m_exportAsImageAction(tr("Export as Image..."))
|
||||||
m_undoAction(tr("&Undo")),
|
, m_undoAction(tr("&Undo"))
|
||||||
m_redoAction(tr("&Redo")),
|
, m_redoAction(tr("&Redo"))
|
||||||
m_deleteAction(tr("Delete")),
|
, m_deleteAction(tr("Delete"))
|
||||||
m_cutAction(tr("Cu&t")),
|
, m_cutAction(tr("Cu&t"))
|
||||||
m_copyAction(tr("&Copy")),
|
, m_copyAction(tr("&Copy"))
|
||||||
m_pasteAction(tr("&Paste")),
|
, m_pasteAction(tr("&Paste"))
|
||||||
m_selectAllAction(tr("Select &All")),
|
, m_selectAllAction(tr("Select &All"))
|
||||||
m_escapeAction(this)
|
, m_escapeAction(this)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -101,7 +103,11 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
connect(&m_exportAsImageAction, &QAction::triggered, [] {
|
connect(&m_exportAsImageAction, &QAction::triggered, [] {
|
||||||
QmlDesignerPlugin::instance()->viewManager().exportAsImage();
|
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
|
//Close Editor
|
||||||
Core::ActionManager::registerAction(&m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
@@ -24,7 +26,7 @@ namespace QmlProjectManager {
|
|||||||
namespace GenerateCmake {
|
namespace GenerateCmake {
|
||||||
|
|
||||||
const QString MENU_ITEM_CONVERT = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
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",
|
const QString ERROR_TITLE = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
||||||
"Creating Project");
|
"Creating Project");
|
||||||
const QString SUCCESS_TITLE = QCoreApplication::translate("QmlDesigner::CmakeProjectConverter",
|
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)
|
void CmakeProjectConverter::generateMenuEntry(QObject *parent)
|
||||||
{
|
{
|
||||||
Core::ActionContainer *menu =
|
Core::ActionContainer *exportMenu = Core::ActionManager::actionContainer(
|
||||||
Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
QmlProjectManager::Constants::EXPORT_MENU);
|
||||||
auto action = new QAction(MENU_ITEM_CONVERT, parent);
|
auto action = new QAction(MENU_ITEM_CONVERT, parent);
|
||||||
QObject::connect(action, &QAction::triggered, CmakeProjectConverter::onConvertProject);
|
QObject::connect(action, &QAction::triggered, CmakeProjectConverter::onConvertProject);
|
||||||
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.ConvertToCmakeProject");
|
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()));
|
action->setEnabled(isProjectConvertable(ProjectExplorer::SessionManager::startupProject()));
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
||||||
|
@@ -14,18 +14,19 @@
|
|||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <qmlprojectmanager/qmlmainfileaspect.h>
|
||||||
#include <qmlprojectmanager/qmlproject.h>
|
#include <qmlprojectmanager/qmlproject.h>
|
||||||
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
#include <qmlprojectmanager/qmlprojectmanagerconstants.h>
|
||||||
#include <qmlprojectmanager/qmlmainfileaspect.h>
|
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtConcurrent>
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace QmlProjectManager::GenerateCmake::Constants;
|
using namespace QmlProjectManager::GenerateCmake::Constants;
|
||||||
@@ -56,16 +57,27 @@ enum ProjectDirectoryError {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const QString MENU_ITEM_GENERATE = QCoreApplication::translate("QmlDesigner::GenerateCmake",
|
const QString MENU_ITEM_GENERATE = QCoreApplication::translate("QmlDesigner::GenerateCmake",
|
||||||
"Generate CMake Build Files");
|
"Generate CMake Build Files...");
|
||||||
|
|
||||||
void generateMenuEntry(QObject *parent)
|
void generateMenuEntry(QObject *parent)
|
||||||
{
|
{
|
||||||
Core::ActionContainer *menu =
|
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||||
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);
|
auto action = new QAction(MENU_ITEM_GENERATE, parent);
|
||||||
QObject::connect(action, &QAction::triggered, GenerateCmake::onGenerateCmakeLists);
|
QObject::connect(action, &QAction::triggered, GenerateCmake::onGenerateCmakeLists);
|
||||||
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.CreateCMakeLists");
|
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);
|
action->setEnabled(false);
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
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 LAST_USED_LANGUAGE[] = "QmlProjectManager.QmlRunConfiguration.LastUsedLanguage";
|
||||||
const char USER_ENVIRONMENT_CHANGES_KEY[] = "QmlProjectManager.QmlRunConfiguration.UserEnvironmentChanges";
|
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 Constants
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
Reference in New Issue
Block a user