widgets/designerplugins.h

Sun, 09 Apr 2023 15:59:08 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 15:59:08 +0300
changeset 362
e1d646a4cbd8
parent 349
673b8dffbe14
permissions
-rw-r--r--

Extracted the state of the program into a MainState structure, and extracted local functions of main() into static functions.
I was planning to make the core logic and state of the program into a Main class, which would be a QObject that would
have lots of signals and slots, but it looks like this works even without it

#pragma once
#include <QObject>
#include <QDesignerCustomWidgetInterface>

class PluginCollection final : public QObject, public QDesignerCustomWidgetCollectionInterface
{
	Q_OBJECT
	Q_PLUGIN_METADATA(IID "org.qgis.customwidgets")
	Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
	// QDesignerCustomWidgetCollectionInterface interface
	QList<QDesignerCustomWidgetInterface*> interfaces;
public:
	PluginCollection(QObject* parent = nullptr);
	QList<QDesignerCustomWidgetInterface*> customWidgets() const override;
};

class Vec3EditorPlugin final : public QObject, public QDesignerCustomWidgetInterface
{
	Q_OBJECT
	Q_INTERFACES(QDesignerCustomWidgetInterface)
	// QDesignerCustomWidgetInterface interface
public:
	Vec3EditorPlugin(QObject* parent) : QObject{parent}{}
	QString name() const override;
	QString group() const override;
	QString toolTip() const override;
	QString whatsThis() const override;
	QString includeFile() const override;
	QIcon icon() const override;
	bool isContainer() const override;
	QWidget* createWidget(QWidget* parent) override;
};

class MatrixEditorPlugin final : public QObject, public QDesignerCustomWidgetInterface
{
	Q_OBJECT
	Q_INTERFACES(QDesignerCustomWidgetInterface)
	// QDesignerCustomWidgetInterface interface
public:
	MatrixEditorPlugin(QObject* parent) : QObject{parent}{}
	QString name() const override;
	QString group() const override;
	QString toolTip() const override;
	QString whatsThis() const override;
	QString includeFile() const override;
	QIcon icon() const override;
	bool isContainer() const override;
	QWidget* createWidget(QWidget* parent) override;
};

class ColorEditPlugin final : public QObject, public QDesignerCustomWidgetInterface
{
	Q_OBJECT
	Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
	ColorEditPlugin(QObject* parent) : QObject{parent}{}
	// QDesignerCustomWidgetInterface interface
	QString name() const override;
	QString group() const override;
	QString toolTip() const override;
	QString whatsThis() const override;
	QString includeFile() const override;
	QIcon icon() const override;
	bool isContainer() const override;
	QWidget* createWidget(QWidget* parent) override;
};

mercurial