From 91362b4af326f6f4a8f45ac070511330d3864150 Mon Sep 17 00:00:00 2001 From: Xuan Nguyen Date: Thu, 1 Jul 2021 17:04:11 +0700 Subject: [PATCH] Fix to support build lib in Windows --- README.md | 8 ++++++++ components/components.pro | 17 ++++++++++++----- components/lib/qtmaterialcheckable.h | 3 ++- components/lib/qtmaterialconst.h | 3 ++- components/lib/qtmaterialoverlaywidget.h | 3 ++- components/lib/qtmaterialripple.h | 3 ++- components/lib/qtmaterialrippleoverlay.h | 3 ++- components/lib/qtmaterialstyle.h | 3 ++- components/lib/qtmaterialtheme.h | 3 ++- components/link_components.pri | 1 + components/plugin/qtmaterialplugins.h | 2 +- components/qtmaterialappbar.h | 3 ++- components/qtmaterialautocomplete.h | 3 ++- components/qtmaterialavatar.h | 3 ++- components/qtmaterialbadge.h | 3 ++- components/qtmaterialcheckbox.h | 3 ++- components/qtmaterialcircularprogress.h | 3 ++- components/qtmaterialdialog.h | 3 ++- components/qtmaterialdrawer.h | 3 ++- components/qtmaterialfab.h | 3 ++- components/qtmaterialflatbutton.h | 3 ++- components/qtmaterialiconbutton.h | 3 ++- components/qtmaterialmenu.h | 1 + components/qtmaterialprogress.h | 3 ++- components/qtmaterialradiobutton.h | 3 ++- components/qtmaterialraisedbutton.h | 3 ++- components/qtmaterialscrollbar.h | 3 ++- components/qtmaterialslider.h | 3 ++- components/qtmaterialsnackbar.h | 3 ++- components/qtmaterialtabs.h | 3 ++- examples/examples.pro | 17 +++++++++++++---- examples/main.cpp | 1 + examples/plugindemoform.ui | 7 +++---- qt-material-widgets.pro | 5 ----- 34 files changed, 90 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index c73eed0..0ecb62d 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 75ba920..6937368 100644 --- a/components/components.pro +++ b/components/components.pro @@ -1,11 +1,7 @@ QT += widgets uiplugin designer -CONFIG += plugin release +CONFIG += plugin #release TEMPLATE = lib -TARGET = $$qtLibraryTarget(qt-material-widget) -target.path = $$[QT_INSTALL_PLUGINS]/designer -INSTALLS += target - include(link_components.pri) SOURCES += \ @@ -13,3 +9,14 @@ SOURCES += \ HEADERS += \ plugin/plugintemplate.h \ plugin/qtmaterialplugins.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 6597dbd..3b4b608 100644 --- a/components/lib/qtmaterialcheckable.h +++ b/components/lib/qtmaterialcheckable.h @@ -2,10 +2,11 @@ #define QTMATERIALCHECKABLE_H #include +#include class QtMaterialCheckablePrivate; -class QtMaterialCheckable : public QAbstractButton +class QDESIGNER_WIDGET_EXPORT QtMaterialCheckable : public QAbstractButton { Q_OBJECT // Q_PROPERTY(LabelPosition labelPosition READ setLabelPosition WRITE labelPosition) diff --git a/components/lib/qtmaterialconst.h b/components/lib/qtmaterialconst.h index 2256314..6690ffe 100644 --- a/components/lib/qtmaterialconst.h +++ b/components/lib/qtmaterialconst.h @@ -2,8 +2,9 @@ #define QTMATERIALCONST_H #include +#include -class MaterialConst: public QObject +class QDESIGNER_WIDGET_EXPORT MaterialConst: public QObject { Q_OBJECT diff --git a/components/lib/qtmaterialoverlaywidget.h b/components/lib/qtmaterialoverlaywidget.h index 11acba0..4f1697d 100644 --- a/components/lib/qtmaterialoverlaywidget.h +++ b/components/lib/qtmaterialoverlaywidget.h @@ -2,8 +2,9 @@ #define QTMATERIALOVERLAYWIDGET_H #include +#include -class QtMaterialOverlayWidget : public QWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialOverlayWidget : public QWidget { Q_OBJECT diff --git a/components/lib/qtmaterialripple.h b/components/lib/qtmaterialripple.h index d263c76..ad80047 100644 --- a/components/lib/qtmaterialripple.h +++ b/components/lib/qtmaterialripple.h @@ -6,10 +6,11 @@ #include #include #include +#include class QtMaterialRippleOverlay; -class QtMaterialRipple : public QParallelAnimationGroup +class QDESIGNER_WIDGET_EXPORT QtMaterialRipple : public QParallelAnimationGroup { Q_OBJECT diff --git a/components/lib/qtmaterialrippleoverlay.h b/components/lib/qtmaterialrippleoverlay.h index 436c2b9..90fc1fc 100644 --- a/components/lib/qtmaterialrippleoverlay.h +++ b/components/lib/qtmaterialrippleoverlay.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialoverlaywidget.h" +#include class QtMaterialRipple; -class QtMaterialRippleOverlay : public QtMaterialOverlayWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialRippleOverlay : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/lib/qtmaterialstyle.h b/components/lib/qtmaterialstyle.h index e16289b..e1f7506 100644 --- a/components/lib/qtmaterialstyle.h +++ b/components/lib/qtmaterialstyle.h @@ -3,13 +3,14 @@ #include #include "lib/qtmaterialstyle_p.h" +#include #define MATERIAL_DISABLE_THEME_COLORS \ if (d->useThemeColors == true) { d->useThemeColors = false; } class QtMaterialTheme; -class QtMaterialStyle : public QCommonStyle +class QDESIGNER_WIDGET_EXPORT QtMaterialStyle : public QCommonStyle { Q_OBJECT diff --git a/components/lib/qtmaterialtheme.h b/components/lib/qtmaterialtheme.h index 6850e42..a522861 100644 --- a/components/lib/qtmaterialtheme.h +++ b/components/lib/qtmaterialtheme.h @@ -6,10 +6,11 @@ #include #include #include "qtmaterialconst.h" +#include class QtMaterialThemePrivate; -class QtMaterialTheme : public QObject +class QDESIGNER_WIDGET_EXPORT QtMaterialTheme : public QObject { Q_OBJECT diff --git a/components/link_components.pri b/components/link_components.pri index b7ddf53..a8dd692 100644 --- a/components/link_components.pri +++ b/components/link_components.pri @@ -1,6 +1,7 @@ COMP_PATH=$$PWD INCLUDEPATH += $$COMP_PATH +DEFINES += QDESIGNER_EXPORT_WIDGETS SOURCES += \ $$COMP_PATH/qtmaterialavatar.cpp \ diff --git a/components/plugin/qtmaterialplugins.h b/components/plugin/qtmaterialplugins.h index ec617b7..0ce1f87 100644 --- a/components/plugin/qtmaterialplugins.h +++ b/components/plugin/qtmaterialplugins.h @@ -1,7 +1,7 @@ #ifndef QTMATERIALPLUGINS_H #define QTMATERIALPLUGINS_H -#include +#include #include "plugintemplate.h" #include "qtmaterialappbar.h" #include "qtmaterialautocomplete.h" diff --git a/components/qtmaterialappbar.h b/components/qtmaterialappbar.h index 4c60564..f6782b7 100644 --- a/components/qtmaterialappbar.h +++ b/components/qtmaterialappbar.h @@ -3,10 +3,11 @@ #include #include +#include class QtMaterialAppBarPrivate; -class QtMaterialAppBar : public QWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialAppBar : public QWidget { Q_OBJECT diff --git a/components/qtmaterialautocomplete.h b/components/qtmaterialautocomplete.h index 534ad20..623950d 100644 --- a/components/qtmaterialautocomplete.h +++ b/components/qtmaterialautocomplete.h @@ -2,10 +2,11 @@ #define QTMATERIALAUTOCOMPLETE_H #include "qtmaterialtextfield.h" +#include class QtMaterialAutoCompletePrivate; -class QtMaterialAutoComplete : public QtMaterialTextField +class QDESIGNER_WIDGET_EXPORT QtMaterialAutoComplete : public QtMaterialTextField { Q_OBJECT Q_PROPERTY(QStringList dataSource WRITE setDataSource READ dataSource) diff --git a/components/qtmaterialavatar.h b/components/qtmaterialavatar.h index d418170..71a9794 100644 --- a/components/qtmaterialavatar.h +++ b/components/qtmaterialavatar.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialtheme.h" +#include class QtMaterialAvatarPrivate; -class QtMaterialAvatar : public QWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialAvatar : public QWidget { Q_OBJECT diff --git a/components/qtmaterialbadge.h b/components/qtmaterialbadge.h index 6b31a8f..76bbc9c 100644 --- a/components/qtmaterialbadge.h +++ b/components/qtmaterialbadge.h @@ -3,10 +3,11 @@ #include "lib/qtmaterialoverlaywidget.h" #include +#include class QtMaterialBadgePrivate; -class QtMaterialBadge : public QtMaterialOverlayWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialBadge : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialcheckbox.h b/components/qtmaterialcheckbox.h index 5aaa8f4..80580b3 100644 --- a/components/qtmaterialcheckbox.h +++ b/components/qtmaterialcheckbox.h @@ -2,10 +2,11 @@ #define QTMATERIALCHECKBOX_H #include "lib/qtmaterialcheckable.h" +#include class QtMaterialCheckBoxPrivate; -class QtMaterialCheckBox : public QtMaterialCheckable +class QDESIGNER_WIDGET_EXPORT QtMaterialCheckBox : public QtMaterialCheckable { Q_OBJECT diff --git a/components/qtmaterialcircularprogress.h b/components/qtmaterialcircularprogress.h index b2ababb..a487414 100644 --- a/components/qtmaterialcircularprogress.h +++ b/components/qtmaterialcircularprogress.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialtheme.h" +#include class QtMaterialCircularProgressPrivate; -class QtMaterialCircularProgress : public QProgressBar +class QDESIGNER_WIDGET_EXPORT QtMaterialCircularProgress : public QProgressBar { Q_OBJECT diff --git a/components/qtmaterialdialog.h b/components/qtmaterialdialog.h index 822a5d9..38dbe8a 100644 --- a/components/qtmaterialdialog.h +++ b/components/qtmaterialdialog.h @@ -3,11 +3,12 @@ #include #include "lib/qtmaterialoverlaywidget.h" +#include class QLayout; class QtMaterialDialogPrivate; -class QtMaterialDialog : public QtMaterialOverlayWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialDialog : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialdrawer.h b/components/qtmaterialdrawer.h index 7bf3219..8f1cf56 100644 --- a/components/qtmaterialdrawer.h +++ b/components/qtmaterialdrawer.h @@ -2,11 +2,12 @@ #define QTMATERIALDRAWER_H #include "lib/qtmaterialoverlaywidget.h" +#include class QtMaterialDrawerPrivate; class QtMaterialDrawerStateMachine; -class QtMaterialDrawer : public QtMaterialOverlayWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialDrawer : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialfab.h b/components/qtmaterialfab.h index 1de23d8..a2eeaaf 100644 --- a/components/qtmaterialfab.h +++ b/components/qtmaterialfab.h @@ -2,10 +2,11 @@ #define QTMATERIALFAB_H #include "qtmaterialraisedbutton.h" +#include class QtMaterialFloatingActionButtonPrivate; -class QtMaterialFloatingActionButton : public QtMaterialRaisedButton +class QDESIGNER_WIDGET_EXPORT QtMaterialFloatingActionButton : public QtMaterialRaisedButton { Q_OBJECT Q_PROPERTY(bool mini WRITE setMini READ isMini) diff --git a/components/qtmaterialflatbutton.h b/components/qtmaterialflatbutton.h index b912cc8..c70a6c5 100644 --- a/components/qtmaterialflatbutton.h +++ b/components/qtmaterialflatbutton.h @@ -4,10 +4,11 @@ #include #include #include "lib/qtmaterialtheme.h" +#include class QtMaterialFlatButtonPrivate; -class QtMaterialFlatButton : public QPushButton +class QDESIGNER_WIDGET_EXPORT QtMaterialFlatButton : public QPushButton { Q_OBJECT Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor) diff --git a/components/qtmaterialiconbutton.h b/components/qtmaterialiconbutton.h index df56dd1..db86f26 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/qtmaterialiconbutton.h @@ -2,10 +2,11 @@ #define QTMATERIALICONBUTTON_H #include +#include class QtMaterialIconButtonPrivate; -class QtMaterialIconButton : public QAbstractButton +class QDESIGNER_WIDGET_EXPORT QtMaterialIconButton : public QAbstractButton { Q_OBJECT // Q_PROPERTY(bool useThemeColors READ setUseThemeColors WRITE useThemeColors) diff --git a/components/qtmaterialmenu.h b/components/qtmaterialmenu.h index c1fc7fd..77aba08 100644 --- a/components/qtmaterialmenu.h +++ b/components/qtmaterialmenu.h @@ -3,6 +3,7 @@ #include #include +#include class QDESIGNER_WIDGET_EXPORT QtMaterialMenu : public QWidget { diff --git a/components/qtmaterialprogress.h b/components/qtmaterialprogress.h index 63cfce0..abbc639 100644 --- a/components/qtmaterialprogress.h +++ b/components/qtmaterialprogress.h @@ -3,10 +3,11 @@ #include #include "lib/qtmaterialtheme.h" +#include class QtMaterialProgressPrivate; -class QtMaterialProgress : public QProgressBar +class QDESIGNER_WIDGET_EXPORT QtMaterialProgress : public QProgressBar { Q_OBJECT diff --git a/components/qtmaterialradiobutton.h b/components/qtmaterialradiobutton.h index adc535c..83dd366 100644 --- a/components/qtmaterialradiobutton.h +++ b/components/qtmaterialradiobutton.h @@ -2,10 +2,11 @@ #define QTMATERIALRADIOBUTTON_H #include "lib/qtmaterialcheckable.h" +#include class QtMaterialRadioButtonPrivate; -class QtMaterialRadioButton : public QtMaterialCheckable +class QDESIGNER_WIDGET_EXPORT QtMaterialRadioButton : public QtMaterialCheckable { Q_OBJECT diff --git a/components/qtmaterialraisedbutton.h b/components/qtmaterialraisedbutton.h index d8b4ef9..6a1ea56 100644 --- a/components/qtmaterialraisedbutton.h +++ b/components/qtmaterialraisedbutton.h @@ -2,10 +2,11 @@ #define QTMATERIALRAISEDBUTTON_H #include "qtmaterialflatbutton.h" +#include class QtMaterialRaisedButtonPrivate; -class QtMaterialRaisedButton : public QtMaterialFlatButton +class QDESIGNER_WIDGET_EXPORT QtMaterialRaisedButton : public QtMaterialFlatButton { Q_OBJECT diff --git a/components/qtmaterialscrollbar.h b/components/qtmaterialscrollbar.h index 2aa20ec..f245a9c 100644 --- a/components/qtmaterialscrollbar.h +++ b/components/qtmaterialscrollbar.h @@ -2,10 +2,11 @@ #define QTMATERIALSCROLLBAR_H #include +#include class QtMaterialScrollBarPrivate; -class QtMaterialScrollBar : public QScrollBar +class QDESIGNER_WIDGET_EXPORT QtMaterialScrollBar : public QScrollBar { Q_OBJECT diff --git a/components/qtmaterialslider.h b/components/qtmaterialslider.h index 6eb3f8e..6b68597 100644 --- a/components/qtmaterialslider.h +++ b/components/qtmaterialslider.h @@ -3,12 +3,13 @@ #include #include +#include #define QT_MATERIAL_SLIDER_MARGIN 30 class QtMaterialSliderPrivate; -class QtMaterialSlider : public QAbstractSlider +class QDESIGNER_WIDGET_EXPORT QtMaterialSlider : public QAbstractSlider { Q_OBJECT diff --git a/components/qtmaterialsnackbar.h b/components/qtmaterialsnackbar.h index 6d94740..7ebecb6 100644 --- a/components/qtmaterialsnackbar.h +++ b/components/qtmaterialsnackbar.h @@ -2,10 +2,11 @@ #define QTMATERIALSNACKBAR_H #include "lib/qtmaterialoverlaywidget.h" +#include class QtMaterialSnackbarPrivate; -class QtMaterialSnackbar : public QtMaterialOverlayWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialSnackbar : public QtMaterialOverlayWidget { Q_OBJECT diff --git a/components/qtmaterialtabs.h b/components/qtmaterialtabs.h index 2f0fd0e..1d822f4 100644 --- a/components/qtmaterialtabs.h +++ b/components/qtmaterialtabs.h @@ -4,11 +4,12 @@ #include #include #include "lib/qtmaterialtheme.h" +#include class QtMaterialTabsPrivate; class QtMaterialTab; -class QtMaterialTabs : public QWidget +class QDESIGNER_WIDGET_EXPORT QtMaterialTabs : public QWidget { Q_OBJECT diff --git a/examples/examples.pro b/examples/examples.pro index 444a090..db4f350 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -2,7 +2,7 @@ QT += core gui widgets TEMPLATE = app CONFIG += c++11 -#include(../components/link_components.pri) +TARGET = examples-exe SOURCES += mainwindow.cpp \ main.cpp \ @@ -74,9 +74,18 @@ FORMS += \ appbarsettingsform.ui RESOURCES += \ + ../components/material_res.qrc \ examples.qrc -LIBS += -L../components/ -lqt-material-widget -INCLUDEPATH += $$top_srcdir/components/ -TARGET = examples-exe +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/main.cpp b/examples/main.cpp index 42510fa..3d9db17 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -6,6 +6,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + Q_INIT_RESOURCE(examples); Q_INIT_RESOURCE(material_res); MainWindow window; diff --git a/examples/plugindemoform.ui b/examples/plugindemoform.ui index 889a01e..5267796 100644 --- a/examples/plugindemoform.ui +++ b/examples/plugindemoform.ui @@ -7,7 +7,7 @@ 0 0 907 - 746 + 849 @@ -202,7 +202,7 @@ 0 0 60 - 54 + 60 @@ -350,7 +350,7 @@ 0 0 60 - 54 + 60 @@ -650,7 +650,6 @@ - diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro index 9d6631f..7f175f1 100644 --- a/qt-material-widgets.pro +++ b/qt-material-widgets.pro @@ -8,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