Add first component to Qt Designer plugin
This commit is contained in:
parent
3a0e226597
commit
9cc62f6d87
|
@ -1,6 +1,21 @@
|
|||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
QT += widgets designer
|
||||
}
|
||||
|
||||
lessThan(QT_MAJOR_VERSION, 5) {
|
||||
CONFIG += designer
|
||||
}
|
||||
|
||||
CONFIG += plugin release
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
TARGET = $$qtLibraryTarget(qt-material-widget)
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/designer
|
||||
INSTALLS += target
|
||||
INCLUDEPATH += .
|
||||
|
||||
SOURCES = \
|
||||
plugin/materialtoggleplugin.cpp \
|
||||
plugin/qtmaterialplugins.cpp \
|
||||
qtmaterialavatar.cpp \
|
||||
lib/qtmaterialstyle.cpp \
|
||||
lib/qtmaterialtheme.cpp \
|
||||
|
@ -49,6 +64,8 @@ SOURCES = \
|
|||
qtmateriallist.cpp \
|
||||
qtmateriallistitem.cpp
|
||||
HEADERS = \
|
||||
plugin/materialtoggleplugin.h \
|
||||
plugin/qtmaterialplugins.h \
|
||||
qtmaterialavatar_p.h \
|
||||
qtmaterialavatar.h \
|
||||
lib/qtmaterialstyle_p.h \
|
||||
|
@ -127,4 +144,4 @@ HEADERS = \
|
|||
qtmateriallistitem.h \
|
||||
qtmateriallistitem_p.h
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
material_res.qrc
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
#include "materialtoggleplugin.h"
|
||||
#include "qtmaterialtoggle.h"
|
||||
#include <QtPlugin>
|
||||
|
||||
MaterialTogglePlugin::
|
||||
MaterialTogglePlugin(QObject* parent) :
|
||||
QObject(parent),
|
||||
initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
QString MaterialTogglePlugin::
|
||||
name() const
|
||||
{
|
||||
return "Material Toggle";
|
||||
}
|
||||
|
||||
QString MaterialTogglePlugin::
|
||||
group() const
|
||||
{
|
||||
return tr("Qt Meterial Widgets");
|
||||
}
|
||||
|
||||
QString MaterialTogglePlugin::
|
||||
toolTip() const
|
||||
{
|
||||
return tr("Material toggle button");
|
||||
}
|
||||
|
||||
QString MaterialTogglePlugin::
|
||||
whatsThis() const
|
||||
{
|
||||
return tr("Material toggle button");
|
||||
}
|
||||
|
||||
QString MaterialTogglePlugin::
|
||||
includeFile() const
|
||||
{
|
||||
return "qtmaterialtoggle.h";
|
||||
}
|
||||
|
||||
QIcon MaterialTogglePlugin::
|
||||
icon() const
|
||||
{
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
bool MaterialTogglePlugin::
|
||||
isContainer() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget * MaterialTogglePlugin::
|
||||
createWidget(QWidget *parent)
|
||||
{
|
||||
return new QtMaterialToggle(parent);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
Q_EXPORT_PLUGIN2(MaterialTogglePlugin, MaterialTogglePlugin)
|
||||
#endif
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef MATERIALTOGGLEPLUGIN_H
|
||||
#define MATERIALTOGGLEPLUGIN_H
|
||||
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
class MaterialTogglePlugin : public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MaterialTogglePlugin(QObject *parent = nullptr);
|
||||
|
||||
QString name() const;
|
||||
QString group() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QString includeFile() const;
|
||||
QIcon icon() const;
|
||||
|
||||
bool isContainer() const;
|
||||
|
||||
QWidget *createWidget(QWidget *parent);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
#endif // MATERIALTOGGLEPLUGIN_H
|
|
@ -0,0 +1,11 @@
|
|||
#include "qtmaterialplugins.h"
|
||||
#include "materialtoggleplugin.h"
|
||||
|
||||
QtMaterialPlugins::QtMaterialPlugins(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_plugins << new MaterialTogglePlugin(this);
|
||||
}
|
||||
|
||||
QList<QDesignerCustomWidgetInterface*> QtMaterialPlugins::customWidgets() const {
|
||||
return m_plugins;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef QTMATERIALPLUGINS_H
|
||||
#define QTMATERIALPLUGINS_H
|
||||
|
||||
#include <QDesignerCustomWidgetCollectionInterface>
|
||||
|
||||
class QtMaterialPlugins : public QObject, public QDesignerCustomWidgetCollectionInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "com.meta-vi.QDesignerCustomWidgetCollectionInterface")
|
||||
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
|
||||
public:
|
||||
explicit QtMaterialPlugins(QObject *parent = nullptr);
|
||||
QList<QDesignerCustomWidgetInterface*> customWidgets() const;
|
||||
|
||||
private:
|
||||
QList<QDesignerCustomWidgetInterface *> m_plugins;
|
||||
|
||||
};
|
||||
|
||||
#endif // QTMATERIALPLUGINS_H
|
|
@ -7,6 +7,7 @@ SOURCES = mainwindow.cpp \
|
|||
badgesettingseditor.cpp \
|
||||
checkboxsettingseditor.cpp \
|
||||
fabsettingseditor.cpp \
|
||||
plugindemoform.cpp \
|
||||
raisedbuttonsettingseditor.cpp \
|
||||
flatbuttonsettingseditor.cpp \
|
||||
iconbuttonsettingseditor.cpp \
|
||||
|
@ -29,6 +30,7 @@ HEADERS = mainwindow.h \
|
|||
badgesettingseditor.h \
|
||||
checkboxsettingseditor.h \
|
||||
fabsettingseditor.h \
|
||||
plugindemoform.h \
|
||||
raisedbuttonsettingseditor.h \
|
||||
flatbuttonsettingseditor.h \
|
||||
iconbuttonsettingseditor.h \
|
||||
|
@ -46,10 +48,9 @@ HEADERS = mainwindow.h \
|
|||
appbarsettingseditor.h \
|
||||
autocompletesettingseditor.h \
|
||||
menusettingseditor.h
|
||||
LIBS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a
|
||||
LIBS += -L../components/ -lqt-material-widget
|
||||
INCLUDEPATH += $$top_srcdir/components/
|
||||
TARGET = examples-exe
|
||||
PRE_TARGETDEPS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a
|
||||
|
||||
RESOURCES += \
|
||||
examples.qrc
|
||||
|
@ -61,6 +62,7 @@ FORMS += \
|
|||
fabsettingsform.ui \
|
||||
flatbuttonsettingsform.ui \
|
||||
iconbuttonsettingsform.ui \
|
||||
plugindemoform.ui \
|
||||
progresssettingsform.ui \
|
||||
circularprogresssettingsform.ui \
|
||||
slidersettingsform.ui \
|
||||
|
|
|
@ -6,7 +6,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Q_INIT_RESOURCE(resources);
|
||||
Q_INIT_RESOURCE(material_res);
|
||||
|
||||
MainWindow window;
|
||||
window.show();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "appbarsettingseditor.h"
|
||||
#include "autocompletesettingseditor.h"
|
||||
#include "menusettingseditor.h"
|
||||
#include "plugindemoform.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
@ -42,6 +43,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
setCentralWidget(widget);
|
||||
|
||||
PluginDemoForm *pluginFrm = new PluginDemoForm;
|
||||
AvatarSettingsEditor *avatar = new AvatarSettingsEditor;
|
||||
BadgeSettingsEditor *badge = new BadgeSettingsEditor;
|
||||
CheckBoxSettingsEditor *checkbox = new CheckBoxSettingsEditor;
|
||||
|
@ -64,6 +66,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
AutoCompleteSettingsEditor *autocomplete = new AutoCompleteSettingsEditor;
|
||||
MenuSettingsEditor *menu = new MenuSettingsEditor;
|
||||
|
||||
stack->addWidget(pluginFrm);
|
||||
stack->addWidget(appBar);
|
||||
stack->addWidget(autocomplete);
|
||||
stack->addWidget(avatar);
|
||||
|
@ -86,6 +89,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
stack->addWidget(textField);
|
||||
stack->addWidget(toggle);
|
||||
|
||||
list->addItem("Plugins");
|
||||
list->addItem("App Bar");
|
||||
list->addItem("Auto Complete");
|
||||
list->addItem("Avatar");
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "plugindemoform.h"
|
||||
#include "ui_plugindemoform.h"
|
||||
|
||||
PluginDemoForm::PluginDemoForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PluginDemoForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
PluginDemoForm::~PluginDemoForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef PLUGINDEMOFORM_H
|
||||
#define PLUGINDEMOFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class PluginDemoForm;
|
||||
}
|
||||
|
||||
class PluginDemoForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PluginDemoForm(QWidget *parent = nullptr);
|
||||
~PluginDemoForm();
|
||||
|
||||
private:
|
||||
Ui::PluginDemoForm *ui;
|
||||
};
|
||||
|
||||
#endif // PLUGINDEMOFORM_H
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PluginDemoForm</class>
|
||||
<widget class="QWidget" name="PluginDemoForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QtMaterialToggle" name="material toggle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>20</y>
|
||||
<width>64</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,5 +1,3 @@
|
|||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = qt-material-widgets
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = components examples
|
||||
|
|
Loading…
Reference in New Issue