From 93bb9646c36a84efdc3be4e4ca60c7e0234a6233 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 12 Aug 2020 11:38:31 +0200 Subject: [PATCH] plugin: [skip ci] add custom widgets Gui::IntSpinBox and Gui::DoubleSpinBox --- src/Tools/plugins/widget/customwidgets.cpp | 23 +++++ src/Tools/plugins/widget/customwidgets.h | 22 +++++ src/Tools/plugins/widget/plugin.cpp | 98 ++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/src/Tools/plugins/widget/customwidgets.cpp b/src/Tools/plugins/widget/customwidgets.cpp index 357f0cc21f..9d8bd78c5b 100644 --- a/src/Tools/plugins/widget/customwidgets.cpp +++ b/src/Tools/plugins/widget/customwidgets.cpp @@ -1626,6 +1626,18 @@ void UIntSpinBox::updateValidator() // -------------------------------------------------------------------- +IntSpinBox::IntSpinBox(QWidget* parent) + : QSpinBox(parent) +{ +} + +IntSpinBox::~IntSpinBox() +{ + +} + +// -------------------------------------------------------------------- + PrefSpinBox::PrefSpinBox ( QWidget * parent ) : QSpinBox(parent) { @@ -1657,6 +1669,17 @@ void PrefSpinBox::setParamGrpPath ( const QByteArray& name ) // -------------------------------------------------------------------- +DoubleSpinBox::DoubleSpinBox(QWidget* parent) + : QDoubleSpinBox(parent) +{ +} + +DoubleSpinBox::~DoubleSpinBox() +{ +} + +// -------------------------------------------------------------------- + PrefDoubleSpinBox::PrefDoubleSpinBox ( QWidget * parent ) : QDoubleSpinBox(parent) { diff --git a/src/Tools/plugins/widget/customwidgets.h b/src/Tools/plugins/widget/customwidgets.h index c2a07b6de6..c185b7747d 100644 --- a/src/Tools/plugins/widget/customwidgets.h +++ b/src/Tools/plugins/widget/customwidgets.h @@ -597,6 +597,28 @@ private: UIntSpinBoxPrivate * d; }; +// ------------------------------------------------------------------------------ + +class IntSpinBox : public QSpinBox +{ + Q_OBJECT + +public: + IntSpinBox ( QWidget* parent=0 ); + virtual ~IntSpinBox(); +}; + +// ------------------------------------------------------------------------------ + +class DoubleSpinBox : public QDoubleSpinBox +{ + Q_OBJECT + +public: + DoubleSpinBox ( QWidget* parent=0 ); + virtual ~DoubleSpinBox(); +}; + // ------------------------------------------------------------- class PrefSpinBox : public QSpinBox diff --git a/src/Tools/plugins/widget/plugin.cpp b/src/Tools/plugins/widget/plugin.cpp index 0937f0d7e1..6c72aceb90 100644 --- a/src/Tools/plugins/widget/plugin.cpp +++ b/src/Tools/plugins/widget/plugin.cpp @@ -879,6 +879,102 @@ public: } }; +class IntSpinBoxPlugin : public QDesignerCustomWidgetInterface +{ + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + IntSpinBoxPlugin() + { + } + QWidget *createWidget(QWidget *parent) + { + return new Gui::IntSpinBox(parent); + } + QString group() const + { + return QLatin1String("Input Widgets"); + } + QIcon icon() const + { + return QIcon( QPixmap( spinbox_pixmap ) ); + } + QString includeFile() const + { + return QLatin1String("Gui/SpinBox.h"); + } + QString toolTip() const + { + return QLatin1String("Spin Box"); + } + QString whatsThis() const + { + return QLatin1String("Spin box widget (spin button)."); + } + bool isContainer() const + { + return false; + } + QString domXml() const + { + return "\n" + " \n" + " \n" + ""; + } + QString name() const + { + return QLatin1String("Gui::IntSpinBox"); + } +}; + +class DoubleSpinBoxPlugin : public QDesignerCustomWidgetInterface +{ + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + DoubleSpinBoxPlugin() + { + } + QWidget *createWidget(QWidget *parent) + { + return new Gui::DoubleSpinBox(parent); + } + QString group() const + { + return QLatin1String("Input Widgets"); + } + QIcon icon() const + { + return QIcon( QPixmap( spinbox_pixmap ) ); + } + QString includeFile() const + { + return QLatin1String("Gui/SpinBox.h"); + } + QString toolTip() const + { + return QLatin1String("Double Spin Box"); + } + QString whatsThis() const + { + return QLatin1String("Spin box widget (spin button)."); + } + bool isContainer() const + { + return false; + } + QString domXml() const + { + return "\n" + " \n" + " \n" + ""; + } + QString name() const + { + return QLatin1String("Gui::DoubleSpinBox"); + } +}; + class PrefSpinBoxPlugin : public QDesignerCustomWidgetInterface { Q_INTERFACES(QDesignerCustomWidgetInterface) @@ -1601,6 +1697,8 @@ QList CustomWidgetPlugin::customWidgets () con cw.append(new QuantitySpinBoxPlugin); cw.append(new CommandIconViewPlugin); cw.append(new UIntSpinBoxPlugin); + cw.append(new IntSpinBoxPlugin); + cw.append(new DoubleSpinBoxPlugin); cw.append(new ColorButtonPlugin); cw.append(new PrefFileChooserPlugin); cw.append(new PrefSpinBoxPlugin);