forked from qt-creator/qt-creator
ScxmlEditor: Use new setup for ScxmlEditorFactory
Change-Id: Iabb25fb8b6cf774631eb5b910532b892321e3cea Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <coreplugin/coreplugintr.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
#include <utils/mimeconstants.h>
|
||||
@@ -15,28 +16,43 @@
|
||||
#include <QGuiApplication>
|
||||
|
||||
using namespace ScxmlEditor::Constants;
|
||||
using namespace ScxmlEditor::Internal;
|
||||
|
||||
ScxmlEditorFactory::ScxmlEditorFactory()
|
||||
namespace ScxmlEditor::Internal {
|
||||
|
||||
class ScxmlEditorFactory final : public QObject, public Core::IEditorFactory
|
||||
{
|
||||
setId(K_SCXML_EDITOR_ID);
|
||||
setDisplayName(::Core::Tr::tr(C_SCXMLEDITOR_DISPLAY_NAME));
|
||||
addMimeType(Utils::Constants::SCXML_MIMETYPE);
|
||||
public:
|
||||
ScxmlEditorFactory(QObject *guard)
|
||||
: QObject(guard)
|
||||
{
|
||||
setId(K_SCXML_EDITOR_ID);
|
||||
setDisplayName(::Core::Tr::tr(C_SCXMLEDITOR_DISPLAY_NAME));
|
||||
addMimeType(Utils::Constants::SCXML_MIMETYPE);
|
||||
|
||||
Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml");
|
||||
Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml");
|
||||
|
||||
setEditorCreator([this] {
|
||||
if (!m_editorData) {
|
||||
m_editorData = new ScxmlEditorData;
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_editorData->fullInit();
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
return m_editorData->createEditor();
|
||||
});
|
||||
setEditorCreator([this] {
|
||||
if (!m_editorData) {
|
||||
m_editorData = new ScxmlEditorData;
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_editorData->fullInit();
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
return m_editorData->createEditor();
|
||||
});
|
||||
}
|
||||
~ScxmlEditorFactory()
|
||||
{
|
||||
delete m_editorData;
|
||||
}
|
||||
|
||||
private:
|
||||
ScxmlEditorData *m_editorData = nullptr;
|
||||
};
|
||||
|
||||
void setupScxmlEditor(QObject *guard)
|
||||
{
|
||||
(void) new ScxmlEditorFactory(guard);
|
||||
}
|
||||
|
||||
ScxmlEditorFactory::~ScxmlEditorFactory()
|
||||
{
|
||||
delete m_editorData;
|
||||
}
|
||||
} // ScxmlEditorFactory
|
||||
|
||||
@@ -3,22 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace ScxmlEditor {
|
||||
namespace Internal {
|
||||
namespace ScxmlEditor::Internal {
|
||||
|
||||
class ScxmlEditorData;
|
||||
void setupScxmlEditor(QObject *guard);
|
||||
|
||||
class ScxmlEditorFactory final : public Core::IEditorFactory
|
||||
{
|
||||
public:
|
||||
ScxmlEditorFactory();
|
||||
~ScxmlEditorFactory();
|
||||
|
||||
private:
|
||||
ScxmlEditorData* m_editorData = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ScxmlEditor
|
||||
} // ScxmlEditor::Internal
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
|
||||
#include <coreplugin/designmode.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ScxmlEditor::Internal {
|
||||
|
||||
class ScxmlEditorPlugin : public ExtensionSystem::IPlugin
|
||||
class ScxmlEditorPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ScxmlEditor.json")
|
||||
@@ -19,15 +17,13 @@ class ScxmlEditorPlugin : public ExtensionSystem::IPlugin
|
||||
private:
|
||||
void initialize() final
|
||||
{
|
||||
editorFactory = std::make_unique<ScxmlEditorFactory>();
|
||||
setupScxmlEditor(this);
|
||||
}
|
||||
|
||||
void extensionsInitialized() final
|
||||
{
|
||||
Core::DesignMode::setDesignModeIsRequired();
|
||||
}
|
||||
|
||||
std::unique_ptr<ScxmlEditorFactory> editorFactory;
|
||||
};
|
||||
|
||||
} // ScxmlEditor::Internal
|
||||
|
||||
Reference in New Issue
Block a user