diff --git a/README.md b/README.md index c73eed0dd..0ecb62da1 100644 --- a/README.md +++ b/README.md @@ -315,3 +315,11 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU - [ ] Stepper - [ ] Subheaders - [ ] Toolbar + + +#### Implement Qt Desinger plugin +- Tested on Windows 10, Ubuntu +- Note: Must build with release mode in Windows +- Copy lib to Qt Design plugin folder. Example: + + Ubuntu: /opt/Qt5.12.8/Tools/QtCreator/lib/Qt/plugins/designer/ + + Windows 10: C:\Qt\Qt5.12.8\Tools\QtCreator\bin\plugins\designer diff --git a/components/components.pro b/components/components.pro index d6080d5db..280adced0 100644 --- a/components/components.pro +++ b/components/components.pro @@ -1,130 +1,28 @@ -TEMPLATE = lib -CONFIG += staticlib -SOURCES = \ - 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 = \ - 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 += \ - resources.qrc +QT += widgets uiplugin designer +CONFIG += plugin #release +TEMPLATE = lib + +include(link_components.pri) + +SOURCES += \ + plugin/qtmaterialplugins.cpp \ + plugin/qtmaterialtabwidgetcontainerextension.cpp \ + plugin/qtmaterialtabwidgetextensionfactory.cpp \ + plugin/qtmaterialtabwidgetplugin.cpp +HEADERS += \ + plugin/plugintemplate.h \ + plugin/qtmaterialplugins.h \ + plugin/qtmaterialtabwidgetcontainerextension.h \ + plugin/qtmaterialtabwidgetextensionfactory.h \ + plugin/qtmaterialtabwidgetplugin.h + +TARGET = $$qtLibraryTarget(qt-material-widget) +target.path = $$[QT_INSTALL_PLUGINS]/designer +INSTALLS += target + +OBJECTS_DIR = $$PWD/../../qt-material-widgets-build/components/build/obj +MOC_DIR = $$PWD/../../qt-material-widgets-build/components/build/moc +RCC_DIR = $$PWD/../../qt-material-widgets-build/components/build/qrc +UI_DIR = $$PWD/../../qt-material-widgets-build/components/build/ui +DESTDIR = $$PWD/../../qt-material-widgets-build/components/lib + diff --git a/components/lib/qtmaterialcheckable.h b/components/lib/qtmaterialcheckable.h index c4cc57469..eeeb5b1dd 100644 --- a/components/lib/qtmaterialcheckable.h +++ b/components/lib/qtmaterialcheckable.h @@ -2,18 +2,28 @@ #define QTMATERIALCHECKABLE_H #include +#include "qtmaterial_global.h" class QtMaterialCheckablePrivate; -class QtMaterialCheckable : public QAbstractButton +class QT_MATERIAL_EXPORT 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 000000000..eac158e00 --- /dev/null +++ b/components/lib/qtmaterialconst.h @@ -0,0 +1,329 @@ +#ifndef QTMATERIALCONST_H +#define QTMATERIALCONST_H + +#include +#include "qtmaterial_global.h" + +class QT_MATERIAL_EXPORT 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/qtmaterialoverlaywidget.h b/components/lib/qtmaterialoverlaywidget.h index 11acba020..56b9fa000 100644 --- a/components/lib/qtmaterialoverlaywidget.h +++ b/components/lib/qtmaterialoverlaywidget.h @@ -2,8 +2,9 @@ #define QTMATERIALOVERLAYWIDGET_H #include +#include "qtmaterial_global.h" -class QtMaterialOverlayWidget : public QWidget +class QT_MATERIAL_EXPORT QtMaterialOverlayWidget : public QWidget { Q_OBJECT diff --git a/components/lib/qtmaterialripple.h b/components/lib/qtmaterialripple.h index d263c76fc..37d66b786 100644 --- a/components/lib/qtmaterialripple.h +++ b/components/lib/qtmaterialripple.h @@ -6,10 +6,11 @@ #include #include #include +#include "qtmaterial_global.h" class QtMaterialRippleOverlay; -class QtMaterialRipple : public QParallelAnimationGroup +class QT_MATERIAL_EXPORT QtMaterialRipple : public QParallelAnimationGroup { Q_OBJECT diff --git a/components/lib/qtmaterialrippleoverlay.h b/components/lib/qtmaterialrippleoverlay.h index 436c2b932..3206dbfde 100644 --- a/components/lib/qtmaterialrippleoverlay.h +++ b/components/lib/qtmaterialrippleoverlay.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialoverlaywidget.h" +#include "qtmaterial_global.h" class QtMaterialRipple; -class QtMaterialRippleOverlay : public QtMaterialOverlayWidget +class QT_MATERIAL_EXPORT QtMaterialRippleOverlay : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/lib/qtmaterialstyle.h b/components/lib/qtmaterialstyle.h index e16289b0f..2db411753 100644 --- a/components/lib/qtmaterialstyle.h +++ b/components/lib/qtmaterialstyle.h @@ -3,13 +3,14 @@ #include #include "lib/qtmaterialstyle_p.h" +#include "qtmaterial_global.h" #define MATERIAL_DISABLE_THEME_COLORS \ if (d->useThemeColors == true) { d->useThemeColors = false; } class QtMaterialTheme; -class QtMaterialStyle : public QCommonStyle +class QT_MATERIAL_EXPORT QtMaterialStyle : public QCommonStyle { Q_OBJECT diff --git a/components/lib/qtmaterialtheme.cpp b/components/lib/qtmaterialtheme.cpp index 725c95480..341d23e9f 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 fe4a11c82..0137cb080 100644 --- a/components/lib/qtmaterialtheme.h +++ b/components/lib/qtmaterialtheme.h @@ -5,320 +5,12 @@ #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" +#include "qtmaterial_global.h" class QtMaterialThemePrivate; -class QtMaterialTheme : public QObject +class QT_MATERIAL_EXPORT QtMaterialTheme : public QObject { Q_OBJECT @@ -329,7 +21,7 @@ class QtMaterialTheme : public QObject 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 000000000..a45baa6eb --- /dev/null +++ b/components/link_components.pri @@ -0,0 +1,138 @@ +COMP_PATH=$$PWD + +INCLUDEPATH += $$COMP_PATH +DEFINES += QT_MATERIAL_LIBRARY + +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 \ + $$PWD/qtmaterialtabwidget.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 \ + $$PWD/qtmaterial_global.h \ + $$PWD/qtmaterialtabwidget.h + +RESOURCES += \ + $$COMP_PATH/material_res.qrc diff --git a/components/resources.qrc b/components/material_res.qrc similarity index 100% rename from components/resources.qrc rename to components/material_res.qrc diff --git a/components/plugin/plugintemplate.h b/components/plugin/plugintemplate.h new file mode 100644 index 000000000..8b56fe14d --- /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 new file mode 100644 index 000000000..a17cc9050 --- /dev/null +++ b/components/plugin/qtmaterialplugins.cpp @@ -0,0 +1,36 @@ +#include "qtmaterialplugins.h" +#include "qtmaterialtabwidgetplugin.h" +QtMaterialPlugins::QtMaterialPlugins(QObject *parent) : QObject(parent) +{ + 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) + << new QtMaterialTabWidgetPlugin(this) + ; +} + +QList QtMaterialPlugins::customWidgets() const { + return m_plugins; +} diff --git a/components/plugin/qtmaterialplugins.h b/components/plugin/qtmaterialplugins.h new file mode 100644 index 000000000..0ce1f877c --- /dev/null +++ b/components/plugin/qtmaterialplugins.h @@ -0,0 +1,72 @@ +#ifndef QTMATERIALPLUGINS_H +#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 +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "com.meta-vi.QDesignerCustomWidgetCollectionInterface") + Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) +public: + explicit QtMaterialPlugins(QObject *parent = nullptr); + QList customWidgets() const; + +private: + QList m_plugins; + +}; + +#endif // QTMATERIALPLUGINS_H diff --git a/components/plugin/qtmaterialtabwidgetcontainerextension.cpp b/components/plugin/qtmaterialtabwidgetcontainerextension.cpp new file mode 100644 index 000000000..2b067c3a4 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetcontainerextension.cpp @@ -0,0 +1,44 @@ +#include "qtmaterialtabwidgetcontainerextension.h" +#include "qtmaterialtabwidget.h" + +QtMaterialTabWidgetContainerExtension::QtMaterialTabWidgetContainerExtension(QtMaterialTabWidget *widget, + QObject *parent) + : QObject(parent) + , myWidget(widget) +{ +} + +void QtMaterialTabWidgetContainerExtension::addWidget(QWidget *widget) +{ + myWidget->addPage(widget); +} + +int QtMaterialTabWidgetContainerExtension::count() const +{ + return myWidget->count(); +} + +int QtMaterialTabWidgetContainerExtension::currentIndex() const +{ + return myWidget->currentIndex(); +} + +void QtMaterialTabWidgetContainerExtension::insertWidget(int index, QWidget *widget) +{ + myWidget->insertPage(index, widget); +} + +void QtMaterialTabWidgetContainerExtension::remove(int index) +{ + myWidget->removePage(index); +} + +void QtMaterialTabWidgetContainerExtension::setCurrentIndex(int index) +{ + myWidget->setCurrentIndex(index); +} + +QWidget* QtMaterialTabWidgetContainerExtension::widget(int index) const +{ + return myWidget->widget(index); +} diff --git a/components/plugin/qtmaterialtabwidgetcontainerextension.h b/components/plugin/qtmaterialtabwidgetcontainerextension.h new file mode 100644 index 000000000..eed4f5e6f --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetcontainerextension.h @@ -0,0 +1,32 @@ +#ifndef QTMATERIALTABWIDGETCONTAINEREXTENSION_H +#define QTMATERIALTABWIDGETCONTAINEREXTENSION_H + +#include + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE +class QtMaterialTabWidget; + +class QtMaterialTabWidgetContainerExtension: public QObject, + public QDesignerContainerExtension +{ +Q_OBJECT +Q_INTERFACES(QDesignerContainerExtension) + +public: +explicit QtMaterialTabWidgetContainerExtension(QtMaterialTabWidget *widget, QObject *parent); + +void addWidget(QWidget *widget) override; +int count() const override; +int currentIndex() const override; +void insertWidget(int index, QWidget *widget) override; +void remove(int index) override; +void setCurrentIndex(int index) override; +QWidget *widget(int index) const override; + +private: +QtMaterialTabWidget *myWidget; +}; + +#endif // QTMATERIALTABWIDGETCONTAINEREXTENSION_H diff --git a/components/plugin/qtmaterialtabwidgetextensionfactory.cpp b/components/plugin/qtmaterialtabwidgetextensionfactory.cpp new file mode 100644 index 000000000..fa12de06a --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetextensionfactory.cpp @@ -0,0 +1,20 @@ +#include "qtmaterialtabwidgetextensionfactory.h" +#include "qtmaterialtabwidgetcontainerextension.h" +#include "qtmaterialtabwidget.h" + +QtMaterialTabWidgetExtensionFactory::QtMaterialTabWidgetExtensionFactory(QExtensionManager *parent) + : QExtensionFactory(parent) +{} +//! [0] + +//! [1] +QObject *QtMaterialTabWidgetExtensionFactory::createExtension(QObject *object, + const QString &iid, + QObject *parent) const +{ + QtMaterialTabWidget *widget = qobject_cast(object); + + if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) + return new QtMaterialTabWidgetContainerExtension(widget, parent); + return nullptr; +} diff --git a/components/plugin/qtmaterialtabwidgetextensionfactory.h b/components/plugin/qtmaterialtabwidgetextensionfactory.h new file mode 100644 index 000000000..00b71e89d --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetextensionfactory.h @@ -0,0 +1,21 @@ +#ifndef QTMATERIALTABWIDGETEXTENSIONFACTORY_H +#define QTMATERIALTABWIDGETEXTENSIONFACTORY_H + +#include + +QT_BEGIN_NAMESPACE +class QExtensionManager; +QT_END_NAMESPACE + +class QtMaterialTabWidgetExtensionFactory: public QExtensionFactory +{ + Q_OBJECT + +public: + explicit QtMaterialTabWidgetExtensionFactory(QExtensionManager *parent = nullptr); + +protected: + QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const override; +}; + +#endif // QTMATERIALTABWIDGETEXTENSIONFACTORY_H diff --git a/components/plugin/qtmaterialtabwidgetplugin.cpp b/components/plugin/qtmaterialtabwidgetplugin.cpp new file mode 100644 index 000000000..b6faa96f8 --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetplugin.cpp @@ -0,0 +1,145 @@ +#include +#include +#include +#include +#include +#include + +#include "qtmaterialtabwidgetplugin.h" +#include "qtmaterialtabwidget.h" +#include "qtmaterialtabwidgetextensionfactory.h" + +QtMaterialTabWidgetPlugin::QtMaterialTabWidgetPlugin(QObject *parent) + : QObject(parent) +{ +} + +QString QtMaterialTabWidgetPlugin::name() const +{ + return QLatin1String("QtMaterialTabWidget"); +} + +QString QtMaterialTabWidgetPlugin::group() const +{ + return QLatin1String("Qt Material Widgets"); +} + +QString QtMaterialTabWidgetPlugin::toolTip() const +{ + return QString(); +} + +QString QtMaterialTabWidgetPlugin::whatsThis() const +{ + return QString(); +} + +QString QtMaterialTabWidgetPlugin::includeFile() const +{ + return QLatin1String("qtmaterialtabwidget.h"); +} + +QIcon QtMaterialTabWidgetPlugin::icon() const +{ + return QIcon(); +} + +//! [0] //! [1] +bool QtMaterialTabWidgetPlugin::isContainer() const +{ + return true; +} + +//! [1] //! [2] +QWidget *QtMaterialTabWidgetPlugin::createWidget(QWidget *parent) +{ + QtMaterialTabWidget *widget = new QtMaterialTabWidget(parent); + connect(widget, &QtMaterialTabWidget::currentIndexChanged, + this, &QtMaterialTabWidgetPlugin::currentIndexChanged); + connect(widget, &QtMaterialTabWidget::pageTitleChanged, + this, &QtMaterialTabWidgetPlugin::pageTitleChanged); + return widget; +} + +//! [2] //! [3] +bool QtMaterialTabWidgetPlugin::isInitialized() const +{ + return initialized; +} +//! [3] + +//! [4] +void QtMaterialTabWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor) +{ + if (initialized) + return; +//! [4] + +//! [5] + QExtensionManager *manager = formEditor->extensionManager(); +//! [5] //! [6] + QExtensionFactory *factory = new QtMaterialTabWidgetExtensionFactory(manager); + + Q_ASSERT(manager != 0); + manager->registerExtensions(factory, Q_TYPEID(QDesignerContainerExtension)); + + initialized = true; +} +//! [6] + +//! [7] +QString QtMaterialTabWidgetPlugin::domXml() const +{ + return QLatin1String("\ +\ + \ + \ + \ + \ + \ + QtMaterialTabWidget\ + QWidget\ + addPage\ + \ + \ +"); +} +//! [7] + +//! [8] +void QtMaterialTabWidgetPlugin::currentIndexChanged(int index) +{ + Q_UNUSED(index); + QtMaterialTabWidget *widget = qobject_cast(sender()); +//! [8] //! [9] + if (widget) { + QDesignerFormWindowInterface *form = QDesignerFormWindowInterface::findFormWindow(widget); + if (form) + form->emitSelectionChanged(); + } +} +//! [9] + +//! [10] +void QtMaterialTabWidgetPlugin::pageTitleChanged(const QString &title) +{ + Q_UNUSED(title); + QtMaterialTabWidget *widget = qobject_cast(sender()); +//! [10] //! [11] + if (widget) { + QWidget *page = widget->widget(widget->currentIndex()); + QDesignerFormWindowInterface *form; + form = QDesignerFormWindowInterface::findFormWindow(widget); +//! [11] + if (form) { +//! [12] + QDesignerFormEditorInterface *editor = form->core(); + QExtensionManager *manager = editor->extensionManager(); +//! [12] //! [13] + QDesignerPropertySheetExtension *sheet; + sheet = qt_extension(manager, page); + const int propertyIndex = sheet->indexOf(QLatin1String("windowTitle")); + sheet->setChanged(propertyIndex, true); + } + } +} diff --git a/components/plugin/qtmaterialtabwidgetplugin.h b/components/plugin/qtmaterialtabwidgetplugin.h new file mode 100644 index 000000000..f07d7f66f --- /dev/null +++ b/components/plugin/qtmaterialtabwidgetplugin.h @@ -0,0 +1,33 @@ +#ifndef QTMATERIALTABWIDGETPLUGIN_H +#define QTMATERIALTABWIDGETPLUGIN_H + +#include +#include + +class QtMaterialTabWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT +public: + explicit QtMaterialTabWidgetPlugin(QObject *parent = nullptr); + + QString name() const override; + QString group() const override; + QString toolTip() const override; + QString whatsThis() const override; + QString includeFile() const override; + QIcon icon() const override; + bool isContainer() const override; + QWidget *createWidget(QWidget *parent) override; + bool isInitialized() const override; + void initialize(QDesignerFormEditorInterface *formEditor) override; + QString domXml() const override; + +private slots: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + bool initialized = false; +}; + +#endif // QTMATERIALTABWIDGETPLUGIN_H diff --git a/components/qtmaterial_global.h b/components/qtmaterial_global.h new file mode 100644 index 000000000..bd2d5a728 --- /dev/null +++ b/components/qtmaterial_global.h @@ -0,0 +1,12 @@ +#ifndef QTMATERIAL_GLOBAL_H +#define QTMATERIAL_GLOBAL_H + +#include + +#if defined(QT_MATERIAL_LIBRARY) +# define QT_MATERIAL_EXPORT Q_DECL_EXPORT +#else +# define QT_MATERIAL_EXPORT Q_DECL_IMPORT +#endif + +#endif // QTMATERIAL_GLOBAL_H diff --git a/components/qtmaterialappbar.h b/components/qtmaterialappbar.h index 4c60564a3..a4581a9d5 100644 --- a/components/qtmaterialappbar.h +++ b/components/qtmaterialappbar.h @@ -3,10 +3,11 @@ #include #include +#include "qtmaterial_global.h" class QtMaterialAppBarPrivate; -class QtMaterialAppBar : public QWidget +class QT_MATERIAL_EXPORT QtMaterialAppBar : public QWidget { Q_OBJECT diff --git a/components/qtmaterialautocomplete.cpp b/components/qtmaterialautocomplete.cpp index df006a68a..321254035 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 8b4686129..3c5a04804 100644 --- a/components/qtmaterialautocomplete.h +++ b/components/qtmaterialautocomplete.h @@ -2,18 +2,21 @@ #define QTMATERIALAUTOCOMPLETE_H #include "qtmaterialtextfield.h" +#include "qtmaterial_global.h" class QtMaterialAutoCompletePrivate; -class QtMaterialAutoComplete : public QtMaterialTextField +class QT_MATERIAL_EXPORT 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 e769f8f56..71964a072 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 9b99ef22f..98c1aa834 100644 --- a/components/qtmaterialavatar.h +++ b/components/qtmaterialavatar.h @@ -3,13 +3,21 @@ #include #include "lib/qtmaterialtheme.h" +#include "qtmaterial_global.h" class QtMaterialAvatarPrivate; -class QtMaterialAvatar : public QWidget +class QT_MATERIAL_EXPORT 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 +40,15 @@ class QtMaterialAvatar : public QWidget int size() const; void setLetter(const QChar &letter); + QChar letter() const; + void setImage(const QImage &image); + QImage image() const; + void setIcon(const QIcon &icon); + QIcon icon() const; - Material::AvatarType type() 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 44b378e10..69477eab8 100644 --- a/components/qtmaterialavatar_p.h +++ b/components/qtmaterialavatar_p.h @@ -24,7 +24,7 @@ class QtMaterialAvatarPrivate 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 deac3ab4b..8f7c282ea 100644 --- a/components/qtmaterialbadge.h +++ b/components/qtmaterialbadge.h @@ -2,16 +2,20 @@ #define QTMATERIALBADGE_H #include "lib/qtmaterialoverlaywidget.h" +#include +#include "qtmaterial_global.h" class QtMaterialBadgePrivate; -class QtMaterialBadge : public QtMaterialOverlayWidget +class QT_MATERIAL_EXPORT QtMaterialBadge : public QtMaterialOverlayWidget { Q_OBJECT 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/qtmaterialcheckbox.h b/components/qtmaterialcheckbox.h index 5aaa8f4dc..a2b1ebc6b 100644 --- a/components/qtmaterialcheckbox.h +++ b/components/qtmaterialcheckbox.h @@ -2,10 +2,11 @@ #define QTMATERIALCHECKBOX_H #include "lib/qtmaterialcheckable.h" +#include "qtmaterial_global.h" class QtMaterialCheckBoxPrivate; -class QtMaterialCheckBox : public QtMaterialCheckable +class QT_MATERIAL_EXPORT QtMaterialCheckBox : public QtMaterialCheckable { Q_OBJECT diff --git a/components/qtmaterialcircularprogress.cpp b/components/qtmaterialcircularprogress.cpp index f38ef0167..c06837775 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 dfc306e16..1610d7cc6 100644 --- a/components/qtmaterialcircularprogress.h +++ b/components/qtmaterialcircularprogress.h @@ -3,13 +3,16 @@ #include #include "lib/qtmaterialtheme.h" +#include "qtmaterial_global.h" class QtMaterialCircularProgressPrivate; -class QtMaterialCircularProgress : public QProgressBar +class QT_MATERIAL_EXPORT 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 +21,8 @@ class QtMaterialCircularProgress : public QProgressBar 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 451bc9c4b..53d29b52b 100644 --- a/components/qtmaterialcircularprogress_p.h +++ b/components/qtmaterialcircularprogress_p.h @@ -20,7 +20,7 @@ class QtMaterialCircularProgressPrivate QtMaterialCircularProgress *const q_ptr; QtMaterialCircularProgressDelegate *delegate; - Material::ProgressType progressType; + MaterialConst::ProgressType progressType; QColor color; qreal penWidth; int size; diff --git a/components/qtmaterialdialog.h b/components/qtmaterialdialog.h index 822a5d9f6..b276a17bc 100644 --- a/components/qtmaterialdialog.h +++ b/components/qtmaterialdialog.h @@ -3,11 +3,12 @@ #include #include "lib/qtmaterialoverlaywidget.h" +#include "qtmaterial_global.h" class QLayout; class QtMaterialDialogPrivate; -class QtMaterialDialog : public QtMaterialOverlayWidget +class QT_MATERIAL_EXPORT QtMaterialDialog : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialdrawer.h b/components/qtmaterialdrawer.h index 7bf3219a0..d9c4b948a 100644 --- a/components/qtmaterialdrawer.h +++ b/components/qtmaterialdrawer.h @@ -2,11 +2,12 @@ #define QTMATERIALDRAWER_H #include "lib/qtmaterialoverlaywidget.h" +#include "qtmaterial_global.h" class QtMaterialDrawerPrivate; class QtMaterialDrawerStateMachine; -class QtMaterialDrawer : public QtMaterialOverlayWidget +class QT_MATERIAL_EXPORT QtMaterialDrawer : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialfab.cpp b/components/qtmaterialfab.cpp index 3c3de8a1f..6eec2471b 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 78838b12b..855f55433 100644 --- a/components/qtmaterialfab.h +++ b/components/qtmaterialfab.h @@ -2,14 +2,20 @@ #define QTMATERIALFAB_H #include "qtmaterialraisedbutton.h" +#include "qtmaterial_global.h" class QtMaterialFloatingActionButtonPrivate; -class QtMaterialFloatingActionButton : public QtMaterialRaisedButton +class QT_MATERIAL_EXPORT 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 b9d84d7e2..00269e003 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 a74ab6afb..6122fbfd3 100644 --- a/components/qtmaterialflatbutton.h +++ b/components/qtmaterialflatbutton.h @@ -4,13 +4,13 @@ #include #include #include "lib/qtmaterialtheme.h" +#include "qtmaterial_global.h" class QtMaterialFlatButtonPrivate; -class QtMaterialFlatButton : public QPushButton +class QT_MATERIAL_EXPORT 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 +18,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 +61,17 @@ class QtMaterialFlatButton : public QPushButton 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 setOverlayStyle(MaterialConst::OverlayStyle style); + MaterialConst::OverlayStyle overlayStyle() const; - void setRippleStyle(Material::RippleStyle style); - Material::RippleStyle rippleStyle() const; + void setRippleStyle(MaterialConst::RippleStyle style); + MaterialConst::RippleStyle rippleStyle() const; - void setIconPlacement(Material::ButtonIconPlacement placement); - Material::ButtonIconPlacement iconPlacement() const; + void setIconPlacement(MaterialConst::ButtonIconPlacement placement); + MaterialConst::ButtonIconPlacement iconPlacement() const; void setCornerRadius(qreal radius); qreal cornerRadius() const; @@ -88,7 +99,7 @@ class QtMaterialFlatButton : public QPushButton 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 1ab3d226f..129e95456 100644 --- a/components/qtmaterialflatbutton_p.h +++ b/components/qtmaterialflatbutton_p.h @@ -23,10 +23,10 @@ class QtMaterialFlatButtonPrivate 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 525d6b206..fa53f9a84 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 5c2afc47b..5c7decc40 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/qtmaterialiconbutton.h @@ -2,14 +2,19 @@ #define QTMATERIALICONBUTTON_H #include +#include "qtmaterial_global.h" class QtMaterialIconButtonPrivate; -class QtMaterialIconButton : public QAbstractButton +class QT_MATERIAL_EXPORT 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 5808a99e0..38b3bbfec 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 beb01b5b9..066073bda 100644 --- a/components/qtmaterialmenu.h +++ b/components/qtmaterialmenu.h @@ -2,14 +2,18 @@ #define QTMATERIALMENU_H #include +#include "qtmaterial_global.h" +#include "qtmaterial_global.h" -class QtMaterialMenu : public QWidget +class QT_MATERIAL_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 03b15b2f0..126329305 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 0e69b1d3c..efa753438 100644 --- a/components/qtmaterialprogress.h +++ b/components/qtmaterialprogress.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialtheme.h" +#include "qtmaterial_global.h" class QtMaterialProgressPrivate; -class QtMaterialProgress : public QProgressBar +class QT_MATERIAL_EXPORT QtMaterialProgress : public QProgressBar { Q_OBJECT @@ -17,8 +18,8 @@ class QtMaterialProgress : public QProgressBar 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 b55fb021c..e01e49e1a 100644 --- a/components/qtmaterialprogress_p.h +++ b/components/qtmaterialprogress_p.h @@ -21,7 +21,7 @@ class QtMaterialProgressPrivate QtMaterialProgress *const q_ptr; QtMaterialProgressDelegate *delegate; - Material::ProgressType progressType; + MaterialConst::ProgressType progressType; QColor progressColor; QColor backgroundColor; bool useThemeColors; diff --git a/components/qtmaterialradiobutton.h b/components/qtmaterialradiobutton.h index adc535cc7..44cda8d3c 100644 --- a/components/qtmaterialradiobutton.h +++ b/components/qtmaterialradiobutton.h @@ -2,10 +2,11 @@ #define QTMATERIALRADIOBUTTON_H #include "lib/qtmaterialcheckable.h" +#include "qtmaterial_global.h" class QtMaterialRadioButtonPrivate; -class QtMaterialRadioButton : public QtMaterialCheckable +class QT_MATERIAL_EXPORT QtMaterialRadioButton : public QtMaterialCheckable { Q_OBJECT diff --git a/components/qtmaterialraisedbutton.h b/components/qtmaterialraisedbutton.h index d8b4ef91e..6e89d9263 100644 --- a/components/qtmaterialraisedbutton.h +++ b/components/qtmaterialraisedbutton.h @@ -2,10 +2,11 @@ #define QTMATERIALRAISEDBUTTON_H #include "qtmaterialflatbutton.h" +#include "qtmaterial_global.h" class QtMaterialRaisedButtonPrivate; -class QtMaterialRaisedButton : public QtMaterialFlatButton +class QT_MATERIAL_EXPORT QtMaterialRaisedButton : public QtMaterialFlatButton { Q_OBJECT diff --git a/components/qtmaterialscrollbar.h b/components/qtmaterialscrollbar.h index 591c9f171..0234c630c 100644 --- a/components/qtmaterialscrollbar.h +++ b/components/qtmaterialscrollbar.h @@ -2,16 +2,19 @@ #define QTMATERIALSCROLLBAR_H #include +#include "qtmaterial_global.h" class QtMaterialScrollBarPrivate; -class QtMaterialScrollBar : public QScrollBar +class QT_MATERIAL_EXPORT 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.cpp b/components/qtmaterialslider.cpp index a0d17dc12..1ef2e949b 100644 --- a/components/qtmaterialslider.cpp +++ b/components/qtmaterialslider.cpp @@ -29,7 +29,7 @@ void QtMaterialSliderPrivate::init() stateMachine = new QtMaterialSliderStateMachine(q, thumb, track); stepTo = 0; oldValue = q->value(); - trackWidth = 2; + trackWidth = 4; hoverTrack = false; hoverThumb = false; hover = false; diff --git a/components/qtmaterialslider.h b/components/qtmaterialslider.h index f8e642d8c..bf19eaee9 100644 --- a/components/qtmaterialslider.h +++ b/components/qtmaterialslider.h @@ -3,18 +3,22 @@ #include #include +#include "qtmaterial_global.h" -#define QT_MATERIAL_SLIDER_MARGIN 30 +#define QT_MATERIAL_SLIDER_MARGIN 10 class QtMaterialSliderPrivate; -class QtMaterialSlider : public QAbstractSlider +class QT_MATERIAL_EXPORT 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/qtmaterialslider_internal.cpp b/components/qtmaterialslider_internal.cpp index fd2d50bf8..22dd0eb97 100644 --- a/components/qtmaterialslider_internal.cpp +++ b/components/qtmaterialslider_internal.cpp @@ -45,9 +45,9 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( m_pulseOutState->assignProperty(thumb, "haloSize", 35); m_pulseInState->assignProperty(thumb, "haloSize", 28); - m_inactiveState->assignProperty(thumb, "diameter", 11); - m_focusState->assignProperty(thumb, "diameter", 11); - m_slidingState->assignProperty(thumb, "diameter", 17); + m_inactiveState->assignProperty(thumb, "diameter", 15); + m_focusState->assignProperty(thumb, "diameter", 15); + m_slidingState->assignProperty(thumb, "diameter", 20); QAbstractTransition *transition; QtMaterialStateTransition *customTransition; diff --git a/components/qtmaterialsnackbar.h b/components/qtmaterialsnackbar.h index 6d9474001..d1a1d1865 100644 --- a/components/qtmaterialsnackbar.h +++ b/components/qtmaterialsnackbar.h @@ -2,10 +2,11 @@ #define QTMATERIALSNACKBAR_H #include "lib/qtmaterialoverlaywidget.h" +#include "qtmaterial_global.h" class QtMaterialSnackbarPrivate; -class QtMaterialSnackbar : public QtMaterialOverlayWidget +class QT_MATERIAL_EXPORT QtMaterialSnackbar : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialtabs.cpp b/components/qtmaterialtabs.cpp index dbc55bdbd..5bc97a5d6 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); @@ -180,6 +180,42 @@ void QtMaterialTabs::setCurrentTab(int index) emit currentChanged(index); } +void QtMaterialTabs::setTabText(int index, const QString &text) +{ + Q_D(QtMaterialTabs); + + if (index > -1) { + QtMaterialTab *tab = static_cast(d->tabLayout->itemAt(index)->widget()); + if (tab) { + tab->setText(text); + } + } +} + +void QtMaterialTabs::insertTab(int index, const QString &text, const QIcon &icon) +{ + Q_D(QtMaterialTabs); + + QtMaterialTab *tab = new QtMaterialTab(this); + tab->setText(text); + tab->setHaloVisible(isHaloVisible()); + tab->setRippleStyle(rippleStyle()); + + if (!icon.isNull()) { + tab->setIcon(icon); + tab->setIconSize(QSize(22, 22)); + } + + d->tabLayout->insertWidget(index, tab); + + if (-1 == d->tab) { + d->tab = 0; + d->inkBar->refreshGeometry(); + d->inkBar->raise(); + tab->setActive(true); + }; +} + void QtMaterialTabs::addTab(const QString &text, const QIcon &icon) { Q_D(QtMaterialTabs); @@ -204,6 +240,27 @@ void QtMaterialTabs::addTab(const QString &text, const QIcon &icon) } } +void QtMaterialTabs::removeTab(int index) +{ + Q_D(QtMaterialTabs); + + if (index > -1) { + QtMaterialTab *tab = static_cast(d->tabLayout->itemAt(index)->widget()); + if (tab) { + d->tabLayout->removeWidget(tab); + delete tab; + } + + setCurrentTab(index - 1); + } +} + +int QtMaterialTabs::count() const +{ + Q_D(const QtMaterialTabs); + return d->tabLayout->count(); +} + int QtMaterialTabs::currentIndex() const { Q_D(const QtMaterialTabs); diff --git a/components/qtmaterialtabs.h b/components/qtmaterialtabs.h index 11a122ee8..750af8418 100644 --- a/components/qtmaterialtabs.h +++ b/components/qtmaterialtabs.h @@ -4,13 +4,19 @@ #include #include #include "lib/qtmaterialtheme.h" +#include "qtmaterial_global.h" class QtMaterialTabsPrivate; class QtMaterialTab; -class QtMaterialTabs : public QWidget +class QT_MATERIAL_EXPORT QtMaterialTabs : public QWidget { Q_OBJECT + Q_PROPERTY(bool haloVisible WRITE setHaloVisible READ isHaloVisible) + Q_PROPERTY(MaterialConst::RippleStyle rippleStyle WRITE setRippleStyle READ rippleStyle) + Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor) + Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) + Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) public: explicit QtMaterialTabs(QWidget *parent = 0); @@ -22,8 +28,8 @@ class QtMaterialTabs : public QWidget 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; @@ -34,14 +40,18 @@ class QtMaterialTabs : public QWidget void setTextColor(const QColor &color); QColor textColor() const; + void insertTab(int index, const QString &text, const QIcon &icon = QIcon()); void addTab(const QString &text, const QIcon &icon = QIcon()); + void removeTab(int index); + int count() const; void setCurrentTab(QtMaterialTab *tab); void setCurrentTab(int index); + void setTabText(int index, const QString &text); int currentIndex() const; -signals: +Q_SIGNALS: void currentChanged(int); protected: diff --git a/components/qtmaterialtabs_internal.cpp b/components/qtmaterialtabs_internal.cpp index e952c0254..34b3cbcaa 100644 --- a/components/qtmaterialtabs_internal.cpp +++ b/components/qtmaterialtabs_internal.cpp @@ -45,11 +45,11 @@ void QtMaterialTabsInkBar::refreshGeometry() const qreal s = 1-m_tween; if (QAbstractAnimation::Running != m_animation->state()) { - m_geometry = QRect(r.left(), r.bottom()-1, r.width(), 2); + m_geometry = QRect(r.left(), r.bottom()-1, r.width(), 4); } else { const qreal left = m_previousGeometry.left()*s + r.left()*m_tween; const qreal width = m_previousGeometry.width()*s + r.width()*m_tween; - m_geometry = QRect(left, r.bottom()-1, width, 2); + m_geometry = QRect(left, r.bottom()-1, width, 4); } m_tabs->update(); } @@ -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 1f32b04ed..757b927bf 100644 --- a/components/qtmaterialtabs_p.h +++ b/components/qtmaterialtabs_p.h @@ -22,7 +22,7 @@ class QtMaterialTabsPrivate QtMaterialTabs *const q_ptr; QtMaterialTabsInkBar *inkBar; QHBoxLayout *tabLayout; - Material::RippleStyle rippleStyle; + MaterialConst::RippleStyle rippleStyle; QColor inkColor; QColor backgroundColor; QColor textColor; diff --git a/components/qtmaterialtabwidget.cpp b/components/qtmaterialtabwidget.cpp new file mode 100644 index 000000000..4485d2727 --- /dev/null +++ b/components/qtmaterialtabwidget.cpp @@ -0,0 +1,149 @@ +#include "qtmaterialtabwidget.h" +#include +#include +#include + +QtMaterialTabWidget::QtMaterialTabWidget(QWidget *parent) + : QWidget(parent) + , tabBar(new QtMaterialTabs) + , stackWidget(new QStackedWidget) +{ + tabBar->setObjectName(QStringLiteral("__qt__passive_tabBar")); + tabBar->setHaloVisible(false); + + connect(tabBar, QOverload::of(&QtMaterialTabs::currentChanged), + this, &QtMaterialTabWidget::setCurrentIndex); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(tabBar); + layout->addWidget(stackWidget); +} + +void QtMaterialTabWidget::setHaloVisible(bool value) +{ + tabBar->setHaloVisible(value); +} + +bool QtMaterialTabWidget::isHaloVisible() const +{ + return tabBar->isHaloVisible(); +} + +void QtMaterialTabWidget::setRippleStyle(MaterialConst::RippleStyle style) +{ + tabBar->setRippleStyle(style); +} + +MaterialConst::RippleStyle QtMaterialTabWidget::rippleStyle() const +{ + return tabBar->rippleStyle(); +} + +void QtMaterialTabWidget::setInkColor(const QColor &color) +{ + tabBar->setInkColor(color); +} + +QColor QtMaterialTabWidget::inkColor() const +{ + return tabBar->inkColor(); +} + +void QtMaterialTabWidget::setBackgroundColor(const QColor &color) +{ + tabBar->setBackgroundColor(color); +} + +QColor QtMaterialTabWidget::backgroundColor() const +{ + return tabBar->backgroundColor(); +} + +void QtMaterialTabWidget::setTextColor(const QColor &color) +{ + tabBar->setTextColor(color); +} + +QColor QtMaterialTabWidget::textColor() const +{ + return tabBar->textColor(); +} + +QSize QtMaterialTabWidget::sizeHint() const +{ + return QSize(300, 200); +} + +void QtMaterialTabWidget::addPage(QWidget *page) +{ + insertPage(count(), page); +} + +void QtMaterialTabWidget::removePage(int index) +{ + QWidget *widget = stackWidget->widget(index); + stackWidget->removeWidget(widget); + + tabBar->removeTab(index); +} + +int QtMaterialTabWidget::count() const +{ + return stackWidget->count(); +} + +int QtMaterialTabWidget::currentIndex() const +{ + return stackWidget->currentIndex(); +} + +void QtMaterialTabWidget::insertPage(int index, QWidget *page) +{ + page->setParent(stackWidget); + + stackWidget->insertWidget(index, page); + + QString title = page->windowTitle(); + if (title.isEmpty()) { + title = tr("Tab %1").arg(tabBar->count() + 1); + page->setWindowTitle(title); + } + connect(page, &QWidget::windowTitleChanged, + this, &QtMaterialTabWidget::pageWindowTitleChanged); + tabBar->insertTab(index, title); +} + +void QtMaterialTabWidget::setCurrentIndex(int index) +{ + if (index != currentIndex()) { + stackWidget->setCurrentIndex(index); + tabBar->setCurrentTab(index); + emit currentIndexChanged(index); + } +} + +void QtMaterialTabWidget::pageWindowTitleChanged() +{ + QWidget *page = qobject_cast(sender()); + const int index = stackWidget->indexOf(page); + tabBar->setTabText(index, page->windowTitle()); +} + +QWidget* QtMaterialTabWidget::widget(int index) +{ + return stackWidget->widget(index); +} + +QString QtMaterialTabWidget::pageTitle() const +{ + if (const QWidget *currentWidget = stackWidget->currentWidget()) + return currentWidget->windowTitle(); + return QString(); +} + +void QtMaterialTabWidget::setPageTitle(QString const &newTitle) +{ + if (QWidget *currentWidget = stackWidget->currentWidget()) + currentWidget->setWindowTitle(newTitle); + emit pageTitleChanged(newTitle); +} diff --git a/components/qtmaterialtabwidget.h b/components/qtmaterialtabwidget.h new file mode 100644 index 000000000..8783b36e4 --- /dev/null +++ b/components/qtmaterialtabwidget.h @@ -0,0 +1,68 @@ +#ifndef QTMATERIALTABWIDGET_H +#define QTMATERIALTABWIDGET_H + +#include +#include "qtmaterial_global.h" +#include "lib/qtmaterialtheme.h" + +QT_BEGIN_NAMESPACE +class QStackedWidget; +QT_END_NAMESPACE +class QtMaterialTabs; + +class QT_MATERIAL_EXPORT QtMaterialTabWidget : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex) + Q_PROPERTY(QString pageTitle READ pageTitle WRITE setPageTitle STORED false) + Q_PROPERTY(bool haloVisible WRITE setHaloVisible READ isHaloVisible) + Q_PROPERTY(MaterialConst::RippleStyle rippleStyle WRITE setRippleStyle READ rippleStyle) + Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor) + Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) + Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) + +public: + explicit QtMaterialTabWidget(QWidget *parent = nullptr); + + void setHaloVisible(bool value); + bool isHaloVisible() const; + + void setRippleStyle(MaterialConst::RippleStyle style); + MaterialConst::RippleStyle rippleStyle() const; + + void setInkColor(const QColor &color); + QColor inkColor() const; + + void setBackgroundColor(const QColor &color); + QColor backgroundColor() const; + + void setTextColor(const QColor &color); + QColor textColor() const; + + QSize sizeHint() const override; + + int count() const; + int currentIndex() const; + QWidget *widget(int index); + QString pageTitle() const; + +public slots: + void addPage(QWidget *page); + void insertPage(int index, QWidget *page); + void removePage(int index); + void setPageTitle(QString const &newTitle); + void setCurrentIndex(int index); + +private slots: + void pageWindowTitleChanged(); + +signals: + void currentIndexChanged(int index); + void pageTitleChanged(const QString &title); + +private: + QtMaterialTabs *tabBar; + QStackedWidget *stackWidget; +}; + +#endif // QTMATERIALTABWIDGET_H diff --git a/components/qtmaterialtextfield.cpp b/components/qtmaterialtextfield.cpp index 080da8291..8b7a16f21 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 dead5cc49..96ef50edb 100644 --- a/components/qtmaterialtextfield.h +++ b/components/qtmaterialtextfield.h @@ -3,16 +3,23 @@ #include #include +#include "qtmaterial_global.h" class QtMaterialTextFieldPrivate; -class QtMaterialTextField : public QLineEdit +class QT_MATERIAL_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 6d11fc986..174a14fce 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 5d5a55701..bf8c551ec 100644 --- a/components/qtmaterialtoggle.h +++ b/components/qtmaterialtoggle.h @@ -2,17 +2,20 @@ #define QTMATERIALTOGGLE_H #include +#include "qtmaterial_global.h" class QtMaterialTogglePrivate; -class QtMaterialToggle : public QAbstractButton +class QT_MATERIAL_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 17204802f..a67112ba9 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 8c049fcd7..15c9703ab 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/examples.pro b/examples/examples.pro index 35d2438ca..ceff3fcaf 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,12 +1,16 @@ QT += core gui widgets TEMPLATE = app CONFIG += c++11 -SOURCES = mainwindow.cpp \ + +TARGET = examples-exe + +SOURCES += mainwindow.cpp \ main.cpp \ avatarsettingseditor.cpp \ badgesettingseditor.cpp \ checkboxsettingseditor.cpp \ fabsettingseditor.cpp \ + plugindemoform.cpp \ raisedbuttonsettingseditor.cpp \ flatbuttonsettingseditor.cpp \ iconbuttonsettingseditor.cpp \ @@ -24,11 +28,12 @@ SOURCES = mainwindow.cpp \ appbarsettingseditor.cpp \ autocompletesettingseditor.cpp \ menusettingseditor.cpp -HEADERS = mainwindow.h \ +HEADERS += mainwindow.h \ avatarsettingseditor.h \ badgesettingseditor.h \ checkboxsettingseditor.h \ fabsettingseditor.h \ + plugindemoform.h \ raisedbuttonsettingseditor.h \ flatbuttonsettingseditor.h \ iconbuttonsettingseditor.h \ @@ -46,13 +51,6 @@ HEADERS = mainwindow.h \ appbarsettingseditor.h \ autocompletesettingseditor.h \ menusettingseditor.h -LIBS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a -INCLUDEPATH += $$top_srcdir/components/ -TARGET = examples-exe -PRE_TARGETDEPS += $$top_builddir/components/$(OBJECTS_DIR)/libcomponents.a - -RESOURCES += \ - examples.qrc FORMS += \ avatarsettingsform.ui \ @@ -61,6 +59,7 @@ FORMS += \ fabsettingsform.ui \ flatbuttonsettingsform.ui \ iconbuttonsettingsform.ui \ + plugindemoform.ui \ progresssettingsform.ui \ circularprogresssettingsform.ui \ slidersettingsform.ui \ @@ -68,8 +67,25 @@ FORMS += \ radiobuttonsettingsform.ui \ togglesettingsform.ui \ textfieldsettingsform.ui \ - tabssettingsform.ui \ dialogsettingsform.ui \ drawersettingsform.ui \ scrollbarsettingsform.ui \ - appbarsettingsform.ui + appbarsettingsform.ui \ + tabssettingsform.ui + +RESOURCES += \ + ../components/material_res.qrc \ + examples.qrc + +OBJECTS_DIR = $$PWD/../../qt-material-widgets-build/examples/build/obj +MOC_DIR = $$PWD/../../qt-material-widgets-build/examples/build/moc +RCC_DIR = $$PWD/../../qt-material-widgets-build/examples/build/qrc +UI_DIR = $$PWD/../../qt-material-widgets-build/examples/build/ui +DESTDIR = $$PWD/../../qt-material-widgets-build/examples/bin + +win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../qt-material-widgets-build/components/lib/ -lqt-material-widget +else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../qt-material-widgets-build/components/lib/ -lqt-material-widgetd +else:unix:!macx: LIBS += -L$$PWD/../../qt-material-widgets-build/components/lib/ -lqt-material-widget + +INCLUDEPATH += $$PWD/../components +DEPENDPATH += $$PWD/../../qt-material-widgets-build/components diff --git a/examples/fabsettingseditor.cpp b/examples/fabsettingseditor.cpp index efbceed64..8aab32809 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 6b620ccc5..5ea27f618 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/main.cpp b/examples/main.cpp index 38f87613e..3d9db17db 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -6,7 +6,8 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - Q_INIT_RESOURCE(resources); + Q_INIT_RESOURCE(examples); + Q_INIT_RESOURCE(material_res); MainWindow window; window.show(); diff --git a/examples/mainwindow.cpp b/examples/mainwindow.cpp index cc4992e45..74cad5b39 100644 --- a/examples/mainwindow.cpp +++ b/examples/mainwindow.cpp @@ -23,6 +23,7 @@ #include "appbarsettingseditor.h" #include "autocompletesettingseditor.h" #include "menusettingseditor.h" +#include "plugindemoform.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -42,6 +43,7 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(widget); + PluginDemoForm *pluginFrm = new PluginDemoForm; AvatarSettingsEditor *avatar = new AvatarSettingsEditor; BadgeSettingsEditor *badge = new BadgeSettingsEditor; CheckBoxSettingsEditor *checkbox = new CheckBoxSettingsEditor; @@ -64,6 +66,7 @@ MainWindow::MainWindow(QWidget *parent) AutoCompleteSettingsEditor *autocomplete = new AutoCompleteSettingsEditor; MenuSettingsEditor *menu = new MenuSettingsEditor; + stack->addWidget(pluginFrm); stack->addWidget(appBar); stack->addWidget(autocomplete); stack->addWidget(avatar); @@ -86,6 +89,7 @@ MainWindow::MainWindow(QWidget *parent) stack->addWidget(textField); stack->addWidget(toggle); + list->addItem("Plugins"); list->addItem("App Bar"); list->addItem("Auto Complete"); list->addItem("Avatar"); diff --git a/examples/plugindemoform.cpp b/examples/plugindemoform.cpp new file mode 100644 index 000000000..c477943f6 --- /dev/null +++ b/examples/plugindemoform.cpp @@ -0,0 +1,51 @@ +#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(); +} + +void PluginDemoForm::tabIndexChanged(int index) +{ +} diff --git a/examples/plugindemoform.h b/examples/plugindemoform.h new file mode 100644 index 000000000..bd673ea60 --- /dev/null +++ b/examples/plugindemoform.h @@ -0,0 +1,29 @@ +#ifndef PLUGINDEMOFORM_H +#define PLUGINDEMOFORM_H + +#include +#include +#include "qtmaterialdialog.h" + +namespace Ui { +class PluginDemoForm; +} + +class PluginDemoForm : public QWidget +{ + Q_OBJECT + +public: + explicit PluginDemoForm(QWidget *parent = nullptr); + ~PluginDemoForm(); + +private slots: + void on_qtmaterialflatbutton_3_clicked(); + void tabIndexChanged(int index); + +private: + Ui::PluginDemoForm *ui; + QtMaterialDialog* m_dialog; +}; + +#endif // PLUGINDEMOFORM_H diff --git a/examples/plugindemoform.ui b/examples/plugindemoform.ui new file mode 100644 index 000000000..1e8ad7ea7 --- /dev/null +++ b/examples/plugindemoform.ui @@ -0,0 +1,666 @@ + + + PluginDemoForm + + + + 0 + 0 + 907 + 908 + + + + Form + + + + + + background-color: rgb(255, 255, 255); + + + false + + + MaterialConst::PositionedRipple + + + + + + + + 0 + 0 + + + + + Roboto + + + + AutoComplete + + + + + + + + 200 + 16777215 + + + + + HELLO + WORLD + MATERIAL + + + + + + + + + 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 + 60 + + + + + 15.000000000000000 + 15.000000000000000 + + + + + + + + + + 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 + 60 + + + + + 15.000000000000000 + 15.000000000000000 + + + + + :/icons/icons/toggle/svg/production/ic_star_24px.svg:/icons/icons/toggle/svg/production/ic_star_24px.svg + + + + + + + + + 0 + 0 + + + + + Roboto + + + + CheckBox + + + + + + + + 200 + 16777215 + + + + CheckBox + + + + + + + + 0 + 0 + + + + + Roboto + + + + CirculaProgress + + + + + + + + 60 + 60 + + + + 40.000000000000000 + + + + + + + + 0 + 0 + + + + + Roboto + + + + Dialog + + + + + + + + 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 + + + + FlatButton + + + + + + + + 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 + + + + + + + + :/icons/icons/navigation/svg/production/ic_more_vert_24px.svg:/icons/icons/navigation/svg/production/ic_more_vert_24px.svg + + + false + + + + + + + + + + + + 0 + 0 + + + + + Roboto + + + + IconButton + + + + + + + + :/icons/icons/content/svg/production/ic_mail_24px.svg:/icons/icons/content/svg/production/ic_mail_24px.svg + + + + 40 + 40 + + + + + + + + + 0 + 0 + + + + + Roboto + + + + Progress + + + + + + + + 200 + 16777215 + + + + + + + + + 0 + 0 + + + + + Roboto + + + + RadioButton + + + + + + + + 200 + 16777215 + + + + RadioButton 1 + + + + + + + + 200 + 16777215 + + + + RadioButton 2 + + + + + + + + 0 + 0 + + + + + Roboto + + + + RaiseButton + + + + + + + + 120 + 16777215 + + + + RAISEBUTTON + + + MaterialConst::Secondary + + + + + + + + 0 + 0 + + + + + Roboto + + + + Slider + + + + + + + + 200 + 16777215 + + + + 50 + + + + + + + + 0 + 0 + + + + + Roboto + + + + TextField + + + + + + + + 200 + 16777215 + + + + Input Text + + + + + + + + 0 + 0 + + + + + Roboto + + + + Toggle + + + + + + + + + + Qt::Vertical + + + + + + + + + + + + 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 +
+ + QtMaterialTabWidget + QWidget +
qtmaterialtabwidget.h
+ addPage + 1 +
+
+ + + + + +
diff --git a/examples/progresssettingseditor.cpp b/examples/progresssettingseditor.cpp index 401eb5770..c8e418ee8 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; diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro index 5654f10a8..7f175f18a 100644 --- a/qt-material-widgets.pro +++ b/qt-material-widgets.pro @@ -1,5 +1,3 @@ -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - TARGET = qt-material-widgets TEMPLATE = subdirs SUBDIRS = components examples @@ -10,8 +8,3 @@ CONFIG += ordered # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0