Squish: Use setup function for ObjectsMapEditor

Change-Id: I355567a863b718f7a058421d2fafb81837208254
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-02-01 17:38:49 +01:00
parent c20c2a8c86
commit e9673e7ea5
3 changed files with 27 additions and 23 deletions

View File

@@ -9,10 +9,13 @@
#include "squishtr.h" #include "squishtr.h"
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/ieditorfactory.h>
using namespace Core;
namespace Squish::Internal { namespace Squish::Internal {
class ObjectsMapEditor : public Core::IEditor class ObjectsMapEditor final : public IEditor
{ {
public: public:
ObjectsMapEditor(std::shared_ptr<ObjectsMapDocument> document) ObjectsMapEditor(std::shared_ptr<ObjectsMapDocument> document)
@@ -21,19 +24,19 @@ public:
setWidget(new ObjectsMapEditorWidget(m_document.get())); setWidget(new ObjectsMapEditorWidget(m_document.get()));
setDuplicateSupported(true); setDuplicateSupported(true);
} }
~ObjectsMapEditor() override { delete m_widget; } ~ObjectsMapEditor() final { delete m_widget; }
private: private:
Core::IDocument *document() const override { return m_document.get(); } IDocument *document() const override { return m_document.get(); }
QWidget *toolBar() override { return nullptr; } QWidget *toolBar() final { return nullptr; }
Core::IEditor *duplicate() override { return new ObjectsMapEditor(m_document); } IEditor *duplicate() final { return new ObjectsMapEditor(m_document); }
std::shared_ptr<ObjectsMapDocument> m_document; std::shared_ptr<ObjectsMapDocument> m_document;
}; };
class ObjectsMapEditorFactory final : public IEditorFactory
// Factory {
public:
ObjectsMapEditorFactory::ObjectsMapEditorFactory() ObjectsMapEditorFactory()
{ {
setId(Constants::OBJECTSMAP_EDITOR_ID); setId(Constants::OBJECTSMAP_EDITOR_ID);
setDisplayName(Tr::tr("Squish Object Map Editor")); setDisplayName(Tr::tr("Squish Object Map Editor"));
@@ -42,5 +45,11 @@ ObjectsMapEditorFactory::ObjectsMapEditorFactory()
return new ObjectsMapEditor(std::shared_ptr<ObjectsMapDocument>(new ObjectsMapDocument)); return new ObjectsMapEditor(std::shared_ptr<ObjectsMapDocument>(new ObjectsMapDocument));
}); });
} }
};
void setupObjectsMapEditor()
{
static ObjectsMapEditorFactory theObjectsMapEditorFactory;
}
} // Squish::Internal } // Squish::Internal

View File

@@ -3,14 +3,8 @@
#pragma once #pragma once
#include <coreplugin/editormanager/ieditorfactory.h>
namespace Squish::Internal { namespace Squish::Internal {
class ObjectsMapEditorFactory : public Core::IEditorFactory void setupObjectsMapEditor();
{
public:
ObjectsMapEditorFactory();
};
} // Squish::Internal } // Squish::Internal

View File

@@ -39,7 +39,6 @@ public:
bool initializeGlobalScripts(); bool initializeGlobalScripts();
ObjectsMapEditorFactory m_objectsMapEditorFactory;
SquishOutputPane m_outputPane; SquishOutputPane m_outputPane;
SquishTools m_squishTools; SquishTools m_squishTools;
}; };
@@ -105,6 +104,8 @@ class SquishPlugin final : public ExtensionSystem::IPlugin
private: private:
void initialize() final void initialize() final
{ {
setupObjectsMapEditor();
d.reset(new SquishPluginPrivate); d.reset(new SquishPluginPrivate);
setupSquishWizardPages(); setupSquishWizardPages();