From 870736b072cbf9da4d29e565db762a6f8a111c3d Mon Sep 17 00:00:00 2001 From: xuannt Date: Wed, 30 Jun 2021 16:30:12 +0700 Subject: [PATCH] Add Qt Designer plugin for all supported widgets --- components/components.pro | 152 +--- components/lib/qtmaterialcheckable.h | 9 + components/lib/qtmaterialconst.h | 328 +++++++++ components/lib/qtmaterialtheme.cpp | 28 +- components/lib/qtmaterialtheme.h | 313 +-------- components/link_components.pri | 134 ++++ components/materialmenuplugin.cpp | 6 + components/materialmenuplugin.h | 16 + components/plugin/materialtextfieldplugin.cpp | 6 + components/plugin/materialtextfieldplugin.h | 16 + components/plugin/materialtoggleplugin.cpp | 62 -- components/plugin/materialtoggleplugin.h | 27 - components/plugin/plugintemplate.h | 33 + components/plugin/qtmaterialplugins.cpp | 28 +- components/plugin/qtmaterialplugins.h | 52 ++ components/qtmaterialautocomplete.cpp | 8 +- components/qtmaterialautocomplete.h | 2 + components/qtmaterialavatar.cpp | 36 +- components/qtmaterialavatar.h | 18 +- components/qtmaterialavatar_p.h | 2 +- components/qtmaterialbadge.h | 3 + components/qtmaterialcircularprogress.cpp | 10 +- components/qtmaterialcircularprogress.h | 6 +- components/qtmaterialcircularprogress_p.h | 2 +- components/qtmaterialfab.cpp | 9 +- components/qtmaterialfab.h | 5 + components/qtmaterialflatbutton.cpp | 66 +- components/qtmaterialflatbutton.h | 40 +- components/qtmaterialflatbutton_p.h | 8 +- components/qtmaterialiconbutton.cpp | 6 + components/qtmaterialiconbutton.h | 4 + components/qtmaterialmenu.cpp | 64 +- components/qtmaterialmenu.h | 7 +- components/qtmaterialprogress.cpp | 8 +- components/qtmaterialprogress.h | 4 +- components/qtmaterialprogress_p.h | 2 +- components/qtmaterialscrollbar.h | 2 + components/qtmaterialslider.h | 3 + components/qtmaterialtabs.cpp | 6 +- components/qtmaterialtabs.h | 4 +- components/qtmaterialtabs_internal.cpp | 2 +- components/qtmaterialtabs_p.h | 2 +- components/qtmaterialtextfield.cpp | 1 + components/qtmaterialtextfield.h | 9 +- components/qtmaterialtoggle.cpp | 1 + components/qtmaterialtoggle.h | 5 +- examples/avatarsettingseditor.cpp | 6 +- examples/circularprogresssettingseditor.cpp | 8 +- examples/components.pri | 0 examples/examples.pro | 21 +- examples/fabsettingseditor.cpp | 24 +- examples/flatbuttonsettingseditor.cpp | 48 +- examples/plugindemoform.cpp | 31 + examples/plugindemoform.h | 6 + examples/plugindemoform.ui | 653 +++++++++++++++++- examples/progresssettingseditor.cpp | 8 +- 56 files changed, 1640 insertions(+), 720 deletions(-) create mode 100644 components/lib/qtmaterialconst.h create mode 100644 components/link_components.pri create mode 100644 components/materialmenuplugin.cpp create mode 100644 components/materialmenuplugin.h create mode 100644 components/plugin/materialtextfieldplugin.cpp create mode 100644 components/plugin/materialtextfieldplugin.h delete mode 100644 components/plugin/materialtoggleplugin.cpp delete mode 100644 components/plugin/materialtoggleplugin.h create mode 100644 components/plugin/plugintemplate.h create mode 100644 examples/components.pri diff --git a/components/components.pro b/components/components.pro index e5a3196..75ba920 100644 --- a/components/components.pro +++ b/components/components.pro @@ -1,147 +1,15 @@ -greaterThan(QT_MAJOR_VERSION, 4) { - QT += widgets designer -} +QT += widgets uiplugin designer +CONFIG += plugin release +TEMPLATE = lib -lessThan(QT_MAJOR_VERSION, 5) { - CONFIG += designer -} - -CONFIG += plugin release -TEMPLATE = lib TARGET = $$qtLibraryTarget(qt-material-widget) target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -INCLUDEPATH += . -SOURCES = \ - plugin/materialtoggleplugin.cpp \ - plugin/qtmaterialplugins.cpp \ - qtmaterialavatar.cpp \ - lib/qtmaterialstyle.cpp \ - lib/qtmaterialtheme.cpp \ - qtmaterialbadge.cpp \ - lib/qtmaterialoverlaywidget.cpp \ - qtmaterialcheckbox.cpp \ - lib/qtmaterialcheckable_internal.cpp \ - lib/qtmaterialcheckable.cpp \ - lib/qtmaterialripple.cpp \ - lib/qtmaterialrippleoverlay.cpp \ - qtmaterialfab.cpp \ - qtmaterialraisedbutton.cpp \ - qtmaterialflatbutton_internal.cpp \ - qtmaterialflatbutton.cpp \ - lib/qtmaterialstatetransition.cpp \ - qtmaterialiconbutton.cpp \ - qtmaterialprogress_internal.cpp \ - qtmaterialprogress.cpp \ - qtmaterialcircularprogress_internal.cpp \ - qtmaterialcircularprogress.cpp \ - qtmaterialslider_internal.cpp \ - qtmaterialslider.cpp \ - qtmaterialsnackbar_internal.cpp \ - qtmaterialsnackbar.cpp \ - qtmaterialradiobutton.cpp \ - qtmaterialtoggle_internal.cpp \ - qtmaterialtoggle.cpp \ - qtmaterialtextfield_internal.cpp \ - qtmaterialtextfield.cpp \ - qtmaterialtabs_internal.cpp \ - qtmaterialtabs.cpp \ - qtmaterialscrollbar_internal.cpp \ - qtmaterialscrollbar.cpp \ - qtmaterialdialog_internal.cpp \ - qtmaterialdialog.cpp \ - qtmaterialdrawer_internal.cpp \ - qtmaterialdrawer.cpp \ - qtmaterialappbar.cpp \ - qtmaterialautocomplete.cpp \ - qtmaterialpaper.cpp \ - qtmaterialtable.cpp \ - layouts/qtmaterialsnackbarlayout.cpp \ - qtmaterialautocomplete_internal.cpp \ - qtmaterialmenu.cpp \ - qtmaterialmenu_internal.cpp \ - qtmateriallist.cpp \ - qtmateriallistitem.cpp -HEADERS = \ - plugin/materialtoggleplugin.h \ - plugin/qtmaterialplugins.h \ - qtmaterialavatar_p.h \ - qtmaterialavatar.h \ - lib/qtmaterialstyle_p.h \ - lib/qtmaterialstyle.h \ - lib/qtmaterialtheme_p.h \ - lib/qtmaterialtheme.h \ - qtmaterialbadge_p.h \ - qtmaterialbadge.h \ - lib/qtmaterialoverlaywidget.h \ - qtmaterialcheckbox_p.h \ - qtmaterialcheckbox.h \ - lib/qtmaterialcheckable_internal.h \ - lib/qtmaterialcheckable_p.h \ - lib/qtmaterialripple.h \ - lib/qtmaterialrippleoverlay.h \ - lib/qtmaterialcheckable.h \ - qtmaterialfab_p.h \ - qtmaterialfab.h \ - qtmaterialraisedbutton_p.h \ - qtmaterialraisedbutton.h \ - qtmaterialflatbutton_internal.h \ - qtmaterialflatbutton_p.h \ - qtmaterialflatbutton.h \ - lib/qtmaterialstatetransition.h \ - lib/qtmaterialstatetransitionevent.h \ - qtmaterialiconbutton_p.h \ - qtmaterialiconbutton.h \ - qtmaterialprogress_internal.h \ - qtmaterialprogress_p.h \ - qtmaterialprogress.h \ - qtmaterialcircularprogress_internal.h \ - qtmaterialcircularprogress_p.h \ - qtmaterialcircularprogress.h \ - qtmaterialslider_internal.h \ - qtmaterialslider_p.h \ - qtmaterialslider.h \ - qtmaterialsnackbar_internal.h \ - qtmaterialsnackbar_p.h \ - qtmaterialsnackbar.h \ - qtmaterialradiobutton_p.h \ - qtmaterialradiobutton.h \ - qtmaterialtoggle_internal.h \ - qtmaterialtoggle_p.h \ - qtmaterialtoggle.h \ - qtmaterialtextfield_internal.h \ - qtmaterialtextfield_p.h \ - qtmaterialtextfield.h \ - qtmaterialtabs_internal.h \ - qtmaterialtabs_p.h \ - qtmaterialtabs.h \ - qtmaterialscrollbar_internal.h \ - qtmaterialscrollbar_p.h \ - qtmaterialscrollbar.h \ - qtmaterialdialog_internal.h \ - qtmaterialdialog_p.h \ - qtmaterialdialog.h \ - qtmaterialdrawer_internal.h \ - qtmaterialdrawer_p.h \ - qtmaterialdrawer.h \ - qtmaterialappbar.h \ - qtmaterialappbar_p.h \ - qtmaterialautocomplete.h \ - qtmaterialautocomplete_p.h \ - qtmaterialpaper.h \ - qtmaterialpaper_p.h \ - qtmaterialtable.h \ - qtmaterialtable_p.h \ - layouts/qtmaterialsnackbarlayout.h \ - layouts/qtmaterialsnackbarlayout_p.h \ - qtmaterialautocomplete_internal.h \ - qtmaterialmenu.h \ - qtmaterialmenu_p.h \ - qtmaterialmenu_internal.h \ - qtmateriallist.h \ - qtmateriallist_p.h \ - qtmateriallistitem.h \ - qtmateriallistitem_p.h -RESOURCES += \ - material_res.qrc +include(link_components.pri) + +SOURCES += \ + plugin/qtmaterialplugins.cpp +HEADERS += \ + plugin/plugintemplate.h \ + plugin/qtmaterialplugins.h diff --git a/components/lib/qtmaterialcheckable.h b/components/lib/qtmaterialcheckable.h index c4cc574..6597dbd 100644 --- a/components/lib/qtmaterialcheckable.h +++ b/components/lib/qtmaterialcheckable.h @@ -8,12 +8,21 @@ class QtMaterialCheckablePrivate; class QtMaterialCheckable : public QAbstractButton { Q_OBJECT +// Q_PROPERTY(LabelPosition labelPosition READ setLabelPosition WRITE labelPosition) +// Q_PROPERTY(bool useThemeColors READ setUseThemeColors WRITE useThemeColors) +// Q_PROPERTY(QColor checkedColor READ setCheckedColor WRITE checkedColor) +// Q_PROPERTY(QColor uncheckedColor READ setUncheckedColor WRITE uncheckedColor) +// Q_PROPERTY(QColor textColor READ setTextColor WRITE textColor) +// Q_PROPERTY(QColor disabledColor READ setDisabledColor WRITE disabledColor) +// Q_PROPERTY(QIcon checkedIcon READ setCheckedIcon WRITE checkedIcon) +// Q_PROPERTY(QIcon uncheckedIcon READ setUncheckedIcon WRITE uncheckedIcon) public: enum LabelPosition { LabelPositionLeft, LabelPositionRight, }; + Q_ENUM(LabelPosition) explicit QtMaterialCheckable(QWidget *parent = 0); ~QtMaterialCheckable(); diff --git a/components/lib/qtmaterialconst.h b/components/lib/qtmaterialconst.h new file mode 100644 index 0000000..2256314 --- /dev/null +++ b/components/lib/qtmaterialconst.h @@ -0,0 +1,328 @@ +#ifndef QTMATERIALCONST_H +#define QTMATERIALCONST_H + +#include + +class MaterialConst: public QObject +{ + Q_OBJECT + +public: + + enum ButtonPreset { + FlatPreset, + CheckablePreset + }; + Q_ENUM(ButtonPreset) + + enum RippleStyle { + CenteredRipple, + PositionedRipple, + NoRipple + }; + Q_ENUM(RippleStyle) + + enum OverlayStyle { + NoOverlay = 0, + TintedOverlay, + GrayOverlay + }; + Q_ENUM(OverlayStyle) + + enum Role { + Default, + Primary, + Secondary + }; + Q_ENUM(Role) + + enum ButtonIconPlacement { + LeftIcon, + RightIcon + }; + Q_ENUM(ButtonIconPlacement) + + enum ProgressType { + DeterminateProgress, + IndeterminateProgress + }; + Q_ENUM(ProgressType) + + enum AvatarType { + ImageAvatar, + IconAvatar, + LetterAvatar + }; + Q_ENUM(AvatarType) + + enum Color { + red50, + red100, + red200, + red300, + red400, + red500, + red600, + red700, + red800, + red900, + redA100, + redA200, + redA400, + redA700, + pink50, + pink100, + pink200, + pink300, + pink400, + pink500, + pink600, + pink700, + pink800, + pink900, + pinkA100, + pinkA200, + pinkA400, + pinkA700, + purple50, + purple100, + purple200, + purple300, + purple400, + purple500, + purple600, + purple700, + purple800, + purple900, + purpleA100, + purpleA200, + purpleA400, + purpleA700, + deepPurple50, + deepPurple100, + deepPurple200, + deepPurple300, + deepPurple400, + deepPurple500, + deepPurple600, + deepPurple700, + deepPurple800, + deepPurple900, + deepPurpleA100, + deepPurpleA200, + deepPurpleA400, + deepPurpleA700, + indigo50, + indigo100, + indigo200, + indigo300, + indigo400, + indigo500, + indigo600, + indigo700, + indigo800, + indigo900, + indigoA100, + indigoA200, + indigoA400, + indigoA700, + blue50, + blue100, + blue200, + blue300, + blue400, + blue500, + blue600, + blue700, + blue800, + blue900, + blueA100, + blueA200, + blueA400, + blueA700, + lightBlue50, + lightBlue100, + lightBlue200, + lightBlue300, + lightBlue400, + lightBlue500, + lightBlue600, + lightBlue700, + lightBlue800, + lightBlue900, + lightBlueA100, + lightBlueA200, + lightBlueA400, + lightBlueA700, + cyan50, + cyan100, + cyan200, + cyan300, + cyan400, + cyan500, + cyan600, + cyan700, + cyan800, + cyan900, + cyanA100, + cyanA200, + cyanA400, + cyanA700, + teal50, + teal100, + teal200, + teal300, + teal400, + teal500, + teal600, + teal700, + teal800, + teal900, + tealA100, + tealA200, + tealA400, + tealA700, + green50, + green100, + green200, + green300, + green400, + green500, + green600, + green700, + green800, + green900, + greenA100, + greenA200, + greenA400, + greenA700, + lightGreen50, + lightGreen100, + lightGreen200, + lightGreen300, + lightGreen400, + lightGreen500, + lightGreen600, + lightGreen700, + lightGreen800, + lightGreen900, + lightGreenA100, + lightGreenA200, + lightGreenA400, + lightGreenA700, + lime50, + lime100, + lime200, + lime300, + lime400, + lime500, + lime600, + lime700, + lime800, + lime900, + limeA100, + limeA200, + limeA400, + limeA700, + yellow50, + yellow100, + yellow200, + yellow300, + yellow400, + yellow500, + yellow600, + yellow700, + yellow800, + yellow900, + yellowA100, + yellowA200, + yellowA400, + yellowA700, + amber50, + amber100, + amber200, + amber300, + amber400, + amber500, + amber600, + amber700, + amber800, + amber900, + amberA100, + amberA200, + amberA400, + amberA700, + orange50, + orange100, + orange200, + orange300, + orange400, + orange500, + orange600, + orange700, + orange800, + orange900, + orangeA100, + orangeA200, + orangeA400, + orangeA700, + deepOrange50, + deepOrange100, + deepOrange200, + deepOrange300, + deepOrange400, + deepOrange500, + deepOrange600, + deepOrange700, + deepOrange800, + deepOrange900, + deepOrangeA100, + deepOrangeA200, + deepOrangeA400, + deepOrangeA700, + brown50, + brown100, + brown200, + brown300, + brown400, + brown500, + brown600, + brown700, + brown800, + brown900, + blueGrey50, + blueGrey100, + blueGrey200, + blueGrey300, + blueGrey400, + blueGrey500, + blueGrey600, + blueGrey700, + blueGrey800, + blueGrey900, + grey50, + grey100, + grey200, + grey300, + grey400, + grey500, + grey600, + grey700, + grey800, + grey900, + black, + white, + transparent, + fullBlack, + darkBlack, + lightBlack, + minBlack, + faintBlack, + fullWhite, + darkWhite, + lightWhite + }; + Q_ENUM(Color) +}; + +#endif // QTMATERIALCONST_H diff --git a/components/lib/qtmaterialtheme.cpp b/components/lib/qtmaterialtheme.cpp index 725c954..341d23e 100644 --- a/components/lib/qtmaterialtheme.cpp +++ b/components/lib/qtmaterialtheme.cpp @@ -33,19 +33,19 @@ QtMaterialTheme::QtMaterialTheme(QObject *parent) : QObject(parent), d_ptr(new QtMaterialThemePrivate(this)) { - setColor("primary1", Material::cyan500); - setColor("primary2", Material::cyan700); - setColor("primary3", Material::lightBlack); - setColor("accent1", Material::pinkA200); - setColor("accent2", Material::grey100); - setColor("accent3", Material::grey500); - setColor("text", Material::darkBlack); - setColor("alternateText", Material::white); - setColor("canvas", Material::white); - setColor("border", Material::grey300); - setColor("disabled", Material::minBlack); - setColor("disabled2", Material::faintBlack); - setColor("disabled3", Material::grey300); + setColor("primary1", MaterialConst::cyan500); + setColor("primary2", MaterialConst::cyan700); + setColor("primary3", MaterialConst::lightBlack); + setColor("accent1", MaterialConst::pinkA200); + setColor("accent2", MaterialConst::grey100); + setColor("accent3", MaterialConst::grey500); + setColor("text", MaterialConst::darkBlack); + setColor("alternateText", MaterialConst::white); + setColor("canvas", MaterialConst::white); + setColor("border", MaterialConst::grey300); + setColor("disabled", MaterialConst::minBlack); + setColor("disabled2", MaterialConst::faintBlack); + setColor("disabled3", MaterialConst::grey300); } QtMaterialTheme::~QtMaterialTheme() @@ -70,7 +70,7 @@ void QtMaterialTheme::setColor(const QString &key, const QColor &color) d->colors.insert(key, color); } -void QtMaterialTheme::setColor(const QString &key, Material::Color color) +void QtMaterialTheme::setColor(const QString &key, MaterialConst::Color color) { Q_D(QtMaterialTheme); diff --git a/components/lib/qtmaterialtheme.h b/components/lib/qtmaterialtheme.h index fe4a11c..6850e42 100644 --- a/components/lib/qtmaterialtheme.h +++ b/components/lib/qtmaterialtheme.h @@ -5,316 +5,7 @@ #include #include #include - -namespace Material -{ - enum ButtonPreset { - FlatPreset, - CheckablePreset - }; - - enum RippleStyle { - CenteredRipple, - PositionedRipple, - NoRipple - }; - - enum OverlayStyle { - NoOverlay, - TintedOverlay, - GrayOverlay - }; - - enum Role { - Default, - Primary, - Secondary - }; - - enum ButtonIconPlacement { - LeftIcon, - RightIcon - }; - - enum ProgressType { - DeterminateProgress, - IndeterminateProgress - }; - - enum AvatarType { - ImageAvatar, - IconAvatar, - LetterAvatar - }; - - enum Color { - red50, - red100, - red200, - red300, - red400, - red500, - red600, - red700, - red800, - red900, - redA100, - redA200, - redA400, - redA700, - pink50, - pink100, - pink200, - pink300, - pink400, - pink500, - pink600, - pink700, - pink800, - pink900, - pinkA100, - pinkA200, - pinkA400, - pinkA700, - purple50, - purple100, - purple200, - purple300, - purple400, - purple500, - purple600, - purple700, - purple800, - purple900, - purpleA100, - purpleA200, - purpleA400, - purpleA700, - deepPurple50, - deepPurple100, - deepPurple200, - deepPurple300, - deepPurple400, - deepPurple500, - deepPurple600, - deepPurple700, - deepPurple800, - deepPurple900, - deepPurpleA100, - deepPurpleA200, - deepPurpleA400, - deepPurpleA700, - indigo50, - indigo100, - indigo200, - indigo300, - indigo400, - indigo500, - indigo600, - indigo700, - indigo800, - indigo900, - indigoA100, - indigoA200, - indigoA400, - indigoA700, - blue50, - blue100, - blue200, - blue300, - blue400, - blue500, - blue600, - blue700, - blue800, - blue900, - blueA100, - blueA200, - blueA400, - blueA700, - lightBlue50, - lightBlue100, - lightBlue200, - lightBlue300, - lightBlue400, - lightBlue500, - lightBlue600, - lightBlue700, - lightBlue800, - lightBlue900, - lightBlueA100, - lightBlueA200, - lightBlueA400, - lightBlueA700, - cyan50, - cyan100, - cyan200, - cyan300, - cyan400, - cyan500, - cyan600, - cyan700, - cyan800, - cyan900, - cyanA100, - cyanA200, - cyanA400, - cyanA700, - teal50, - teal100, - teal200, - teal300, - teal400, - teal500, - teal600, - teal700, - teal800, - teal900, - tealA100, - tealA200, - tealA400, - tealA700, - green50, - green100, - green200, - green300, - green400, - green500, - green600, - green700, - green800, - green900, - greenA100, - greenA200, - greenA400, - greenA700, - lightGreen50, - lightGreen100, - lightGreen200, - lightGreen300, - lightGreen400, - lightGreen500, - lightGreen600, - lightGreen700, - lightGreen800, - lightGreen900, - lightGreenA100, - lightGreenA200, - lightGreenA400, - lightGreenA700, - lime50, - lime100, - lime200, - lime300, - lime400, - lime500, - lime600, - lime700, - lime800, - lime900, - limeA100, - limeA200, - limeA400, - limeA700, - yellow50, - yellow100, - yellow200, - yellow300, - yellow400, - yellow500, - yellow600, - yellow700, - yellow800, - yellow900, - yellowA100, - yellowA200, - yellowA400, - yellowA700, - amber50, - amber100, - amber200, - amber300, - amber400, - amber500, - amber600, - amber700, - amber800, - amber900, - amberA100, - amberA200, - amberA400, - amberA700, - orange50, - orange100, - orange200, - orange300, - orange400, - orange500, - orange600, - orange700, - orange800, - orange900, - orangeA100, - orangeA200, - orangeA400, - orangeA700, - deepOrange50, - deepOrange100, - deepOrange200, - deepOrange300, - deepOrange400, - deepOrange500, - deepOrange600, - deepOrange700, - deepOrange800, - deepOrange900, - deepOrangeA100, - deepOrangeA200, - deepOrangeA400, - deepOrangeA700, - brown50, - brown100, - brown200, - brown300, - brown400, - brown500, - brown600, - brown700, - brown800, - brown900, - blueGrey50, - blueGrey100, - blueGrey200, - blueGrey300, - blueGrey400, - blueGrey500, - blueGrey600, - blueGrey700, - blueGrey800, - blueGrey900, - grey50, - grey100, - grey200, - grey300, - grey400, - grey500, - grey600, - grey700, - grey800, - grey900, - black, - white, - transparent, - fullBlack, - darkBlack, - lightBlack, - minBlack, - faintBlack, - fullWhite, - darkWhite, - lightWhite - }; -} +#include "qtmaterialconst.h" class QtMaterialThemePrivate; @@ -329,7 +20,7 @@ public: QColor getColor(const QString &key) const; void setColor(const QString &key, const QColor &color); - void setColor(const QString &key, Material::Color color); + void setColor(const QString &key, MaterialConst::Color color); static QIcon icon(QString category, QString icon); diff --git a/components/link_components.pri b/components/link_components.pri new file mode 100644 index 0000000..b7ddf53 --- /dev/null +++ b/components/link_components.pri @@ -0,0 +1,134 @@ +COMP_PATH=$$PWD + +INCLUDEPATH += $$COMP_PATH + +SOURCES += \ + $$COMP_PATH/qtmaterialavatar.cpp \ + $$COMP_PATH/lib/qtmaterialstyle.cpp \ + $$COMP_PATH/lib/qtmaterialtheme.cpp \ + $$COMP_PATH/qtmaterialbadge.cpp \ + $$COMP_PATH/lib/qtmaterialoverlaywidget.cpp \ + $$COMP_PATH/qtmaterialcheckbox.cpp \ + $$COMP_PATH/lib/qtmaterialcheckable_internal.cpp \ + $$COMP_PATH/lib/qtmaterialcheckable.cpp \ + $$COMP_PATH/lib/qtmaterialripple.cpp \ + $$COMP_PATH/lib/qtmaterialrippleoverlay.cpp \ + $$COMP_PATH/qtmaterialfab.cpp \ + $$COMP_PATH/qtmaterialraisedbutton.cpp \ + $$COMP_PATH/qtmaterialflatbutton_internal.cpp \ + $$COMP_PATH/qtmaterialflatbutton.cpp \ + $$COMP_PATH/lib/qtmaterialstatetransition.cpp \ + $$COMP_PATH/qtmaterialiconbutton.cpp \ + $$COMP_PATH/qtmaterialprogress_internal.cpp \ + $$COMP_PATH/qtmaterialprogress.cpp \ + $$COMP_PATH/qtmaterialcircularprogress_internal.cpp \ + $$COMP_PATH/qtmaterialcircularprogress.cpp \ + $$COMP_PATH/qtmaterialslider_internal.cpp \ + $$COMP_PATH/qtmaterialslider.cpp \ + $$COMP_PATH/qtmaterialsnackbar_internal.cpp \ + $$COMP_PATH/qtmaterialsnackbar.cpp \ + $$COMP_PATH/qtmaterialradiobutton.cpp \ + $$COMP_PATH/qtmaterialtoggle_internal.cpp \ + $$COMP_PATH/qtmaterialtoggle.cpp \ + $$COMP_PATH/qtmaterialtextfield_internal.cpp \ + $$COMP_PATH/qtmaterialtextfield.cpp \ + $$COMP_PATH/qtmaterialtabs_internal.cpp \ + $$COMP_PATH/qtmaterialtabs.cpp \ + $$COMP_PATH/qtmaterialscrollbar_internal.cpp \ + $$COMP_PATH/qtmaterialscrollbar.cpp \ + $$COMP_PATH/qtmaterialdialog_internal.cpp \ + $$COMP_PATH/qtmaterialdialog.cpp \ + $$COMP_PATH/qtmaterialdrawer_internal.cpp \ + $$COMP_PATH/qtmaterialdrawer.cpp \ + $$COMP_PATH/qtmaterialappbar.cpp \ + $$COMP_PATH/qtmaterialautocomplete.cpp \ + $$COMP_PATH/qtmaterialpaper.cpp \ + $$COMP_PATH/qtmaterialtable.cpp \ + $$COMP_PATH/layouts/qtmaterialsnackbarlayout.cpp \ + $$COMP_PATH/qtmaterialautocomplete_internal.cpp \ + $$COMP_PATH/qtmaterialmenu.cpp \ + $$COMP_PATH/qtmaterialmenu_internal.cpp \ + $$COMP_PATH/qtmateriallist.cpp \ + $$COMP_PATH/qtmateriallistitem.cpp +HEADERS += \ + $$COMP_PATH/qtmaterialavatar_p.h \ + $$COMP_PATH/qtmaterialavatar.h \ + $$COMP_PATH/lib/qtmaterialstyle_p.h \ + $$COMP_PATH/lib/qtmaterialstyle.h \ + $$COMP_PATH/lib/qtmaterialtheme_p.h \ + $$COMP_PATH/lib/qtmaterialtheme.h \ + $$COMP_PATH/qtmaterialbadge_p.h \ + $$COMP_PATH/qtmaterialbadge.h \ + $$COMP_PATH/lib/qtmaterialoverlaywidget.h \ + $$COMP_PATH/qtmaterialcheckbox_p.h \ + $$COMP_PATH/qtmaterialcheckbox.h \ + $$COMP_PATH/lib/qtmaterialcheckable_internal.h \ + $$COMP_PATH/lib/qtmaterialcheckable_p.h \ + $$COMP_PATH/lib/qtmaterialripple.h \ + $$COMP_PATH/lib/qtmaterialrippleoverlay.h \ + $$COMP_PATH/lib/qtmaterialcheckable.h \ + $$COMP_PATH/qtmaterialfab_p.h \ + $$COMP_PATH/qtmaterialfab.h \ + $$COMP_PATH/qtmaterialraisedbutton_p.h \ + $$COMP_PATH/qtmaterialraisedbutton.h \ + $$COMP_PATH/qtmaterialflatbutton_internal.h \ + $$COMP_PATH/qtmaterialflatbutton_p.h \ + $$COMP_PATH/qtmaterialflatbutton.h \ + $$COMP_PATH/lib/qtmaterialstatetransition.h \ + $$COMP_PATH/lib/qtmaterialstatetransitionevent.h \ + $$COMP_PATH/qtmaterialiconbutton_p.h \ + $$COMP_PATH/qtmaterialiconbutton.h \ + $$COMP_PATH/qtmaterialprogress_internal.h \ + $$COMP_PATH/qtmaterialprogress_p.h \ + $$COMP_PATH/qtmaterialprogress.h \ + $$COMP_PATH/qtmaterialcircularprogress_internal.h \ + $$COMP_PATH/qtmaterialcircularprogress_p.h \ + $$COMP_PATH/qtmaterialcircularprogress.h \ + $$COMP_PATH/qtmaterialslider_internal.h \ + $$COMP_PATH/qtmaterialslider_p.h \ + $$COMP_PATH/qtmaterialslider.h \ + $$COMP_PATH/qtmaterialsnackbar_internal.h \ + $$COMP_PATH/qtmaterialsnackbar_p.h \ + $$COMP_PATH/qtmaterialsnackbar.h \ + $$COMP_PATH/qtmaterialradiobutton_p.h \ + $$COMP_PATH/qtmaterialradiobutton.h \ + $$COMP_PATH/qtmaterialtoggle_internal.h \ + $$COMP_PATH/qtmaterialtoggle_p.h \ + $$COMP_PATH/qtmaterialtoggle.h \ + $$COMP_PATH/qtmaterialtextfield_internal.h \ + $$COMP_PATH/qtmaterialtextfield_p.h \ + $$COMP_PATH/qtmaterialtextfield.h \ + $$COMP_PATH/qtmaterialtabs_internal.h \ + $$COMP_PATH/qtmaterialtabs_p.h \ + $$COMP_PATH/qtmaterialtabs.h \ + $$COMP_PATH/qtmaterialscrollbar_internal.h \ + $$COMP_PATH/qtmaterialscrollbar_p.h \ + $$COMP_PATH/qtmaterialscrollbar.h \ + $$COMP_PATH/qtmaterialdialog_internal.h \ + $$COMP_PATH/qtmaterialdialog_p.h \ + $$COMP_PATH/qtmaterialdialog.h \ + $$COMP_PATH/qtmaterialdrawer_internal.h \ + $$COMP_PATH/qtmaterialdrawer_p.h \ + $$COMP_PATH/qtmaterialdrawer.h \ + $$COMP_PATH/qtmaterialappbar.h \ + $$COMP_PATH/qtmaterialappbar_p.h \ + $$COMP_PATH/qtmaterialautocomplete.h \ + $$COMP_PATH/qtmaterialautocomplete_p.h \ + $$COMP_PATH/qtmaterialpaper.h \ + $$COMP_PATH/qtmaterialpaper_p.h \ + $$COMP_PATH/qtmaterialtable.h \ + $$COMP_PATH/qtmaterialtable_p.h \ + $$COMP_PATH/layouts/qtmaterialsnackbarlayout.h \ + $$COMP_PATH/layouts/qtmaterialsnackbarlayout_p.h \ + $$COMP_PATH/qtmaterialautocomplete_internal.h \ + $$COMP_PATH/qtmaterialmenu.h \ + $$COMP_PATH/qtmaterialmenu_p.h \ + $$COMP_PATH/qtmaterialmenu_internal.h \ + $$COMP_PATH/qtmateriallist.h \ + $$COMP_PATH/qtmateriallist_p.h \ + $$COMP_PATH/qtmateriallistitem.h \ + $$COMP_PATH/qtmateriallistitem_p.h \ + $$PWD/lib/qtmaterialconst.h + +RESOURCES += \ + $$COMP_PATH/material_res.qrc diff --git a/components/materialmenuplugin.cpp b/components/materialmenuplugin.cpp new file mode 100644 index 0000000..43c29a6 --- /dev/null +++ b/components/materialmenuplugin.cpp @@ -0,0 +1,6 @@ +#include "materialmenuplugin.h" + +MaterialMenuPlugin::MaterialMenuPlugin(QObject *parent) : QObject(parent) +{ + +} diff --git a/components/materialmenuplugin.h b/components/materialmenuplugin.h new file mode 100644 index 0000000..b2e77f7 --- /dev/null +++ b/components/materialmenuplugin.h @@ -0,0 +1,16 @@ +#ifndef MATERIALMENUPLUGIN_H +#define MATERIALMENUPLUGIN_H + +#include + +class MaterialMenuPlugin : public QObject +{ + Q_OBJECT +public: + explicit MaterialMenuPlugin(QObject *parent = nullptr); + +signals: + +}; + +#endif // MATERIALMENUPLUGIN_H diff --git a/components/plugin/materialtextfieldplugin.cpp b/components/plugin/materialtextfieldplugin.cpp new file mode 100644 index 0000000..4718b87 --- /dev/null +++ b/components/plugin/materialtextfieldplugin.cpp @@ -0,0 +1,6 @@ +#include "materialtextfieldplugin.h" + +MaterialTextFieldPlugin::MaterialTextFieldPlugin(QObject *parent) : QObject(parent) +{ + +} diff --git a/components/plugin/materialtextfieldplugin.h b/components/plugin/materialtextfieldplugin.h new file mode 100644 index 0000000..76379b6 --- /dev/null +++ b/components/plugin/materialtextfieldplugin.h @@ -0,0 +1,16 @@ +#ifndef MATERIALTEXTFIELDPLUGIN_H +#define MATERIALTEXTFIELDPLUGIN_H + +#include + +class MaterialTextFieldPlugin : public QObject +{ + Q_OBJECT +public: + explicit MaterialTextFieldPlugin(QObject *parent = nullptr); + +signals: + +}; + +#endif // MATERIALTEXTFIELDPLUGIN_H diff --git a/components/plugin/materialtoggleplugin.cpp b/components/plugin/materialtoggleplugin.cpp deleted file mode 100644 index 7a29126..0000000 --- a/components/plugin/materialtoggleplugin.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "materialtoggleplugin.h" -#include "qtmaterialtoggle.h" -#include - -MaterialTogglePlugin:: -MaterialTogglePlugin(QObject* parent) : - QObject(parent), - initialized(false) -{ -} - -QString MaterialTogglePlugin:: -name() const -{ - return "Material Toggle"; -} - -QString MaterialTogglePlugin:: -group() const -{ - return tr("Qt Meterial Widgets"); -} - -QString MaterialTogglePlugin:: -toolTip() const -{ - return tr("Material toggle button"); -} - -QString MaterialTogglePlugin:: -whatsThis() const -{ - return tr("Material toggle button"); -} - -QString MaterialTogglePlugin:: -includeFile() const -{ - return "qtmaterialtoggle.h"; -} - -QIcon MaterialTogglePlugin:: -icon() const -{ - return QIcon(); -} - -bool MaterialTogglePlugin:: -isContainer() const -{ - return false; -} - -QWidget * MaterialTogglePlugin:: -createWidget(QWidget *parent) -{ - return new QtMaterialToggle(parent); -} - -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) -Q_EXPORT_PLUGIN2(MaterialTogglePlugin, MaterialTogglePlugin) -#endif diff --git a/components/plugin/materialtoggleplugin.h b/components/plugin/materialtoggleplugin.h deleted file mode 100644 index 74a38eb..0000000 --- a/components/plugin/materialtoggleplugin.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MATERIALTOGGLEPLUGIN_H -#define MATERIALTOGGLEPLUGIN_H - -#include - -class MaterialTogglePlugin : public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT -public: - explicit MaterialTogglePlugin(QObject *parent = nullptr); - - QString name() const; - QString group() const; - QString toolTip() const; - QString whatsThis() const; - QString includeFile() const; - QIcon icon() const; - - bool isContainer() const; - - QWidget *createWidget(QWidget *parent); - -private: - bool initialized; -}; - -#endif // MATERIALTOGGLEPLUGIN_H diff --git a/components/plugin/plugintemplate.h b/components/plugin/plugintemplate.h new file mode 100644 index 0000000..8b56fe1 --- /dev/null +++ b/components/plugin/plugintemplate.h @@ -0,0 +1,33 @@ +#ifndef PLUGINTEMPLATE_H +#define PLUGINTEMPLATE_H + +#define QT_DESIGN_PLUGIN(pluginName, headerFile, className) \ +class pluginName : public QObject, public QDesignerCustomWidgetInterface \ +{ \ + Q_OBJECT \ +public: \ + explicit pluginName(QObject *parent = nullptr):QObject(parent) {} \ + \ + QString name() const override { return #className; } \ + QString group() const override { return "Qt Material Widgets"; } \ + QString toolTip() const override { return QString(); } \ + QString whatsThis() const override { return QString(); } \ + QString includeFile() const override { return headerFile; } \ + QIcon icon() const override { return QIcon(); } \ + \ + QWidget *createWidget(QWidget *parent) override { return new className(parent); } \ + bool isContainer() const override { return true; } \ + bool isInitialized() const override { return initialized; } \ + void initialize(QDesignerFormEditorInterface * /*core*/) override { \ + if (initialized) \ + return; \ + \ + initialized = true; \ + } \ + \ +private: \ + bool initialized; \ +}; \ + + +#endif // PLUGINTEMPLATE_H diff --git a/components/plugin/qtmaterialplugins.cpp b/components/plugin/qtmaterialplugins.cpp index 7c5e25b..b010611 100644 --- a/components/plugin/qtmaterialplugins.cpp +++ b/components/plugin/qtmaterialplugins.cpp @@ -1,9 +1,33 @@ #include "qtmaterialplugins.h" -#include "materialtoggleplugin.h" QtMaterialPlugins::QtMaterialPlugins(QObject *parent) : QObject(parent) { - m_plugins << new MaterialTogglePlugin(this); + m_plugins << new MaterialAppBarPlugin(this) + << new MaterialAutoCompletePlugin(this) + << new MaterialAvatarPlugin(this) + << new MaterialBadgePlugin(this) + << new MaterialCheckBoxPlugin(this) + << new MaterialCircularProgressPlugin(this) + << new MaterialDialogPlugin(this) + << new MaterialDrawerPlugin(this) + << new MaterialFabPlugin(this) + << new MaterialFlatButtonPlugin(this) + << new MaterialIconButtonPlugin(this) +//// << new MaterialListPlugin(this) +//// << new MaterialListItemPlugin(this) +// << new MaterialMenuPlugin(this) +//// << new MaterialPaperPlugin(this) + << new MaterialProgressPlugin(this) + << new MaterialRadioButtonPlugin(this) + << new MaterialRaisedButtonPlugin(this) +// << new MaterialScrollbarPlugin(this) + << new MaterialSliderPlugin(this) + << new MaterialSnackbarPlugin(this) +//// << new MaterialTablePlugin(this) + << new MaterialTabsPlugin(this) + << new MaterialTextFieldPlugin(this) + << new MaterialTogglePlugin(this) + ; } QList QtMaterialPlugins::customWidgets() const { diff --git a/components/plugin/qtmaterialplugins.h b/components/plugin/qtmaterialplugins.h index 31735ad..ec617b7 100644 --- a/components/plugin/qtmaterialplugins.h +++ b/components/plugin/qtmaterialplugins.h @@ -2,6 +2,58 @@ #define QTMATERIALPLUGINS_H #include +#include "plugintemplate.h" +#include "qtmaterialappbar.h" +#include "qtmaterialautocomplete.h" +#include "qtmaterialavatar.h" +#include "qtmaterialbadge.h" +#include "qtmaterialcheckbox.h" +#include "qtmaterialcircularprogress.h" +#include "qtmaterialdialog.h" +#include "qtmaterialdrawer.h" +#include "qtmaterialfab.h" +#include "qtmaterialflatbutton.h" +#include "qtmaterialiconbutton.h" +#include "qtmateriallist.h" +#include "qtmateriallistitem.h" +#include "qtmaterialmenu.h" +#include "qtmaterialpaper.h" +#include "qtmaterialprogress.h" +#include "qtmaterialradiobutton.h" +#include "qtmaterialraisedbutton.h" +#include "qtmaterialscrollbar.h" +#include "qtmaterialslider.h" +#include "qtmaterialsnackbar.h" +#include "qtmaterialtable.h" +#include "qtmaterialtabs.h" +#include "qtmaterialtextfield.h" +#include "qtmaterialtoggle.h" + +QT_DESIGN_PLUGIN(MaterialAppBarPlugin , "qtmaterialappbar.h" , QtMaterialAppBar ) +QT_DESIGN_PLUGIN(MaterialAutoCompletePlugin , "qtmaterialautocomplete.h" , QtMaterialAutoComplete ) +QT_DESIGN_PLUGIN(MaterialAvatarPlugin , "qtmaterialavatar.h" , QtMaterialAvatar ) +QT_DESIGN_PLUGIN(MaterialBadgePlugin , "qtmaterialbadge.h" , QtMaterialBadge ) +QT_DESIGN_PLUGIN(MaterialCheckBoxPlugin , "qtmaterialcheckbox.h" , QtMaterialCheckBox ) +QT_DESIGN_PLUGIN(MaterialCircularProgressPlugin, "qtmaterialcircularprogress.h", QtMaterialCircularProgress) +QT_DESIGN_PLUGIN(MaterialDialogPlugin , "qtmaterialdialog.h" , QtMaterialDialog ) +QT_DESIGN_PLUGIN(MaterialDrawerPlugin , "qtmaterialdrawer.h" , QtMaterialDrawer ) +QT_DESIGN_PLUGIN(MaterialFabPlugin , "qtmaterialfab.h" , QtMaterialFloatingActionButton) +QT_DESIGN_PLUGIN(MaterialFlatButtonPlugin , "qtmaterialflatbutton.h" , QtMaterialFlatButton ) +QT_DESIGN_PLUGIN(MaterialIconButtonPlugin , "qtmaterialiconbutton.h" , QtMaterialIconButton ) +//QT_DESIGN_PLUGIN(MaterialListPlugin , "qtmateriallist.h" , QtMaterialList ) +//QT_DESIGN_PLUGIN(MaterialListItemPlugin , "qtmateriallistitem.h" , QtMaterialListItem ) +QT_DESIGN_PLUGIN(MaterialMenuPlugin , "qtmaterialmenu.h" , QtMaterialMenu ) +//QT_DESIGN_PLUGIN(MaterialPaperPlugin , "qtmaterialpaper.h" , QtMaterialPaper ) +QT_DESIGN_PLUGIN(MaterialProgressPlugin , "qtmaterialprogress.h" , QtMaterialProgress ) +QT_DESIGN_PLUGIN(MaterialRadioButtonPlugin , "qtmaterialradiobutton.h" , QtMaterialRadioButton ) +QT_DESIGN_PLUGIN(MaterialRaisedButtonPlugin , "qtmaterialraisedbutton.h" , QtMaterialRaisedButton ) +QT_DESIGN_PLUGIN(MaterialScrollbarPlugin , "qtmaterialscrollbar.h" , QtMaterialScrollBar ) +QT_DESIGN_PLUGIN(MaterialSliderPlugin , "qtmaterialslider.h" , QtMaterialSlider ) +QT_DESIGN_PLUGIN(MaterialSnackbarPlugin , "qtmaterialsnackbar.h" , QtMaterialSnackbar ) +//QT_DESIGN_PLUGIN(MaterialTablePlugin , "qtmaterialtable.h" , QtMaterialTable ) +QT_DESIGN_PLUGIN(MaterialTabsPlugin , "qtmaterialtabs.h" , QtMaterialTabs ) +QT_DESIGN_PLUGIN(MaterialTextFieldPlugin , "qtmaterialtextfield.h" , QtMaterialTextField ) +QT_DESIGN_PLUGIN(MaterialTogglePlugin , "qtmaterialtoggle.h" , QtMaterialToggle ) class QtMaterialPlugins : public QObject, public QDesignerCustomWidgetCollectionInterface { diff --git a/components/qtmaterialautocomplete.cpp b/components/qtmaterialautocomplete.cpp index df006a6..3212540 100644 --- a/components/qtmaterialautocomplete.cpp +++ b/components/qtmaterialautocomplete.cpp @@ -89,6 +89,12 @@ void QtMaterialAutoComplete::setDataSource(const QStringList &data) update(); } +QStringList QtMaterialAutoComplete::dataSource() const +{ + Q_D(const QtMaterialAutoComplete); + return d->dataSource; +} + void QtMaterialAutoComplete::updateResults(QString text) { Q_D(QtMaterialAutoComplete); @@ -117,7 +123,7 @@ void QtMaterialAutoComplete::updateResults(QString text) item->setCornerRadius(0); item->setHaloVisible(false); item->setFixedHeight(50); - item->setOverlayStyle(Material::TintedOverlay); + item->setOverlayStyle(MaterialConst::TintedOverlay); d->menuLayout->addWidget(item); item->installEventFilter(this); } diff --git a/components/qtmaterialautocomplete.h b/components/qtmaterialautocomplete.h index 8b46861..534ad20 100644 --- a/components/qtmaterialautocomplete.h +++ b/components/qtmaterialautocomplete.h @@ -8,12 +8,14 @@ class QtMaterialAutoCompletePrivate; class QtMaterialAutoComplete : public QtMaterialTextField { Q_OBJECT + Q_PROPERTY(QStringList dataSource WRITE setDataSource READ dataSource) public: explicit QtMaterialAutoComplete(QWidget *parent = 0); ~QtMaterialAutoComplete(); void setDataSource(const QStringList &data); + QStringList dataSource() const; signals: void itemSelected(QString); diff --git a/components/qtmaterialavatar.cpp b/components/qtmaterialavatar.cpp index e769f8f..71964a0 100644 --- a/components/qtmaterialavatar.cpp +++ b/components/qtmaterialavatar.cpp @@ -32,7 +32,7 @@ void QtMaterialAvatarPrivate::init() Q_Q(QtMaterialAvatar); size = 40; - type = Material::LetterAvatar; + type = MaterialConst::LetterAvatar; useThemeColors = true; QFont font(q->font()); @@ -188,16 +188,22 @@ void QtMaterialAvatar::setLetter(const QChar &letter) Q_D(QtMaterialAvatar); d->letter = letter; - d->type = Material::LetterAvatar; + d->type = MaterialConst::LetterAvatar; update(); } +QChar QtMaterialAvatar::letter() const +{ + Q_D(const QtMaterialAvatar); + return d->letter; +} + void QtMaterialAvatar::setImage(const QImage &image) { Q_D(QtMaterialAvatar); d->image = image; - d->type = Material::ImageAvatar; + d->type = MaterialConst::ImageAvatar; d->pixmap = QPixmap::fromImage(image.scaled(d->size, d->size, Qt::IgnoreAspectRatio, @@ -205,16 +211,28 @@ void QtMaterialAvatar::setImage(const QImage &image) update(); } +QImage QtMaterialAvatar::image() const +{ + Q_D(const QtMaterialAvatar); + return d->image; +} + void QtMaterialAvatar::setIcon(const QIcon &icon) { Q_D(QtMaterialAvatar); d->icon = icon; - d->type = Material::IconAvatar; + d->type = MaterialConst::IconAvatar; update(); } -Material::AvatarType QtMaterialAvatar::type() const +QIcon QtMaterialAvatar::icon() const +{ + Q_D(const QtMaterialAvatar); + return d->icon; +} + +MaterialConst::AvatarType QtMaterialAvatar::type() const { Q_D(const QtMaterialAvatar); @@ -248,7 +266,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) return; } - if (Material::ImageAvatar != d->type) + if (MaterialConst::ImageAvatar != d->type) { QBrush brush; brush.setStyle(Qt::SolidPattern); @@ -261,7 +279,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) switch (d->type) { - case Material::ImageAvatar: + case MaterialConst::ImageAvatar: { QPainterPath path; path.addEllipse(width()/2-hs, height()/2-hs, d->size, d->size); @@ -271,7 +289,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) d->pixmap); break; } - case Material::IconAvatar: + case MaterialConst::IconAvatar: { QRect iconGeometry((width()-hs)/2, (height()-hs)/2, hs, hs); QPixmap pixmap = d->icon.pixmap(hs, hs); @@ -281,7 +299,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) painter.drawPixmap(iconGeometry, pixmap); break; } - case Material::LetterAvatar: + case MaterialConst::LetterAvatar: { painter.setPen(textColor()); painter.setBrush(Qt::NoBrush); diff --git a/components/qtmaterialavatar.h b/components/qtmaterialavatar.h index 9b99ef2..d418170 100644 --- a/components/qtmaterialavatar.h +++ b/components/qtmaterialavatar.h @@ -10,6 +10,13 @@ class QtMaterialAvatar : public QWidget { Q_OBJECT + Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) + Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) + Q_PROPERTY(int size WRITE setSize READ size) + Q_PROPERTY(QChar letter WRITE setLetter READ letter) + Q_PROPERTY(QImage image WRITE setImage READ image) + Q_PROPERTY(QIcon icon WRITE setIcon READ icon) + public: explicit QtMaterialAvatar(QWidget *parent = 0); explicit QtMaterialAvatar(const QIcon &icon, QWidget *parent = 0); @@ -32,10 +39,15 @@ public: int size() const; void setLetter(const QChar &letter); - void setImage(const QImage &image); - void setIcon(const QIcon &icon); + QChar letter() const; - Material::AvatarType type() const; + void setImage(const QImage &image); + QImage image() const; + + void setIcon(const QIcon &icon); + QIcon icon() const; + + MaterialConst::AvatarType type() const; protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; diff --git a/components/qtmaterialavatar_p.h b/components/qtmaterialavatar_p.h index 44b378e..69477ea 100644 --- a/components/qtmaterialavatar_p.h +++ b/components/qtmaterialavatar_p.h @@ -24,7 +24,7 @@ public: QtMaterialAvatar *const q_ptr; int size; - Material::AvatarType type; + MaterialConst::AvatarType type; QChar letter; QImage image; QIcon icon; diff --git a/components/qtmaterialbadge.h b/components/qtmaterialbadge.h index deac3ab..6b31a8f 100644 --- a/components/qtmaterialbadge.h +++ b/components/qtmaterialbadge.h @@ -2,6 +2,7 @@ #define QTMATERIALBADGE_H #include "lib/qtmaterialoverlaywidget.h" +#include class QtMaterialBadgePrivate; @@ -12,6 +13,8 @@ class QtMaterialBadge : public QtMaterialOverlayWidget Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) Q_PROPERTY(QPointF relativePosition WRITE setRelativePosition READ relativePosition) + Q_PROPERTY(QIcon icon WRITE setIcon READ icon) + Q_PROPERTY(QString text WRITE setText READ text) public: explicit QtMaterialBadge(QWidget *parent = 0); diff --git a/components/qtmaterialcircularprogress.cpp b/components/qtmaterialcircularprogress.cpp index f38ef01..c068377 100644 --- a/components/qtmaterialcircularprogress.cpp +++ b/components/qtmaterialcircularprogress.cpp @@ -26,7 +26,7 @@ void QtMaterialCircularProgressPrivate::init() Q_Q(QtMaterialCircularProgress); delegate = new QtMaterialCircularProgressDelegate(q); - progressType = Material::IndeterminateProgress; + progressType = MaterialConst::IndeterminateProgress; penWidth = 6.25; size = 64; useThemeColors = true; @@ -92,7 +92,7 @@ QtMaterialCircularProgress::~QtMaterialCircularProgress() { } -void QtMaterialCircularProgress::setProgressType(Material::ProgressType type) +void QtMaterialCircularProgress::setProgressType(MaterialConst::ProgressType type) { Q_D(QtMaterialCircularProgress); @@ -100,7 +100,7 @@ void QtMaterialCircularProgress::setProgressType(Material::ProgressType type) update(); } -Material::ProgressType QtMaterialCircularProgress::progressType() const +MaterialConst::ProgressType QtMaterialCircularProgress::progressType() const { Q_D(const QtMaterialCircularProgress); @@ -214,7 +214,7 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event) return; } - if (Material::IndeterminateProgress == d->progressType) + if (MaterialConst::IndeterminateProgress == d->progressType) { painter.translate(width()/2, height()/2); painter.rotate(d->delegate->angle()); @@ -225,7 +225,7 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event) pen.setWidthF(d->penWidth); pen.setColor(color()); - if (Material::IndeterminateProgress == d->progressType) + if (MaterialConst::IndeterminateProgress == d->progressType) { QVector pattern; pattern << d->delegate->dashLength()*d->size/50 << 30*d->size/50; diff --git a/components/qtmaterialcircularprogress.h b/components/qtmaterialcircularprogress.h index dfc306e..b2ababb 100644 --- a/components/qtmaterialcircularprogress.h +++ b/components/qtmaterialcircularprogress.h @@ -10,6 +10,8 @@ class QtMaterialCircularProgress : public QProgressBar { Q_OBJECT + Q_PROPERTY(MaterialConst::ProgressType progressType WRITE setProgressType READ progressType) + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) Q_PROPERTY(qreal lineWidth WRITE setLineWidth READ lineWidth) Q_PROPERTY(qreal size WRITE setSize READ size) Q_PROPERTY(QColor color WRITE setColor READ color) @@ -18,8 +20,8 @@ public: explicit QtMaterialCircularProgress(QWidget *parent = 0); ~QtMaterialCircularProgress(); - void setProgressType(Material::ProgressType type); - Material::ProgressType progressType() const; + void setProgressType(MaterialConst::ProgressType type); + MaterialConst::ProgressType progressType() const; void setUseThemeColors(bool value); bool useThemeColors() const; diff --git a/components/qtmaterialcircularprogress_p.h b/components/qtmaterialcircularprogress_p.h index 451bc9c..53d29b5 100644 --- a/components/qtmaterialcircularprogress_p.h +++ b/components/qtmaterialcircularprogress_p.h @@ -20,7 +20,7 @@ public: QtMaterialCircularProgress *const q_ptr; QtMaterialCircularProgressDelegate *delegate; - Material::ProgressType progressType; + MaterialConst::ProgressType progressType; QColor color; qreal penWidth; int size; diff --git a/components/qtmaterialfab.cpp b/components/qtmaterialfab.cpp index 3c3de8a..6eec247 100644 --- a/components/qtmaterialfab.cpp +++ b/components/qtmaterialfab.cpp @@ -38,7 +38,7 @@ void QtMaterialFloatingActionButtonPrivate::init() offsX = 34; offsY = 36; - q->setRole(Material::Primary); + q->setRole(MaterialConst::Primary); q->setFixedSize(DefaultDiameter, DefaultDiameter); q->setGeometry(fabGeometry()); @@ -104,6 +104,13 @@ void QtMaterialFloatingActionButtonPrivate::setupProperties() * \class QtMaterialFloatingActionButton */ +QtMaterialFloatingActionButton::QtMaterialFloatingActionButton(QWidget *parent) + : QtMaterialRaisedButton(*new QtMaterialFloatingActionButtonPrivate(this), parent) +{ + d_func()->init(); +} + + QtMaterialFloatingActionButton::QtMaterialFloatingActionButton(const QIcon &icon, QWidget *parent) : QtMaterialRaisedButton(*new QtMaterialFloatingActionButtonPrivate(this), parent) { diff --git a/components/qtmaterialfab.h b/components/qtmaterialfab.h index 78838b1..1de23d8 100644 --- a/components/qtmaterialfab.h +++ b/components/qtmaterialfab.h @@ -8,8 +8,13 @@ class QtMaterialFloatingActionButtonPrivate; class QtMaterialFloatingActionButton : public QtMaterialRaisedButton { Q_OBJECT + Q_PROPERTY(bool mini WRITE setMini READ isMini) + Q_PROPERTY(Qt::Corner corner WRITE setCorner READ corner) + Q_PROPERTY(int xOffset WRITE setXOffset READ xOffset) + Q_PROPERTY(int yOffset WRITE setYOffset READ yOffset) public: + explicit QtMaterialFloatingActionButton(QWidget *parent = 0); explicit QtMaterialFloatingActionButton(const QIcon &icon, QWidget *parent = 0); ~QtMaterialFloatingActionButton(); diff --git a/components/qtmaterialflatbutton.cpp b/components/qtmaterialflatbutton.cpp index b9d84d7..00269e0 100644 --- a/components/qtmaterialflatbutton.cpp +++ b/components/qtmaterialflatbutton.cpp @@ -40,10 +40,10 @@ void QtMaterialFlatButtonPrivate::init() rippleOverlay = new QtMaterialRippleOverlay(q); stateMachine = new QtMaterialFlatButtonStateMachine(q); - role = Material::Default; - rippleStyle = Material::PositionedRipple; - iconPlacement = Material::LeftIcon; - overlayStyle = Material::GrayOverlay; + role = MaterialConst::Default; + rippleStyle = MaterialConst::PositionedRipple; + iconPlacement = MaterialConst::LeftIcon; + overlayStyle = MaterialConst::GrayOverlay; bgMode = Qt::TransparentMode; textAlignment = Qt::AlignHCenter; fixedRippleRadius = 64; @@ -75,7 +75,7 @@ void QtMaterialFlatButtonPrivate::init() * \class QtMaterialFlatButton */ -QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, Material::ButtonPreset preset) +QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, MaterialConst::ButtonPreset preset) : QPushButton(parent), d_ptr(new QtMaterialFlatButtonPrivate(this)) { @@ -84,7 +84,7 @@ QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, Material::ButtonPres applyPreset(preset); } -QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, QWidget *parent, Material::ButtonPreset preset) +QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, QWidget *parent, MaterialConst::ButtonPreset preset) : QPushButton(text, parent), d_ptr(new QtMaterialFlatButtonPrivate(this)) { @@ -93,7 +93,7 @@ QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, QWidget *parent, applyPreset(preset); } -QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, Material::Role role, QWidget *parent, Material::ButtonPreset preset) +QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, MaterialConst::Role role, QWidget *parent, MaterialConst::ButtonPreset preset) : QPushButton(text, parent), d_ptr(new QtMaterialFlatButtonPrivate(this)) { @@ -107,15 +107,15 @@ QtMaterialFlatButton::~QtMaterialFlatButton() { } -void QtMaterialFlatButton::applyPreset(Material::ButtonPreset preset) +void QtMaterialFlatButton::applyPreset(MaterialConst::ButtonPreset preset) { switch (preset) { - case Material::FlatPreset: - setOverlayStyle(Material::NoOverlay); + case MaterialConst::FlatPreset: + setOverlayStyle(MaterialConst::NoOverlay); break; - case Material::CheckablePreset: - setOverlayStyle(Material::NoOverlay); + case MaterialConst::CheckablePreset: + setOverlayStyle(MaterialConst::NoOverlay); setCheckable(true); setHaloVisible(false); break; @@ -143,7 +143,7 @@ bool QtMaterialFlatButton::useThemeColors() const return d->useThemeColors; } -void QtMaterialFlatButton::setRole(Material::Role role) +void QtMaterialFlatButton::setRole(MaterialConst::Role role) { Q_D(QtMaterialFlatButton); @@ -151,7 +151,7 @@ void QtMaterialFlatButton::setRole(Material::Role role) d->stateMachine->setupProperties(); } -Material::Role QtMaterialFlatButton::role() const +MaterialConst::Role QtMaterialFlatButton::role() const { Q_D(const QtMaterialFlatButton); @@ -179,11 +179,11 @@ QColor QtMaterialFlatButton::foregroundColor() const } switch (d->role) { - case Material::Primary: + case MaterialConst::Primary: return QtMaterialStyle::instance().themeColor("primary1"); - case Material::Secondary: + case MaterialConst::Secondary: return QtMaterialStyle::instance().themeColor("accent1"); - case Material::Default: + case MaterialConst::Default: default: return QtMaterialStyle::instance().themeColor("text"); } @@ -209,11 +209,11 @@ QColor QtMaterialFlatButton::backgroundColor() const { switch (d->role) { - case Material::Primary: + case MaterialConst::Primary: return QtMaterialStyle::instance().themeColor("primary1"); - case Material::Secondary: + case MaterialConst::Secondary: return QtMaterialStyle::instance().themeColor("accent1"); - case Material::Default: + case MaterialConst::Default: default: return QtMaterialStyle::instance().themeColor("text"); } @@ -229,7 +229,7 @@ void QtMaterialFlatButton::setOverlayColor(const QColor &color) MATERIAL_DISABLE_THEME_COLORS - setOverlayStyle(Material::TintedOverlay); + setOverlayStyle(MaterialConst::TintedOverlay); update(); } @@ -320,7 +320,7 @@ bool QtMaterialFlatButton::isHaloVisible() const return d->haloVisible; } -void QtMaterialFlatButton::setOverlayStyle(Material::OverlayStyle style) +void QtMaterialFlatButton::setOverlayStyle(MaterialConst::OverlayStyle style) { Q_D(QtMaterialFlatButton); @@ -328,28 +328,28 @@ void QtMaterialFlatButton::setOverlayStyle(Material::OverlayStyle style) update(); } -Material::OverlayStyle QtMaterialFlatButton::overlayStyle() const +MaterialConst::OverlayStyle QtMaterialFlatButton::overlayStyle() const { Q_D(const QtMaterialFlatButton); return d->overlayStyle; } -void QtMaterialFlatButton::setRippleStyle(Material::RippleStyle style) +void QtMaterialFlatButton::setRippleStyle(MaterialConst::RippleStyle style) { Q_D(QtMaterialFlatButton); d->rippleStyle = style; } -Material::RippleStyle QtMaterialFlatButton::rippleStyle() const +MaterialConst::RippleStyle QtMaterialFlatButton::rippleStyle() const { Q_D(const QtMaterialFlatButton); return d->rippleStyle; } -void QtMaterialFlatButton::setIconPlacement(Material::ButtonIconPlacement placement) +void QtMaterialFlatButton::setIconPlacement(MaterialConst::ButtonIconPlacement placement) { Q_D(QtMaterialFlatButton); @@ -357,7 +357,7 @@ void QtMaterialFlatButton::setIconPlacement(Material::ButtonIconPlacement placem update(); } -Material::ButtonIconPlacement QtMaterialFlatButton::iconPlacement() const +MaterialConst::ButtonIconPlacement QtMaterialFlatButton::iconPlacement() const { Q_D(const QtMaterialFlatButton); @@ -473,7 +473,7 @@ QSize QtMaterialFlatButton::sizeHint() const return QSize(w, 20 + h); } -QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidget *parent, Material::ButtonPreset preset) +QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidget *parent, MaterialConst::ButtonPreset preset) : QPushButton(parent), d_ptr(&d) { @@ -501,12 +501,12 @@ void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event) { Q_D(QtMaterialFlatButton); - if (Material::NoRipple != d->rippleStyle) + if (MaterialConst::NoRipple != d->rippleStyle) { QPoint pos; qreal radiusEndValue; - if (Material::CenteredRipple == d->rippleStyle) { + if (MaterialConst::CenteredRipple == d->rippleStyle) { pos = rect().center(); } else { pos = event->pos(); @@ -615,8 +615,8 @@ void QtMaterialFlatButton::paintBackground(QPainter *painter) return; } - if ((Material::NoOverlay != d->overlayStyle) && (overlayOpacity > 0)) { - if (Material::TintedOverlay == d->overlayStyle) { + if ((MaterialConst::NoOverlay != d->overlayStyle) && (overlayOpacity > 0)) { + if (MaterialConst::TintedOverlay == d->overlayStyle) { brush.setColor(overlayColor()); } else { brush.setColor(Qt::gray); @@ -711,7 +711,7 @@ void QtMaterialFlatButton::paintForeground(QPainter *painter) QRect textGeometry(pos + QPoint(0, base.height()/2), textSize); QRect iconGeometry(pos + QPoint(0, (height()-iconSize().height())/2), iconSize()); - if (Material::LeftIcon == d->iconPlacement) { + if (MaterialConst::LeftIcon == d->iconPlacement) { textGeometry.translate(iw, 0); } else { iconGeometry.translate(textSize.width() + IconPadding, 0); diff --git a/components/qtmaterialflatbutton.h b/components/qtmaterialflatbutton.h index a74ab6a..b912cc8 100644 --- a/components/qtmaterialflatbutton.h +++ b/components/qtmaterialflatbutton.h @@ -10,7 +10,6 @@ class QtMaterialFlatButtonPrivate; class QtMaterialFlatButton : public QPushButton { Q_OBJECT - Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor) Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) Q_PROPERTY(QColor overlayColor WRITE setOverlayColor READ overlayColor) @@ -18,20 +17,28 @@ class QtMaterialFlatButton : public QPushButton Q_PROPERTY(QColor disabledBackgroundColor WRITE setDisabledBackgroundColor READ disabledBackgroundColor) Q_PROPERTY(qreal fontSize WRITE setFontSize READ fontSize) + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) + Q_PROPERTY(bool haloVisible WRITE setHaloVisible READ isHaloVisible) + Q_PROPERTY(MaterialConst::Role role WRITE setRole READ role) + Q_PROPERTY(MaterialConst::OverlayStyle overlayStyle WRITE setOverlayStyle READ overlayStyle) + Q_PROPERTY(MaterialConst::RippleStyle rippleStyle WRITE setRippleStyle READ rippleStyle) + Q_PROPERTY(MaterialConst::ButtonIconPlacement iconPlacement WRITE setIconPlacement READ iconPlacement) + Q_PROPERTY(qreal cornerRadius WRITE setCornerRadius READ cornerRadius) + Q_PROPERTY(Qt::BGMode backgroundMode WRITE setBackgroundMode READ backgroundMode) + Q_PROPERTY(qreal baseOpacity WRITE setBaseOpacity READ baseOpacity) + Q_PROPERTY(bool checkable WRITE setCheckable) + public: - explicit QtMaterialFlatButton(QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); - explicit QtMaterialFlatButton(const QString &text, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); - QtMaterialFlatButton(const QString &text, Material::Role role, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + explicit QtMaterialFlatButton(QWidget *parent = 0, MaterialConst::ButtonPreset preset = MaterialConst::FlatPreset); + explicit QtMaterialFlatButton(const QString &text, QWidget *parent = 0, MaterialConst::ButtonPreset preset = MaterialConst::FlatPreset); + QtMaterialFlatButton(const QString &text, MaterialConst::Role role, QWidget *parent = 0, MaterialConst::ButtonPreset preset = MaterialConst::FlatPreset); ~QtMaterialFlatButton(); - void applyPreset(Material::ButtonPreset preset); + void applyPreset(MaterialConst::ButtonPreset preset); void setUseThemeColors(bool value); bool useThemeColors() const; - void setRole(Material::Role role); - Material::Role role() const; - void setForegroundColor(const QColor &color); QColor foregroundColor() const; @@ -53,14 +60,17 @@ public: void setHaloVisible(bool visible); bool isHaloVisible() const; - void setOverlayStyle(Material::OverlayStyle style); - Material::OverlayStyle overlayStyle() const; + void setRole(MaterialConst::Role role); + MaterialConst::Role role() const; - void setRippleStyle(Material::RippleStyle style); - Material::RippleStyle rippleStyle() const; + void setOverlayStyle(MaterialConst::OverlayStyle style); + MaterialConst::OverlayStyle overlayStyle() const; - void setIconPlacement(Material::ButtonIconPlacement placement); - Material::ButtonIconPlacement iconPlacement() const; + void setRippleStyle(MaterialConst::RippleStyle style); + MaterialConst::RippleStyle rippleStyle() const; + + void setIconPlacement(MaterialConst::ButtonIconPlacement placement); + MaterialConst::ButtonIconPlacement iconPlacement() const; void setCornerRadius(qreal radius); qreal cornerRadius() const; @@ -88,7 +98,7 @@ protected: IconPadding = 12 }; - QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d, QWidget *parent = 0, MaterialConst::ButtonPreset preset = MaterialConst::FlatPreset); void checkStateSet() Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; diff --git a/components/qtmaterialflatbutton_p.h b/components/qtmaterialflatbutton_p.h index 1ab3d22..129e954 100644 --- a/components/qtmaterialflatbutton_p.h +++ b/components/qtmaterialflatbutton_p.h @@ -23,10 +23,10 @@ public: QtMaterialFlatButton *const q_ptr; QtMaterialRippleOverlay *rippleOverlay; QtMaterialFlatButtonStateMachine *stateMachine; - Material::Role role; - Material::RippleStyle rippleStyle; - Material::ButtonIconPlacement iconPlacement; - Material::OverlayStyle overlayStyle; + MaterialConst::Role role; + MaterialConst::RippleStyle rippleStyle; + MaterialConst::ButtonIconPlacement iconPlacement; + MaterialConst::OverlayStyle overlayStyle; Qt::BGMode bgMode; Qt::Alignment textAlignment; QColor backgroundColor; diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp index 525d6b2..fa53f9a 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/qtmaterialiconbutton.cpp @@ -48,6 +48,12 @@ void QtMaterialIconButtonPrivate::updateRipple() /*! * \class QtMaterialIconButton */ +QtMaterialIconButton::QtMaterialIconButton(QWidget *parent) + : QAbstractButton(parent), + d_ptr(new QtMaterialIconButtonPrivate(this)) +{ + d_func()->init(); +} QtMaterialIconButton::QtMaterialIconButton(const QIcon &icon, QWidget *parent) : QAbstractButton(parent), diff --git a/components/qtmaterialiconbutton.h b/components/qtmaterialiconbutton.h index 5c2afc4..df56dd1 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/qtmaterialiconbutton.h @@ -8,8 +8,12 @@ class QtMaterialIconButtonPrivate; class QtMaterialIconButton : public QAbstractButton { Q_OBJECT +// Q_PROPERTY(bool useThemeColors READ setUseThemeColors WRITE useThemeColors) +// Q_PROPERTY(QColor color READ setColor WRITE color) +// Q_PROPERTY(QColor disabledColor READ setDisabledColor WRITE disabledColor) public: + explicit QtMaterialIconButton(QWidget *parent = 0); explicit QtMaterialIconButton(const QIcon &icon, QWidget *parent = 0); ~QtMaterialIconButton(); diff --git a/components/qtmaterialmenu.cpp b/components/qtmaterialmenu.cpp index 5808a99..38b3bbf 100644 --- a/components/qtmaterialmenu.cpp +++ b/components/qtmaterialmenu.cpp @@ -1,11 +1,73 @@ #include "qtmaterialmenu.h" #include "qtmaterialmenu_p.h" +#include +#include +#include +#include QtMaterialMenu::QtMaterialMenu(QWidget *parent) : QWidget(parent) { + QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, QOverload<>::of(&QWidget::update)); + timer->start(1000); + + setWindowTitle(tr("Analog Clock")); + resize(200, 200); } -QtMaterialMenu::~QtMaterialMenu() +void QtMaterialMenu::paintEvent(QPaintEvent *) { + static const QPoint hourHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -40) + }; + static const QPoint minuteHand[3] = { + QPoint(7, 8), + QPoint(-7, 8), + QPoint(0, -70) + }; + + QColor hourColor(127, 0, 127); + QColor minuteColor(0, 127, 127, 191); + + int side = qMin(width(), height()); + QTime time = QTime::currentTime(); + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + painter.translate(width() / 2, height() / 2); + painter.scale(side / 200.0, side / 200.0); + + painter.setPen(Qt::NoPen); + painter.setBrush(hourColor); + + painter.save(); + painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); + painter.drawConvexPolygon(hourHand, 3); + painter.restore(); + + painter.setPen(hourColor); + + for (int i = 0; i < 12; ++i) { + painter.drawLine(88, 0, 96, 0); + painter.rotate(30.0); + } + + painter.setPen(Qt::NoPen); + painter.setBrush(minuteColor); + + painter.save(); + painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); + painter.drawConvexPolygon(minuteHand, 3); + painter.restore(); + + painter.setPen(minuteColor); + + for (int j = 0; j < 60; ++j) { + if ((j % 5) != 0) + painter.drawLine(92, 0, 96, 0); + painter.rotate(6.0); + } } diff --git a/components/qtmaterialmenu.h b/components/qtmaterialmenu.h index beb01b5..c1fc7fd 100644 --- a/components/qtmaterialmenu.h +++ b/components/qtmaterialmenu.h @@ -2,14 +2,17 @@ #define QTMATERIALMENU_H #include +#include -class QtMaterialMenu : public QWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialMenu : public QWidget { Q_OBJECT public: explicit QtMaterialMenu(QWidget *parent = 0); - ~QtMaterialMenu(); + +protected: + void paintEvent(QPaintEvent *event) override; }; #endif // QTMATERIALMENU_H diff --git a/components/qtmaterialprogress.cpp b/components/qtmaterialprogress.cpp index 03b15b2..1263293 100644 --- a/components/qtmaterialprogress.cpp +++ b/components/qtmaterialprogress.cpp @@ -25,7 +25,7 @@ void QtMaterialProgressPrivate::init() Q_Q(QtMaterialProgress); delegate = new QtMaterialProgressDelegate(q); - progressType = Material::IndeterminateProgress; + progressType = MaterialConst::IndeterminateProgress; useThemeColors = true; QPropertyAnimation *animation; @@ -57,7 +57,7 @@ QtMaterialProgress::~QtMaterialProgress() { } -void QtMaterialProgress::setProgressType(Material::ProgressType type) +void QtMaterialProgress::setProgressType(MaterialConst::ProgressType type) { Q_D(QtMaterialProgress); @@ -65,7 +65,7 @@ void QtMaterialProgress::setProgressType(Material::ProgressType type) update(); } -Material::ProgressType QtMaterialProgress::progressType() const +MaterialConst::ProgressType QtMaterialProgress::progressType() const { Q_D(const QtMaterialProgress); @@ -163,7 +163,7 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event) brush.setColor(progressColor()); painter.setBrush(brush); - if (Material::IndeterminateProgress == d->progressType) { + if (MaterialConst::IndeterminateProgress == d->progressType) { painter.drawRect(d->delegate->offset()*width()*2-width(), 0, width(), height()); } else { qreal p = static_cast(width())*(value()-minimum())/(maximum()-minimum()); diff --git a/components/qtmaterialprogress.h b/components/qtmaterialprogress.h index 0e69b1d..63cfce0 100644 --- a/components/qtmaterialprogress.h +++ b/components/qtmaterialprogress.h @@ -17,8 +17,8 @@ public: explicit QtMaterialProgress(QWidget *parent = 0); ~QtMaterialProgress(); - void setProgressType(Material::ProgressType type); - Material::ProgressType progressType() const; + void setProgressType(MaterialConst::ProgressType type); + MaterialConst::ProgressType progressType() const; void setUseThemeColors(bool state); bool useThemeColors() const; diff --git a/components/qtmaterialprogress_p.h b/components/qtmaterialprogress_p.h index b55fb02..e01e49e 100644 --- a/components/qtmaterialprogress_p.h +++ b/components/qtmaterialprogress_p.h @@ -21,7 +21,7 @@ public: QtMaterialProgress *const q_ptr; QtMaterialProgressDelegate *delegate; - Material::ProgressType progressType; + MaterialConst::ProgressType progressType; QColor progressColor; QColor backgroundColor; bool useThemeColors; diff --git a/components/qtmaterialscrollbar.h b/components/qtmaterialscrollbar.h index 591c9f1..2aa20ec 100644 --- a/components/qtmaterialscrollbar.h +++ b/components/qtmaterialscrollbar.h @@ -9,9 +9,11 @@ class QtMaterialScrollBar : public QScrollBar { Q_OBJECT + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) Q_PROPERTY(QColor canvasColor WRITE setCanvasColor READ canvasColor) Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) Q_PROPERTY(QColor sliderColor WRITE setSliderColor READ sliderColor) + Q_PROPERTY(bool hideOnMouseOut WRITE setHideOnMouseOut READ hideOnMouseOut) public: explicit QtMaterialScrollBar(QWidget *parent = 0); diff --git a/components/qtmaterialslider.h b/components/qtmaterialslider.h index f8e642d..6eb3f8e 100644 --- a/components/qtmaterialslider.h +++ b/components/qtmaterialslider.h @@ -12,9 +12,12 @@ class QtMaterialSlider : public QAbstractSlider { Q_OBJECT + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) Q_PROPERTY(QColor thumbColor WRITE setThumbColor READ thumbColor) Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor) Q_PROPERTY(QColor disabledColor WRITE setDisabledColor READ disabledColor) + Q_PROPERTY(bool pageStepMode WRITE setPageStepMode READ pageStepMode) + Q_PROPERTY(bool invertedAppearance WRITE setInvertedAppearance) public: explicit QtMaterialSlider(QWidget *parent = 0); diff --git a/components/qtmaterialtabs.cpp b/components/qtmaterialtabs.cpp index dbc55bd..aa1f3a9 100644 --- a/components/qtmaterialtabs.cpp +++ b/components/qtmaterialtabs.cpp @@ -24,7 +24,7 @@ void QtMaterialTabsPrivate::QtMaterialTabsPrivate::init() inkBar = new QtMaterialTabsInkBar(q); tabLayout = new QHBoxLayout; - rippleStyle = Material::CenteredRipple; + rippleStyle = MaterialConst::CenteredRipple; tab = -1; showHalo = true; useThemeColors = true; @@ -80,7 +80,7 @@ bool QtMaterialTabs::isHaloVisible() const return d->showHalo; } -void QtMaterialTabs::setRippleStyle(Material::RippleStyle style) +void QtMaterialTabs::setRippleStyle(MaterialConst::RippleStyle style) { Q_D(QtMaterialTabs); @@ -88,7 +88,7 @@ void QtMaterialTabs::setRippleStyle(Material::RippleStyle style) updateTabs(); } -Material::RippleStyle QtMaterialTabs::rippleStyle() const +MaterialConst::RippleStyle QtMaterialTabs::rippleStyle() const { Q_D(const QtMaterialTabs); diff --git a/components/qtmaterialtabs.h b/components/qtmaterialtabs.h index 11a122e..2f0fd0e 100644 --- a/components/qtmaterialtabs.h +++ b/components/qtmaterialtabs.h @@ -22,8 +22,8 @@ public: void setHaloVisible(bool value); bool isHaloVisible() const; - void setRippleStyle(Material::RippleStyle style); - Material::RippleStyle rippleStyle() const; + void setRippleStyle(MaterialConst::RippleStyle style); + MaterialConst::RippleStyle rippleStyle() const; void setInkColor(const QColor &color); QColor inkColor() const; diff --git a/components/qtmaterialtabs_internal.cpp b/components/qtmaterialtabs_internal.cpp index e952c02..7041ba9 100644 --- a/components/qtmaterialtabs_internal.cpp +++ b/components/qtmaterialtabs_internal.cpp @@ -112,7 +112,7 @@ QtMaterialTab::QtMaterialTab(QtMaterialTabs *parent) setFont(f); setCornerRadius(0); - setRole(Material::Primary); + setRole(MaterialConst::Primary); setBackgroundMode(Qt::OpaqueMode); setBaseOpacity(0.25); diff --git a/components/qtmaterialtabs_p.h b/components/qtmaterialtabs_p.h index 1f32b04..757b927 100644 --- a/components/qtmaterialtabs_p.h +++ b/components/qtmaterialtabs_p.h @@ -22,7 +22,7 @@ public: QtMaterialTabs *const q_ptr; QtMaterialTabsInkBar *inkBar; QHBoxLayout *tabLayout; - Material::RippleStyle rippleStyle; + MaterialConst::RippleStyle rippleStyle; QColor inkColor; QColor backgroundColor; QColor textColor; diff --git a/components/qtmaterialtextfield.cpp b/components/qtmaterialtextfield.cpp index 080da82..8b7a16f 100644 --- a/components/qtmaterialtextfield.cpp +++ b/components/qtmaterialtextfield.cpp @@ -56,6 +56,7 @@ QtMaterialTextField::QtMaterialTextField(QWidget *parent) QtMaterialTextField::~QtMaterialTextField() { + } void QtMaterialTextField::setUseThemeColors(bool value) diff --git a/components/qtmaterialtextfield.h b/components/qtmaterialtextfield.h index dead5cc..674ac30 100644 --- a/components/qtmaterialtextfield.h +++ b/components/qtmaterialtextfield.h @@ -3,16 +3,23 @@ #include #include +#include class QtMaterialTextFieldPrivate; -class QtMaterialTextField : public QLineEdit +class QDESIGNER_WIDGET_EXPORT QtMaterialTextField : public QLineEdit { Q_OBJECT + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) + Q_PROPERTY(bool showLabel WRITE setShowLabel READ hasLabel) + Q_PROPERTY(QString label WRITE setLabel READ label) + Q_PROPERTY(qreal labelFontSize WRITE setLabelFontSize READ labelFontSize) + Q_PROPERTY(QColor labelColor WRITE setLabelColor READ labelColor) Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor) Q_PROPERTY(QColor inputLineColor WRITE setInputLineColor READ inputLineColor) + Q_PROPERTY(bool showInputLine WRITE setShowInputLine READ hasInputLine) public: explicit QtMaterialTextField(QWidget *parent = 0); diff --git a/components/qtmaterialtoggle.cpp b/components/qtmaterialtoggle.cpp index 6d11fc9..174a14f 100644 --- a/components/qtmaterialtoggle.cpp +++ b/components/qtmaterialtoggle.cpp @@ -143,6 +143,7 @@ QtMaterialToggle::QtMaterialToggle(QWidget *parent) QtMaterialToggle::~QtMaterialToggle() { + } void QtMaterialToggle::setUseThemeColors(bool value) diff --git a/components/qtmaterialtoggle.h b/components/qtmaterialtoggle.h index 5d5a557..ec9b48d 100644 --- a/components/qtmaterialtoggle.h +++ b/components/qtmaterialtoggle.h @@ -2,17 +2,20 @@ #define QTMATERIALTOGGLE_H #include +#include class QtMaterialTogglePrivate; -class QtMaterialToggle : public QAbstractButton +class QDESIGNER_WIDGET_EXPORT QtMaterialToggle : public QAbstractButton { Q_OBJECT + Q_PROPERTY(bool useThemeColors WRITE setUseThemeColors READ useThemeColors) Q_PROPERTY(QColor disabledColor WRITE setDisabledColor READ disabledColor) Q_PROPERTY(QColor activeColor WRITE setActiveColor READ activeColor) Q_PROPERTY(QColor inactiveColor WRITE setInactiveColor READ inactiveColor) Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor) + Q_PROPERTY(Qt::Orientation orientation WRITE setOrientation READ orientation) public: explicit QtMaterialToggle(QWidget *parent = 0); diff --git a/examples/avatarsettingseditor.cpp b/examples/avatarsettingseditor.cpp index 1720480..a67112b 100644 --- a/examples/avatarsettingseditor.cpp +++ b/examples/avatarsettingseditor.cpp @@ -47,13 +47,13 @@ void AvatarSettingsEditor::setupForm() { switch (m_avatar->type()) { - case Material::LetterAvatar: + case MaterialConst::LetterAvatar: ui->typeComboBox->setCurrentIndex(0); break; - case Material::ImageAvatar: + case MaterialConst::ImageAvatar: ui->typeComboBox->setCurrentIndex(1); break; - case Material::IconAvatar: + case MaterialConst::IconAvatar: ui->typeComboBox->setCurrentIndex(2); break; default: diff --git a/examples/circularprogresssettingseditor.cpp b/examples/circularprogresssettingseditor.cpp index 8c049fc..15c9703 100644 --- a/examples/circularprogresssettingseditor.cpp +++ b/examples/circularprogresssettingseditor.cpp @@ -49,10 +49,10 @@ void CircularProgressSettingsEditor::setupForm() { switch (m_progress->progressType()) { - case Material::DeterminateProgress: + case MaterialConst::DeterminateProgress: ui->progressTypeComboBox->setCurrentIndex(0); break; - case Material::IndeterminateProgress: + case MaterialConst::IndeterminateProgress: ui->progressTypeComboBox->setCurrentIndex(1); break; default: @@ -71,10 +71,10 @@ void CircularProgressSettingsEditor::updateWidget() switch (ui->progressTypeComboBox->currentIndex()) { case 0: - m_progress->setProgressType(Material::DeterminateProgress); + m_progress->setProgressType(MaterialConst::DeterminateProgress); break; case 1: - m_progress->setProgressType(Material::IndeterminateProgress); + m_progress->setProgressType(MaterialConst::IndeterminateProgress); break; default: break; diff --git a/examples/components.pri b/examples/components.pri new file mode 100644 index 0000000..e69de29 diff --git a/examples/examples.pro b/examples/examples.pro index 5fa2de9..444a090 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,7 +1,10 @@ QT += core gui widgets TEMPLATE = app CONFIG += c++11 -SOURCES = mainwindow.cpp \ + +#include(../components/link_components.pri) + +SOURCES += mainwindow.cpp \ main.cpp \ avatarsettingseditor.cpp \ badgesettingseditor.cpp \ @@ -25,7 +28,7 @@ SOURCES = mainwindow.cpp \ appbarsettingseditor.cpp \ autocompletesettingseditor.cpp \ menusettingseditor.cpp -HEADERS = mainwindow.h \ +HEADERS += mainwindow.h \ avatarsettingseditor.h \ badgesettingseditor.h \ checkboxsettingseditor.h \ @@ -48,12 +51,6 @@ HEADERS = mainwindow.h \ appbarsettingseditor.h \ autocompletesettingseditor.h \ menusettingseditor.h -LIBS += -L../components/ -lqt-material-widget -INCLUDEPATH += $$top_srcdir/components/ -TARGET = examples-exe - -RESOURCES += \ - examples.qrc FORMS += \ avatarsettingsform.ui \ @@ -75,3 +72,11 @@ FORMS += \ drawersettingsform.ui \ scrollbarsettingsform.ui \ appbarsettingsform.ui + +RESOURCES += \ + examples.qrc + +LIBS += -L../components/ -lqt-material-widget +INCLUDEPATH += $$top_srcdir/components/ +TARGET = examples-exe + diff --git a/examples/fabsettingseditor.cpp b/examples/fabsettingseditor.cpp index efbceed..8aab328 100644 --- a/examples/fabsettingseditor.cpp +++ b/examples/fabsettingseditor.cpp @@ -49,13 +49,13 @@ void FloatingActionButtonSettingsEditor::setupForm() { switch (m_fab->role()) { - case Material::Default: + case MaterialConst::Default: ui->buttonRoleComboBox->setCurrentIndex(0); break; - case Material::Primary: + case MaterialConst::Primary: ui->buttonRoleComboBox->setCurrentIndex(1); break; - case Material::Secondary: + case MaterialConst::Secondary: ui->buttonRoleComboBox->setCurrentIndex(2); break; default: @@ -82,13 +82,13 @@ void FloatingActionButtonSettingsEditor::setupForm() switch (m_fab->rippleStyle()) { - case Material::CenteredRipple: + case MaterialConst::CenteredRipple: ui->rippleStyleComboBox->setCurrentIndex(0); break; - case Material::PositionedRipple: + case MaterialConst::PositionedRipple: ui->rippleStyleComboBox->setCurrentIndex(1); break; - case Material::NoRipple: + case MaterialConst::NoRipple: ui->rippleStyleComboBox->setCurrentIndex(2); break; default: @@ -107,13 +107,13 @@ void FloatingActionButtonSettingsEditor::updateWidget() switch (ui->buttonRoleComboBox->currentIndex()) { case 0: - m_fab->setRole(Material::Default); + m_fab->setRole(MaterialConst::Default); break; case 1: - m_fab->setRole(Material::Primary); + m_fab->setRole(MaterialConst::Primary); break; case 2: - m_fab->setRole(Material::Secondary); + m_fab->setRole(MaterialConst::Secondary); break; default: break; @@ -140,13 +140,13 @@ void FloatingActionButtonSettingsEditor::updateWidget() switch (ui->rippleStyleComboBox->currentIndex()) { case 0: - m_fab->setRippleStyle(Material::CenteredRipple); + m_fab->setRippleStyle(MaterialConst::CenteredRipple); break; case 1: - m_fab->setRippleStyle(Material::PositionedRipple); + m_fab->setRippleStyle(MaterialConst::PositionedRipple); break; case 2: - m_fab->setRippleStyle(Material::NoRipple); + m_fab->setRippleStyle(MaterialConst::NoRipple); break; default: break; diff --git a/examples/flatbuttonsettingseditor.cpp b/examples/flatbuttonsettingseditor.cpp index 6b620cc..5ea27f6 100644 --- a/examples/flatbuttonsettingseditor.cpp +++ b/examples/flatbuttonsettingseditor.cpp @@ -28,13 +28,13 @@ void FlatButtonSettingsEditor::setupForm() { switch (m_button->role()) { - case Material::Default: + case MaterialConst::Default: ui->buttonRoleComboBox->setCurrentIndex(0); break; - case Material::Primary: + case MaterialConst::Primary: ui->buttonRoleComboBox->setCurrentIndex(1); break; - case Material::Secondary: + case MaterialConst::Secondary: ui->buttonRoleComboBox->setCurrentIndex(2); break; default: @@ -43,13 +43,13 @@ void FlatButtonSettingsEditor::setupForm() switch (m_button->overlayStyle()) { - case Material::NoOverlay: + case MaterialConst::NoOverlay: ui->hoverStyleComboBox->setCurrentIndex(0); break; - case Material::TintedOverlay: + case MaterialConst::TintedOverlay: ui->hoverStyleComboBox->setCurrentIndex(1); break; - case Material::GrayOverlay: + case MaterialConst::GrayOverlay: ui->hoverStyleComboBox->setCurrentIndex(2); break; default: @@ -58,13 +58,13 @@ void FlatButtonSettingsEditor::setupForm() switch (m_button->rippleStyle()) { - case Material::CenteredRipple: + case MaterialConst::CenteredRipple: ui->rippleStyleComboBox->setCurrentIndex(0); break; - case Material::PositionedRipple: + case MaterialConst::PositionedRipple: ui->rippleStyleComboBox->setCurrentIndex(1); break; - case Material::NoRipple: + case MaterialConst::NoRipple: ui->rippleStyleComboBox->setCurrentIndex(2); break; default: @@ -73,10 +73,10 @@ void FlatButtonSettingsEditor::setupForm() switch (m_button->iconPlacement()) { - case Material::LeftIcon: + case MaterialConst::LeftIcon: ui->iconPlacementComboBox->setCurrentIndex(0); break; - case Material::RightIcon: + case MaterialConst::RightIcon: ui->iconPlacementComboBox->setCurrentIndex(1); break; } @@ -111,13 +111,13 @@ void FlatButtonSettingsEditor::updateWidget() switch (ui->buttonRoleComboBox->currentIndex()) { case 0: - m_button->setRole(Material::Default); + m_button->setRole(MaterialConst::Default); break; case 1: - m_button->setRole(Material::Primary); + m_button->setRole(MaterialConst::Primary); break; case 2: - m_button->setRole(Material::Secondary); + m_button->setRole(MaterialConst::Secondary); break; default: break; @@ -126,13 +126,13 @@ void FlatButtonSettingsEditor::updateWidget() switch (ui->hoverStyleComboBox->currentIndex()) { case 0: - m_button->setOverlayStyle(Material::NoOverlay); + m_button->setOverlayStyle(MaterialConst::NoOverlay); break; case 1: - m_button->setOverlayStyle(Material::TintedOverlay); + m_button->setOverlayStyle(MaterialConst::TintedOverlay); break; case 2: - m_button->setOverlayStyle(Material::GrayOverlay); + m_button->setOverlayStyle(MaterialConst::GrayOverlay); break; default: break; @@ -141,13 +141,13 @@ void FlatButtonSettingsEditor::updateWidget() switch (ui->rippleStyleComboBox->currentIndex()) { case 0: - m_button->setRippleStyle(Material::CenteredRipple); + m_button->setRippleStyle(MaterialConst::CenteredRipple); break; case 1: - m_button->setRippleStyle(Material::PositionedRipple); + m_button->setRippleStyle(MaterialConst::PositionedRipple); break; case 2: - m_button->setRippleStyle(Material::NoRipple); + m_button->setRippleStyle(MaterialConst::NoRipple); break; default: break; @@ -156,10 +156,10 @@ void FlatButtonSettingsEditor::updateWidget() switch (ui->iconPlacementComboBox->currentIndex()) { case 0: - m_button->setIconPlacement(Material::LeftIcon); + m_button->setIconPlacement(MaterialConst::LeftIcon); break; case 1: - m_button->setIconPlacement(Material::RightIcon); + m_button->setIconPlacement(MaterialConst::RightIcon); break; default: break; @@ -236,7 +236,7 @@ void FlatButtonSettingsEditor::applyDefaultPreset() ui->checkableCheckBox->setChecked(false); ui->disabledCheckBox->setChecked(false); updateWidget(); - m_button->applyPreset(Material::FlatPreset); + m_button->applyPreset(MaterialConst::FlatPreset); } void FlatButtonSettingsEditor::applyCheckablePreset() @@ -255,7 +255,7 @@ void FlatButtonSettingsEditor::applyCheckablePreset() ui->checkableCheckBox->setChecked(true); ui->disabledCheckBox->setChecked(false); updateWidget(); - m_button->applyPreset(Material::CheckablePreset); + m_button->applyPreset(MaterialConst::CheckablePreset); } void FlatButtonSettingsEditor::init() diff --git a/examples/plugindemoform.cpp b/examples/plugindemoform.cpp index 8d59c30..e00e020 100644 --- a/examples/plugindemoform.cpp +++ b/examples/plugindemoform.cpp @@ -1,14 +1,45 @@ #include "plugindemoform.h" #include "ui_plugindemoform.h" +#include PluginDemoForm::PluginDemoForm(QWidget *parent) : QWidget(parent), ui(new Ui::PluginDemoForm) { ui->setupUi(this); + +// QStringList list1 = {"Hello", "Material", "Auto Complete"}; +// ui->qtmaterialautocomplete->setDataSource(list1); + + m_dialog = new QtMaterialDialog; + m_dialog->setParent(this); + + QWidget *dialogWidget = new QWidget; + QVBoxLayout *dialogWidgetLayout = new QVBoxLayout; + dialogWidget->setLayout(dialogWidgetLayout); + + QtMaterialFlatButton *closeButton = new QtMaterialFlatButton("Close"); + dialogWidgetLayout->addWidget(closeButton); + dialogWidgetLayout->setAlignment(closeButton, Qt::AlignBottom | Qt::AlignCenter); + + closeButton->setMaximumWidth(150); + + QVBoxLayout *dialogLayout = new QVBoxLayout; + m_dialog->setWindowLayout(dialogLayout); + + dialogWidget->setMinimumHeight(300); + + dialogLayout->addWidget(dialogWidget); + + connect(closeButton, SIGNAL(pressed()), m_dialog, SLOT(hideDialog())); } PluginDemoForm::~PluginDemoForm() { delete ui; } + +void PluginDemoForm::on_qtmaterialflatbutton_3_clicked() +{ + m_dialog->showDialog(); +} diff --git a/examples/plugindemoform.h b/examples/plugindemoform.h index 3bc90bb..bf169df 100644 --- a/examples/plugindemoform.h +++ b/examples/plugindemoform.h @@ -2,6 +2,8 @@ #define PLUGINDEMOFORM_H #include +#include +#include "qtmaterialdialog.h" namespace Ui { class PluginDemoForm; @@ -15,8 +17,12 @@ public: explicit PluginDemoForm(QWidget *parent = nullptr); ~PluginDemoForm(); +private slots: + void on_qtmaterialflatbutton_3_clicked(); + private: Ui::PluginDemoForm *ui; + QtMaterialDialog* m_dialog; }; #endif // PLUGINDEMOFORM_H diff --git a/examples/plugindemoform.ui b/examples/plugindemoform.ui index 4af9ffa..889a01e 100644 --- a/examples/plugindemoform.ui +++ b/examples/plugindemoform.ui @@ -6,24 +6,651 @@ 0 0 - 400 - 300 + 907 + 746 Form - - - - 60 - 20 - 64 - 48 - - - + + + + + + 0 + 0 + + + + + Roboto + + + + CheckBox + + + + + + + + 200 + 16777215 + + + + CheckBox + + + + + + + + 0 + 0 + + + + + Roboto + + + + FloatActionButton + + + + + + + + 200 + 16777215 + + + + + HELLO + WORLD + MATERIAL + + + + + + + + + 0 + 0 + + + + + Roboto + + + + IconButton + + + + + + + + :/icons/icons/navigation/svg/production/ic_more_vert_24px.svg:/icons/icons/navigation/svg/production/ic_more_vert_24px.svg + + + false + + + + + + + + 200 + 16777215 + + + + RadioButton 1 + + + + + + + + 0 + 0 + + + + + Roboto + + + + Slider + + + + + + + + 0 + 0 + + + + + Roboto + + + + Progress + + + + + + + + 0 + 0 + + + + + Roboto + + + + Avatar & Badge + + + + + + + + 60 + 60 + + + + 40 + + + + 79 + + + + + :/icons/icons/communication/svg/production/ic_call_24px.svg:/icons/icons/communication/svg/production/ic_call_24px.svg + + + + + 0 + 0 + 60 + 54 + + + + + 15.000000000000000 + 15.000000000000000 + + + + + :/icons/icons/toggle/svg/production/ic_star_24px.svg:/icons/icons/toggle/svg/production/ic_star_24px.svg + + + + + + + + + 200 + 16777215 + + + + + + + + + 200 + 16777215 + + + + Input Text + + + + + + + + 150 + 16777215 + + + + FlatButton + + + + :/icons/icons/maps/svg/production/ic_local_see_24px.svg:/icons/icons/maps/svg/production/ic_local_see_24px.svg + + + + 20 + 20 + + + + MaterialConst::TintedOverlay + + + + + + + + 0 + 0 + + + + + Roboto + + + + RaiseButton + + + + + + + + 0 + 0 + + + + + Roboto + + + + FlatButton + + + + + + + + + + + 0 + 0 + + + + + Roboto + + + + TextField + + + + + + + + 60 + 60 + + + + 40 + + + + 79 + + + + + :/icons/icons/communication/svg/production/ic_call_24px.svg:/icons/icons/communication/svg/production/ic_call_24px.svg + + + + + 0 + 0 + 60 + 54 + + + + + 15.000000000000000 + 15.000000000000000 + + + + + + + + + + 200 + 16777215 + + + + 50 + + + + + + + + 60 + 60 + + + + 40.000000000000000 + + + + + + + Qt::Vertical + + + + + + + + 120 + 16777215 + + + + RAISEBUTTON + + + MaterialConst::Secondary + + + + + + + + :/icons/icons/content/svg/production/ic_mail_24px.svg:/icons/icons/content/svg/production/ic_mail_24px.svg + + + + 40 + 40 + + + + + + + + + 0 + 0 + + + + + Roboto + + + + Dialog + + + + + + + + 0 + 0 + + + + + Roboto + + + + CirculaProgress + + + + + + + + 150 + 16777215 + + + + Show Dialog + + + + :/icons/icons/communication/svg/production/ic_chat_bubble_24px.svg:/icons/icons/communication/svg/production/ic_chat_bubble_24px.svg + + + + 20 + 20 + + + + MaterialConst::Primary + + + MaterialConst::TintedOverlay + + + MaterialConst::RightIcon + + + + + + + + 0 + 0 + + + + + Roboto + + + + RadioButton + + + + + + + + 0 + 0 + + + + + Roboto + + + + Toggle + + + + + + + + 0 + 0 + + + + + Roboto + + + + AutoComplete + + + + + + + + 200 + 16777215 + + + + RadioButton 2 + + + + - + + + QtMaterialAutoComplete + QtMaterialTextField +
qtmaterialautocomplete.h
+ 1 +
+ + QtMaterialAvatar + QWidget +
qtmaterialavatar.h
+ 1 +
+ + QtMaterialBadge + QWidget +
qtmaterialbadge.h
+ 1 +
+ + QtMaterialCheckBox + QWidget +
qtmaterialcheckbox.h
+ 1 +
+ + QtMaterialCircularProgress + QProgressBar +
qtmaterialcircularprogress.h
+ 1 +
+ + QtMaterialFloatingActionButton + QtMaterialRaisedButton +
qtmaterialfab.h
+ 1 +
+ + QtMaterialFlatButton + QPushButton +
qtmaterialflatbutton.h
+ 1 +
+ + QtMaterialIconButton + QWidget +
qtmaterialiconbutton.h
+ 1 +
+ + QtMaterialProgress + QProgressBar +
qtmaterialprogress.h
+ 1 +
+ + QtMaterialRadioButton + QWidget +
qtmaterialradiobutton.h
+ 1 +
+ + QtMaterialRaisedButton + QtMaterialFlatButton +
qtmaterialraisedbutton.h
+ 1 +
+ + QtMaterialSlider + QWidget +
qtmaterialslider.h
+ 1 +
+ + QtMaterialTextField + QLineEdit +
qtmaterialtextfield.h
+ 1 +
+ + QtMaterialToggle + QWidget +
qtmaterialtoggle.h
+ 1 +
+
+ + + + diff --git a/examples/progresssettingseditor.cpp b/examples/progresssettingseditor.cpp index 401eb57..c8e418e 100644 --- a/examples/progresssettingseditor.cpp +++ b/examples/progresssettingseditor.cpp @@ -47,10 +47,10 @@ void ProgressSettingsEditor::setupForm() { switch (m_progress->progressType()) { - case Material::DeterminateProgress: + case MaterialConst::DeterminateProgress: ui->progressTypeComboBox->setCurrentIndex(0); break; - case Material::IndeterminateProgress: + case MaterialConst::IndeterminateProgress: ui->progressTypeComboBox->setCurrentIndex(1); break; default: @@ -67,10 +67,10 @@ void ProgressSettingsEditor::updateWidget() switch (ui->progressTypeComboBox->currentIndex()) { case 0: - m_progress->setProgressType(Material::DeterminateProgress); + m_progress->setProgressType(MaterialConst::DeterminateProgress); break; case 1: - m_progress->setProgressType(Material::IndeterminateProgress); + m_progress->setProgressType(MaterialConst::IndeterminateProgress); break; default: break;