Commit bf3f89d2 authored by Guenter Schwann's avatar Guenter Schwann
Browse files

696: Move IVE toolbar actions to actionbar

parent 65e9e66e
Pipeline #6640 passed with stage
in 7 minutes and 53 seconds
......@@ -81,8 +81,6 @@ MainWindow::MainWindow(ive::IVEditorCore *core, QWidget *parent)
connect(m_core->actionSaveFile(), &QAction::triggered, this, [=]() { exportXml(); });
connect(m_core->actionSaveFileAs(), &QAction::triggered, this, [=]() { exportXmlAs(); });
connect(m_core->actionQuit(), &QAction::triggered, this, &MainWindow::onQuitRequested);
connect(m_core->actionExportFunctions(), &QAction::triggered, this, &MainWindow::onExportFunctionsRequested);
connect(m_core->actionExportType(), &QAction::triggered, this, &MainWindow::onExportTypeRequested);
// Register the actions to the action manager
ActionsManager::registerAction(Q_FUNC_INFO, m_core->actionNewFile(), "Create file", "Create new empty file");
......@@ -177,16 +175,6 @@ void MainWindow::onCreateFileRequested()
}
}
void MainWindow::onExportFunctionsRequested()
{
m_core->document()->exportSelectedFunctions();
}
void MainWindow::onExportTypeRequested()
{
m_core->document()->exportSelectedType();
}
/*!
* \brief Exports the document document to the output file \a savePath using the template file \a templatePath.
* Returns \c true on success.
......
......@@ -57,8 +57,6 @@ protected:
public Q_SLOTS:
void onOpenFileRequested();
void onCreateFileRequested();
void onExportFunctionsRequested();
void onExportTypeRequested();
bool exportXml(const QString &savePath = QString(), const QString &templatePath = QString());
bool exportXmlAs(const QString &savePath = QString(), const QString &templatePath = QString());
void onQuitRequested();
......
......@@ -28,6 +28,7 @@
#include "itemeditor/ivfunctiongraphicsitem.h"
#include "itemeditor/ivitemmodel.h"
#include "ivcreatortool.h"
#include "iveditorcore.h"
#include "ivexporter.h"
#include "ivvisualizationmodelbase.h"
#include "properties/ivpropertiesdialog.h"
......@@ -45,10 +46,11 @@
namespace ive {
IVAppWidget::IVAppWidget(InterfaceDocument *doc, QWidget *parent)
IVAppWidget::IVAppWidget(IVEditorCore *core, QWidget *parent)
: QWidget(parent)
, ui(new Ui::IVAppWidget)
, m_document(doc)
, m_ivCore(core)
, m_document(core->document())
{
ui->setupUi(this);
......@@ -66,6 +68,10 @@ IVAppWidget::IVAppWidget(InterfaceDocument *doc, QWidget *parent)
for (QAction *action : initActions()) {
ui->toolBar->addAction(action);
}
ui->toolBar->addSeparator();
for (QAction *action : initViewActions()) {
ui->toolBar->addAction(action);
}
});
}
......@@ -493,4 +499,25 @@ QVector<QAction *> IVAppWidget::initActions()
return m_toolbarActions;
}
QVector<QAction *> IVAppWidget::initViewActions()
{
if (!m_viewActions.isEmpty() || !m_ivCore) {
return m_viewActions;
}
m_viewActions.append(m_ivCore->actionToggleMinimap());
m_viewActions.append(m_ivCore->actionToggleE2EView());
m_viewActions.append(m_ivCore->actionExportFunctions());
m_viewActions.append(m_ivCore->actionExportType());
auto actionSaveSceneRender =
new QAction(QIcon(QLatin1String(":/toolbar/icns/render.svg")), tr("Render Scene..."), this);
ive::ActionsManager::registerAction(
Q_FUNC_INFO, actionSaveSceneRender, "Render", "Save current scene complete render.");
connect(actionSaveSceneRender, &QAction::triggered, this, [this]() { m_ivCore->onSaveRenderRequested(); });
m_viewActions.append(actionSaveSceneRender);
return m_viewActions;
}
} // namespace ive
......@@ -32,6 +32,7 @@ namespace ive {
class GraphicsView;
class InterfaceDocument;
class IVCreatorTool;
class IVEditorCore;
/*!
The main widget including all of the IV editor UI
......@@ -41,7 +42,7 @@ class IVAppWidget : public QWidget
Q_OBJECT
public:
explicit IVAppWidget(InterfaceDocument *doc, QWidget *parent = nullptr);
explicit IVAppWidget(IVEditorCore *core, QWidget *parent = nullptr);
~IVAppWidget();
GraphicsView *graphicsView() const;
......@@ -68,6 +69,7 @@ private:
void initSharedView();
QVector<QAction *> initActions();
QVector<QAction *> initViewActions();
Ui::IVAppWidget *ui = nullptr;
IVCreatorTool *m_tool { nullptr };
......@@ -77,8 +79,11 @@ private:
QAction *m_actZoomOut { nullptr };
QAction *m_actExitToRoot { nullptr };
QAction *m_actExitToParent { nullptr };
QVector<QAction *> m_toolbarActions;
QVector<QAction *> m_viewActions;
QPointer<IVEditorCore> m_ivCore;
QPointer<InterfaceDocument> m_document;
};
......
......@@ -93,7 +93,7 @@ shared::ui::GraphicsViewBase *IVEditorCore::chartView()
QWidget *IVEditorCore::mainwidget()
{
if (!m_mainWidget) {
m_mainWidget = new IVAppWidget(m_document);
m_mainWidget = new IVAppWidget(this);
}
return m_mainWidget;
}
......@@ -125,7 +125,9 @@ void IVEditorCore::populateCommandLineArguments(shared::CommandLineParser *parse
QAction *IVEditorCore::actionExportFunctions()
{
if (m_actionExportFunctions == nullptr) {
m_actionExportFunctions = new QAction(tr("Export selected entity"), this);
m_actionExportFunctions =
new QAction(QIcon(":/toolbar/icns/export_selected.svg"), tr("Export selected entity"), this);
connect(m_actionExportFunctions, &QAction::triggered, m_document, &InterfaceDocument::exportSelectedFunctions);
}
return m_actionExportFunctions;
}
......@@ -133,7 +135,9 @@ QAction *IVEditorCore::actionExportFunctions()
QAction *IVEditorCore::actionExportType()
{
if (m_actionExportType == nullptr) {
m_actionExportType = new QAction(tr("Export component type"), this);
m_actionExportType =
new QAction(QIcon(":/toolbar/icns/export_component_type.svg"), tr("Export component type"), this);
connect(m_actionExportType, &QAction::triggered, m_document, &InterfaceDocument::exportSelectedType);
}
return m_actionExportType;
}
......@@ -141,7 +145,8 @@ QAction *IVEditorCore::actionExportType()
QAction *IVEditorCore::actionToggleE2EView()
{
if (m_actionToggleE2EView == nullptr) {
m_actionToggleE2EView = new QAction(tr("&Show end to end dataflow"), this);
m_actionToggleE2EView =
new QAction(QIcon(QIcon(":/toolbar/icns/end_to_end.png")), tr("Show end to end dataflow"), this);
m_actionToggleE2EView->setCheckable(true);
}
return m_actionToggleE2EView;
......@@ -489,7 +494,7 @@ void IVEditorCore::onSaveRenderRequested()
dialog.setDefaultSuffix(".png");
if (dialog.exec() == QDialog::Accepted) {
const QString fileName = dialog.selectedUrls().value(0).toLocalFile();
// saveSceneRender(fileName);
saveSceneRender(fileName);
}
}
......
......@@ -35,12 +35,10 @@
namespace spctr {
IVEditorData::IVEditorData(
SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions, QObject *parent)
IVEditorData::IVEditorData(SpaceCreatorProjectManager *projectManager, QObject *parent)
: QObject(parent)
, m_undoGroup(new QUndoGroup(this))
, m_projectManager(projectManager)
, m_ivActions(ivActions)
{
Core::Context contexts;
contexts.add(spctr::Constants::K_IV_EDITOR_ID);
......@@ -73,30 +71,10 @@ IVEditorData::~IVEditorData()
Core::IEditor *IVEditorData::createEditor()
{
auto *ivEditor = new IVQtCEditor(m_projectManager, m_ivActions);
connect(ivEditor->ivDocument(), &spctr::IVEditorDocument::ivDataLoaded, this,
[this](const QString &fileName, IVEditorCorePtr data) {
data->minimapView()->setVisible(m_minimapVisible);
m_undoGroup->addStack(data->undoStack());
});
auto *ivEditor = new IVQtCEditor(m_projectManager);
return ivEditor;
}
void IVEditorData::showMinimap(bool visible)
{
m_minimapVisible = visible;
for (auto openedDocument : Core::DocumentModel::openedDocuments()) {
if (auto document = qobject_cast<spctr::IVEditorDocument *>(openedDocument)) {
if (document->ivEditorCore()) {
document->ivEditorCore()->minimapView()->setVisible(visible);
}
}
}
}
void IVEditorData::onCurrentEditorChanged(Core::IEditor *editor)
{
if (auto ivEditor = qobject_cast<IVQtCEditor *>(editor)) {
......
......@@ -37,14 +37,11 @@ class IVEditorData : public QObject
{
Q_OBJECT
public:
IVEditorData(
SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions, QObject *parent = nullptr);
IVEditorData(SpaceCreatorProjectManager *projectManager, QObject *parent = nullptr);
~IVEditorData() override;
Core::IEditor *createEditor();
void showMinimap(bool visible);
IVEditorCorePtr ivPlugin(const QString &fileName);
private Q_SLOTS:
......@@ -54,10 +51,7 @@ private:
MscContext *m_context = nullptr;
QUndoGroup *m_undoGroup = nullptr;
bool m_minimapVisible = false;
QPointer<SpaceCreatorProjectManager> m_projectManager;
QList<QAction *> m_ivActions;
};
}
......@@ -27,10 +27,9 @@
namespace spctr {
IVEditorFactory::IVEditorFactory(
SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions, QObject *parent)
IVEditorFactory::IVEditorFactory(SpaceCreatorProjectManager *projectManager, QObject *parent)
: IEditorFactory()
, m_editorData(new IVEditorData(projectManager, ivActions))
, m_editorData(new IVEditorData(projectManager))
{
setId(spctr::Constants::K_IV_EDITOR_ID);
setDisplayName(QCoreApplication::translate("IV Editor", spctr::Constants::C_IVEDITOR_DISPLAY_NAME));
......
......@@ -34,8 +34,7 @@ class IVEditorFactory : public Core::IEditorFactory
Q_OBJECT
public:
explicit IVEditorFactory(
SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions, QObject *parent);
explicit IVEditorFactory(SpaceCreatorProjectManager *projectManager, QObject *parent);
#if QTC_VERSION == 48
Core::IEditor *createEditor() override { return createIVEditor(); }
......
......@@ -73,6 +73,7 @@ void IVMainWidget::init()
m_plugin->document()->init();
layout->addWidget(m_plugin->mainwidget());
connect(m_plugin->actionToggleE2EView(), &QAction::triggered, this, &IVMainWidget::requestE2EDataflow);
m_plugin->setupMiniMap();
}
......
......@@ -38,6 +38,9 @@ public:
IVEditorCorePtr ivPlugin() const;
Q_SIGNALS:
void requestE2EDataflow();
public Q_SLOTS:
void setMinimapVisible(bool visible);
......
......@@ -26,27 +26,29 @@
#include "mainmodel.h"
#include "msceditorcore.h"
#include "spacecreatorpluginconstants.h"
#include "spacecreatorprojectimpl.h"
#include "spacecreatorprojectmanager.h"
#include <QFileInfo>
#include <QToolBar>
#include <QUndoCommand>
#include <editormanager/editormanager.h>
#include <utils/qtcassert.h>
namespace spctr {
IVQtCEditor::IVQtCEditor(SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions)
IVQtCEditor::IVQtCEditor(SpaceCreatorProjectManager *projectManager)
: Core::IEditor()
, m_document(new IVEditorDocument(projectManager, this))
, m_editorWidget(new IVMainWidget)
, m_projectManager(projectManager)
, m_globalToolbarActions(ivActions)
{
setContext(Core::Context(spctr::Constants::K_IV_EDITOR_ID));
setWidget(m_editorWidget);
connect(m_document, &spctr::IVEditorDocument::ivDataLoaded, this,
[this](const QString &, IVEditorCorePtr data) { m_editorWidget->init(data); });
connect(m_editorWidget, &IVMainWidget::requestE2EDataflow, this, &IVQtCEditor::showCurrentE2EDataflow);
}
IVQtCEditor::~IVQtCEditor()
......@@ -76,15 +78,21 @@ QWidget *IVQtCEditor::toolBar()
m_toolbar = new QToolBar;
m_toolbar->addAction(ivCore->actionUndo());
m_toolbar->addAction(ivCore->actionRedo());
m_toolbar->addSeparator();
for (QAction *action : qAsConst(m_globalToolbarActions)) {
m_toolbar->addAction(action);
}
}
return m_toolbar;
}
void IVQtCEditor::showCurrentE2EDataflow()
{
if (auto ivEditor = qobject_cast<spctr::IVQtCEditor *>(Core::EditorManager::currentEditor())) {
SpaceCreatorProjectImpl *project = m_projectManager->project(ivEditor->ivPlugin());
if (project) {
ivEditor->showE2EDataflow(project->allMscFiles());
}
}
}
void IVQtCEditor::showE2EDataflow(const QStringList &mscFiles)
{
if (ivPlugin().isNull()) {
......
......@@ -40,7 +40,7 @@ class IVQtCEditor : public Core::IEditor
Q_OBJECT
public:
IVQtCEditor(SpaceCreatorProjectManager *projectManager, const QList<QAction *> &ivActions);
IVQtCEditor(SpaceCreatorProjectManager *projectManager);
~IVQtCEditor();
Core::IDocument *document() const override;
......@@ -50,6 +50,7 @@ public:
QWidget *toolBar() override;
public Q_SLOTS:
void showCurrentE2EDataflow();
void showE2EDataflow(const QStringList &mscFiles);
private:
......@@ -58,7 +59,6 @@ private:
IVMainWidget *m_editorWidget = nullptr;
QPointer<ive::EndToEndView> m_endToEndView;
QPointer<SpaceCreatorProjectManager> m_projectManager;
QList<QAction *> m_globalToolbarActions;
};
}
......@@ -129,16 +129,9 @@ bool SpaceCreatorPlugin::initialize(const QStringList &arguments, QString *error
m_showMinimapAction, Constants::SHOW_MINIMAP_ID, Core::Context(Core::Constants::C_EDIT_MODE));
connect(m_showMinimapAction, &QAction::triggered, this, &SpaceCreatorPlugin::setMinimapVisible);
m_showE2EDataflow =
new QAction(QIcon(QLatin1String(":/toolbar/icns/end_to_end.png")), tr("Show end to end dataflow"), this);
Core::Command *showE2ECmd = Core::ActionManager::registerAction(
m_showE2EDataflow, Constants::SHOW_E2E_ID, Core::Context(Core::Constants::C_EDIT_MODE));
connect(m_showE2EDataflow, &QAction::triggered, this, &SpaceCreatorPlugin::showE2EDataflow);
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID);
menu->menu()->setTitle(tr("SpaceCreator"));
menu->addAction(showMinimapCmd);
menu->addAction(showE2ECmd);
menu->addSeparator();
menu->addAction(messageDeclCmd);
menu->addAction(checkInstancesCmd);
......@@ -148,38 +141,10 @@ bool SpaceCreatorPlugin::initialize(const QStringList &arguments, QString *error
menu->addAction(checkDVMessagesCmd);
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
// IV
m_actionSaveSceneRender =
new QAction(QIcon(QLatin1String(":/toolbar/icns/render.svg")), tr("Render Scene..."), this);
Core::Command *renderCmd = Core::ActionManager::registerAction(m_actionSaveSceneRender, Constants::IV_RENDER_ID);
ive::ActionsManager::registerAction(
Q_FUNC_INFO, m_actionSaveSceneRender, "Render", "Save current scene complete render.");
connect(m_actionSaveSceneRender, &QAction::triggered, this, []() {
if (auto ivEditor = qobject_cast<spctr::IVQtCEditor *>(Core::EditorManager::currentEditor())) {
ivEditor->ivPlugin()->onSaveRenderRequested();
}
});
m_exportSelectedIV =
new QAction(QIcon(QLatin1String(":/toolbar/icns/export_selected.svg")), tr("Export selected entity"), this);
Core::Command *exportElectedCmd = Core::ActionManager::registerAction(
m_exportSelectedIV, Constants::IV_EXPORT_SELECTED_ID, Core::Context(Core::Constants::C_EDIT_MODE));
connect(m_exportSelectedIV, &QAction::triggered, this, &SpaceCreatorPlugin::exportSelectedIV);
m_exportIVType = new QAction(
QIcon(QLatin1String(":/toolbar/icns/export_component_type.svg")), tr("Export component type"), this);
Core::Command *exporttypeCmd = Core::ActionManager::registerAction(
m_exportIVType, Constants::IV_EXPORT_IV_TYPE_ID, Core::Context(Core::Constants::C_EDIT_MODE));
connect(m_exportIVType, &QAction::triggered, this, &SpaceCreatorPlugin::exportComponentType);
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, this,
&spctr::SpaceCreatorPlugin::updateActions);
updateActions();
menu->addSeparator();
menu->addAction(renderCmd);
menu->addAction(exportElectedCmd);
menu->addAction(exporttypeCmd);
menu->menu()->setEnabled(true);
Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu);
......@@ -197,10 +162,7 @@ bool SpaceCreatorPlugin::initialize(const QStringList &arguments, QString *error
QList<QAction *> mscActions;
mscActions << m_showMinimapAction << m_checkInstancesAction << m_checkMessagesAction;
m_mscFactory = new MscEditorFactory(m_projectsManager, mscActions, this);
QList<QAction *> ivActions;
ivActions << m_showMinimapAction << m_showE2EDataflow << m_exportSelectedIV << m_exportIVType
<< m_actionSaveSceneRender;
m_ivFactory = new IVEditorFactory(m_projectsManager, ivActions, this);
m_ivFactory = new IVEditorFactory(m_projectsManager, this);
QList<QAction *> dvActions;
dvActions << m_checkDvFunctionsAction << m_checkDvMessagesAction;
m_dvFactory = new DVEditorFactory(m_projectsManager, dvActions, this);
......@@ -238,37 +200,6 @@ void SpaceCreatorPlugin::showMessageDeclarations()
void SpaceCreatorPlugin::setMinimapVisible(bool visible)
{
m_mscFactory->editorData()->setMinimapVisible(visible);
m_ivFactory->editorData()->showMinimap(visible);
}
void SpaceCreatorPlugin::showE2EDataflow()
{
if (auto ivEditor = qobject_cast<spctr::IVQtCEditor *>(Core::EditorManager::currentEditor())) {
SpaceCreatorProjectImpl *project = m_projectsManager->project(ivEditor->ivPlugin());
if (project) {
ivEditor->showE2EDataflow(project->allMscFiles());
}
}
}
void SpaceCreatorPlugin::exportSelectedIV()
{
if (auto ivEditor = qobject_cast<spctr::IVQtCEditor *>(Core::EditorManager::currentEditor())) {
SpaceCreatorProjectImpl *project = m_projectsManager->project(ivEditor->ivPlugin());
if (project) {
ivEditor->ivPlugin()->document()->exportSelectedFunctions();
}
}
}
void SpaceCreatorPlugin::exportComponentType()
{
if (auto ivEditor = qobject_cast<spctr::IVQtCEditor *>(Core::EditorManager::currentEditor())) {
SpaceCreatorProjectImpl *project = m_projectsManager->project(ivEditor->ivPlugin());
if (project) {
ivEditor->ivPlugin()->document()->exportSelectedType();
}
}
}
/*!
......@@ -284,11 +215,7 @@ void SpaceCreatorPlugin::updateActions()
isIV = editor->document()->filePath().toString().endsWith("interfaceview.xml", Qt::CaseInsensitive);
}
m_messageDeclarationAction->setEnabled(isMsc);
m_actionSaveSceneRender->setEnabled(isIV);
m_showMinimapAction->setEnabled(isIV || isMsc);
m_showE2EDataflow->setEnabled(isIV);
m_exportSelectedIV->setEnabled(isIV);
m_exportIVType->setEnabled(isIV);
}
void SpaceCreatorPlugin::checkInstancesForCurrentEditor()
......
......@@ -70,9 +70,6 @@ public:
private Q_SLOTS:
void showMessageDeclarations();
void setMinimapVisible(bool visible);
void showE2EDataflow();
void exportSelectedIV();
void exportComponentType();
void updateActions();
void checkInstancesForCurrentEditor();
void checkMesagesForCurrentEditor();
......@@ -90,11 +87,7 @@ private:
QAction *m_checkMessagesAction = nullptr;
QAction *m_checkDvFunctionsAction = nullptr;
QAction *m_checkDvMessagesAction = nullptr;
QAction *m_actionSaveSceneRender = nullptr;
QAction *m_showMinimapAction = nullptr;
QAction *m_showE2EDataflow = nullptr;
QAction *m_exportSelectedIV = nullptr;
QAction *m_exportIVType = nullptr;
SpaceCreatorProjectManager *m_projectsManager = nullptr;
Asn1SccOption m_asnCommandOptions;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment