├── .gitignore ├── plugins ├── ImageFrame │ ├── imageframe.pri │ ├── icons │ │ └── photo.png │ ├── icons.qrc │ ├── README.md │ ├── ImageFrame.pro │ └── src │ │ ├── imageframe.h │ │ ├── imageframeplugin.h │ │ ├── imageframeplugin.cpp │ │ └── imageframe.cpp ├── LineEditTag │ ├── icons │ │ └── tag.png │ ├── lineedittag.pri │ ├── icons.qrc │ ├── README.md │ ├── LineEditTag.pro │ └── src │ │ ├── lineedittag.h │ │ ├── lineedittagplugin.h │ │ ├── lineedittagplugin.cpp │ │ └── lineedittag.cpp ├── ComboBoxCheckable │ ├── README.md │ ├── icons │ │ └── checklist.png │ ├── icons.qrc │ ├── comboboxcheckable.pri │ ├── ComboBoxCheckable.pro │ └── src │ │ ├── comboboxcheckable.h │ │ ├── abstractlistmodelcheckablecbx.h │ │ ├── comboboxcheckableplugin.h │ │ ├── comboboxcheckable.cpp │ │ ├── comboboxcheckableplugin.cpp │ │ └── abstractlistmodelcheckablecbx.cpp ├── LineEditRegex │ ├── icons │ │ └── text.png │ ├── icons.qrc │ ├── lineeditregex.pri │ ├── README.md │ ├── LineEditRegex.pro │ └── src │ │ ├── lineediticon.h │ │ ├── lineeditregex.h │ │ ├── lineediticon.cpp │ │ ├── lineeditregexplugin.h │ │ ├── lineeditregex.cpp │ │ └── lineeditregexplugin.cpp ├── CircularProgress │ ├── circularprogress.pri │ ├── icons │ │ └── pie-chart.png │ ├── icons.qrc │ ├── README.md │ ├── CircularProgress.pro │ └── src │ │ ├── circularprogressplugin.h │ │ ├── circularprogressplugin.cpp │ │ ├── circularprogress.h │ │ └── circularprogress.cpp ├── CheckBoxWordWrap │ ├── icons │ │ └── check_icon.png │ ├── icons.qrc │ ├── checkboxwordwrap.pri │ ├── README.md │ ├── src │ │ ├── clickablelabel.cpp │ │ ├── clickablelabel.h │ │ ├── checkboxwordwrap.h │ │ ├── checkboxwordwrapplugin.h │ │ ├── checkboxwordwrapplugin.cpp │ │ └── checkboxwordwrap.cpp │ └── CheckBoxWordWrap.pro └── customPlugins.pro ├── screenshots ├── plugins_results.png ├── active_in_designer.png ├── plugins_in_designer.png ├── imageframe_properties.png ├── lineeditregex_properties.png ├── lineedittag_properties.png ├── checkboxwordwrap_properties.png └── circularprogress_properties.png ├── .travis.yml ├── .github └── FUNDING.yml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | plugins/customPlugins.pro.user 2 | 3 | -------------------------------------------------------------------------------- /plugins/ImageFrame/imageframe.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/src/imageframe.h 2 | SOURCES += $$PWD/src/imageframe.cpp 3 | -------------------------------------------------------------------------------- /screenshots/plugins_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/plugins_results.png -------------------------------------------------------------------------------- /plugins/ImageFrame/icons/photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/ImageFrame/icons/photo.png -------------------------------------------------------------------------------- /plugins/LineEditTag/icons/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/LineEditTag/icons/tag.png -------------------------------------------------------------------------------- /screenshots/active_in_designer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/active_in_designer.png -------------------------------------------------------------------------------- /screenshots/plugins_in_designer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/plugins_in_designer.png -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/README.md: -------------------------------------------------------------------------------- 1 | # ComboBoxCheckable 2 | 3 | ## Properties 4 | 5 | Same properties as the QComboBox 6 | 7 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/icons/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/LineEditRegex/icons/text.png -------------------------------------------------------------------------------- /screenshots/imageframe_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/imageframe_properties.png -------------------------------------------------------------------------------- /plugins/CircularProgress/circularprogress.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/src/circularprogress.h 2 | SOURCES += $$PWD/src/circularprogress.cpp 3 | -------------------------------------------------------------------------------- /screenshots/lineeditregex_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/lineeditregex_properties.png -------------------------------------------------------------------------------- /screenshots/lineedittag_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/lineedittag_properties.png -------------------------------------------------------------------------------- /plugins/LineEditTag/lineedittag.pri: -------------------------------------------------------------------------------- 1 | HEADERS += \ 2 | $$PWD/src/lineedittag.h 3 | SOURCES += \ 4 | $$PWD/src/lineedittag.cpp 5 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/icons/check_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/CheckBoxWordWrap/icons/check_icon.png -------------------------------------------------------------------------------- /plugins/CircularProgress/icons/pie-chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/CircularProgress/icons/pie-chart.png -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/icons/checklist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/plugins/ComboBoxCheckable/icons/checklist.png -------------------------------------------------------------------------------- /plugins/ImageFrame/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/photo.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /plugins/LineEditTag/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/tag.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /screenshots/checkboxwordwrap_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/checkboxwordwrap_properties.png -------------------------------------------------------------------------------- /screenshots/circularprogress_properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThiBsc/qtCustomPlugins/HEAD/screenshots/circularprogress_properties.png -------------------------------------------------------------------------------- /plugins/LineEditRegex/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/text.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/check_icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /plugins/CircularProgress/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/pie-chart.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/checklist.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | before_install: sudo apt-get install qt5-default libqt5designer5 qttools5-dev 3 | script: cd plugins && mkdir build && cd build && qmake ../customPlugins.pro && make 4 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/checkboxwordwrap.pri: -------------------------------------------------------------------------------- 1 | HEADERS += src/checkboxwordwrap.h \ 2 | $$PWD/src/clickablelabel.h 3 | SOURCES += src/checkboxwordwrap.cpp \ 4 | $$PWD/src/clickablelabel.cpp 5 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/lineeditregex.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/src/lineediticon.h \ 2 | $$PWD/src/lineeditregex.h 3 | SOURCES += $$PWD/src/lineediticon.cpp \ 4 | $$PWD/src/lineeditregex.cpp 5 | -------------------------------------------------------------------------------- /plugins/LineEditTag/README.md: -------------------------------------------------------------------------------- 1 | # LineEditRegex 2 | 3 | ## Properties 4 | 5 | |Property|Type| 6 | |-|-| 7 | |tags|[QString](http://doc.qt.io/qt-5/qstring.html)| 8 | 9 | ![plugins render](../../screenshots/lineedittag_properties.png) 10 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/comboboxcheckable.pri: -------------------------------------------------------------------------------- 1 | HEADERS += $$PWD/src/comboboxcheckable.h \ 2 | $$PWD/src/abstractlistmodelcheckablecbx.h 3 | SOURCES += $$PWD/src/comboboxcheckable.cpp \ 4 | $$PWD/src/abstractlistmodelcheckablecbx.cpp 5 | -------------------------------------------------------------------------------- /plugins/customPlugins.pro: -------------------------------------------------------------------------------- 1 | TARGET = customPlugins 2 | TEMPLATE = subdirs 3 | SUBDIRS += ./CheckBoxWordWrap \ 4 | ./LineEditRegex \ 5 | ./LineEditTag \ 6 | ./ImageFrame \ 7 | ./CircularProgress \ 8 | ./ComboBoxCheckable 9 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/README.md: -------------------------------------------------------------------------------- 1 | # LineEditRegex 2 | 3 | ## Properties 4 | 5 | |Property|Type| 6 | |-|-| 7 | |icon|[QIcon](http://doc.qt.io/qt-5/qicon.html)| 8 | |pattern|[QString](http://doc.qt.io/qt-5/qregularexpression.html#setPattern)| 9 | 10 | ![plugins render](../../screenshots/lineeditregex_properties.png) 11 | -------------------------------------------------------------------------------- /plugins/ImageFrame/README.md: -------------------------------------------------------------------------------- 1 | # ImageFrame 2 | 3 | ## Properties 4 | 5 | |Property|Type| 6 | |-|-| 7 | |pixmap|[QPixmap](http://doc.qt.io/qt-5/qpixmap.html)| 8 | |ratiomode|[Qt::AspectRatioMode](http://doc.qt.io/qt-5/qt.html#AspectRatioMode-enum)| 9 | 10 | ![plugins render](../../screenshots/imageframe_properties.png) 11 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/README.md: -------------------------------------------------------------------------------- 1 | # CheckBoxWordWrap 2 | 3 | ## Properties 4 | 5 | |Property|Type| 6 | |-|-| 7 | |wordwrap|[bool](http://doc.qt.io/qt-5/qlabel.html#wordWrap-prop)| 8 | |text|[QString](http://doc.qt.io/qt-5/qlabel.html#text-prop)| 9 | 10 | ![plugins render](../../screenshots/checkboxwordwrap_properties.png) 11 | -------------------------------------------------------------------------------- /plugins/CircularProgress/README.md: -------------------------------------------------------------------------------- 1 | # CircularProgress 2 | 3 | ## Properties 4 | 5 | |Property|Type| 6 | |-|-| 7 | |min|int| 8 | |max|int| 9 | |value|int| 10 | |bgColor|[QColor](http://doc.qt.io/qt-5/qcolor.html)| 11 | |valueColor|[QColor](http://doc.qt.io/qt-5/qcolor.html)| 12 | |barWidth|int| 13 | |showtext|bool| 14 | |infinity|bool| 15 | |startAngle|int [(1/360 = 1*16)](http://doc.qt.io/qt-5/qpainter.html#drawArc)| 16 | 17 | ![plugins render](../../screenshots/circularprogress_properties.png) 18 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/clickablelabel.cpp: -------------------------------------------------------------------------------- 1 | #include "clickablelabel.h" 2 | 3 | ClickableLabel::ClickableLabel(QWidget *parent, Qt::WindowFlags f) 4 | : QLabel(parent, f) 5 | { 6 | 7 | } 8 | 9 | ClickableLabel::ClickableLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) 10 | : QLabel(text, parent, f) 11 | { 12 | 13 | } 14 | 15 | ClickableLabel::~ClickableLabel() 16 | { 17 | 18 | } 19 | 20 | void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) 21 | { 22 | Q_UNUSED(event); 23 | emit clicked(); 24 | } 25 | -------------------------------------------------------------------------------- /plugins/ImageFrame/ImageFrame.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(imageframeplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/imageframeplugin.h 6 | SOURCES = src/imageframeplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(imageframe.pri) 22 | -------------------------------------------------------------------------------- /plugins/LineEditTag/LineEditTag.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(lineedittagplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/lineedittagplugin.h 6 | SOURCES = src/lineedittagplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(lineedittag.pri) 22 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/LineEditRegex.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(lineeditregexplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/lineeditregexplugin.h 6 | SOURCES = src/lineeditregexplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(lineeditregex.pri) 22 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/CheckBoxWordWrap.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(checkboxwordwrapplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/checkboxwordwrapplugin.h 6 | SOURCES = src/checkboxwordwrapplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(checkboxwordwrap.pri) 22 | -------------------------------------------------------------------------------- /plugins/CircularProgress/CircularProgress.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(circularprogressplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/circularprogressplugin.h 6 | SOURCES = src/circularprogressplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(circularprogress.pri) 22 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/ComboBoxCheckable.pro: -------------------------------------------------------------------------------- 1 | CONFIG += plugin debug_and_release 2 | TARGET = $$qtLibraryTarget(comboboxcheckableplugin) 3 | TEMPLATE = lib 4 | 5 | HEADERS = src/comboboxcheckableplugin.h 6 | SOURCES = src/comboboxcheckableplugin.cpp 7 | RESOURCES = icons.qrc 8 | LIBS += -L. 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4) { 11 | QT += designer 12 | CONFIG += c++11 13 | } else { 14 | CONFIG += designer 15 | QMAKE_CXXFLAGS += -std=c++11 16 | } 17 | 18 | target.path = $$[QT_INSTALL_PLUGINS]/designer 19 | INSTALLS += target 20 | 21 | include(comboboxcheckable.pri) 22 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/comboboxcheckable.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBOBOXCHECKABLE_H 2 | #define COMBOBOXCHECKABLE_H 3 | 4 | #include 5 | 6 | class AbstractListModelCheckableCbx; 7 | 8 | /** 9 | * @author thibsc 10 | * @brief The ComboBoxCheckable class 11 | */ 12 | class ComboBoxCheckable : public QComboBox 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | ComboBoxCheckable(QWidget *parent = Q_NULLPTR); 18 | ~ComboBoxCheckable(); 19 | void addItem(const QString& item); 20 | void addItems(const QStringList& items); 21 | QList getItems() const; 22 | 23 | private slots: 24 | void checkItem(); 25 | 26 | private: 27 | AbstractListModelCheckableCbx *listModel; 28 | 29 | }; 30 | 31 | #endif // COMBOBOXCHECKABLE_H 32 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [thibsc] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | #patreon: # Replace with a single Patreon username 5 | #open_collective: # Replace with a single Open Collective username 6 | #ko_fi: # Replace with a single Ko-fi username 7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | #liberapay: # Replace with a single Liberapay username 10 | #issuehunt: # Replace with a single IssueHunt username 11 | #otechie: # Replace with a single Otechie username 12 | #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/clickablelabel.h: -------------------------------------------------------------------------------- 1 | #ifndef CLICKABLELABEL_H 2 | #define CLICKABLELABEL_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief The ClickableLabel class 9 | * https://wiki.qt.io/Clickable_QLabel 10 | */ 11 | class ClickableLabel : public QLabel 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit ClickableLabel(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); 16 | explicit ClickableLabel(const QString &text, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); 17 | ~ClickableLabel() override; 18 | 19 | signals: 20 | void clicked(); 21 | 22 | protected: 23 | void mouseReleaseEvent(QMouseEvent *event) override; 24 | 25 | }; 26 | 27 | #endif // CLICKABLELABEL_H 28 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineediticon.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITICON_H 2 | #define LINEEDITICON_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @author thibsc 9 | * @brief The LineEditIcon class 10 | * Allow to add an icon before the text 11 | */ 12 | class LineEditIcon : public QLineEdit 13 | { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(QIcon icon READ getIcon WRITE setIcon) 17 | 18 | public: 19 | LineEditIcon(QWidget *parent = Q_NULLPTR); 20 | LineEditIcon(const QIcon icon, QWidget *parent = Q_NULLPTR); 21 | ~LineEditIcon(); 22 | QIcon getIcon() const; 23 | void setIcon(QIcon icon); 24 | 25 | protected: 26 | void paintEvent(QPaintEvent *event) override; 27 | 28 | private: 29 | QIcon m_icon; 30 | 31 | }; 32 | 33 | #endif // LINEEDITICON_H 34 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineeditregex.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITREGEX_H 2 | #define LINEEDITREGEX_H 3 | 4 | #include "lineediticon.h" 5 | 6 | class QRegularExpression; 7 | class QRegularExpressionValidator; 8 | 9 | /** 10 | * @author thibsc 11 | * @brief The LineEditRegex class 12 | * Allow text by regular expression 13 | */ 14 | class LineEditRegex : public LineEditIcon 15 | { 16 | Q_OBJECT 17 | 18 | Q_PROPERTY(QString pattern READ getPattern WRITE setPattern) 19 | 20 | public: 21 | LineEditRegex(QWidget *parent = Q_NULLPTR); 22 | LineEditRegex(const QString pattern, QWidget *parent = Q_NULLPTR); 23 | ~LineEditRegex(); 24 | QString getPattern() const; 25 | void setPattern(const QString pattern); 26 | QVariant getValue(const QString regexGroup) const; 27 | QVariant getValue(int group) const; 28 | bool isValid() const; 29 | 30 | private: 31 | QRegularExpression *regex; 32 | QRegularExpressionValidator *validator; 33 | 34 | }; 35 | 36 | #endif // LINEEDITREGEX_H 37 | -------------------------------------------------------------------------------- /plugins/ImageFrame/src/imageframe.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGE_H 2 | #define IMAGE_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @author thibsc 9 | * @brief The Image class 10 | */ 11 | class ImageFrame : public QFrame 12 | { 13 | Q_OBJECT 14 | 15 | Q_PROPERTY(QPixmap pixmap READ getPixmap WRITE setPixmap) 16 | Q_PROPERTY(Qt::AspectRatioMode ratiomode READ getAspectRatioMode WRITE setAspectRatioMode) 17 | 18 | public: 19 | ImageFrame(QWidget *parent = Q_NULLPTR); 20 | ImageFrame(const QPixmap pixmap, QWidget *parent = Q_NULLPTR); 21 | ~ImageFrame(); 22 | QPixmap getPixmap() const; 23 | void setPixmap(QPixmap pixmap); 24 | Qt::AspectRatioMode getAspectRatioMode() const; 25 | void setAspectRatioMode(Qt::AspectRatioMode ratiomode); 26 | 27 | protected: 28 | void paintEvent(QPaintEvent *event) override; 29 | 30 | private: 31 | QPixmap m_pixmap, m_nopixmap; 32 | Qt::AspectRatioMode m_aspectRatioMode; 33 | bool hasPixmap; 34 | 35 | }; 36 | 37 | #endif // LINEEDITICON_H 38 | -------------------------------------------------------------------------------- /plugins/LineEditTag/src/lineedittag.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITTAG_H 2 | #define LINEEDITTAG_H 3 | 4 | #include 5 | 6 | /** 7 | * @author thibsc 8 | * @brief The LineEditTag class 9 | */ 10 | class LineEditTag : public QLineEdit 11 | { 12 | Q_OBJECT 13 | 14 | Q_PROPERTY(QString tags READ getTagsStr WRITE setTags) 15 | 16 | public: 17 | explicit LineEditTag(QWidget *parent = nullptr); 18 | ~LineEditTag() override; 19 | QStringList getTags() const; 20 | QString getTagsStr() const; 21 | void setTags(const QString& tags); 22 | void setTags(const QStringList& tags); 23 | 24 | private slots: 25 | void addTag(); 26 | 27 | protected: 28 | void leaveEvent(QEvent *evt) override; 29 | void keyPressEvent(QKeyEvent *evt) override; 30 | void mousePressEvent(QMouseEvent *evt) override; 31 | void mouseMoveEvent(QMouseEvent *evt) override; 32 | void paintEvent(QPaintEvent *evt) override; 33 | 34 | private: 35 | QStringList tags; 36 | QPoint cursorPos, clickedPos; 37 | 38 | }; 39 | 40 | #endif // LINEEDITTAG_H 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Thibaut B. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineediticon.cpp: -------------------------------------------------------------------------------- 1 | #include "lineediticon.h" 2 | #include 3 | 4 | LineEditIcon::LineEditIcon(QWidget *parent) 5 | : QLineEdit(parent) 6 | { 7 | setIcon(QIcon()); 8 | } 9 | 10 | LineEditIcon::LineEditIcon(const QIcon icon, QWidget *parent) 11 | : QLineEdit(parent) 12 | { 13 | setIcon(icon); 14 | } 15 | 16 | LineEditIcon::~LineEditIcon() 17 | { 18 | 19 | } 20 | 21 | QIcon LineEditIcon::getIcon() const 22 | { 23 | return m_icon; 24 | } 25 | 26 | void LineEditIcon::setIcon(QIcon icon) 27 | { 28 | m_icon = icon; 29 | if (m_icon.isNull()){ 30 | setTextMargins(0, 0, 0, 0); 31 | } else { 32 | setTextMargins(height(), 0, 0, 0); 33 | } 34 | } 35 | 36 | void LineEditIcon::paintEvent(QPaintEvent * event) 37 | { 38 | QLineEdit::paintEvent(event); 39 | if (!m_icon.isNull()) { 40 | QPainter painter(this); 41 | QPixmap pxm = m_icon.pixmap(height() - 6, height() - 6); 42 | int x = 2, cx = pxm.width(); 43 | 44 | painter.drawPixmap(2, 3, pxm); 45 | painter.setPen(QColor("lightgrey")); 46 | painter.drawLine(cx + 2, 3, cx + 2, height() - 4); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/checkboxwordwrap.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKBOXWORDWRAP_H 2 | #define CHECKBOXWORDWRAP_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "clickablelabel.h" 9 | 10 | /** 11 | * @author thibsc 12 | */ 13 | class CheckBoxWordWrap : public QCheckBox 14 | { 15 | Q_OBJECT 16 | 17 | Q_PROPERTY(bool wordwrap READ isWordWrap WRITE setWordWrap) 18 | Q_PROPERTY(QString text READ text WRITE setText) 19 | 20 | public: 21 | CheckBoxWordWrap(QWidget *parent = Q_NULLPTR); 22 | CheckBoxWordWrap(const QString &text, QWidget *parent = Q_NULLPTR); 23 | ~CheckBoxWordWrap(); 24 | bool isWordWrap() const; 25 | void setWordWrap(bool wordwrap); 26 | QString text() const; 27 | void setText(const QString &text); 28 | QSize sizeHint() const override; 29 | 30 | private slots: 31 | void labelIsClicked(); 32 | 33 | protected: 34 | void resizeEvent(QResizeEvent *event) override; 35 | 36 | private: 37 | void init(); 38 | const int separation = 5; 39 | QHBoxLayout *m_hMainLayout; 40 | ClickableLabel *m_label; 41 | 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/abstractlistmodelcheckablecbx.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTLISTMODELCHECKABLECBX_H 2 | #define ABSTRACTLISTMODELCHECKABLECBX_H 3 | 4 | #include 5 | 6 | /** 7 | * @author thibsc 8 | * @brief The AbstractListModelCheckableCbx class 9 | */ 10 | class AbstractListModelCheckableCbx : public QAbstractListModel 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | AbstractListModelCheckableCbx(QObject *parent = Q_NULLPTR); 16 | ~AbstractListModelCheckableCbx(); 17 | virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; 18 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 19 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; 20 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; 21 | virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 22 | void addItem(const QString& item); 23 | void clearItems(); 24 | QList getItems() const; 25 | 26 | signals: 27 | void selectionChanged(); 28 | 29 | private: 30 | QMap *_data; 31 | QStringList selectionText; 32 | 33 | }; 34 | 35 | #endif // ABSTRACTLISTMODELCHECKABLECBX_H 36 | -------------------------------------------------------------------------------- /plugins/ImageFrame/src/imageframeplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGEFRAMEPLUGIN_H 2 | #define IMAGEFRAMEPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief ImageFramePlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class ImageFramePlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | ImageFramePlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif // IMAGEFRAMEPLUGIN_H 38 | -------------------------------------------------------------------------------- /plugins/LineEditTag/src/lineedittagplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITTAGPLUGIN_H 2 | #define LINEEDITTAGPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief The LineEditTagPlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class LineEditTagPlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | LineEditTagPlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif // LINEEDITTAGPLUGIN_H 38 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/checkboxwordwrapplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKBOXWORDWRAPPLUGIN_H 2 | #define CHECKBOXWORDWRAPPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief The CheckBoxWordWrapPlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class CheckBoxWordWrapPlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | CheckBoxWordWrapPlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineeditregexplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITREGEXPLUGIN_H 2 | #define LINEEDITREGEXPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief The LineEditRegexPlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class LineEditRegexPlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | LineEditRegexPlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif // LINEEDITREGEXPLUGIN_H 38 | -------------------------------------------------------------------------------- /plugins/CircularProgress/src/circularprogressplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCULARPROGRESSPLUGIN_H 2 | #define CIRCULARPROGRESSPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief CircularProgressPlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class CircularProgressPlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | CircularProgressPlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif // CIRCULARPROGRESSPLUGIN_H 38 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/comboboxcheckableplugin.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBOBOXCHECKABLEPLUGIN_H 2 | #define COMBOBOXCHECKABLEPLUGIN_H 3 | 4 | #include 5 | 6 | /** 7 | * @brief The ComboBoxCheckablePlugin class 8 | * http://doc.qt.io/archives/qt-4.8/designer-creating-custom-widgets.html 9 | */ 10 | class ComboBoxCheckablePlugin : public QObject, public QDesignerCustomWidgetInterface 11 | { 12 | Q_OBJECT 13 | Q_INTERFACES(QDesignerCustomWidgetInterface) 14 | #if QT_VERSION >= 0x050000 15 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface") 16 | #endif // QT_VERSION >= 0x050000 17 | 18 | public: 19 | ComboBoxCheckablePlugin(QObject *parent = Q_NULLPTR); 20 | 21 | bool isContainer() const; 22 | bool isInitialized() const; 23 | QIcon icon() const; 24 | QString domXml() const; 25 | QString group() const; 26 | QString includeFile() const; 27 | QString name() const; 28 | QString toolTip() const; 29 | QString whatsThis() const; 30 | QWidget *createWidget(QWidget *parent); 31 | void initialize(QDesignerFormEditorInterface *core); 32 | 33 | private: 34 | bool m_initialized; 35 | }; 36 | 37 | #endif // COMBOBOXCHECKABLEPLUGIN_H 38 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/comboboxcheckable.cpp: -------------------------------------------------------------------------------- 1 | #include "comboboxcheckable.h" 2 | #include "abstractlistmodelcheckablecbx.h" 3 | #include 4 | 5 | ComboBoxCheckable::ComboBoxCheckable(QWidget *parent) 6 | : QComboBox(parent) 7 | { 8 | listModel = new AbstractListModelCheckableCbx(); 9 | setModel(listModel); 10 | #ifdef __GNUC__ 11 | // Force Windows style because Fusions doesn't show CheckBox in model 12 | setStyle(QStyleFactory::create("Windows")); 13 | #endif 14 | 15 | connect(listModel, SIGNAL(selectionChanged()), this, SLOT(checkItem())); 16 | } 17 | 18 | ComboBoxCheckable::~ComboBoxCheckable() 19 | { 20 | delete listModel; 21 | } 22 | 23 | void ComboBoxCheckable::addItem(const QString& item) 24 | { 25 | listModel->addItem(item); 26 | } 27 | 28 | void ComboBoxCheckable::addItems(const QStringList& items) 29 | { 30 | for (const QString& item : items){ 31 | listModel->addItem(item); 32 | } 33 | } 34 | 35 | QList ComboBoxCheckable::getItems() const 36 | { 37 | return listModel->getItems(); 38 | } 39 | 40 | void ComboBoxCheckable::checkItem() 41 | { 42 | QModelIndex index = listModel->index(0); 43 | setCurrentText(index.data(Qt::DisplayRole).toString()); 44 | setToolTip(index.data(Qt::ToolTipRole).toString()); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineeditregex.cpp: -------------------------------------------------------------------------------- 1 | #include "lineeditregex.h" 2 | #include 3 | #include 4 | 5 | LineEditRegex::LineEditRegex(QWidget *parent) 6 | : LineEditIcon(QIcon(), parent) 7 | , regex(new QRegularExpression()) 8 | { 9 | validator = new QRegularExpressionValidator(*regex, this); 10 | setValidator(validator); 11 | } 12 | 13 | LineEditRegex::LineEditRegex(const QString pattern, QWidget *parent) 14 | : LineEditIcon(QIcon(), parent) 15 | , regex(new QRegularExpression(pattern, QRegularExpression::NoPatternOption)) 16 | { 17 | validator = new QRegularExpressionValidator(*regex, this); 18 | setValidator(validator); 19 | } 20 | 21 | LineEditRegex::~LineEditRegex() 22 | { 23 | delete regex; 24 | delete validator; 25 | } 26 | 27 | QString LineEditRegex::getPattern() const 28 | { 29 | return regex->pattern(); 30 | } 31 | 32 | void LineEditRegex::setPattern(const QString pattern) 33 | { 34 | if (!pattern.isEmpty()){ 35 | regex->setPattern(pattern); 36 | validator->setRegularExpression(QRegularExpression(pattern)); 37 | } 38 | } 39 | 40 | QVariant LineEditRegex::getValue(const QString regexGroup) const 41 | { 42 | QRegularExpressionMatch rem = regex->match(text()); 43 | return rem.captured(regexGroup); 44 | } 45 | 46 | QVariant LineEditRegex::getValue(int group) const 47 | { 48 | QRegularExpressionMatch rem = regex->match(text()); 49 | return rem.captured(group); 50 | } 51 | 52 | bool LineEditRegex::isValid() const 53 | { 54 | int pos = 0; 55 | QString input = text(); 56 | QValidator::State state = validator->validate(input, pos); 57 | return state == QValidator::Acceptable; 58 | } 59 | -------------------------------------------------------------------------------- /plugins/ImageFrame/src/imageframeplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "imageframe.h" 2 | #include "imageframeplugin.h" 3 | 4 | #include 5 | 6 | ImageFramePlugin::ImageFramePlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void ImageFramePlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool ImageFramePlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *ImageFramePlugin::createWidget(QWidget *parent) 28 | { 29 | return new ImageFrame(parent); 30 | } 31 | 32 | QString ImageFramePlugin::name() const 33 | { 34 | return QLatin1String("ImageFrame"); 35 | } 36 | 37 | QString ImageFramePlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon ImageFramePlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/photo.png")); 45 | } 46 | 47 | QString ImageFramePlugin::toolTip() const 48 | { 49 | return QLatin1String("An image"); 50 | } 51 | 52 | QString ImageFramePlugin::whatsThis() const 53 | { 54 | return QLatin1String("The possibility to put an image in a frame."); 55 | } 56 | 57 | bool ImageFramePlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString ImageFramePlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString ImageFramePlugin::includeFile() const 68 | { 69 | return QLatin1String("imageframe.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(ImageFramePlugin, ImageFramePlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /plugins/LineEditTag/src/lineedittagplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "lineedittag.h" 2 | #include "lineedittagplugin.h" 3 | 4 | #include 5 | 6 | LineEditTagPlugin::LineEditTagPlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void LineEditTagPlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool LineEditTagPlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *LineEditTagPlugin::createWidget(QWidget *parent) 28 | { 29 | return new LineEditTag(parent); 30 | } 31 | 32 | QString LineEditTagPlugin::name() const 33 | { 34 | return QLatin1String("LineEditTag"); 35 | } 36 | 37 | QString LineEditTagPlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon LineEditTagPlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/tag.png")); 45 | } 46 | 47 | QString LineEditTagPlugin::toolTip() const 48 | { 49 | return QLatin1String("Line edit with tags"); 50 | } 51 | 52 | QString LineEditTagPlugin::whatsThis() const 53 | { 54 | return QLatin1String("Line edit with tags like the Stackoverflow tag system."); 55 | } 56 | 57 | bool LineEditTagPlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString LineEditTagPlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString LineEditTagPlugin::includeFile() const 68 | { 69 | return QLatin1String("lineedittag.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(LineEditTagPlugin, LineEditTagPlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /plugins/LineEditRegex/src/lineeditregexplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "lineeditregex.h" 2 | #include "lineeditregexplugin.h" 3 | 4 | #include 5 | 6 | LineEditRegexPlugin::LineEditRegexPlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void LineEditRegexPlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool LineEditRegexPlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *LineEditRegexPlugin::createWidget(QWidget *parent) 28 | { 29 | return new LineEditRegex(parent); 30 | } 31 | 32 | QString LineEditRegexPlugin::name() const 33 | { 34 | return QLatin1String("LineEditRegex"); 35 | } 36 | 37 | QString LineEditRegexPlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon LineEditRegexPlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/text.png")); 45 | } 46 | 47 | QString LineEditRegexPlugin::toolTip() const 48 | { 49 | return QLatin1String("Line edit controled by regular expression"); 50 | } 51 | 52 | QString LineEditRegexPlugin::whatsThis() const 53 | { 54 | return QLatin1String("Line edit controled by regular expression."); 55 | } 56 | 57 | bool LineEditRegexPlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString LineEditRegexPlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString LineEditRegexPlugin::includeFile() const 68 | { 69 | return QLatin1String("lineeditregex.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(LineEditRegexPlugin, LineEditRegexPlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /plugins/ImageFrame/src/imageframe.cpp: -------------------------------------------------------------------------------- 1 | #include "imageframe.h" 2 | #include 3 | 4 | ImageFrame::ImageFrame(QWidget *parent) 5 | : QFrame(parent) 6 | , m_aspectRatioMode(Qt::KeepAspectRatio) 7 | { 8 | setPixmap(QPixmap()); 9 | m_nopixmap.load("://icons/photo.png", nullptr, Qt::AutoColor); 10 | } 11 | 12 | ImageFrame::ImageFrame(const QPixmap pixmap, QWidget *parent) 13 | : QFrame(parent) 14 | , m_aspectRatioMode(Qt::KeepAspectRatio) 15 | { 16 | setPixmap(pixmap); 17 | m_nopixmap.load("://icons/photo.png", nullptr, Qt::AutoColor); 18 | } 19 | 20 | ImageFrame::~ImageFrame() 21 | { 22 | 23 | } 24 | 25 | QPixmap ImageFrame::getPixmap() const 26 | { 27 | return m_pixmap; 28 | } 29 | 30 | void ImageFrame::setPixmap(QPixmap pixmap) 31 | { 32 | m_pixmap = pixmap; 33 | update(); 34 | } 35 | 36 | Qt::AspectRatioMode ImageFrame::getAspectRatioMode() const 37 | { 38 | return m_aspectRatioMode; 39 | } 40 | 41 | void ImageFrame::setAspectRatioMode(Qt::AspectRatioMode ratiomode) 42 | { 43 | m_aspectRatioMode = ratiomode; 44 | update(); 45 | } 46 | 47 | void ImageFrame::paintEvent(QPaintEvent * event) 48 | { 49 | QFrame::paintEvent(event); 50 | QPainter painter(this); 51 | QPen pen = painter.pen(); 52 | int w = width(), h = height(); 53 | QPixmap pix; 54 | if (m_pixmap.isNull()) { 55 | pen.setStyle(Qt::DashLine); 56 | pen.setColor(QColor(Qt::lightGray)); 57 | pen.setWidth(2); 58 | painter.setPen(pen); 59 | QRect frame(1, 1, w-pen.width(), h-pen.width()); 60 | painter.drawRect(frame); 61 | pix = m_nopixmap.scaled(QSize(w/2, h/2), Qt::KeepAspectRatio); 62 | painter.drawPixmap(w/2-pix.width()/2, h/2-pix.height()/2, pix); 63 | } else { 64 | pix = m_pixmap.scaled(w, h, m_aspectRatioMode); 65 | if (pix.width() < w || pix.height() < h){ 66 | // Center 67 | painter.drawPixmap(w/2-pix.width()/2, h/2-pix.height()/2, pix); 68 | } else { 69 | painter.drawPixmap(0, 0, pix); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /plugins/CircularProgress/src/circularprogressplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "circularprogress.h" 2 | #include "circularprogressplugin.h" 3 | 4 | #include 5 | 6 | CircularProgressPlugin::CircularProgressPlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void CircularProgressPlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool CircularProgressPlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *CircularProgressPlugin::createWidget(QWidget *parent) 28 | { 29 | return new CircularProgress(parent); 30 | } 31 | 32 | QString CircularProgressPlugin::name() const 33 | { 34 | return QLatin1String("CircularProgress"); 35 | } 36 | 37 | QString CircularProgressPlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon CircularProgressPlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/pie-chart.png")); 45 | } 46 | 47 | QString CircularProgressPlugin::toolTip() const 48 | { 49 | return QLatin1String("A circular progress bar"); 50 | } 51 | 52 | QString CircularProgressPlugin::whatsThis() const 53 | { 54 | return QLatin1String("A circular progress bar."); 55 | } 56 | 57 | bool CircularProgressPlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString CircularProgressPlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString CircularProgressPlugin::includeFile() const 68 | { 69 | return QLatin1String("circularprogress.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(CircularProgressPlugin, CircularProgressPlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/checkboxwordwrapplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "checkboxwordwrap.h" 2 | #include "checkboxwordwrapplugin.h" 3 | 4 | #include 5 | 6 | CheckBoxWordWrapPlugin::CheckBoxWordWrapPlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void CheckBoxWordWrapPlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool CheckBoxWordWrapPlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *CheckBoxWordWrapPlugin::createWidget(QWidget *parent) 28 | { 29 | return new CheckBoxWordWrap(parent); 30 | } 31 | 32 | QString CheckBoxWordWrapPlugin::name() const 33 | { 34 | return QLatin1String("CheckBoxWordWrap"); 35 | } 36 | 37 | QString CheckBoxWordWrapPlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon CheckBoxWordWrapPlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/check_icon.png")); 45 | } 46 | 47 | QString CheckBoxWordWrapPlugin::toolTip() const 48 | { 49 | return QLatin1String("CheckBox with word-wrap"); 50 | } 51 | 52 | QString CheckBoxWordWrapPlugin::whatsThis() const 53 | { 54 | return QLatin1String("A Checkbox with auto word-wrap"); 55 | } 56 | 57 | bool CheckBoxWordWrapPlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString CheckBoxWordWrapPlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString CheckBoxWordWrapPlugin::includeFile() const 68 | { 69 | return QLatin1String("checkboxwordwrap.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(checkboxwordwrapplugin, CheckBoxWordWrapPlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # qtCustomPlugins 2 | [![Build Status](https://travis-ci.org/ThiBsc/qtCustomPlugins.svg?branch=master)](https://travis-ci.org/ThiBsc/qtCustomPlugins) 3 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 4 | 5 | A set of custom widgets to use directly in QtDesigner. 6 | 7 | ## Requirements 8 | 9 | * qt5-default 10 | * libqt5designer5 11 | * qttools5-dev 12 | 13 | ## Plugins 14 | 15 | * [CheckBoxWordWrap](./plugins/CheckBoxWordWrap) 16 | * [LineEditRegex](./plugins/LineEditRegex) 17 | * [LineEditTag](./plugins/LineEditTag) 18 | * [ImageFrame](./plugins/ImageFrame) 19 | * [CircularProgress](./plugins/CircularProgress) 20 | * [ComboBoxCheckable](./plugins/ComboBoxCheckable) 21 | 22 | ![plugins render](screenshots/plugins_results.png) 23 | 24 | ### How to use 25 | It's very easy, just drag & drop the widget in QtDesigner like with all others QtWidgets. 26 | 27 | ![plugins designer](screenshots/plugins_in_designer.png) 28 | 29 | ## Compile 30 | ### All plugins 31 | ```sh 32 | cd plugins 33 | mkdir build 34 | cd build 35 | qmake ../customPlugins.pro 36 | make 37 | ``` 38 | ### Individually 39 | ```sh 40 | # Juste replace the last step by this line: 41 | make sub-[YourWantedPlugin] 42 | ``` 43 | 44 | ## Install 45 | After the build step, take the `.so` file and copy it into the QtCreator directory. 46 | Ex. `cp liblineeditregexplugin.so ~/Qt/Tools/QtCreator/lib/Qt/plugins/designer/` 47 | If the plugins are correctly installed, they appear in menu `Tools/Form Editor/About Qt Designer plugins` 48 | 49 | ![active designer](screenshots/active_in_designer.png) 50 | 51 | ## Plugins icons 52 | 53 | CheckBoxWordWrap, ImageFrame, ComboBoxCheckable and LineEditTag icon made by [Freepik](https://www.freepik.com/) from [Flaticon](www.flaticon.com) 54 | LineEditRegex icon made by [Alfredo creates](https://www.alfredocreates.com/) from [Flaticon](www.flaticon.com) 55 | CircularProgress icon made by [Smashicons](https://smashicons.com/) from [Flaticon](www.flaticon.com) 56 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/comboboxcheckableplugin.cpp: -------------------------------------------------------------------------------- 1 | #include "comboboxcheckable.h" 2 | #include "comboboxcheckableplugin.h" 3 | 4 | #include 5 | 6 | ComboBoxCheckablePlugin::ComboBoxCheckablePlugin(QObject *parent) 7 | : QObject(parent) 8 | { 9 | m_initialized = false; 10 | } 11 | 12 | void ComboBoxCheckablePlugin::initialize(QDesignerFormEditorInterface * /* core */) 13 | { 14 | if (m_initialized) 15 | return; 16 | 17 | // Add extension registrations, etc. here 18 | 19 | m_initialized = true; 20 | } 21 | 22 | bool ComboBoxCheckablePlugin::isInitialized() const 23 | { 24 | return m_initialized; 25 | } 26 | 27 | QWidget *ComboBoxCheckablePlugin::createWidget(QWidget *parent) 28 | { 29 | return new ComboBoxCheckable(parent); 30 | } 31 | 32 | QString ComboBoxCheckablePlugin::name() const 33 | { 34 | return QLatin1String("ComboBoxCheckable"); 35 | } 36 | 37 | QString ComboBoxCheckablePlugin::group() const 38 | { 39 | return QLatin1String("My Custom Plugins"); 40 | } 41 | 42 | QIcon ComboBoxCheckablePlugin::icon() const 43 | { 44 | return QIcon(QLatin1String("://icons/checklist.png")); 45 | } 46 | 47 | QString ComboBoxCheckablePlugin::toolTip() const 48 | { 49 | return QLatin1String("ComboBox with multiple selection"); 50 | } 51 | 52 | QString ComboBoxCheckablePlugin::whatsThis() const 53 | { 54 | return QLatin1String("ComboBox with multiple selection."); 55 | } 56 | 57 | bool ComboBoxCheckablePlugin::isContainer() const 58 | { 59 | return false; 60 | } 61 | 62 | QString ComboBoxCheckablePlugin::domXml() const 63 | { 64 | return QLatin1String("\n\n"); 65 | } 66 | 67 | QString ComboBoxCheckablePlugin::includeFile() const 68 | { 69 | return QLatin1String("comboboxcheckable.h"); 70 | } 71 | #if QT_VERSION < 0x050000 72 | Q_EXPORT_PLUGIN2(ComboBoxCheckablePlugin, ComboBoxCheckablePlugin) 73 | #endif // QT_VERSION < 0x050000 74 | -------------------------------------------------------------------------------- /plugins/CircularProgress/src/circularprogress.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCULARPROGRESS_H 2 | #define CIRCULARPROGRESS_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @author thibsc 9 | * @brief The CircularProgress class 10 | */ 11 | 12 | class CircularProgress : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | Q_PROPERTY(int min READ getMin WRITE setMin NOTIFY minChanged) 17 | Q_PROPERTY(int max READ getMax WRITE setMax NOTIFY maxChanged) 18 | Q_PROPERTY(int value READ getValue WRITE setValue NOTIFY valueChanged) 19 | Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor) 20 | Q_PROPERTY(QColor valueColor READ getValueColor WRITE setValueColor) 21 | Q_PROPERTY(int barWidth READ getBarWidth WRITE setBarWidth) 22 | Q_PROPERTY(bool showtext READ isShowingText WRITE setTextVisible) 23 | Q_PROPERTY(bool infinity READ infinityMode WRITE setInfinityMode) 24 | Q_PROPERTY(int startAngle READ getStartAngle WRITE setStartAngle) 25 | 26 | public: 27 | enum ProgressType { Filled=0, Ellipse }; 28 | explicit CircularProgress(QWidget *parent = nullptr); 29 | void setProgressType(ProgressType progressType); 30 | int getValue() const; 31 | int getMin() const; 32 | int getMax() const; 33 | QColor getBgColor() const; 34 | QColor getValueColor() const; 35 | int getBarWidth() const; 36 | bool isShowingText() const; 37 | bool infinityMode() const; 38 | int getStartAngle() const; 39 | 40 | signals: 41 | void valueChanged(int nval); 42 | void minChanged(int nmin); 43 | void maxChanged(int nmax); 44 | 45 | public slots: 46 | void setValue(int value); 47 | void setMin(int min); 48 | void setMax(int max); 49 | void setRange(int min, int max); 50 | void setBgColor(QColor bgcolor); 51 | void setValueColor(QColor valuecolor); 52 | void setBarWidth(int bwidth); 53 | void setTextVisible(bool visible = true); 54 | void setInfinityMode(bool infinite); 55 | void setStartAngle(int s_angle); 56 | 57 | protected: 58 | void paintEvent(QPaintEvent *event) override; 59 | 60 | private: 61 | QPropertyAnimation *m_animation; 62 | ProgressType m_progressType; 63 | QColor m_bgColor, m_valueColor; 64 | int m_min, m_max, m_value; 65 | int m_startAngle, m_barWidth; 66 | bool m_showTextPercent, m_infinityMode; 67 | 68 | }; 69 | 70 | #endif // CIRCULARPROGRESS_H 71 | -------------------------------------------------------------------------------- /plugins/CheckBoxWordWrap/src/checkboxwordwrap.cpp: -------------------------------------------------------------------------------- 1 | #include "checkboxwordwrap.h" 2 | 3 | #include 4 | #include 5 | 6 | CheckBoxWordWrap::CheckBoxWordWrap(QWidget *parent) 7 | : QCheckBox (parent) 8 | , m_hMainLayout(new QHBoxLayout(this)) 9 | , m_label(new ClickableLabel(this)) 10 | { 11 | init(); 12 | } 13 | 14 | CheckBoxWordWrap::CheckBoxWordWrap(const QString &text, QWidget *parent) 15 | : QCheckBox (parent) 16 | , m_hMainLayout(new QHBoxLayout(this)) 17 | , m_label(new ClickableLabel(text, this)) 18 | { 19 | init(); 20 | } 21 | 22 | CheckBoxWordWrap::~CheckBoxWordWrap() 23 | { 24 | delete m_label; 25 | delete m_hMainLayout; 26 | } 27 | 28 | bool CheckBoxWordWrap::isWordWrap() const 29 | { 30 | return m_label->wordWrap(); 31 | } 32 | 33 | void CheckBoxWordWrap::setWordWrap(bool wordwrap) 34 | { 35 | m_label->setWordWrap(wordwrap); 36 | } 37 | 38 | QString CheckBoxWordWrap::text() const 39 | { 40 | return m_label->text(); 41 | } 42 | 43 | void CheckBoxWordWrap::setText(const QString &text) 44 | { 45 | m_label->setText(text); 46 | } 47 | 48 | QSize CheckBoxWordWrap::sizeHint() const 49 | { 50 | QFontMetrics fm(m_label->font()); 51 | QRect r = m_label->rect(); 52 | r.setLeft(r.left()+m_label->indent()+separation); 53 | QRect bRect = fm.boundingRect(r, int(Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap), m_label->text()); 54 | QSize ret = QSize(QWidget::sizeHint().width(), bRect.height()); 55 | return ret; 56 | } 57 | 58 | void CheckBoxWordWrap::labelIsClicked() 59 | { 60 | setChecked(!isChecked()); 61 | } 62 | 63 | void CheckBoxWordWrap::resizeEvent(QResizeEvent *event) 64 | { 65 | QWidget::resizeEvent(event); 66 | updateGeometry(); 67 | } 68 | 69 | void CheckBoxWordWrap::init() 70 | { 71 | setLayout(m_hMainLayout); 72 | QStyleOptionButton opt; 73 | initStyleOption(&opt); 74 | int indicatorW = style()->pixelMetric(QStyle::PixelMetric::PM_IndicatorWidth, &opt, this); 75 | // Useless in our case, we only need the indicator width 76 | //int indicatorH = style()->pixelMetric(QStyle::PixelMetric::PM_IndicatorHeight, &opt, this); 77 | m_hMainLayout->setContentsMargins(0, 0, 0, 0); 78 | m_hMainLayout->addWidget(m_label); 79 | m_label->setIndent(indicatorW+separation); 80 | m_label->setWordWrap(true); 81 | 82 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); 83 | connect(m_label, SIGNAL(clicked()), this, SLOT(labelIsClicked())); 84 | } 85 | -------------------------------------------------------------------------------- /plugins/ComboBoxCheckable/src/abstractlistmodelcheckablecbx.cpp: -------------------------------------------------------------------------------- 1 | #include "abstractlistmodelcheckablecbx.h" 2 | 3 | AbstractListModelCheckableCbx::AbstractListModelCheckableCbx(QObject *parent) 4 | : QAbstractListModel(parent) 5 | { 6 | _data = new QMap(); 7 | } 8 | 9 | AbstractListModelCheckableCbx::~AbstractListModelCheckableCbx() 10 | { 11 | delete _data; 12 | } 13 | 14 | int AbstractListModelCheckableCbx::columnCount(const QModelIndex & parent) const 15 | { 16 | Q_UNUSED(parent); 17 | return 1; 18 | } 19 | 20 | QVariant AbstractListModelCheckableCbx::data(const QModelIndex & index, int role) const 21 | { 22 | QVariant ret = QVariant(); 23 | if (index.isValid()) { 24 | switch (role) { 25 | case Qt::DisplayRole: 26 | ret = (index.row()==0 ? selectionText.join(',') : _data->keys().at(index.row()-1)); 27 | break; 28 | case Qt::ToolTipRole: 29 | ret = (index.row()==0 ? selectionText.join('\n') : _data->keys().at(index.row()-1)); 30 | break; 31 | case Qt::CheckStateRole: 32 | ret = index.row()==0 ? QVariant() : (_data->value(data(index, Qt::DisplayRole).toString()) ? Qt::Checked : Qt::Unchecked); 33 | break; 34 | default: 35 | break; 36 | } 37 | } 38 | return ret; 39 | } 40 | 41 | int AbstractListModelCheckableCbx::rowCount(const QModelIndex & parent) const 42 | { 43 | Q_UNUSED(parent); 44 | return _data->size()+1; 45 | } 46 | 47 | Qt::ItemFlags AbstractListModelCheckableCbx::flags(const QModelIndex & index) const 48 | { 49 | Qt::ItemFlags flags = Qt::ItemIsEnabled; 50 | if (index.row() > 0){ 51 | flags |= Qt::ItemIsUserCheckable; 52 | } 53 | return flags; 54 | } 55 | 56 | bool AbstractListModelCheckableCbx::setData(const QModelIndex & index, const QVariant & value, int role) 57 | { 58 | switch (role) { 59 | case Qt::CheckStateRole: 60 | _data->insert(data(index, Qt::DisplayRole).toString(), !data(index, Qt::CheckStateRole).toBool()); 61 | if (data(index, Qt::CheckStateRole).toBool()){ 62 | selectionText.append(data(index, Qt::DisplayRole).toString()); 63 | } else { 64 | selectionText.removeOne(data(index, Qt::DisplayRole).toString()); 65 | } 66 | emit dataChanged(AbstractListModelCheckableCbx::index(0), AbstractListModelCheckableCbx::index(0)); 67 | emit selectionChanged(); 68 | return true; 69 | default: 70 | return QAbstractListModel::setData(index, value, role); 71 | } 72 | } 73 | 74 | void AbstractListModelCheckableCbx::addItem(const QString& item) 75 | { 76 | beginInsertRows(index(rowCount()), rowCount(), rowCount()); 77 | _data->insert(item, false); 78 | endInsertRows(); 79 | } 80 | 81 | void AbstractListModelCheckableCbx::clearItems() 82 | { 83 | _data->clear(); 84 | selectionText.clear(); 85 | emit dataChanged(index(0), index(0)); 86 | emit selectionChanged(); 87 | } 88 | 89 | QList AbstractListModelCheckableCbx::getItems() const 90 | { 91 | return _data->keys(); 92 | } 93 | -------------------------------------------------------------------------------- /plugins/LineEditTag/src/lineedittag.cpp: -------------------------------------------------------------------------------- 1 | #include "lineedittag.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | LineEditTag::LineEditTag(QWidget *parent) 8 | : QLineEdit (parent) 9 | { 10 | setMinimumHeight(24); 11 | } 12 | 13 | LineEditTag::~LineEditTag() 14 | { 15 | 16 | } 17 | 18 | QStringList LineEditTag::getTags() const 19 | { 20 | return tags; 21 | } 22 | 23 | QString LineEditTag::getTagsStr() const 24 | { 25 | return tags.join(' '); 26 | } 27 | 28 | void LineEditTag::setTags(const QString& tags) 29 | { 30 | if (!tags.isEmpty()){ 31 | this->tags = tags.split(' '); 32 | clear(); 33 | update(); 34 | } 35 | } 36 | 37 | void LineEditTag::setTags(const QStringList& tags) 38 | { 39 | if (!tags.isEmpty()){ 40 | this->tags = tags; 41 | clear(); 42 | update(); 43 | } 44 | } 45 | 46 | void LineEditTag::addTag() 47 | { 48 | if (!text().isEmpty()){ 49 | tags.append(text()); 50 | clear(); 51 | update(); 52 | } 53 | } 54 | 55 | void LineEditTag::leaveEvent(QEvent *evt) 56 | { 57 | QLineEdit::leaveEvent(evt); 58 | cursorPos = clickedPos = QPoint(); 59 | } 60 | 61 | void LineEditTag::keyPressEvent(QKeyEvent *evt) 62 | { 63 | if (evt->key() == Qt::Key_Return || evt->key() == Qt::Key_Enter || evt->key() == Qt::Key_Space){ 64 | evt->accept(); 65 | addTag(); 66 | } else { 67 | QLineEdit::keyPressEvent(evt); 68 | } 69 | } 70 | 71 | void LineEditTag::mousePressEvent(QMouseEvent *evt) 72 | { 73 | clickedPos = evt->pos(); 74 | QLineEdit::mousePressEvent(evt); 75 | } 76 | 77 | void LineEditTag::mouseMoveEvent(QMouseEvent *evt) 78 | { 79 | QLineEdit::mouseMoveEvent(evt); 80 | cursorPos = evt->pos(); 81 | } 82 | 83 | void LineEditTag::paintEvent(QPaintEvent *evt) 84 | { 85 | QLineEdit::paintEvent(evt); 86 | 87 | QPainter painter(this); 88 | painter.setRenderHint(QPainter::Antialiasing); 89 | 90 | QFontMetrics fm = fontMetrics(); 91 | QRectF r = rect(); 92 | double space = double(r.height()-fm.height())/2; 93 | int padding = 4; 94 | int cross_size = int(r.height()-space*2); 95 | r.setX(padding); 96 | r.setY(double(r.height()-fm.height())/4); 97 | QPen pen = painter.pen(); 98 | QBrush brush = painter.brush(); 99 | // Stackoverflow tag like 100 | QColor tag_bg(225, 236, 244); 101 | QColor tag_txt(44, 87, 119); 102 | int x_offset = padding; 103 | int idx = 0; 104 | for (const QString& tag : tags){ 105 | QRect tag_rect = fm.boundingRect(tag); 106 | r.setWidth(tag_rect.width()+(padding*2)+(padding+cross_size)); 107 | r.setHeight(tag_rect.height()+space); 108 | QRectF cross_rect = QRectF(r.x()+r.width()-cross_size-padding, space, cross_size, cross_size); 109 | if (cross_rect.contains(clickedPos)){ 110 | clickedPos = QPoint(); 111 | tags.removeAt(idx); 112 | } else { 113 | QPainterPath tag_path; 114 | tag_path.addRoundedRect(r, 2, 2); 115 | // Draw tag background and text 116 | painter.fillPath(tag_path, QBrush(tag_bg)); 117 | painter.setPen(tag_txt); 118 | painter.drawText(QRectF(r.x()+padding, 0, tag_rect.width(), height()), Qt::AlignVCenter, tag); 119 | // Draw the cross to remove tag 120 | bool isHovered = r.contains(cursorPos); 121 | if (isHovered){ 122 | // Manage the hovered 123 | QPainterPath cross_path; 124 | cross_path.addRoundedRect(cross_rect, 2, 2); 125 | painter.fillPath(cross_path, QBrush(tag_txt)); 126 | // Manage the remove tag mouse cursor 127 | if (cross_rect.contains(cursorPos)){ 128 | setCursor(Qt::PointingHandCursor); 129 | } else { 130 | setCursor(Qt::ArrowCursor); 131 | } 132 | } 133 | pen.setWidth(2); 134 | pen.setColor( (isHovered ? tag_bg : tag_txt) ); 135 | painter.setPen(pen); 136 | QPointF topL = cross_rect.topLeft(), topR = cross_rect.topRight(), botL = cross_rect.bottomLeft(), botR = cross_rect.bottomRight(); 137 | topL.setX(topL.x()+3); 138 | topL.setY(topL.y()+3); 139 | topR.setX(topR.x()-3); 140 | topR.setY(topR.y()+3); 141 | botL.setX(botL.x()+3); 142 | botL.setY(botL.y()-3); 143 | botR.setX(botR.x()-3); 144 | botR.setY(botR.y()-3); 145 | painter.drawLine(topL, botR); 146 | painter.drawLine(topR, botL); 147 | 148 | x_offset += r.width()+(padding); 149 | r.setX(x_offset); 150 | idx++; 151 | } 152 | } 153 | if (textMargins().left() != (x_offset)){ 154 | if (tags.isEmpty()){ 155 | setTextMargins(0, 0, 0, 0); 156 | } else { 157 | setTextMargins(x_offset-padding, 0, 0, 0); 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /plugins/CircularProgress/src/circularprogress.cpp: -------------------------------------------------------------------------------- 1 | #include "circularprogress.h" 2 | #include 3 | #include 4 | 5 | CircularProgress::CircularProgress(QWidget *parent) 6 | : QWidget(parent) 7 | , m_animation(new QPropertyAnimation(this, "startAngle")) 8 | , m_progressType(CircularProgress::Ellipse) 9 | , m_bgColor(QColor("dimgrey")) 10 | , m_valueColor(QColor("cornflowerblue")) 11 | , m_min(0) 12 | , m_max(100) 13 | , m_value(5) 14 | , m_startAngle(90 * 16) // All angle must be specified in 1/16th of a degree 15 | , m_barWidth(16) 16 | , m_showTextPercent(true) 17 | , m_infinityMode(false) 18 | { 19 | //setMouseTracking(true); 20 | connect(this, SIGNAL(minChanged(int)), this, SLOT(update())); 21 | connect(this, SIGNAL(maxChanged(int)), this, SLOT(update())); 22 | connect(this, SIGNAL(valueChanged(int)), this, SLOT(update())); 23 | } 24 | 25 | void CircularProgress::setProgressType(CircularProgress::ProgressType progressType) 26 | { 27 | m_progressType = progressType; 28 | } 29 | 30 | int CircularProgress::getValue() const 31 | { 32 | return m_value; 33 | } 34 | 35 | void CircularProgress::setValue(int value) 36 | { 37 | m_value = value; 38 | emit valueChanged(value); 39 | } 40 | 41 | int CircularProgress::getMin() const 42 | { 43 | return m_min; 44 | } 45 | 46 | void CircularProgress::setMin(int min) 47 | { 48 | m_min = min; 49 | emit minChanged(min); 50 | } 51 | 52 | int CircularProgress::getMax() const 53 | { 54 | return m_max; 55 | } 56 | 57 | void CircularProgress::setMax(int max) 58 | { 59 | m_max = max; 60 | emit maxChanged(max); 61 | } 62 | 63 | void CircularProgress::setRange(int min, int max) 64 | { 65 | blockSignals(true); 66 | setMin(min); 67 | blockSignals(false); 68 | setMax(max); 69 | } 70 | 71 | QColor CircularProgress::getBgColor() const 72 | { 73 | return m_bgColor; 74 | } 75 | 76 | void CircularProgress::setBgColor(QColor bgcolor) 77 | { 78 | m_bgColor = bgcolor; 79 | update(); 80 | } 81 | 82 | QColor CircularProgress::getValueColor() const 83 | { 84 | return m_valueColor; 85 | } 86 | 87 | void CircularProgress::setValueColor(QColor valuecolor) 88 | { 89 | m_valueColor = valuecolor; 90 | update(); 91 | } 92 | 93 | int CircularProgress::getBarWidth() const 94 | { 95 | return m_barWidth; 96 | } 97 | 98 | void CircularProgress::setBarWidth(int bwidth) 99 | { 100 | m_barWidth = bwidth; 101 | update(); 102 | } 103 | 104 | bool CircularProgress::isShowingText() const 105 | { 106 | return m_showTextPercent; 107 | } 108 | 109 | void CircularProgress::setTextVisible(bool visible) 110 | { 111 | m_showTextPercent = visible; 112 | update(); 113 | } 114 | 115 | bool CircularProgress::infinityMode() const 116 | { 117 | return m_infinityMode; 118 | } 119 | 120 | void CircularProgress::setInfinityMode(bool infinite) 121 | { 122 | m_infinityMode = infinite; 123 | if (m_infinityMode){ 124 | // Playing with 20% of the circle 125 | m_min = 0; 126 | m_value = 20; 127 | m_max = 100; 128 | // -1 to make an infinite animation 129 | m_animation->setLoopCount(-1); 130 | m_animation->setDuration(2500); 131 | // The start position to the end (complete loop) 132 | m_animation->setStartValue(90*16); 133 | m_animation->setEndValue(-270*16); 134 | m_animation->start(); 135 | } else { 136 | m_animation->stop(); 137 | m_startAngle = 90 * 16; 138 | } 139 | } 140 | 141 | int CircularProgress::getStartAngle() const 142 | { 143 | return m_startAngle; 144 | } 145 | 146 | void CircularProgress::setStartAngle(int s_angle) 147 | { 148 | m_startAngle = s_angle; 149 | update(); 150 | } 151 | 152 | void CircularProgress::paintEvent(QPaintEvent *event) 153 | { 154 | QWidget::paintEvent(event); 155 | QPainter painter(this); 156 | //painter.fillRect(rect(), QColor(Qt::white)); 157 | 158 | QPen pen = painter.pen(); 159 | QBrush brush = painter.brush(); 160 | QFont font = painter.font(); 161 | //int w = width(), h = height(); 162 | 163 | pen.setWidth(m_barWidth); 164 | pen.setCapStyle(Qt::FlatCap); 165 | int offset = pen.width()/2; 166 | QRect rectArea(rect().adjusted(offset, offset, -offset, -offset)); 167 | painter.setRenderHint(QPainter::Antialiasing); 168 | 169 | int angle = int(((double(m_value-m_min)/double(m_max-m_min))*16) * 360); 170 | // All angle must be specified in 1/16th of a degree 171 | pen.setColor(m_bgColor); 172 | painter.setPen(pen); 173 | painter.drawArc(rectArea, m_startAngle, (16 * 360)); 174 | // draw value text 175 | if (m_showTextPercent){ 176 | font.setPointSize(rectArea.width()/4); 177 | painter.setFont(font); 178 | painter.drawText(rect(), Qt::AlignCenter, (m_infinityMode ? "∞" : QString::number(int((double(m_value-m_min)/double(m_max-m_min))*100))+"%")); 179 | } 180 | // draw value arc 181 | pen.setColor(m_valueColor); 182 | pen.setWidth(m_barWidth-m_barWidth/3); 183 | painter.setPen(pen); 184 | painter.drawArc(rectArea, m_startAngle, -angle); 185 | } 186 | --------------------------------------------------------------------------------