Wed, 30 Mar 2022 23:15:08 +0200
More progress in building designer plugins.
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
designer/NullDateEditPlugin.cpp | file | annotate | diff | comparison | revisions | |
designer/NullDateEditPlugin.h | file | annotate | diff | comparison | revisions | |
designer/RangedSliderPlugin.cpp | file | annotate | diff | comparison | revisions | |
designer/RangedSliderPlugin.h | file | annotate | diff | comparison | revisions | |
src/NullDateEdit.cpp | file | annotate | diff | comparison | revisions | |
src/NullDateEdit.h | file | annotate | diff | comparison | revisions | |
src/nulldateedit.cpp | file | annotate | diff | comparison | revisions | |
src/nulldateedit.h | file | annotate | diff | comparison | revisions | |
ui/EditFermentable.ui | file | annotate | diff | comparison | revisions | |
ui/EditHop.ui | file | annotate | diff | comparison | revisions | |
ui/EditMisc.ui | file | annotate | diff | comparison | revisions | |
ui/EditRecipe.ui | file | annotate | diff | comparison | revisions | |
ui/EditYeast.ui | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Wed Mar 30 17:21:43 2022 +0200 +++ b/CMakeLists.txt Wed Mar 30 23:15:08 2022 +0200 @@ -115,7 +115,7 @@ set( SRC_FILES ${SRCDIR}/RangedSlider.cpp - # ${SRCDIR}/nulldateedit.cpp + ${SRCDIR}/NullDateEdit.cpp ) # By default only QtCore and QtGui are enabled @@ -123,26 +123,31 @@ set( MOC_FILES ${SRCDIR}/RangedSlider.h - # ${SRCDIR}/nulldateedit.h + ${SRCDIR}/NullDateEdit.h ) set( PLUGIN_MOCS designer/RangedSliderPlugin.h + designer/NullDateEditPlugin.h ) set( PLUGIN_SRCS designer/RangedSliderPlugin.cpp + designer/NullDateEditPlugin.cpp ) - add_library( bmsapp_plugins SHARED - ${SRC_FILES} - ${PLUGIN_SRCS} - ${MOC_FILES} - ${PLUGIN_MOCS} + QT_WRAP_CPP( GEN_MOC_FILES1 ${SRCDIR}/RangedSlider.h designer/RangedSliderPlugin.h) + add_library(bmsapp_rangeslider SHARED + ${SRCDIR}/RangedSlider.cpp + designer/RangedSliderPlugin.cpp + ${GEN_MOC_FILES1} ) - TARGET_LINK_LIBRARIES( bmsapp_plugins - ${QT_LIBRARIES} + QT_WRAP_CPP( GEN_MOC_FILES2 ${SRCDIR}/NullDateEdit.h designer/NullDateEditPlugin.h) + add_library(bmsapp_nulldate SHARED + ${SRCDIR}/NullDateEdit.cpp + designer/NullDateEditPlugin.cpp + ${GEN_MOC_FILES2} ) ELSE() @@ -180,7 +185,7 @@ ${SRCDIR}/MainWindow.cpp ${SRCDIR}/database/database.cpp ${SRCDIR}/RangedSlider.cpp - ${SRCDIR}/nulldateedit.cpp + ${SRCDIR}/NullDateEdit.cpp ) set( HDRS @@ -215,7 +220,7 @@ ${SRCDIR}/MainWindow.h ${SRCDIR}/database/database.h ${SRCDIR}/RangedSlider.h - ${SRCDIR}/nulldateedit.h + ${SRCDIR}/NullDateEdit.h ) set( UIS @@ -282,7 +287,7 @@ IF( ${BUILD_DESIGNER_PLUGINS} ) - INSTALL(TARGETS bmsapp_plugins + INSTALL(TARGETS bmsapp_rangeslider bmsapp_nulldate DESTINATION "${LIBPATH}/plugins/designer" )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/designer/NullDateEditPlugin.cpp Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,100 @@ +/* + * NullDateEditPlugin.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <QObject> +#include <QtUiPlugin/QDesignerCustomWidgetInterface> +#include <QString> +#include <QWidget> +#include <QIcon> +#include <QtPlugin> + +#include "NullDateEditPlugin.h" +#include "NullDateEdit.h" + +NullDateEditPlugin::NullDateEditPlugin(QObject* parent) + : QObject(parent) +{ +} + +void NullDateEditPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + if(initialized) + return; + + initialized = true; + return; +} + +bool NullDateEditPlugin::isInitialized() const +{ + return initialized; +} + +QWidget* NullDateEditPlugin::createWidget(QWidget *parent) +{ + return new NullDateEdit(parent); +} + +QString NullDateEditPlugin::name() const +{ + return "NullDateEdit"; +} + +QString NullDateEditPlugin::group() const +{ + return "BMSapp Widgets"; +} + +QIcon NullDateEditPlugin::icon() const +{ + return QIcon(); +} + +QString NullDateEditPlugin::toolTip() const +{ + return QString(); +} + +QString NullDateEditPlugin::whatsThis() const +{ + return QString(); +} + +bool NullDateEditPlugin::isContainer() const +{ + return false; +} + +QString NullDateEditPlugin::domXml() const +{ + return "<ui language=\"c++\">\n" + " <widget class=\"NullDateEdit\" name=\"nullDatEditWidget\">\n" + " <property name=\"toolTip\" >\n" + " <string>Date editor</string>\n" + " </property>\n" + " <property name=\"whatsThis\" >\n" + " <string>Date editor that allows a null date.</string>\n" + " </property>\n" + " </widget>\n" + "</ui>\n"; +} + +QString NullDateEditPlugin::includeFile() const +{ + return "NullDateEdit.h"; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/designer/NullDateEditPlugin.h Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,54 @@ +/* + * NullDateEditPlugin.h is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _NULLDATEPLUGIN_H +#define _NULLDATEPLUGIN_H + +#include <QObject> +#include <QString> +#include <QWidget> +#include <QIcon> +#include <QtUiPlugin/QDesignerCustomWidgetInterface> + +class NullDateEditPlugin; + +class NullDateEditPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface") + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + NullDateEditPlugin(QObject* parent = nullptr); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized = false; +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/designer/RangedSliderPlugin.cpp Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,100 @@ +/* + * RangedSliderPlugin.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <QObject> +#include <QtUiPlugin/QDesignerCustomWidgetInterface> +#include <QString> +#include <QWidget> +#include <QIcon> +#include <QtPlugin> + +#include "RangedSliderPlugin.h" +#include "RangedSlider.h" + +RangedSliderPlugin::RangedSliderPlugin(QObject* parent) + : QObject(parent) +{ +} + +void RangedSliderPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + if(initialized) + return; + + initialized = true; + return; +} + +bool RangedSliderPlugin::isInitialized() const +{ + return initialized; +} + +QWidget* RangedSliderPlugin::createWidget(QWidget *parent) +{ + return new RangedSlider(parent); +} + +QString RangedSliderPlugin::name() const +{ + return "RangedSlider"; +} + +QString RangedSliderPlugin::group() const +{ + return "BMSapp Widgets"; +} + +QIcon RangedSliderPlugin::icon() const +{ + return QIcon(); +} + +QString RangedSliderPlugin::toolTip() const +{ + return QString(); +} + +QString RangedSliderPlugin::whatsThis() const +{ + return QString(); +} + +bool RangedSliderPlugin::isContainer() const +{ + return false; +} + +QString RangedSliderPlugin::domXml() const +{ + return "<ui language=\"c++\">\n" + " <widget class=\"RangedSlider\" name=\"rangedSliderWidget\">\n" + " <property name=\"toolTip\" >\n" + " <string>The ranged slider</string>\n" + " </property>\n" + " <property name=\"whatsThis\" >\n" + " <string>Slider that shows if a value is in range.</string>\n" + " </property>\n" + " </widget>\n" + "</ui>\n"; +} + +QString RangedSliderPlugin::includeFile() const +{ + return "RangedSlider.h"; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/designer/RangedSliderPlugin.h Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,54 @@ +/* + * RangedSliderPlugin.h is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _RANGEDSLIDERPLUGIN_H +#define _RANGEDSLIDERPLUGIN_H + +#include <QObject> +#include <QString> +#include <QWidget> +#include <QIcon> +#include <QtUiPlugin/QDesignerCustomWidgetInterface> + +class RangedSliderPlugin; + +class RangedSliderPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface") + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + RangedSliderPlugin(QObject* parent = nullptr); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized = false; +}; + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NullDateEdit.cpp Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,55 @@ +/** + * NullDateEdit.cpp is part of bmsapp. + * + * See https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include "NullDateEdit.h" + + +NullDateEdit::NullDateEdit(const QDate& date, QWidget* parent) + : QDateEdit(date, parent) +{ + this->setSpecialValueText("Null"); +} + +NullDateEdit::NullDateEdit(QWidget* parent) + : QDateEdit(parent) +{ + this->setSpecialValueText("Null"); +} + +NullDateEdit::~NullDateEdit() +{ +} + +void NullDateEdit::clear() +{ + this->setDate(this->minimumDate()); +} + +QDate NullDateEdit::nullDate() const +{ + if (date() == this->minimumDate()) + return QDate(); + return date(); +} + +void NullDateEdit::setDate(const QDate & date) +{ + if (date.isNull()) + QDateEdit::setDate(this->minimumDate()); + QDateEdit::setDate(date); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/NullDateEdit.h Wed Mar 30 23:15:08 2022 +0200 @@ -0,0 +1,16 @@ +#include <QDateEdit> +class NullDateEdit : public QDateEdit +{ + Q_OBJECT + Q_PROPERTY(QDate nullDate READ nullDate WRITE setDate USER true) +public: + NullDateEdit(const QDate& date, QWidget* parent); + NullDateEdit(QWidget* parent); + ~NullDateEdit(); + + QDate nullDate() const; + +public slots: + void clear(); + void setDate(const QDate& date); +};
--- a/src/nulldateedit.cpp Wed Mar 30 17:21:43 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/** - * Utils.cpp is part of bmsapp. - * - * See https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit - * - * bmsapp is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * bmsapp is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#include "nulldateedit.h" - - -NullDateEdit::NullDateEdit(const QDate& date, QWidget* parent) - : QDateEdit(date, parent) -{ - this->setSpecialValueText("Null"); -} - -NullDateEdit::NullDateEdit(QWidget* parent) - : QDateEdit(parent) -{ - this->setSpecialValueText("Null"); -} - -NullDateEdit::~NullDateEdit() -{ -} - -void NullDateEdit::clear() -{ - this->setDate(this->minimumDate()); -} - -QDate NullDateEdit::nullDate() const -{ - if (date() == this->minimumDate()) - return QDate(); - return date(); -} - -void NullDateEdit::setDate(const QDate & date) -{ - if (date.isNull()) - QDateEdit::setDate(this->minimumDate()); - QDateEdit::setDate(date); -}
--- a/src/nulldateedit.h Wed Mar 30 17:21:43 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#include <QDateEdit> -class NullDateEdit : public QDateEdit -{ - Q_OBJECT - Q_PROPERTY(QDate nullDate READ nullDate WRITE setDate USER true) -public: - NullDateEdit(const QDate& date, QWidget* parent); - NullDateEdit(QWidget* parent); - ~NullDateEdit(); - - QDate nullDate() const; - -public slots: - void clear(); - void setDate(const QDate& date); -};
--- a/ui/EditFermentable.ui Wed Mar 30 17:21:43 2022 +0200 +++ b/ui/EditFermentable.ui Wed Mar 30 23:15:08 2022 +0200 @@ -936,7 +936,7 @@ <customwidget> <class>NullDateEdit</class> <extends>QWidget</extends> - <header>nulldateedit.h</header> + <header>NullDateEdit.h</header> </customwidget> </customwidgets> <tabstops>
--- a/ui/EditHop.ui Wed Mar 30 17:21:43 2022 +0200 +++ b/ui/EditHop.ui Wed Mar 30 23:15:08 2022 +0200 @@ -767,7 +767,7 @@ <customwidget> <class>NullDateEdit</class> <extends>QWidget</extends> - <header>nulldateedit.h</header> + <header>NullDateEdit.h</header> </customwidget> </customwidgets> <tabstops>
--- a/ui/EditMisc.ui Wed Mar 30 17:21:43 2022 +0200 +++ b/ui/EditMisc.ui Wed Mar 30 23:15:08 2022 +0200 @@ -547,7 +547,7 @@ <customwidget> <class>NullDateEdit</class> <extends>QWidget</extends> - <header>nulldateedit.h</header> + <header>NullDateEdit.h</header> </customwidget> </customwidgets> <tabstops>
--- a/ui/EditRecipe.ui Wed Mar 30 17:21:43 2022 +0200 +++ b/ui/EditRecipe.ui Wed Mar 30 23:15:08 2022 +0200 @@ -423,6 +423,54 @@ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> </widget> + <widget class="RangedSlider" name="rangeSliderWidget"> + <property name="geometry"> + <rect> + <x>90</x> + <y>350</y> + <width>148</width> + <height>37</height> + </rect> + </property> + <property name="toolTip"> + <string>The ranged slider</string> + </property> + <property name="whatsThis"> + <string>Slider that shows if a value is in range.</string> + </property> + </widget> + <widget class="RangedSlider" name="rangedSliderWidget"> + <property name="geometry"> + <rect> + <x>350</x> + <y>350</y> + <width>148</width> + <height>37</height> + </rect> + </property> + <property name="toolTip"> + <string>The ranged slider</string> + </property> + <property name="whatsThis"> + <string>Slider that shows if a value is in range.</string> + </property> + </widget> + <widget class="NullDateEdit" name="nullDatEditWidget"> + <property name="geometry"> + <rect> + <x>660</x> + <y>360</y> + <width>101</width> + <height>24</height> + </rect> + </property> + <property name="toolTip"> + <string>Date editor</string> + </property> + <property name="whatsThis"> + <string>Date editor that allows a null date.</string> + </property> + </widget> </widget> <widget class="QWidget" name="fermentables"> <attribute name="icon"> @@ -519,6 +567,11 @@ </widget> <customwidgets> <customwidget> + <class>NullDateEdit</class> + <extends>QDateEdit</extends> + <header>NullDateEdit.h</header> + </customwidget> + <customwidget> <class>RangedSlider</class> <extends>QWidget</extends> <header>RangedSlider.h</header>
--- a/ui/EditYeast.ui Wed Mar 30 17:21:43 2022 +0200 +++ b/ui/EditYeast.ui Wed Mar 30 23:15:08 2022 +0200 @@ -1111,7 +1111,7 @@ <customwidget> <class>NullDateEdit</class> <extends>QWidget</extends> - <header>nulldateedit.h</header> + <header>NullDateEdit.h</header> </customwidget> </customwidgets> <tabstops>