diff --git a/.gitignore b/.gitignore index 75c107bcc..1dcdf89fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pro.user +CMakeLists.txt.user diff --git a/.qmake.conf b/.qmake.conf deleted file mode 100644 index b303d719d..000000000 --- a/.qmake.conf +++ /dev/null @@ -1,2 +0,0 @@ -top_srcdir=$$PWD -top_builddir=$$shadowed($$PWD) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2434c784d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 3.5) + +project(QtMaterialWidgets VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) + +add_subdirectory(components) +add_subdirectory(examples) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) +# qt_add_executable(QtMaterialWidgets +# MANUAL_FINALIZATION +# ${PROJECT_SOURCES} +# ) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET QtMaterialWidgets APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(QtMaterialWidgets SHARED ${PROJECT_SOURCES}) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(QtMaterialWidgets + ${PROJECT_SOURCES} + ) + endif() +endif() + + +#set_target_properties(QtMaterialWidgets PROPERTIES +# MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com +# MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} +# MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} +# MACOSX_BUNDLE TRUE +# WIN32_EXECUTABLE TRUE +#) + +#file(COPY fonts DESTINATION ${CMAKE_BINARY_DIR}) + +if(QT_VERSION_MAJOR EQUAL 6) +# qt_finalize_executable(QtMaterialWidgets) +endif() diff --git a/README.md b/README.md index c73eed0dd..f4746c7e8 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU App Bar - QtMaterialAppBar + md::AppBar @@ -25,7 +25,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Auto Complete - QtMaterialAutoComplete + md::AutoComplete @@ -38,7 +38,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Avatar - QtMaterialAvatar + md::Avatar @@ -51,7 +51,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Badge - QtMaterialBadge + md::Badge @@ -64,7 +64,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Check Box - QtMaterialCheckBox + md::CheckBox @@ -77,7 +77,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Circular Progress - QtMaterialCircularProgress + md::CircularProgress @@ -90,7 +90,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Dialog - QtMaterialDialog + md::Dialog @@ -103,7 +103,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Drawer - QtMaterialDrawer + md::Drawer @@ -116,7 +116,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU FAB - QtMaterialFloatingActionButton + md::FloatingActionButton @@ -129,7 +129,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Flat Button - QtMaterialFlatButton + md::FlatButton @@ -155,7 +155,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Progress - QtMaterialProgress + md::Progress @@ -168,7 +168,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Radio Button - QtMaterialRadioButton + md::RadioButton @@ -181,7 +181,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Raised Button - QtMaterialRaisedButton + md::RaisedButton @@ -194,7 +194,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Scroll Bar - QtMaterialScrollBar + md::ScrollBar @@ -207,7 +207,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Slider - QtMaterialSlider + md::Slider @@ -220,7 +220,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Snackbar - QtMaterialSnackBar + md::SnackBar @@ -233,7 +233,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Tabs - QtMaterialTabs + md::Tabs @@ -246,7 +246,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Text Field - QtMaterialTextField + md::TextField @@ -259,7 +259,7 @@ YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU Toggle - QtMaterialToggle + md::Toggle diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt new file mode 100644 index 000000000..dcb40f459 --- /dev/null +++ b/components/CMakeLists.txt @@ -0,0 +1,190 @@ +cmake_minimum_required(VERSION 3.5) + +#project(components VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS StateMachine REQUIRED) + +# Create a library called "components" which includes the source file "*.cpp". +# The extension is already found. Any number of sources could be listed here. +set(PROJECT_SOURCES +# sources + avatar.cpp + lib/style.cpp + lib/theme.cpp + badge.cpp + lib/overlaywidget.cpp + checkbox.cpp + lib/checkable_internal.cpp + lib/checkable.cpp + lib/ripple.cpp + lib/rippleoverlay.cpp + fab.cpp + raisedbutton.cpp + flatbutton_internal.cpp + flatbutton.cpp + lib/statetransition.cpp + iconbutton.cpp + progress_internal.cpp + progress.cpp + circularprogress_internal.cpp + circularprogress.cpp + slider_internal.cpp + slider.cpp + snackbar_internal.cpp + snackbar.cpp + radiobutton.cpp + toggle_internal.cpp + toggle.cpp + textfield_internal.cpp + textfield.cpp + tabs_internal.cpp + tabs.cpp + scrollbar_internal.cpp + scrollbar.cpp + dialog_internal.cpp + dialog.cpp + drawer_internal.cpp + drawer.cpp + appbar.cpp + autocomplete.cpp + paper.cpp + table.cpp + layouts/snackbarlayout.cpp + autocomplete_internal.cpp + menu.cpp + menu_internal.cpp + list.cpp + listitem.cpp +# headers + avatar_p.h + avatar.h + lib/style_p.h + lib/style.h + lib/theme_p.h + lib/theme.h + badge_p.h + badge.h + lib/overlaywidget.h + checkbox_p.h + checkbox.h + lib/checkable_internal.h + lib/checkable_p.h + lib/ripple.h + lib/rippleoverlay.h + lib/checkable.h + fab_p.h + fab.h + raisedbutton_p.h + raisedbutton.h + flatbutton_internal.h + flatbutton_p.h + flatbutton.h + lib/statetransition.h + lib/statetransitionevent.h + iconbutton_p.h + iconbutton.h + progress_internal.h + progress_p.h + progress.h + circularprogress_internal.h + circularprogress_p.h + circularprogress.h + slider_internal.h + slider_p.h + slider.h + snackbar_internal.h + snackbar_p.h + snackbar.h + radiobutton_p.h + radiobutton.h + toggle_internal.h + toggle_p.h + toggle.h + textfield_internal.h + textfield_p.h + textfield.h + tabs_internal.h + tabs_p.h + tabs.h + scrollbar_internal.h + scrollbar_p.h + scrollbar.h + dialog_internal.h + dialog_p.h + dialog.h + drawer_internal.h + drawer_p.h + drawer.h + appbar.h + appbar_p.h + autocomplete.h + autocomplete_p.h + paper.h + paper_p.h + table.h + table_p.h + layouts/snackbarlayout.h + layouts/snackbarlayout_p.h + autocomplete_internal.h + menu.h + menu_p.h + menu_internal.h + list.h + list_p.h + listitem.h + listitem_p.h + # resources + resources.qrc +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + add_library(components SHARED ${PROJECT_SOURCES}) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET components APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(components SHARED ${PROJECT_SOURCES}) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() +# add_executable(components ${PROJECT_SOURCES}) + endif() +endif() + +target_link_libraries(components PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) +target_link_libraries(components PRIVATE Qt${QT_VERSION_MAJOR}::Core) +target_link_libraries(components PRIVATE Qt${QT_VERSION_MAJOR}::Gui) +target_link_libraries(components PRIVATE Qt${QT_VERSION_MAJOR}::Core5Compat) +target_link_libraries(components PRIVATE Qt${QT_VERSION_MAJOR}::StateMachine) + +# Make sure the compiler can find include files for our 'components' library +# when other libraries or executables link to components +target_include_directories (components PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +set_target_properties(components PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +if(QT_VERSION_MAJOR EQUAL 6) +# qt_finalize_executable(components) +endif() diff --git a/components/qtmaterialappbar.cpp b/components/appbar.cpp similarity index 51% rename from components/qtmaterialappbar.cpp rename to components/appbar.cpp index 2170ca496..6b8103d95 100644 --- a/components/qtmaterialappbar.cpp +++ b/components/appbar.cpp @@ -1,18 +1,17 @@ -#include "qtmaterialappbar.h" -#include "qtmaterialappbar_p.h" -#include -#include -#include "lib/qtmaterialstyle.h" +#include "appbar.h" +#include "appbar_p.h" +#include "lib/style.h" +namespace md { /*! - * \class QtMaterialAppBarPrivate + * \class AppBarPrivate * \internal */ /*! * \internal */ -QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q) +AppBarPrivate::AppBarPrivate(AppBar *q) : q_ptr(q) { } @@ -20,16 +19,16 @@ QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q) /*! * \internal */ -QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate() +AppBarPrivate::~AppBarPrivate() { } /*! * \internal */ -void QtMaterialAppBarPrivate::init() +void AppBarPrivate::init() { - Q_Q(QtMaterialAppBar); + Q_Q(AppBar); useThemeColors = true; @@ -48,23 +47,23 @@ void QtMaterialAppBarPrivate::init() * \class QtMaterialAppBar */ -QtMaterialAppBar::QtMaterialAppBar(QWidget *parent) +AppBar::AppBar(QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAppBarPrivate(this)) + d_ptr(new AppBarPrivate(this)) { d_func()->init(); } -QtMaterialAppBar::~QtMaterialAppBar() +AppBar::~AppBar() { } -QSize QtMaterialAppBar::sizeHint() const +QSize AppBar::sizeHint() const { return QSize(-1, 64); } -void QtMaterialAppBar::paintEvent(QPaintEvent *event) +void AppBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -73,9 +72,9 @@ void QtMaterialAppBar::paintEvent(QPaintEvent *event) painter.fillRect(rect(), backgroundColor()); } -void QtMaterialAppBar::setUseThemeColors(bool value) +void AppBar::setUseThemeColors(bool value) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); if (d->useThemeColors == value) { return; @@ -85,16 +84,16 @@ void QtMaterialAppBar::setUseThemeColors(bool value) update(); } -bool QtMaterialAppBar::useThemeColors() const +bool AppBar::useThemeColors() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); return d->useThemeColors; } -void QtMaterialAppBar::setForegroundColor(const QColor &color) +void AppBar::setForegroundColor(const QColor &color) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); d->foregroundColor = color; @@ -104,20 +103,20 @@ void QtMaterialAppBar::setForegroundColor(const QColor &color) update(); } -QColor QtMaterialAppBar::foregroundColor() const +QColor AppBar::foregroundColor() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); if (d->useThemeColors || !d->foregroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->foregroundColor; } } -void QtMaterialAppBar::setBackgroundColor(const QColor &color) +void AppBar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); d->backgroundColor = color; @@ -127,13 +126,15 @@ void QtMaterialAppBar::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialAppBar::backgroundColor() const +QColor AppBar::backgroundColor() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->backgroundColor; } } + +} diff --git a/components/qtmaterialappbar.h b/components/appbar.h similarity index 63% rename from components/qtmaterialappbar.h rename to components/appbar.h index 4c60564a3..e0168a410 100644 --- a/components/qtmaterialappbar.h +++ b/components/appbar.h @@ -1,12 +1,15 @@ -#ifndef QTMATERIALAPPBAR_H -#define QTMATERIALAPPBAR_H +#ifndef APPBAR_H +#define APPBAR_H #include #include -class QtMaterialAppBarPrivate; +namespace md +{ + +class AppBarPrivate; -class QtMaterialAppBar : public QWidget +class AppBar : public QWidget { Q_OBJECT @@ -14,8 +17,8 @@ class QtMaterialAppBar : public QWidget Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) public: - explicit QtMaterialAppBar(QWidget *parent = 0); - ~QtMaterialAppBar(); + explicit AppBar(QWidget *parent = 0); + ~AppBar(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -33,16 +36,18 @@ class QtMaterialAppBar : public QWidget protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialAppBar) - Q_DECLARE_PRIVATE(QtMaterialAppBar) + Q_DISABLE_COPY(AppBar) + Q_DECLARE_PRIVATE(AppBar) }; -inline QHBoxLayout *QtMaterialAppBar::appBarLayout() const +inline QHBoxLayout *AppBar::appBarLayout() const { return static_cast(layout()); } -#endif // QTMATERIALAPPBAR_H +} + +#endif // APPBAR_H diff --git a/components/appbar_p.h b/components/appbar_p.h new file mode 100644 index 000000000..dcb1cb2f9 --- /dev/null +++ b/components/appbar_p.h @@ -0,0 +1,33 @@ +#ifndef APPBAR_P_H +#define APPBAR_P_H + +#include +#include +#include +#include + +namespace md +{ + +class AppBar; + +class AppBarPrivate +{ + Q_DISABLE_COPY(AppBarPrivate) + Q_DECLARE_PUBLIC(AppBar) + +public: + AppBarPrivate(AppBar *q); + ~AppBarPrivate(); + + void init(); + + AppBar *const q_ptr; + bool useThemeColors; + QColor foregroundColor; + QColor backgroundColor; +}; + +} + +#endif // APPBAR_P_H diff --git a/components/qtmaterialautocomplete.cpp b/components/autocomplete.cpp similarity index 73% rename from components/qtmaterialautocomplete.cpp rename to components/autocomplete.cpp index df006a68a..463595fff 100644 --- a/components/qtmaterialautocomplete.cpp +++ b/components/autocomplete.cpp @@ -1,14 +1,8 @@ -#include "qtmaterialautocomplete.h" -#include "qtmaterialautocomplete_p.h" -#include -#include -#include -#include -#include -#include -#include "qtmaterialautocomplete_internal.h" -#include "qtmaterialflatbutton.h" +#include "autocomplete_p.h" + +namespace md +{ /*! * \class QtMaterialAutoCompletePrivate * \internal @@ -17,28 +11,28 @@ /*! * \internal */ -QtMaterialAutoCompletePrivate::QtMaterialAutoCompletePrivate(QtMaterialAutoComplete *q) - : QtMaterialTextFieldPrivate(q) +AutoCompletePrivate::AutoCompletePrivate(AutoComplete *q) + : TextFieldPrivate(q) { } /*! * \internal */ -QtMaterialAutoCompletePrivate::~QtMaterialAutoCompletePrivate() +AutoCompletePrivate::~AutoCompletePrivate() { } /*! * \internal */ -void QtMaterialAutoCompletePrivate::init() +void AutoCompletePrivate::init() { - Q_Q(QtMaterialAutoComplete); + Q_Q(AutoComplete); menu = new QWidget; frame = new QWidget; - stateMachine = new QtMaterialAutoCompleteStateMachine(menu); + stateMachine = new AutoCompleteStateMachine(menu); menuLayout = new QVBoxLayout; maxWidth = 0; @@ -71,27 +65,27 @@ void QtMaterialAutoCompletePrivate::init() * \class QtMaterialAutoComplete */ -QtMaterialAutoComplete::QtMaterialAutoComplete(QWidget *parent) - : QtMaterialTextField(*new QtMaterialAutoCompletePrivate(this), parent) +AutoComplete::AutoComplete(QWidget *parent) + : TextField(*new AutoCompletePrivate(this), parent) { d_func()->init(); } -QtMaterialAutoComplete::~QtMaterialAutoComplete() +AutoComplete::~AutoComplete() { } -void QtMaterialAutoComplete::setDataSource(const QStringList &data) +void AutoComplete::setDataSource(const QStringList &data) { - Q_D(QtMaterialAutoComplete); + Q_D(AutoComplete); d->dataSource = data; update(); } -void QtMaterialAutoComplete::updateResults(QString text) +void AutoComplete::updateResults(QString text) { - Q_D(QtMaterialAutoComplete); + Q_D(AutoComplete); QStringList results; QString trimmed(text.trimmed()); @@ -111,7 +105,7 @@ void QtMaterialAutoComplete::updateResults(QString text) if (diff > 0) { for (int c = 0; c < diff; c++) { - QtMaterialFlatButton *item = new QtMaterialFlatButton; + FlatButton *item = new FlatButton; item->setFont(font); item->setTextAlignment(Qt::AlignLeft); item->setCornerRadius(0); @@ -136,8 +130,8 @@ void QtMaterialAutoComplete::updateResults(QString text) for (int i = 0; i < results.count(); ++i) { QWidget *widget = d->menuLayout->itemAt(i)->widget(); - QtMaterialFlatButton *item; - if ((item = static_cast(widget))) { + FlatButton *item; + if ((item = static_cast(widget))) { QString text = results.at(i); QRect rect = fm->boundingRect(text); d->maxWidth = qMax(d->maxWidth, rect.width()); @@ -156,9 +150,9 @@ void QtMaterialAutoComplete::updateResults(QString text) d->menu->update(); } -bool QtMaterialAutoComplete::QtMaterialAutoComplete::event(QEvent *event) +bool AutoComplete::AutoComplete::event(QEvent *event) { - Q_D(QtMaterialAutoComplete); + Q_D(AutoComplete); switch (event->type()) { @@ -178,12 +172,12 @@ bool QtMaterialAutoComplete::QtMaterialAutoComplete::event(QEvent *event) default: break; } - return QtMaterialTextField::event(event); + return TextField::event(event); } -bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event) +bool AutoComplete::eventFilter(QObject *watched, QEvent *event) { - Q_D(QtMaterialAutoComplete); + Q_D(AutoComplete); if (d->frame == watched) { @@ -226,8 +220,8 @@ bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event) { case QEvent::MouseButtonPress: { emit d->stateMachine->shouldFade(); - QtMaterialFlatButton *widget; - if ((widget = static_cast(watched))) { + FlatButton *widget; + if ((widget = static_cast(watched))) { QString text(widget->text()); setText(text); emit itemSelected(text); @@ -238,5 +232,7 @@ bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event) break; } } - return QtMaterialTextField::eventFilter(watched, event); + return TextField::eventFilter(watched, event); +} + } diff --git a/components/autocomplete.h b/components/autocomplete.h new file mode 100644 index 000000000..cf126c131 --- /dev/null +++ b/components/autocomplete.h @@ -0,0 +1,38 @@ +#ifndef AUTOCOMPLETE_H +#define AUTOCOMPLETE_H + +#include "textfield.h" + +namespace md +{ + +class AutoCompletePrivate; + +class AutoComplete : public TextField +{ + Q_OBJECT + +public: + explicit AutoComplete(QWidget *parent = 0); + ~AutoComplete(); + + void setDataSource(const QStringList &data); + +signals: + void itemSelected(QString); + +protected slots: + void updateResults(QString text); + +protected: + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(AutoComplete) + Q_DECLARE_PRIVATE(AutoComplete) +}; + +} + +#endif // AUTOCOMPLETE_H diff --git a/components/qtmaterialautocomplete_internal.cpp b/components/autocomplete_internal.cpp similarity index 81% rename from components/qtmaterialautocomplete_internal.cpp rename to components/autocomplete_internal.cpp index e01848d8c..621dbc982 100644 --- a/components/qtmaterialautocomplete_internal.cpp +++ b/components/autocomplete_internal.cpp @@ -1,18 +1,16 @@ -#include "qtmaterialautocomplete_internal.h" -#include -#include -#include -#include +#include "autocomplete_internal.h" +namespace md +{ /*! - * \class QtMaterialAutoCompleteStateMachine + * \class AutoCompleteStateMachine * \internal */ /*! * \internal */ -QtMaterialAutoCompleteStateMachine::QtMaterialAutoCompleteStateMachine(QWidget *menu) +AutoCompleteStateMachine::AutoCompleteStateMachine(QWidget *menu) : QStateMachine(menu), m_menu(menu), m_closedState(new QState), @@ -64,6 +62,8 @@ QtMaterialAutoCompleteStateMachine::QtMaterialAutoCompleteStateMachine(QWidget * /*! * \internal */ -QtMaterialAutoCompleteStateMachine::~QtMaterialAutoCompleteStateMachine() +AutoCompleteStateMachine::~AutoCompleteStateMachine() { } + +} diff --git a/components/autocomplete_internal.h b/components/autocomplete_internal.h new file mode 100644 index 000000000..a913eca2b --- /dev/null +++ b/components/autocomplete_internal.h @@ -0,0 +1,39 @@ +#ifndef AUTOCOMPLETESTATEMACHINE_H +#define AUTOCOMPLETESTATEMACHINE_H + +#include +#include +#include +#include +#include + +#include "autocomplete.h" + +namespace md +{ + +class AutoCompleteStateMachine : public QStateMachine +{ + Q_OBJECT + +public: + explicit AutoCompleteStateMachine(QWidget *menu); + ~AutoCompleteStateMachine(); + +signals: + void shouldOpen(); + void shouldClose(); + void shouldFade(); + +private: + Q_DISABLE_COPY(AutoCompleteStateMachine) + + QWidget *const m_menu; + QState *const m_closedState; + QState *const m_openState; + QState *const m_closingState; +}; + +} + +#endif // AUTOCOMPLETESTATEMACHINE_H diff --git a/components/autocomplete_p.h b/components/autocomplete_p.h new file mode 100644 index 000000000..a0baae9e9 --- /dev/null +++ b/components/autocomplete_p.h @@ -0,0 +1,43 @@ +#ifndef AUTOCOMPLETE_P_H +#define AUTOCOMPLETE_P_H + +#include +#include +#include +#include +#include +#include + +#include "autocomplete.h" +#include "autocomplete_internal.h" +#include "flatbutton.h" +#include "textfield_p.h" + +namespace md +{ + +class AutoCompleteOverlay; +class AutoCompleteStateMachine; + +class AutoCompletePrivate : public TextFieldPrivate +{ + Q_DISABLE_COPY(AutoCompletePrivate) + Q_DECLARE_PUBLIC(AutoComplete) + +public: + AutoCompletePrivate(AutoComplete *q); + virtual ~AutoCompletePrivate(); + + void init(); + + QWidget *menu; + QWidget *frame; + AutoCompleteStateMachine *stateMachine; + QVBoxLayout *menuLayout; + QStringList dataSource; + int maxWidth; +}; + +} + +#endif // AUTOCOMPLETE_P_H diff --git a/components/qtmaterialavatar.cpp b/components/avatar.cpp similarity index 65% rename from components/qtmaterialavatar.cpp rename to components/avatar.cpp index e769f8f56..ef3bfb77a 100644 --- a/components/qtmaterialavatar.cpp +++ b/components/avatar.cpp @@ -1,18 +1,18 @@ -#include "qtmaterialavatar.h" -#include "qtmaterialavatar_p.h" -#include -#include -#include "lib/qtmaterialstyle.h" +#include "avatar.h" +#include "avatar_p.h" +#include "lib/style.h" +namespace md +{ /*! - * \class QtMaterialAvatarPrivate + * \class AvatarPrivate * \internal */ /*! * \internal */ -QtMaterialAvatarPrivate::QtMaterialAvatarPrivate(QtMaterialAvatar *q) +AvatarPrivate::AvatarPrivate(Avatar *q) : q_ptr(q) { } @@ -20,16 +20,16 @@ QtMaterialAvatarPrivate::QtMaterialAvatarPrivate(QtMaterialAvatar *q) /*! * \internal */ -QtMaterialAvatarPrivate::~QtMaterialAvatarPrivate() +AvatarPrivate::~AvatarPrivate() { } /*! * \internal */ -void QtMaterialAvatarPrivate::init() +void AvatarPrivate::init() { - Q_Q(QtMaterialAvatar); + Q_Q(Avatar); size = 40; type = Material::LetterAvatar; @@ -48,47 +48,47 @@ void QtMaterialAvatarPrivate::init() * \class QtMaterialAvatar */ -QtMaterialAvatar::QtMaterialAvatar(QWidget *parent) +Avatar::Avatar(QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAvatarPrivate(this)) + d_ptr(new AvatarPrivate(this)) { d_func()->init(); } -QtMaterialAvatar::QtMaterialAvatar(const QIcon &icon, QWidget *parent) +Avatar::Avatar(const QIcon &icon, QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAvatarPrivate(this)) + d_ptr(new AvatarPrivate(this)) { d_func()->init(); setIcon(icon); } -QtMaterialAvatar::QtMaterialAvatar(const QChar &letter, QWidget *parent) +Avatar::Avatar(const QChar &letter, QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAvatarPrivate(this)) + d_ptr(new AvatarPrivate(this)) { d_func()->init(); setLetter(letter); } -QtMaterialAvatar::QtMaterialAvatar(const QImage &image, QWidget *parent) +Avatar::Avatar(const QImage &image, QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAvatarPrivate(this)) + d_ptr(new AvatarPrivate(this)) { d_func()->init(); setImage(image); } -QtMaterialAvatar::~QtMaterialAvatar() +Avatar::~Avatar() { } -void QtMaterialAvatar::setUseThemeColors(bool value) +void Avatar::setUseThemeColors(bool value) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); if (d->useThemeColors == value) { return; @@ -98,16 +98,16 @@ void QtMaterialAvatar::setUseThemeColors(bool value) update(); } -bool QtMaterialAvatar::useThemeColors() const +bool Avatar::useThemeColors() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); return d->useThemeColors; } -void QtMaterialAvatar::setTextColor(const QColor &color) +void Avatar::setTextColor(const QColor &color) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->textColor = color; @@ -115,33 +115,33 @@ void QtMaterialAvatar::setTextColor(const QColor &color) update(); } -QColor QtMaterialAvatar::textColor() const +QColor Avatar::textColor() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("canvas"); + return Style::instance().themeColor("canvas"); } else { return d->textColor; } } -void QtMaterialAvatar::setBackgroundColor(const QColor &color) +void Avatar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->backgroundColor = color; - + MATERIAL_DISABLE_THEME_COLORS update(); } -QColor QtMaterialAvatar::backgroundColor() const +QColor Avatar::backgroundColor() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->backgroundColor; } @@ -150,16 +150,16 @@ QColor QtMaterialAvatar::backgroundColor() const /*! * \reimp */ -QSize QtMaterialAvatar::sizeHint() const +QSize Avatar::sizeHint() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); return QSize(d->size+2, d->size+2); } -void QtMaterialAvatar::setSize(int size) +void Avatar::setSize(int size) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->size = size; @@ -176,25 +176,25 @@ void QtMaterialAvatar::setSize(int size) update(); } -int QtMaterialAvatar::size() const +int Avatar::size() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); return d->size; } -void QtMaterialAvatar::setLetter(const QChar &letter) +void Avatar::setLetter(const QChar &letter) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->letter = letter; d->type = Material::LetterAvatar; update(); } -void QtMaterialAvatar::setImage(const QImage &image) +void Avatar::setImage(const QImage &image) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->image = image; d->type = Material::ImageAvatar; @@ -205,18 +205,18 @@ void QtMaterialAvatar::setImage(const QImage &image) update(); } -void QtMaterialAvatar::setIcon(const QIcon &icon) +void Avatar::setIcon(const QIcon &icon) { - Q_D(QtMaterialAvatar); + Q_D(Avatar); d->icon = icon; d->type = Material::IconAvatar; update(); } -Material::AvatarType QtMaterialAvatar::type() const +Material::AvatarType Avatar::type() const { - Q_D(const QtMaterialAvatar); + Q_D(const Avatar); return d->type; } @@ -224,11 +224,11 @@ Material::AvatarType QtMaterialAvatar::type() const /*! * \reimp */ -void QtMaterialAvatar::paintEvent(QPaintEvent *event) +void Avatar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialAvatar); + Q_D(Avatar); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -240,7 +240,7 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) { QBrush brush; brush.setStyle(Qt::SolidPattern); - brush.setColor(QtMaterialStyle::instance().themeColor("disabled")); + brush.setColor(Style::instance().themeColor("disabled")); painter.setPen(Qt::NoPen); painter.setBrush(brush); painter.drawEllipse(QRectF((width()-d->size)/2, (height()-d->size)/2, @@ -292,3 +292,5 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event) break; } } + +} diff --git a/components/qtmaterialavatar.h b/components/avatar.h similarity index 50% rename from components/qtmaterialavatar.h rename to components/avatar.h index 9b99ef22f..3fefc28e8 100644 --- a/components/qtmaterialavatar.h +++ b/components/avatar.h @@ -1,21 +1,22 @@ -#ifndef QTMATERIALAVATAR_H -#define QTMATERIALAVATAR_H +#ifndef AVATAR_H +#define AVATAR_H #include -#include "lib/qtmaterialtheme.h" +#include "lib/theme.h" -class QtMaterialAvatarPrivate; +namespace md { +class AvatarPrivate; -class QtMaterialAvatar : public QWidget +class Avatar : public QWidget { Q_OBJECT public: - explicit QtMaterialAvatar(QWidget *parent = 0); - explicit QtMaterialAvatar(const QIcon &icon, QWidget *parent = 0); - explicit QtMaterialAvatar(const QChar &letter, QWidget *parent = 0); - explicit QtMaterialAvatar(const QImage &image, QWidget *parent = 0); - ~QtMaterialAvatar(); + explicit Avatar(QWidget *parent = 0); + explicit Avatar(const QIcon &icon, QWidget *parent = 0); + explicit Avatar(const QChar &letter, QWidget *parent = 0); + explicit Avatar(const QImage &image, QWidget *parent = 0); + ~Avatar(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -40,11 +41,12 @@ class QtMaterialAvatar : public QWidget protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialAvatar) - Q_DECLARE_PRIVATE(QtMaterialAvatar) + Q_DISABLE_COPY(Avatar) + Q_DECLARE_PRIVATE(Avatar) }; +} -#endif // QTMATERIALAVATAR_H +#endif // AVATAR_H diff --git a/components/avatar_p.h b/components/avatar_p.h new file mode 100644 index 000000000..127496b9b --- /dev/null +++ b/components/avatar_p.h @@ -0,0 +1,45 @@ +#ifndef AVATAR_P_H +#define AVATAR_P_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lib/theme.h" + +namespace md +{ + +class Avatar; + +class AvatarPrivate +{ + Q_DISABLE_COPY(AvatarPrivate) + Q_DECLARE_PUBLIC(Avatar) + +public: + AvatarPrivate(Avatar *q); + ~AvatarPrivate(); + + void init(); + + Avatar *const q_ptr; + int size; + Material::AvatarType type; + QChar letter; + QImage image; + QIcon icon; + QPixmap pixmap; + bool useThemeColors; + QColor textColor; + QColor backgroundColor; +}; + +} + +#endif // AVATAR_P_H diff --git a/components/qtmaterialbadge.cpp b/components/badge.cpp similarity index 53% rename from components/qtmaterialbadge.cpp rename to components/badge.cpp index b30aa95ba..0461c3eff 100644 --- a/components/qtmaterialbadge.cpp +++ b/components/badge.cpp @@ -1,17 +1,19 @@ -#include "qtmaterialbadge.h" -#include "qtmaterialbadge_p.h" -#include -#include "lib/qtmaterialstyle.h" +#include "badge.h" +#include "badge_p.h" +#include "lib/style.h" + +namespace md +{ /*! - * \class QtMaterialBadgePrivate + * \class BadgePrivate * \internal */ /*! * \internal */ -QtMaterialBadgePrivate::QtMaterialBadgePrivate(QtMaterialBadge *q) +BadgePrivate::BadgePrivate(Badge *q) : q_ptr(q) { } @@ -19,16 +21,16 @@ QtMaterialBadgePrivate::QtMaterialBadgePrivate(QtMaterialBadge *q) /*! * \internal */ -QtMaterialBadgePrivate::~QtMaterialBadgePrivate() +BadgePrivate::~BadgePrivate() { } /*! * \internal */ -void QtMaterialBadgePrivate::init() +void BadgePrivate::init() { - Q_Q(QtMaterialBadge); + Q_Q(Badge); x = 0; y = 0; @@ -49,38 +51,38 @@ void QtMaterialBadgePrivate::init() * \class QtMaterialBadge */ -QtMaterialBadge::QtMaterialBadge(QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialBadgePrivate(this)) +Badge::Badge(QWidget *parent) + : OverlayWidget(parent), + d_ptr(new BadgePrivate(this)) { d_func()->init(); } -QtMaterialBadge::QtMaterialBadge(const QIcon &icon, QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialBadgePrivate(this)) +Badge::Badge(const QIcon &icon, QWidget *parent) + : OverlayWidget(parent), + d_ptr(new BadgePrivate(this)) { d_func()->init(); setIcon(icon); } -QtMaterialBadge::QtMaterialBadge(const QString &text, QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialBadgePrivate(this)) +Badge::Badge(const QString &text, QWidget *parent) + : OverlayWidget(parent), + d_ptr(new BadgePrivate(this)) { d_func()->init(); setText(text); } -QtMaterialBadge::~QtMaterialBadge() +Badge::~Badge() { } -void QtMaterialBadge::setUseThemeColors(bool value) +void Badge::setUseThemeColors(bool value) { - Q_D(QtMaterialBadge); + Q_D(Badge); if (d->useThemeColors == value) { return; @@ -90,16 +92,16 @@ void QtMaterialBadge::setUseThemeColors(bool value) update(); } -bool QtMaterialBadge::useThemeColors() const +bool Badge::useThemeColors() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return d->useThemeColors; } -void QtMaterialBadge::setTextColor(const QColor &color) +void Badge::setTextColor(const QColor &color) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->textColor = color; @@ -107,20 +109,20 @@ void QtMaterialBadge::setTextColor(const QColor &color) update(); } -QColor QtMaterialBadge::textColor() const +QColor Badge::textColor() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("canvas"); + return Style::instance().themeColor("canvas"); } else { return d->textColor; } } -void QtMaterialBadge::setBackgroundColor(const QColor &color) +void Badge::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->backgroundColor = color; @@ -128,64 +130,64 @@ void QtMaterialBadge::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialBadge::backgroundColor() const +QColor Badge::backgroundColor() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent1"); + return Style::instance().themeColor("accent1"); } else { return d->backgroundColor; } } -void QtMaterialBadge::setRelativePosition(const QPointF &pos) +void Badge::setRelativePosition(const QPointF &pos) { setRelativePosition(pos.x(), pos.y()); } -void QtMaterialBadge::setRelativePosition(qreal x, qreal y) +void Badge::setRelativePosition(qreal x, qreal y) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->x = x; d->y = y; update(); } -QPointF QtMaterialBadge::relativePosition() const +QPointF Badge::relativePosition() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return QPointF(d->x, d->y); } -void QtMaterialBadge::setRelativeXPosition(qreal x) +void Badge::setRelativeXPosition(qreal x) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->x = x; update(); } -qreal QtMaterialBadge::relativeXPosition() const +qreal Badge::relativeXPosition() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return d->x; } -void QtMaterialBadge::setRelativeYPosition(qreal y) +void Badge::setRelativeYPosition(qreal y) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->y = y; update(); } -qreal QtMaterialBadge::relativeYPosition() const +qreal Badge::relativeYPosition() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return d->y; } @@ -193,30 +195,30 @@ qreal QtMaterialBadge::relativeYPosition() const /*! * \reimp */ -QSize QtMaterialBadge::sizeHint() const +QSize Badge::sizeHint() const { const int s = getDiameter(); return QSize(s+4, s+4); } -void QtMaterialBadge::setIcon(const QIcon &icon) +void Badge::setIcon(const QIcon &icon) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->icon = icon; update(); } -QIcon QtMaterialBadge::icon() const +QIcon Badge::icon() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return d->icon; } -void QtMaterialBadge::setText(const QString &text) +void Badge::setText(const QString &text) { - Q_D(QtMaterialBadge); + Q_D(Badge); d->text = text; @@ -229,9 +231,9 @@ void QtMaterialBadge::setText(const QString &text) update(); } -QString QtMaterialBadge::text() const +QString Badge::text() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); return d->text; } @@ -239,11 +241,11 @@ QString QtMaterialBadge::text() const /*! * \reimp */ -void QtMaterialBadge::paintEvent(QPaintEvent *event) +void Badge::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialBadge); + Q_D(Badge); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -253,7 +255,7 @@ void QtMaterialBadge::paintEvent(QPaintEvent *event) QBrush brush; brush.setStyle(Qt::SolidPattern); brush.setColor(isEnabled() ? backgroundColor() - : QtMaterialStyle::instance().themeColor("disabled")); + : Style::instance().themeColor("disabled")); painter.setBrush(brush); painter.setPen(Qt::NoPen); @@ -282,9 +284,9 @@ void QtMaterialBadge::paintEvent(QPaintEvent *event) } } -int QtMaterialBadge::getDiameter() const +int Badge::getDiameter() const { - Q_D(const QtMaterialBadge); + Q_D(const Badge); if (d->icon.isNull()) { return qMax(d->size.width(), d->size.height()) + d->padding; @@ -292,3 +294,5 @@ int QtMaterialBadge::getDiameter() const return 24; } } + +} diff --git a/components/qtmaterialbadge.h b/components/badge.h similarity index 66% rename from components/qtmaterialbadge.h rename to components/badge.h index deac3ab4b..80f504f45 100644 --- a/components/qtmaterialbadge.h +++ b/components/badge.h @@ -1,11 +1,13 @@ -#ifndef QTMATERIALBADGE_H -#define QTMATERIALBADGE_H +#ifndef BADGE_H +#define BADGE_H -#include "lib/qtmaterialoverlaywidget.h" +#include "lib/overlaywidget.h" +namespace md +{ -class QtMaterialBadgePrivate; +class BadgePrivate; -class QtMaterialBadge : public QtMaterialOverlayWidget +class Badge : public OverlayWidget { Q_OBJECT @@ -14,10 +16,10 @@ class QtMaterialBadge : public QtMaterialOverlayWidget Q_PROPERTY(QPointF relativePosition WRITE setRelativePosition READ relativePosition) public: - explicit QtMaterialBadge(QWidget *parent = 0); - explicit QtMaterialBadge(const QIcon &icon, QWidget *parent = 0); - explicit QtMaterialBadge(const QString &text, QWidget *parent = 0); - ~QtMaterialBadge(); + explicit Badge(QWidget *parent = 0); + explicit Badge(const QIcon &icon, QWidget *parent = 0); + explicit Badge(const QString &text, QWidget *parent = 0); + ~Badge(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -51,11 +53,13 @@ class QtMaterialBadge : public QtMaterialOverlayWidget int getDiameter() const; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialBadge) - Q_DECLARE_PRIVATE(QtMaterialBadge) + Q_DISABLE_COPY(Badge) + Q_DECLARE_PRIVATE(Badge) }; -#endif // QTMATERIALBADGE_H +} + +#endif // BADGE_H diff --git a/components/qtmaterialbadge_p.h b/components/badge_p.h similarity index 56% rename from components/qtmaterialbadge_p.h rename to components/badge_p.h index 19757e7bb..b4a98c9cf 100644 --- a/components/qtmaterialbadge_p.h +++ b/components/badge_p.h @@ -1,25 +1,28 @@ -#ifndef QTMATERIALBADGE_P_H -#define QTMATERIALBADGE_P_H +#ifndef BADGE_P_H +#define BADGE_P_H #include #include #include #include +#include -class QtMaterialBadge; +namespace md +{ +class Badge; -class QtMaterialBadgePrivate +class BadgePrivate { - Q_DISABLE_COPY(QtMaterialBadgePrivate) - Q_DECLARE_PUBLIC(QtMaterialBadge) + Q_DISABLE_COPY(BadgePrivate) + Q_DECLARE_PUBLIC(Badge) public: - QtMaterialBadgePrivate(QtMaterialBadge *q); - ~QtMaterialBadgePrivate(); + BadgePrivate(Badge *q); + ~BadgePrivate(); void init(); - QtMaterialBadge *const q_ptr; + Badge *const q_ptr; QString text; QColor textColor; QColor backgroundColor; @@ -30,5 +33,6 @@ class QtMaterialBadgePrivate int padding; bool useThemeColors; }; +} -#endif // QTMATERIALBADGE_P_H +#endif // BADGE_P_H diff --git a/components/qtmaterialcheckbox.cpp b/components/checkbox.cpp similarity index 72% rename from components/qtmaterialcheckbox.cpp rename to components/checkbox.cpp index b693a90d9..4e491b444 100644 --- a/components/qtmaterialcheckbox.cpp +++ b/components/checkbox.cpp @@ -1,9 +1,7 @@ -#include "qtmaterialcheckbox.h" -#include "qtmaterialcheckbox_p.h" -#include -#include -#include -#include "lib/qtmaterialcheckable_internal.h" +#include "checkbox_p.h" + +namespace md +{ /*! * \class QtMaterialCheckBoxPrivate @@ -13,24 +11,24 @@ /*! * \internal */ -QtMaterialCheckBoxPrivate::QtMaterialCheckBoxPrivate(QtMaterialCheckBox *q) - : QtMaterialCheckablePrivate(q) +CheckBoxPrivate::CheckBoxPrivate(CheckBox *q) + : CheckablePrivate(q) { } /*! * \internal */ -QtMaterialCheckBoxPrivate::~QtMaterialCheckBoxPrivate() +CheckBoxPrivate::~CheckBoxPrivate() { } /*! * \internal */ -void QtMaterialCheckBoxPrivate::init() +void CheckBoxPrivate::init() { - Q_Q(QtMaterialCheckBox); + Q_Q(CheckBox); checkedState->assignProperty(checkedIcon, "iconSize", 24); uncheckedState->assignProperty(checkedIcon, "iconSize", 0); @@ -74,12 +72,14 @@ void QtMaterialCheckBoxPrivate::init() * \class QtMaterialCheckBox */ -QtMaterialCheckBox::QtMaterialCheckBox(QWidget *parent) - : QtMaterialCheckable(*new QtMaterialCheckBoxPrivate(this), parent) +CheckBox::CheckBox(QWidget *parent) + : Checkable(*new CheckBoxPrivate(this), parent) { d_func()->init(); } -QtMaterialCheckBox::~QtMaterialCheckBox() +CheckBox::~CheckBox() { } + +} diff --git a/components/checkbox.h b/components/checkbox.h new file mode 100644 index 000000000..743cb4050 --- /dev/null +++ b/components/checkbox.h @@ -0,0 +1,25 @@ +#ifndef CHECKBOX_H +#define CHECKBOX_H + +#include "lib/checkable.h" + +namespace md +{ + +class CheckBoxPrivate; + +class CheckBox : public Checkable +{ + Q_OBJECT + +public: + explicit CheckBox(QWidget *parent = 0); + ~CheckBox(); + +private: + Q_DISABLE_COPY(CheckBox) + Q_DECLARE_PRIVATE(CheckBox) +}; + +} +#endif // CHECKBOX_H diff --git a/components/checkbox_p.h b/components/checkbox_p.h new file mode 100644 index 000000000..da3471ca7 --- /dev/null +++ b/components/checkbox_p.h @@ -0,0 +1,29 @@ +#ifndef CHECKBOX_P_H +#define CHECKBOX_P_H + +#include +#include +#include + +#include "checkbox.h" +#include "lib/checkable_internal.h" +#include "lib/checkable_p.h" + +namespace md +{ + +class CheckBox; + +class CheckBoxPrivate : public CheckablePrivate +{ + Q_DISABLE_COPY(CheckBoxPrivate) + Q_DECLARE_PUBLIC(CheckBox) + +public: + CheckBoxPrivate(CheckBox *q); + ~CheckBoxPrivate(); + + void init(); +}; +} +#endif // CHECKBOX_P_H diff --git a/components/qtmaterialcircularprogress.cpp b/components/circularprogress.cpp similarity index 64% rename from components/qtmaterialcircularprogress.cpp rename to components/circularprogress.cpp index f38ef0167..32849799f 100644 --- a/components/qtmaterialcircularprogress.cpp +++ b/components/circularprogress.cpp @@ -1,31 +1,30 @@ -#include "qtmaterialcircularprogress.h" -#include "qtmaterialcircularprogress_p.h" -#include -#include -#include -#include -#include "qtmaterialcircularprogress_internal.h" -#include "lib/qtmaterialstyle.h" +#include "circularprogress.h" +#include "circularprogress_p.h" +#include "circularprogress_internal.h" +#include "lib/style.h" + +namespace md +{ /*! - * \class QtMaterialCircularProgressPrivate + * \class CircularProgressPrivate * \internal */ -QtMaterialCircularProgressPrivate::QtMaterialCircularProgressPrivate(QtMaterialCircularProgress *q) +CircularProgressPrivate::CircularProgressPrivate(CircularProgress *q) : q_ptr(q) { } -QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate() +CircularProgressPrivate::~CircularProgressPrivate() { } -void QtMaterialCircularProgressPrivate::init() +void CircularProgressPrivate::init() { - Q_Q(QtMaterialCircularProgress); + Q_Q(CircularProgress); - delegate = new QtMaterialCircularProgressDelegate(q); + delegate = new CircularProgressDelegate(q); progressType = Material::IndeterminateProgress; penWidth = 6.25; size = 64; @@ -81,35 +80,35 @@ void QtMaterialCircularProgressPrivate::init() * \class QtMaterialCircularProgress */ -QtMaterialCircularProgress::QtMaterialCircularProgress(QWidget *parent) +CircularProgress::CircularProgress(QWidget *parent) : QProgressBar(parent), - d_ptr(new QtMaterialCircularProgressPrivate(this)) + d_ptr(new CircularProgressPrivate(this)) { d_func()->init(); } -QtMaterialCircularProgress::~QtMaterialCircularProgress() +CircularProgress::~CircularProgress() { } -void QtMaterialCircularProgress::setProgressType(Material::ProgressType type) +void CircularProgress::setProgressType(Material::ProgressType type) { - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); d->progressType = type; update(); } -Material::ProgressType QtMaterialCircularProgress::progressType() const +Material::ProgressType CircularProgress::progressType() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); return d->progressType; } -void QtMaterialCircularProgress::setUseThemeColors(bool value) +void CircularProgress::setUseThemeColors(bool value) { - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); if (d->useThemeColors == value) { return; @@ -119,48 +118,48 @@ void QtMaterialCircularProgress::setUseThemeColors(bool value) update(); } -bool QtMaterialCircularProgress::useThemeColors() const +bool CircularProgress::useThemeColors() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); return d->useThemeColors; } -void QtMaterialCircularProgress::setLineWidth(qreal width) +void CircularProgress::setLineWidth(qreal width) { - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); d->penWidth = width; update(); updateGeometry(); } -qreal QtMaterialCircularProgress::lineWidth() const +qreal CircularProgress::lineWidth() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); return d->penWidth; } -void QtMaterialCircularProgress::setSize(int size) +void CircularProgress::setSize(int size) { - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); d->size = size; update(); updateGeometry(); } -int QtMaterialCircularProgress::size() const +int CircularProgress::size() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); return d->size; } -void QtMaterialCircularProgress::setColor(const QColor &color) +void CircularProgress::setColor(const QColor &color) { - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); d->color = color; @@ -168,12 +167,12 @@ void QtMaterialCircularProgress::setColor(const QColor &color) update(); } -QColor QtMaterialCircularProgress::color() const +QColor CircularProgress::color() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); if (d->useThemeColors || !d->color.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->color; } @@ -182,9 +181,9 @@ QColor QtMaterialCircularProgress::color() const /*! * \reimp */ -QSize QtMaterialCircularProgress::sizeHint() const +QSize CircularProgress::sizeHint() const { - Q_D(const QtMaterialCircularProgress); + Q_D(const CircularProgress); const qreal s = d->size+d->penWidth+8; return QSize(s, s); @@ -193,11 +192,11 @@ QSize QtMaterialCircularProgress::sizeHint() const /*! * \reimp */ -void QtMaterialCircularProgress::paintEvent(QPaintEvent *event) +void CircularProgress::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialCircularProgress); + Q_D(CircularProgress); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -207,7 +206,7 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event) QPen pen; pen.setCapStyle(Qt::RoundCap); pen.setWidthF(d->penWidth); - pen.setColor(QtMaterialStyle::instance().themeColor("border")); + pen.setColor(Style::instance().themeColor("border")); painter.setPen(pen); painter.drawLine(rect().center()-QPointF(20, 20), rect().center()+QPointF(20, 20)); painter.drawLine(rect().center()+QPointF(20, -20), rect().center()-QPointF(20, -20)); @@ -253,3 +252,5 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event) painter.drawPath(path); } } + +} diff --git a/components/qtmaterialcircularprogress.h b/components/circularprogress.h similarity index 59% rename from components/qtmaterialcircularprogress.h rename to components/circularprogress.h index dfc306e16..365e7d313 100644 --- a/components/qtmaterialcircularprogress.h +++ b/components/circularprogress.h @@ -1,12 +1,15 @@ -#ifndef QTMATERIALCIRCULARPROGRESS_H -#define QTMATERIALCIRCULARPROGRESS_H +#ifndef CIRCULARPROGRESS_H +#define CIRCULARPROGRESS_H #include -#include "lib/qtmaterialtheme.h" +#include "lib/theme.h" -class QtMaterialCircularProgressPrivate; +namespace md +{ + +class CircularProgressPrivate; -class QtMaterialCircularProgress : public QProgressBar +class CircularProgress : public QProgressBar { Q_OBJECT @@ -15,8 +18,8 @@ class QtMaterialCircularProgress : public QProgressBar Q_PROPERTY(QColor color WRITE setColor READ color) public: - explicit QtMaterialCircularProgress(QWidget *parent = 0); - ~QtMaterialCircularProgress(); + explicit CircularProgress(QWidget *parent = 0); + ~CircularProgress(); void setProgressType(Material::ProgressType type); Material::ProgressType progressType() const; @@ -38,11 +41,13 @@ class QtMaterialCircularProgress : public QProgressBar protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialCircularProgress) - Q_DECLARE_PRIVATE(QtMaterialCircularProgress) + Q_DISABLE_COPY(CircularProgress) + Q_DECLARE_PRIVATE(CircularProgress) }; -#endif // QTMATERIALCIRCULARPROGRESS_H +} + +#endif // CIRCULARPROGRESS_H diff --git a/components/circularprogress_internal.cpp b/components/circularprogress_internal.cpp new file mode 100644 index 000000000..5480a1ff7 --- /dev/null +++ b/components/circularprogress_internal.cpp @@ -0,0 +1,25 @@ +#include "circularprogress_internal.h" + +namespace md +{ + +/*! + * \class QtMaterialCircularProgressDelegate + * \internal + */ + +CircularProgressDelegate::CircularProgressDelegate(CircularProgress *parent) + : QObject(parent), + m_progress(parent), + m_dashOffset(0), + m_dashLength(89), + m_angle(0) +{ + Q_ASSERT(parent); +} + +CircularProgressDelegate::~CircularProgressDelegate() +{ +} + +} diff --git a/components/qtmaterialcircularprogress_internal.h b/components/circularprogress_internal.h similarity index 50% rename from components/qtmaterialcircularprogress_internal.h rename to components/circularprogress_internal.h index a05bd6371..5273a8e37 100644 --- a/components/qtmaterialcircularprogress_internal.h +++ b/components/circularprogress_internal.h @@ -1,10 +1,12 @@ -#ifndef QTMATERIALCIRCULARPROGRESS_INTERNAL_H -#define QTMATERIALCIRCULARPROGRESS_INTERNAL_H +#ifndef CIRCULARPROGRESS_INTERNAL_H +#define CIRCULARPROGRESS_INTERNAL_H #include -#include "qtmaterialcircularprogress.h" +#include "circularprogress.h" +namespace md +{ -class QtMaterialCircularProgressDelegate : public QObject +class CircularProgressDelegate : public QObject { Q_OBJECT @@ -13,8 +15,8 @@ class QtMaterialCircularProgressDelegate : public QObject Q_PROPERTY(int angle WRITE setAngle READ angle) public: - QtMaterialCircularProgressDelegate(QtMaterialCircularProgress *parent); - ~QtMaterialCircularProgressDelegate(); + CircularProgressDelegate(CircularProgress *parent); + ~CircularProgressDelegate(); inline void setDashOffset(qreal offset); inline qreal dashOffset() const; @@ -26,45 +28,47 @@ class QtMaterialCircularProgressDelegate : public QObject inline int angle() const; private: - Q_DISABLE_COPY(QtMaterialCircularProgressDelegate) + Q_DISABLE_COPY(CircularProgressDelegate) - QtMaterialCircularProgress *const m_progress; + CircularProgress *const m_progress; qreal m_dashOffset; qreal m_dashLength; int m_angle; }; -inline void QtMaterialCircularProgressDelegate::setDashOffset(qreal offset) +inline void CircularProgressDelegate::setDashOffset(qreal offset) { m_dashOffset = offset; m_progress->update(); } -inline qreal QtMaterialCircularProgressDelegate::dashOffset() const +inline qreal CircularProgressDelegate::dashOffset() const { return m_dashOffset; } -inline void QtMaterialCircularProgressDelegate::setDashLength(qreal length) +inline void CircularProgressDelegate::setDashLength(qreal length) { m_dashLength = length; m_progress->update(); } -inline qreal QtMaterialCircularProgressDelegate::dashLength() const +inline qreal CircularProgressDelegate::dashLength() const { return m_dashLength; } -inline void QtMaterialCircularProgressDelegate::setAngle(int angle) +inline void CircularProgressDelegate::setAngle(int angle) { m_angle = angle; m_progress->update(); } -inline int QtMaterialCircularProgressDelegate::angle() const +inline int CircularProgressDelegate::angle() const { return m_angle; } -#endif // QTMATERIALCIRCULARPROGRESS_INTERNAL_H +} + +#endif // CIRCULARPROGRESS_INTERNAL_H diff --git a/components/circularprogress_p.h b/components/circularprogress_p.h new file mode 100644 index 000000000..5f5f05123 --- /dev/null +++ b/components/circularprogress_p.h @@ -0,0 +1,40 @@ +#ifndef CIRCULARPROGRESS_P_H +#define CIRCULARPROGRESS_P_H + +#include +#include +#include +#include +#include + +#include "lib/theme.h" + +namespace md +{ + +class CircularProgress; +class CircularProgressDelegate; + +class CircularProgressPrivate +{ + Q_DISABLE_COPY(CircularProgressPrivate) + Q_DECLARE_PUBLIC(CircularProgress) + +public: + CircularProgressPrivate(CircularProgress *q); + ~CircularProgressPrivate(); + + void init(); + + CircularProgress *const q_ptr; + CircularProgressDelegate *delegate; + Material::ProgressType progressType; + QColor color; + qreal penWidth; + int size; + bool useThemeColors; +}; + +} + +#endif // CIRCULARPROGRESS_P_H diff --git a/components/components.pro b/components/components.pro deleted file mode 100644 index d6080d5db..000000000 --- a/components/components.pro +++ /dev/null @@ -1,130 +0,0 @@ -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 diff --git a/components/qtmaterialdialog.cpp b/components/dialog.cpp similarity index 63% rename from components/qtmaterialdialog.cpp rename to components/dialog.cpp index 82afc898f..78e7f6176 100644 --- a/components/qtmaterialdialog.cpp +++ b/components/dialog.cpp @@ -1,37 +1,30 @@ -#include "qtmaterialdialog.h" -#include "qtmaterialdialog_p.h" -#include -#include -#include -#include -#include -#include -#include -#include "qtmaterialdialog_internal.h" -#include "lib/qtmaterialstatetransition.h" +#include "dialog.h" + +namespace md +{ /*! - * \class QtMaterialDialogPrivate + * \class DialogPrivate * \internal */ -QtMaterialDialogPrivate::QtMaterialDialogPrivate(QtMaterialDialog *q) +DialogPrivate::DialogPrivate(Dialog *q) : q_ptr(q) { } -QtMaterialDialogPrivate::~QtMaterialDialogPrivate() +DialogPrivate::~DialogPrivate() { } -void QtMaterialDialogPrivate::init() +void DialogPrivate::init() { - Q_Q(QtMaterialDialog); + Q_Q(Dialog); - dialogWindow = new QtMaterialDialogWindow(q); + dialogWindow = new DialogWindow(q); proxyStack = new QStackedLayout; stateMachine = new QStateMachine(q); - proxy = new QtMaterialDialogProxy(dialogWindow, proxyStack, q); + proxy = new DialogProxy(dialogWindow, proxyStack, q); QVBoxLayout *layout = new QVBoxLayout; q->setLayout(layout); @@ -62,13 +55,13 @@ void QtMaterialDialogPrivate::init() stateMachine->addState(visibleState); stateMachine->setInitialState(hiddenState); - QtMaterialStateTransition *transition; + StateTransition *transition; - transition = new QtMaterialStateTransition(DialogShowTransition); + transition = new StateTransition(DialogShowTransition); transition->setTargetState(visibleState); hiddenState->addTransition(transition); - transition = new QtMaterialStateTransition(DialogHideTransition); + transition = new StateTransition(DialogHideTransition); transition->setTargetState(hiddenState); visibleState->addTransition(transition); @@ -104,56 +97,56 @@ void QtMaterialDialogPrivate::init() } /*! - * \class QtMaterialDialog + * \class Dialog */ -QtMaterialDialog::QtMaterialDialog(QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialDialogPrivate(this)) +Dialog::Dialog(QWidget *parent) + : OverlayWidget(parent), + d_ptr(new DialogPrivate(this)) { d_func()->init(); } -QtMaterialDialog::~QtMaterialDialog() +Dialog::~Dialog() { } -QLayout *QtMaterialDialog::windowLayout() const +QLayout *Dialog::windowLayout() const { - Q_D(const QtMaterialDialog); + Q_D(const Dialog); return d->dialogWindow->layout(); } -void QtMaterialDialog::setWindowLayout(QLayout *layout) +void Dialog::setWindowLayout(QLayout *layout) { - Q_D(QtMaterialDialog); + Q_D(Dialog); d->dialogWindow->setLayout(layout); } -void QtMaterialDialog::showDialog() +void Dialog::showDialog() { - Q_D(QtMaterialDialog); + Q_D(Dialog); - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(DialogShowTransition)); + d->stateMachine->postEvent(new StateTransitionEvent(DialogShowTransition)); raise(); } -void QtMaterialDialog::hideDialog() +void Dialog::hideDialog() { - Q_D(QtMaterialDialog); + Q_D(Dialog); - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(DialogHideTransition)); + d->stateMachine->postEvent(new StateTransitionEvent(DialogHideTransition)); setAttribute(Qt::WA_TransparentForMouseEvents); d->proxyStack->setCurrentIndex(1); } -void QtMaterialDialog::paintEvent(QPaintEvent *event) +void Dialog::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialDialog); + Q_D(Dialog); QPainter painter(this); @@ -165,3 +158,4 @@ void QtMaterialDialog::paintEvent(QPaintEvent *event) painter.setOpacity(d->proxy->opacity()/2.4); painter.drawRect(rect()); } +} diff --git a/components/dialog.h b/components/dialog.h new file mode 100644 index 000000000..5429c85f3 --- /dev/null +++ b/components/dialog.h @@ -0,0 +1,42 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include +#include + +#include "dialog_p.h" +#include "dialog_internal.h" +#include "lib/statetransition.h" +#include "lib/overlaywidget.h" + +namespace md +{ + +class DialogPrivate; + +class Dialog : public OverlayWidget +{ + Q_OBJECT + +public: + explicit Dialog(QWidget *parent = 0); + ~Dialog(); + + QLayout *windowLayout() const; + void setWindowLayout(QLayout *layout); + +public slots: + void showDialog(); + void hideDialog(); + +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + + const QScopedPointer d_ptr; + +private: + Q_DISABLE_COPY(Dialog) + Q_DECLARE_PRIVATE(Dialog) +}; +} +#endif // DIALOG_H diff --git a/components/qtmaterialdialog_internal.cpp b/components/dialog_internal.cpp similarity index 63% rename from components/qtmaterialdialog_internal.cpp rename to components/dialog_internal.cpp index 6cac9b8c9..167c62315 100644 --- a/components/qtmaterialdialog_internal.cpp +++ b/components/dialog_internal.cpp @@ -1,19 +1,17 @@ -#include "qtmaterialdialog_internal.h" -#include -#include -#include -#include -#include "qtmaterialdialog.h" +#include "dialog_internal.h" + +namespace md +{ /*! * \class QtMaterialDialogProxy * \internal */ -QtMaterialDialogProxy::QtMaterialDialogProxy( - QtMaterialDialogWindow *source, +DialogProxy::DialogProxy( + DialogWindow *source, QStackedLayout *layout, - QtMaterialDialog *dialog, + Dialog *dialog, QWidget *parent) : QWidget(parent), m_source(source), @@ -24,11 +22,11 @@ QtMaterialDialogProxy::QtMaterialDialogProxy( { } -QtMaterialDialogProxy::~QtMaterialDialogProxy() +DialogProxy::~DialogProxy() { } -void QtMaterialDialogProxy::setOpacity(qreal opacity) +void DialogProxy::setOpacity(qreal opacity) { m_opacity = opacity; m_mode = SemiTransparent; @@ -37,7 +35,7 @@ void QtMaterialDialogProxy::setOpacity(qreal opacity) } -void QtMaterialDialogProxy::makeOpaque() +void DialogProxy::makeOpaque() { m_dialog->setAttribute(Qt::WA_TransparentForMouseEvents, false); m_layout->setCurrentIndex(0); @@ -46,19 +44,19 @@ void QtMaterialDialogProxy::makeOpaque() update(); } -void QtMaterialDialogProxy::makeTransparent() +void DialogProxy::makeTransparent() { m_opacity = 0.0; m_mode = Transparent; update(); } -QSize QtMaterialDialogProxy::sizeHint() const +QSize DialogProxy::sizeHint() const { return m_source->sizeHint(); } -bool QtMaterialDialogProxy::event(QEvent *event) +bool DialogProxy::event(QEvent *event) { const QEvent::Type type = event->type(); @@ -68,7 +66,7 @@ bool QtMaterialDialogProxy::event(QEvent *event) return QWidget::event(event); } -void QtMaterialDialogProxy::paintEvent(QPaintEvent *event) +void DialogProxy::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -84,35 +82,35 @@ void QtMaterialDialogProxy::paintEvent(QPaintEvent *event) } /*! - * \class QtMaterialDialogWindow + * \class DialogWindow * \internal */ -QtMaterialDialogWindow::QtMaterialDialogWindow( - QtMaterialDialog *dialog, +DialogWindow::DialogWindow( + Dialog *dialog, QWidget *parent) : QWidget(parent), m_dialog(dialog) { } -QtMaterialDialogWindow::~QtMaterialDialogWindow() +DialogWindow::~DialogWindow() { } -void QtMaterialDialogWindow::setOffset(int offset) +void DialogWindow::setOffset(int offset) { QMargins margins = m_dialog->layout()->contentsMargins(); margins.setBottom(offset); m_dialog->layout()->setContentsMargins(margins); } -int QtMaterialDialogWindow::offset() const +int DialogWindow::offset() const { return m_dialog->layout()->contentsMargins().bottom(); } -void QtMaterialDialogWindow::paintEvent(QPaintEvent *event) +void DialogWindow::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -125,3 +123,5 @@ void QtMaterialDialogWindow::paintEvent(QPaintEvent *event) painter.setBrush(brush); painter.drawRect(rect()); } + +} diff --git a/components/qtmaterialdialog_internal.h b/components/dialog_internal.h similarity index 55% rename from components/qtmaterialdialog_internal.h rename to components/dialog_internal.h index 52f5a0557..11468882a 100644 --- a/components/qtmaterialdialog_internal.h +++ b/components/dialog_internal.h @@ -1,13 +1,21 @@ -#ifndef QTMATERIALDIALOG_INTERNAL_H -#define QTMATERIALDIALOG_INTERNAL_H +#ifndef DIALOG_INTERNAL_H +#define DIALOG_INTERNAL_H #include +#include +#include +#include +#include -class QStackedLayout; -class QtMaterialDialog; -class QtMaterialDialogWindow; +#include "dialog.h" -class QtMaterialDialogProxy : public QWidget +namespace md +{ + +class Dialog; +class DialogWindow; + +class DialogProxy : public QWidget { Q_OBJECT @@ -20,11 +28,11 @@ class QtMaterialDialogProxy : public QWidget }; public: - QtMaterialDialogProxy(QtMaterialDialogWindow *source, + DialogProxy(DialogWindow *source, QStackedLayout *layout, - QtMaterialDialog *dialog, + Dialog *dialog, QWidget *parent = 0); - ~QtMaterialDialogProxy(); + ~DialogProxy(); void setOpacity(qreal opacity); inline qreal opacity() const; @@ -40,29 +48,29 @@ protected slots: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialDialogProxy) + Q_DISABLE_COPY(DialogProxy) - QtMaterialDialogWindow *const m_source; + DialogWindow *const m_source; QStackedLayout *const m_layout; - QtMaterialDialog *const m_dialog; + Dialog *const m_dialog; qreal m_opacity; TransparencyMode m_mode; }; -inline qreal QtMaterialDialogProxy::opacity() const +inline qreal DialogProxy::opacity() const { return m_opacity; } -class QtMaterialDialogWindow : public QWidget +class DialogWindow : public QWidget { Q_OBJECT Q_PROPERTY(int offset WRITE setOffset READ offset) public: - explicit QtMaterialDialogWindow(QtMaterialDialog *dialog, QWidget *parent = 0); - ~QtMaterialDialogWindow(); + explicit DialogWindow(Dialog *dialog, QWidget *parent = 0); + ~DialogWindow(); void setOffset(int offset); int offset() const; @@ -71,9 +79,11 @@ class QtMaterialDialogWindow : public QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialDialogWindow) + Q_DISABLE_COPY(DialogWindow) - QtMaterialDialog *const m_dialog; + Dialog *const m_dialog; }; +} + +#endif // DIALOG_INTERNAL_H -#endif // QTMATERIALDIALOG_INTERNAL_H diff --git a/components/dialog_p.h b/components/dialog_p.h new file mode 100644 index 000000000..11db165d0 --- /dev/null +++ b/components/dialog_p.h @@ -0,0 +1,39 @@ +#ifndef DIALOG_P_H +#define DIALOG_P_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace md +{ + +class Dialog; +class DialogWindow; +class DialogProxy; + +class DialogPrivate +{ + Q_DISABLE_COPY(DialogPrivate) + Q_DECLARE_PUBLIC(Dialog) + +public: + DialogPrivate(Dialog *q); + ~DialogPrivate(); + + void init(); + + Dialog *const q_ptr; + DialogWindow *dialogWindow; + QStackedLayout *proxyStack; + QStateMachine *stateMachine; + DialogProxy *proxy; +}; +} +#endif // DIALOG_P_H diff --git a/components/qtmaterialdrawer.cpp b/components/drawer.cpp similarity index 55% rename from components/qtmaterialdrawer.cpp rename to components/drawer.cpp index 1bddd4729..49e2261d7 100644 --- a/components/qtmaterialdrawer.cpp +++ b/components/drawer.cpp @@ -1,14 +1,7 @@ -#include "qtmaterialdrawer.h" -#include "qtmaterialdrawer_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "qtmaterialdrawer_internal.h" +#include "drawer.h" + +namespace md +{ /*! * \class QtMaterialDrawerPrivate @@ -18,7 +11,7 @@ /*! * \internal */ -QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q) +DrawerPrivate::DrawerPrivate(Drawer *q) : q_ptr(q) { } @@ -26,19 +19,19 @@ QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q) /*! * \internal */ -QtMaterialDrawerPrivate::~QtMaterialDrawerPrivate() +DrawerPrivate::~DrawerPrivate() { } /*! * \internal */ -void QtMaterialDrawerPrivate::init() +void DrawerPrivate::init() { - Q_Q(QtMaterialDrawer); + Q_Q(Drawer); - widget = new QtMaterialDrawerWidget; - stateMachine = new QtMaterialDrawerStateMachine(widget, q); + widget = new DrawerWidget; + stateMachine = new DrawerStateMachine(widget, q); window = new QWidget; width = 250; clickToClose = false; @@ -62,93 +55,93 @@ void QtMaterialDrawerPrivate::init() * \class QtMaterialDrawer */ -QtMaterialDrawer::QtMaterialDrawer(QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialDrawerPrivate(this)) +Drawer::Drawer(QWidget *parent) + : OverlayWidget(parent), + d_ptr(new DrawerPrivate(this)) { d_func()->init(); } -QtMaterialDrawer::~QtMaterialDrawer() +Drawer::~Drawer() { } -void QtMaterialDrawer::setDrawerWidth(int width) +void Drawer::setDrawerWidth(int width) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); d->width = width; d->stateMachine->updatePropertyAssignments(); d->widget->setFixedWidth(width+16); } -int QtMaterialDrawer::drawerWidth() const +int Drawer::drawerWidth() const { - Q_D(const QtMaterialDrawer); + Q_D(const Drawer); return d->width; } -void QtMaterialDrawer::setDrawerLayout(QLayout *layout) +void Drawer::setDrawerLayout(QLayout *layout) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); d->window->setLayout(layout); } -QLayout *QtMaterialDrawer::drawerLayout() const +QLayout *Drawer::drawerLayout() const { - Q_D(const QtMaterialDrawer); + Q_D(const Drawer); return d->window->layout(); } -void QtMaterialDrawer::setClickOutsideToClose(bool state) +void Drawer::setClickOutsideToClose(bool state) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); d->clickToClose = state; } -bool QtMaterialDrawer::clickOutsideToClose() const +bool Drawer::clickOutsideToClose() const { - Q_D(const QtMaterialDrawer); + Q_D(const Drawer); return d->clickToClose; } -void QtMaterialDrawer::setAutoRaise(bool state) +void Drawer::setAutoRaise(bool state) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); d->autoRaise = state; } -bool QtMaterialDrawer::autoRaise() const +bool Drawer::autoRaise() const { - Q_D(const QtMaterialDrawer); + Q_D(const Drawer); return d->autoRaise; } -void QtMaterialDrawer::setOverlayMode(bool value) +void Drawer::setOverlayMode(bool value) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); d->overlay = value; update(); } -bool QtMaterialDrawer::overlayMode() const +bool Drawer::overlayMode() const { - Q_D(const QtMaterialDrawer); + Q_D(const Drawer); return d->overlay; } -void QtMaterialDrawer::openDrawer() +void Drawer::openDrawer() { - Q_D(QtMaterialDrawer); + Q_D(Drawer); emit d->stateMachine->signalOpen(); @@ -159,9 +152,9 @@ void QtMaterialDrawer::openDrawer() setAttribute(Qt::WA_NoSystemBackground, false); } -void QtMaterialDrawer::closeDrawer() +void Drawer::closeDrawer() { - Q_D(QtMaterialDrawer); + Q_D(Drawer); emit d->stateMachine->signalClose(); @@ -171,9 +164,9 @@ void QtMaterialDrawer::closeDrawer() } } -bool QtMaterialDrawer::event(QEvent *event) +bool Drawer::event(QEvent *event) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); switch (event->type()) { @@ -186,12 +179,12 @@ bool QtMaterialDrawer::event(QEvent *event) default: break; } - return QtMaterialOverlayWidget::event(event); + return OverlayWidget::event(event); } -bool QtMaterialDrawer::eventFilter(QObject *obj, QEvent *event) +bool Drawer::eventFilter(QObject *obj, QEvent *event) { - Q_D(QtMaterialDrawer); + Q_D(Drawer); switch (event->type()) { @@ -216,14 +209,14 @@ bool QtMaterialDrawer::eventFilter(QObject *obj, QEvent *event) default: break; } - return QtMaterialOverlayWidget::eventFilter(obj, event); + return OverlayWidget::eventFilter(obj, event); } -void QtMaterialDrawer::paintEvent(QPaintEvent *event) +void Drawer::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialDrawer); + Q_D(Drawer); if (!d->overlay || d->stateMachine->isInClosedState()) { return; @@ -232,3 +225,5 @@ void QtMaterialDrawer::paintEvent(QPaintEvent *event) painter.setOpacity(d->stateMachine->opacity()); painter.fillRect(rect(), Qt::SolidPattern); } + +} diff --git a/components/qtmaterialdrawer.h b/components/drawer.h similarity index 51% rename from components/qtmaterialdrawer.h rename to components/drawer.h index 7bf3219a0..a88147682 100644 --- a/components/qtmaterialdrawer.h +++ b/components/drawer.h @@ -1,18 +1,32 @@ -#ifndef QTMATERIALDRAWER_H -#define QTMATERIALDRAWER_H - -#include "lib/qtmaterialoverlaywidget.h" +#ifndef DRAWER_H +#define DRAWER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "drawer_p.h" +#include "drawer_internal.h" +#include "lib/overlaywidget.h" + +namespace md +{ -class QtMaterialDrawerPrivate; -class QtMaterialDrawerStateMachine; +class DrawerPrivate; +class DrawerStateMachine; -class QtMaterialDrawer : public QtMaterialOverlayWidget +class Drawer : public OverlayWidget { Q_OBJECT public: - explicit QtMaterialDrawer(QWidget *parent = 0); - ~QtMaterialDrawer(); + explicit Drawer(QWidget *parent = 0); + ~Drawer(); void setDrawerWidth(int width); int drawerWidth() const; @@ -38,11 +52,11 @@ public slots: bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialDrawer) - Q_DECLARE_PRIVATE(QtMaterialDrawer) + Q_DISABLE_COPY(Drawer) + Q_DECLARE_PRIVATE(Drawer) }; - -#endif // QTMATERIALDRAWER_H +} +#endif // DRAWER_H diff --git a/components/qtmaterialdrawer_internal.cpp b/components/drawer_internal.cpp similarity index 79% rename from components/qtmaterialdrawer_internal.cpp rename to components/drawer_internal.cpp index 7f327005d..62308c920 100644 --- a/components/qtmaterialdrawer_internal.cpp +++ b/components/drawer_internal.cpp @@ -1,17 +1,14 @@ -#include "qtmaterialdrawer_internal.h" -#include -#include -#include -#include -#include -#include "qtmaterialdrawer.h" +#include "drawer_internal.h" +#include "drawer.h" +namespace md +{ /*! - * \class QtMaterialDrawerStateMachine + * \class DrawerStateMachine * \internal */ -QtMaterialDrawerStateMachine::QtMaterialDrawerStateMachine(QtMaterialDrawerWidget *drawer, QtMaterialDrawer *parent) +DrawerStateMachine::DrawerStateMachine(DrawerWidget *drawer, Drawer *parent) : QStateMachine(parent), m_drawer(drawer), m_main(parent), @@ -85,22 +82,22 @@ QtMaterialDrawerStateMachine::QtMaterialDrawerStateMachine(QtMaterialDrawerWidge updatePropertyAssignments(); } -QtMaterialDrawerStateMachine::~QtMaterialDrawerStateMachine() +DrawerStateMachine::~DrawerStateMachine() { } -void QtMaterialDrawerStateMachine::setOpacity(qreal opacity) +void DrawerStateMachine::setOpacity(qreal opacity) { m_opacity = opacity; m_main->update(); } -bool QtMaterialDrawerStateMachine::isInClosedState() const +bool DrawerStateMachine::isInClosedState() const { return m_closedState->active(); } -void QtMaterialDrawerStateMachine::updatePropertyAssignments() +void DrawerStateMachine::updatePropertyAssignments() { const qreal closedOffset = -(m_drawer->width()+32); @@ -119,17 +116,17 @@ void QtMaterialDrawerStateMachine::updatePropertyAssignments() * \internal */ -QtMaterialDrawerWidget::QtMaterialDrawerWidget(QWidget *parent) - : QtMaterialOverlayWidget(parent), +DrawerWidget::DrawerWidget(QWidget *parent) + : OverlayWidget(parent), m_offset(0) { } -QtMaterialDrawerWidget::~QtMaterialDrawerWidget() +DrawerWidget::~DrawerWidget() { } -void QtMaterialDrawerWidget::setOffset(int offset) +void DrawerWidget::setOffset(int offset) { m_offset = offset; @@ -140,7 +137,7 @@ void QtMaterialDrawerWidget::setOffset(int offset) update(); } -void QtMaterialDrawerWidget::paintEvent(QPaintEvent *event) +void DrawerWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -163,7 +160,9 @@ void QtMaterialDrawerWidget::paintEvent(QPaintEvent *event) painter.drawRect(width()-16, 0, 16, height()); } -QRect QtMaterialDrawerWidget::overlayGeometry() const +QRect DrawerWidget::overlayGeometry() const { - return QtMaterialOverlayWidget::overlayGeometry().translated(m_offset, 0); + return OverlayWidget::overlayGeometry().translated(m_offset, 0); +} + } diff --git a/components/qtmaterialdrawer_internal.h b/components/drawer_internal.h similarity index 57% rename from components/qtmaterialdrawer_internal.h rename to components/drawer_internal.h index 76d219db2..dea6fb8a4 100644 --- a/components/qtmaterialdrawer_internal.h +++ b/components/drawer_internal.h @@ -2,21 +2,30 @@ #define DRAWER_INTERNAL_H #include -#include "lib/qtmaterialoverlaywidget.h" +#include +#include +#include +#include +#include -class QtMaterialDrawer; -class QtMaterialDrawerWidget; +#include "lib/overlaywidget.h" -class QtMaterialDrawerStateMachine : public QStateMachine +namespace md +{ + +class Drawer; +class DrawerWidget; + +class DrawerStateMachine : public QStateMachine { Q_OBJECT Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity) public: - explicit QtMaterialDrawerStateMachine(QtMaterialDrawerWidget *drawer, - QtMaterialDrawer *parent); - ~QtMaterialDrawerStateMachine(); + explicit DrawerStateMachine(DrawerWidget *drawer, + Drawer *parent); + ~DrawerStateMachine(); void setOpacity(qreal opacity); inline qreal opacity() const; @@ -30,10 +39,10 @@ class QtMaterialDrawerStateMachine : public QStateMachine void signalClose(); private: - Q_DISABLE_COPY(QtMaterialDrawerStateMachine) + Q_DISABLE_COPY(DrawerStateMachine) - QtMaterialDrawerWidget *const m_drawer; - QtMaterialDrawer *const m_main; + DrawerWidget *const m_drawer; + Drawer *const m_main; QState *const m_openingState; QState *const m_openedState; QState *const m_closingState; @@ -41,20 +50,19 @@ class QtMaterialDrawerStateMachine : public QStateMachine qreal m_opacity; }; -inline qreal QtMaterialDrawerStateMachine::opacity() const +inline qreal DrawerStateMachine::opacity() const { return m_opacity; } -class QtMaterialDrawerWidget : public QtMaterialOverlayWidget +class DrawerWidget : public OverlayWidget { Q_OBJECT - Q_PROPERTY(int offset WRITE setOffset READ offset) public: - explicit QtMaterialDrawerWidget(QWidget *parent = 0); - ~QtMaterialDrawerWidget(); + explicit DrawerWidget(QWidget *parent = 0); + ~DrawerWidget(); void setOffset(int offset); inline int offset() const; @@ -68,9 +76,9 @@ class QtMaterialDrawerWidget : public QtMaterialOverlayWidget int m_offset; }; -inline int QtMaterialDrawerWidget::offset() const +inline int DrawerWidget::offset() const { return m_offset; } - +} #endif // DRAWER_INTERNAL_H diff --git a/components/drawer_p.h b/components/drawer_p.h new file mode 100644 index 000000000..aab0441a5 --- /dev/null +++ b/components/drawer_p.h @@ -0,0 +1,35 @@ +#ifndef DRAWER_P_H +#define DRAWER_P_H + +#include +namespace md +{ + +class Drawer; +class DrawerWidget; +class DrawerStateMachine; + +class DrawerPrivate +{ + Q_DISABLE_COPY(DrawerPrivate) + Q_DECLARE_PUBLIC(Drawer) + +public: + DrawerPrivate(Drawer *q); + ~DrawerPrivate(); + + void init(); + void setClosed(bool value = true); + + Drawer *const q_ptr; + DrawerWidget *widget; + DrawerStateMachine *stateMachine; + QWidget *window; + int width; + bool clickToClose; + bool autoRaise; + bool closed; + bool overlay; +}; +} +#endif // DRAWER_P_H diff --git a/components/qtmaterialfab.cpp b/components/fab.cpp similarity index 59% rename from components/qtmaterialfab.cpp rename to components/fab.cpp index 3c3de8a1f..0d4212379 100644 --- a/components/qtmaterialfab.cpp +++ b/components/fab.cpp @@ -1,37 +1,36 @@ -#include "qtmaterialfab.h" -#include "qtmaterialfab_p.h" -#include -#include -#include -#include -#include "lib/qtmaterialrippleoverlay.h" +#include "fab.h" +#include "fab_p.h" +#include "lib/rippleoverlay.h" + +namespace md +{ /*! - * \class QtMaterialFloatingActionButtonPrivate + * \class FloatingActionButtonPrivate * \internal */ /*! * \internal */ -QtMaterialFloatingActionButtonPrivate::QtMaterialFloatingActionButtonPrivate(QtMaterialFloatingActionButton *q) - : QtMaterialRaisedButtonPrivate(q) +FloatingActionButtonPrivate::FloatingActionButtonPrivate(FloatingActionButton *q) + : RaisedButtonPrivate(q) { } /*! * \internal */ -QtMaterialFloatingActionButtonPrivate::~QtMaterialFloatingActionButtonPrivate() +FloatingActionButtonPrivate::~FloatingActionButtonPrivate() { } /*! * \internal */ -void QtMaterialFloatingActionButtonPrivate::init() +void FloatingActionButtonPrivate::init() { - Q_Q(QtMaterialFloatingActionButton); + Q_Q(FloatingActionButton); corner = Qt::BottomRightCorner; mini = false; @@ -54,9 +53,9 @@ void QtMaterialFloatingActionButtonPrivate::init() /*! * \internal */ -QRect QtMaterialFloatingActionButtonPrivate::fabGeometry() const +QRect FloatingActionButtonPrivate::fabGeometry() const { - Q_Q(const QtMaterialFloatingActionButton); + Q_Q(const FloatingActionButton); QWidget *parent = q->parentWidget(); if (!parent) { @@ -83,7 +82,7 @@ QRect QtMaterialFloatingActionButtonPrivate::fabGeometry() const /*! * \internal */ -void QtMaterialFloatingActionButtonPrivate::setupProperties() +void FloatingActionButtonPrivate::setupProperties() { if (mini) { effect->setColor(QColor(0, 0, 0, 80)); @@ -104,37 +103,37 @@ void QtMaterialFloatingActionButtonPrivate::setupProperties() * \class QtMaterialFloatingActionButton */ -QtMaterialFloatingActionButton::QtMaterialFloatingActionButton(const QIcon &icon, QWidget *parent) - : QtMaterialRaisedButton(*new QtMaterialFloatingActionButtonPrivate(this), parent) +FloatingActionButton::FloatingActionButton(const QIcon &icon, QWidget *parent) + : RaisedButton(*new FloatingActionButtonPrivate(this), parent) { d_func()->init(); setIcon(icon); } -QtMaterialFloatingActionButton::~QtMaterialFloatingActionButton() +FloatingActionButton::~FloatingActionButton() { } /*! * \reimp */ -QSize QtMaterialFloatingActionButton::sizeHint() const +QSize FloatingActionButton::sizeHint() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); if (d->mini) { - return QSize(QtMaterialFloatingActionButtonPrivate::MiniDiameter, - QtMaterialFloatingActionButtonPrivate::MiniDiameter); + return QSize(FloatingActionButtonPrivate::MiniDiameter, + FloatingActionButtonPrivate::MiniDiameter); } else { - return QSize(QtMaterialFloatingActionButtonPrivate::DefaultDiameter, - QtMaterialFloatingActionButtonPrivate::DefaultDiameter); + return QSize(FloatingActionButtonPrivate::DefaultDiameter, + FloatingActionButtonPrivate::DefaultDiameter); } } -void QtMaterialFloatingActionButton::setMini(bool state) +void FloatingActionButton::setMini(bool state) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); if (d->mini == state) { return; @@ -151,16 +150,16 @@ void QtMaterialFloatingActionButton::setMini(bool state) update(); } -bool QtMaterialFloatingActionButton::isMini() const +bool FloatingActionButton::isMini() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); return d->mini; } -void QtMaterialFloatingActionButton::setCorner(Qt::Corner corner) +void FloatingActionButton::setCorner(Qt::Corner corner) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); if (d->corner == corner) { return; @@ -171,16 +170,16 @@ void QtMaterialFloatingActionButton::setCorner(Qt::Corner corner) update(); } -Qt::Corner QtMaterialFloatingActionButton::corner() const +Qt::Corner FloatingActionButton::corner() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); return d->corner; } -void QtMaterialFloatingActionButton::setOffset(int x, int y) +void FloatingActionButton::setOffset(int x, int y) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); d->offsX = x; d->offsY = y; @@ -188,41 +187,41 @@ void QtMaterialFloatingActionButton::setOffset(int x, int y) update(); } -QSize QtMaterialFloatingActionButton::offset() const +QSize FloatingActionButton::offset() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); return QSize(d->offsX, d->offsY); } -void QtMaterialFloatingActionButton::setXOffset(int x) +void FloatingActionButton::setXOffset(int x) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); d->offsX = x; setGeometry(d->fabGeometry()); update(); } -int QtMaterialFloatingActionButton::xOffset() const +int FloatingActionButton::xOffset() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); return d->offsX; } -void QtMaterialFloatingActionButton::setYOffset(int y) +void FloatingActionButton::setYOffset(int y) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); d->offsY = y; setGeometry(d->fabGeometry()); update(); } -int QtMaterialFloatingActionButton::yOffset() const +int FloatingActionButton::yOffset() const { - Q_D(const QtMaterialFloatingActionButton); + Q_D(const FloatingActionButton); return d->offsY; } @@ -230,12 +229,12 @@ int QtMaterialFloatingActionButton::yOffset() const /*! * \reimp */ -bool QtMaterialFloatingActionButton::event(QEvent *event) +bool FloatingActionButton::event(QEvent *event) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); if (!parent()) { - return QtMaterialRaisedButton::event(event); + return RaisedButton::event(event); } switch (event->type()) { @@ -253,33 +252,33 @@ bool QtMaterialFloatingActionButton::event(QEvent *event) default: break; } - return QtMaterialRaisedButton::event(event); + return RaisedButton::event(event); } /*! * \reimp */ -bool QtMaterialFloatingActionButton::eventFilter(QObject *obj, QEvent *event) +bool FloatingActionButton::eventFilter(QObject *obj, QEvent *event) { const QEvent::Type type = event->type(); if (QEvent::Move == type || QEvent::Resize == type) { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); setGeometry(d->fabGeometry()); } - return QtMaterialRaisedButton::eventFilter(obj, event); + return RaisedButton::eventFilter(obj, event); } /*! * \reimp */ -void QtMaterialFloatingActionButton::paintEvent(QPaintEvent *event) +void FloatingActionButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); QRect square = QRect(0, 0, d->diameter(), d->diameter()); square.moveCenter(rect().center()); @@ -311,11 +310,13 @@ void QtMaterialFloatingActionButton::paintEvent(QPaintEvent *event) painter.drawPixmap(iconGeometry, pixmap); } -void QtMaterialFloatingActionButton::updateClipPath() +void FloatingActionButton::updateClipPath() { - Q_D(QtMaterialFloatingActionButton); + Q_D(FloatingActionButton); QPainterPath path; path.addEllipse(0, 0, d->diameter(), d->diameter()); d->rippleOverlay->setClipPath(path); } + +} diff --git a/components/qtmaterialfab.h b/components/fab.h similarity index 57% rename from components/qtmaterialfab.h rename to components/fab.h index 78838b12b..5a979430a 100644 --- a/components/qtmaterialfab.h +++ b/components/fab.h @@ -1,17 +1,19 @@ -#ifndef QTMATERIALFAB_H -#define QTMATERIALFAB_H +#ifndef FAB_H +#define FAB_H -#include "qtmaterialraisedbutton.h" +#include "raisedbutton.h" +namespace md +{ -class QtMaterialFloatingActionButtonPrivate; +class FloatingActionButtonPrivate; -class QtMaterialFloatingActionButton : public QtMaterialRaisedButton +class FloatingActionButton : public RaisedButton { Q_OBJECT public: - explicit QtMaterialFloatingActionButton(const QIcon &icon, QWidget *parent = 0); - ~QtMaterialFloatingActionButton(); + explicit FloatingActionButton(const QIcon &icon, QWidget *parent = 0); + ~FloatingActionButton(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -38,9 +40,9 @@ class QtMaterialFloatingActionButton : public QtMaterialRaisedButton void updateClipPath() Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialFloatingActionButton) - Q_DECLARE_PRIVATE(QtMaterialFloatingActionButton) + Q_DISABLE_COPY(FloatingActionButton) + Q_DECLARE_PRIVATE(FloatingActionButton) }; - -#endif // QTMATERIALFAB_H +} +#endif // FAB_H diff --git a/components/fab_p.h b/components/fab_p.h new file mode 100644 index 000000000..2e784bb33 --- /dev/null +++ b/components/fab_p.h @@ -0,0 +1,58 @@ +#ifndef FAB_P_H +#define FAB_P_H + +#include +#include +#include +#include + +#include "raisedbutton_p.h" + +namespace md +{ + +class FloatingActionButton; + +class FloatingActionButtonPrivate : public RaisedButtonPrivate +{ + Q_DISABLE_COPY(FloatingActionButtonPrivate) + Q_DECLARE_PUBLIC(FloatingActionButton) + +public: + enum { + DefaultDiameter = 56, + MiniDiameter = 40 + }; + + enum { + DefaultIconSize = 24, + MiniIconSize = 18 + }; + + FloatingActionButtonPrivate(FloatingActionButton *q); + ~FloatingActionButtonPrivate(); + + void init(); + QRect fabGeometry() const; + void setupProperties(); + + inline int diameter() const; + inline int iconSize() const; + + Qt::Corner corner; + bool mini; + int offsX; + int offsY; +}; + +inline int FloatingActionButtonPrivate::diameter() const +{ + return mini ? MiniDiameter : DefaultDiameter; +} + +inline int FloatingActionButtonPrivate::iconSize() const +{ + return mini ? MiniIconSize : DefaultIconSize; +} +} +#endif // FAB_P_H diff --git a/components/qtmaterialflatbutton.cpp b/components/flatbutton.cpp similarity index 63% rename from components/qtmaterialflatbutton.cpp rename to components/flatbutton.cpp index b9d84d7e2..5b1c0fb9c 100644 --- a/components/qtmaterialflatbutton.cpp +++ b/components/flatbutton.cpp @@ -1,16 +1,18 @@ -#include "qtmaterialflatbutton.h" -#include "qtmaterialflatbutton_p.h" +#include "flatbutton.h" +#include "flatbutton_p.h" #include #include #include #include #include #include -#include "lib/qtmaterialrippleoverlay.h" -#include "lib/qtmaterialripple.h" -#include "lib/qtmaterialstyle.h" -#include "qtmaterialflatbutton_internal.h" +#include "lib/rippleoverlay.h" +#include "lib/ripple.h" +#include "lib/style.h" +#include "flatbutton_internal.h" +namespace md +{ /*! * \class QtMaterialFlatButtonPrivate * \internal @@ -19,7 +21,7 @@ /*! * \internal */ -QtMaterialFlatButtonPrivate::QtMaterialFlatButtonPrivate(QtMaterialFlatButton *q) +FlatButtonPrivate::FlatButtonPrivate(FlatButton *q) : q_ptr(q) { } @@ -27,19 +29,19 @@ QtMaterialFlatButtonPrivate::QtMaterialFlatButtonPrivate(QtMaterialFlatButton *q /*! * \internal */ -QtMaterialFlatButtonPrivate::~QtMaterialFlatButtonPrivate() +FlatButtonPrivate::~FlatButtonPrivate() { } /*! * \internal */ -void QtMaterialFlatButtonPrivate::init() +void FlatButtonPrivate::init() { - Q_Q(QtMaterialFlatButton); + Q_Q(FlatButton); - rippleOverlay = new QtMaterialRippleOverlay(q); - stateMachine = new QtMaterialFlatButtonStateMachine(q); + rippleOverlay = new RippleOverlay(q); + stateMachine = new FlatButtonStateMachine(q); role = Material::Default; rippleStyle = Material::PositionedRipple; iconPlacement = Material::LeftIcon; @@ -54,7 +56,7 @@ void QtMaterialFlatButtonPrivate::init() useFixedRippleRadius = false; haloVisible = true; - q->setStyle(&QtMaterialStyle::instance()); + q->setStyle(&Style::instance()); q->setAttribute(Qt::WA_Hover); q->setMouseTracking(true); @@ -75,27 +77,27 @@ void QtMaterialFlatButtonPrivate::init() * \class QtMaterialFlatButton */ -QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, Material::ButtonPreset preset) +FlatButton::FlatButton(QWidget *parent, Material::ButtonPreset preset) : QPushButton(parent), - d_ptr(new QtMaterialFlatButtonPrivate(this)) + d_ptr(new FlatButtonPrivate(this)) { d_func()->init(); applyPreset(preset); } -QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, QWidget *parent, Material::ButtonPreset preset) +FlatButton::FlatButton(const QString &text, QWidget *parent, Material::ButtonPreset preset) : QPushButton(text, parent), - d_ptr(new QtMaterialFlatButtonPrivate(this)) + d_ptr(new FlatButtonPrivate(this)) { d_func()->init(); applyPreset(preset); } -QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, Material::Role role, QWidget *parent, Material::ButtonPreset preset) +FlatButton::FlatButton(const QString &text, Material::Role role, QWidget *parent, Material::ButtonPreset preset) : QPushButton(text, parent), - d_ptr(new QtMaterialFlatButtonPrivate(this)) + d_ptr(new FlatButtonPrivate(this)) { d_func()->init(); @@ -103,11 +105,11 @@ QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, Material::Role r setRole(role); } -QtMaterialFlatButton::~QtMaterialFlatButton() +FlatButton::~FlatButton() { } -void QtMaterialFlatButton::applyPreset(Material::ButtonPreset preset) +void FlatButton::applyPreset(Material::ButtonPreset preset) { switch (preset) { @@ -124,9 +126,9 @@ void QtMaterialFlatButton::applyPreset(Material::ButtonPreset preset) } } -void QtMaterialFlatButton::setUseThemeColors(bool value) +void FlatButton::setUseThemeColors(bool value) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); if (d->useThemeColors == value) { return; @@ -136,31 +138,31 @@ void QtMaterialFlatButton::setUseThemeColors(bool value) d->stateMachine->setupProperties(); } -bool QtMaterialFlatButton::useThemeColors() const +bool FlatButton::useThemeColors() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->useThemeColors; } -void QtMaterialFlatButton::setRole(Material::Role role) +void FlatButton::setRole(Material::Role role) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->role = role; d->stateMachine->setupProperties(); } -Material::Role QtMaterialFlatButton::role() const +Material::Role FlatButton::role() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->role; } -void QtMaterialFlatButton::setForegroundColor(const QColor &color) +void FlatButton::setForegroundColor(const QColor &color) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->foregroundColor = color; @@ -168,32 +170,32 @@ void QtMaterialFlatButton::setForegroundColor(const QColor &color) update(); } -QColor QtMaterialFlatButton::foregroundColor() const +QColor FlatButton::foregroundColor() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); if (d->useThemeColors || !d->foregroundColor.isValid()) { if (Qt::OpaqueMode == d->bgMode) { - return QtMaterialStyle::instance().themeColor("canvas"); + return Style::instance().themeColor("canvas"); } switch (d->role) { case Material::Primary: - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); case Material::Secondary: - return QtMaterialStyle::instance().themeColor("accent1"); + return Style::instance().themeColor("accent1"); case Material::Default: default: - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } } return d->foregroundColor; } -void QtMaterialFlatButton::setBackgroundColor(const QColor &color) +void FlatButton::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->backgroundColor = color; @@ -201,29 +203,29 @@ void QtMaterialFlatButton::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialFlatButton::backgroundColor() const +QColor FlatButton::backgroundColor() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); if (d->useThemeColors || !d->backgroundColor.isValid()) { switch (d->role) { case Material::Primary: - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); case Material::Secondary: - return QtMaterialStyle::instance().themeColor("accent1"); + return Style::instance().themeColor("accent1"); case Material::Default: default: - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } } return d->backgroundColor; } -void QtMaterialFlatButton::setOverlayColor(const QColor &color) +void FlatButton::setOverlayColor(const QColor &color) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->overlayColor = color; @@ -233,9 +235,9 @@ void QtMaterialFlatButton::setOverlayColor(const QColor &color) update(); } -QColor QtMaterialFlatButton::overlayColor() const +QColor FlatButton::overlayColor() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); if (d->useThemeColors || !d->overlayColor.isValid()) { return foregroundColor(); @@ -243,9 +245,9 @@ QColor QtMaterialFlatButton::overlayColor() const return d->overlayColor; } -void QtMaterialFlatButton::setDisabledForegroundColor(const QColor &color) +void FlatButton::setDisabledForegroundColor(const QColor &color) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->disabledColor = color; @@ -253,20 +255,20 @@ void QtMaterialFlatButton::setDisabledForegroundColor(const QColor &color) update(); } -QColor QtMaterialFlatButton::disabledForegroundColor() const +QColor FlatButton::disabledForegroundColor() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); if (d->useThemeColors || !d->disabledColor.isValid()) { - return QtMaterialStyle::instance().themeColor("disabled"); + return Style::instance().themeColor("disabled"); } else { return d->disabledColor; } } -void QtMaterialFlatButton::setDisabledBackgroundColor(const QColor &color) +void FlatButton::setDisabledBackgroundColor(const QColor &color) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->disabledBackgroundColor = color; @@ -274,20 +276,20 @@ void QtMaterialFlatButton::setDisabledBackgroundColor(const QColor &color) update(); } -QColor QtMaterialFlatButton::disabledBackgroundColor() const +QColor FlatButton::disabledBackgroundColor() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); if (d->useThemeColors || !d->disabledBackgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("disabled3"); + return Style::instance().themeColor("disabled3"); } else { return d->disabledBackgroundColor; } } -void QtMaterialFlatButton::setFontSize(qreal size) +void FlatButton::setFontSize(qreal size) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->fontSize = size; @@ -298,159 +300,159 @@ void QtMaterialFlatButton::setFontSize(qreal size) update(); } -qreal QtMaterialFlatButton::fontSize() const +qreal FlatButton::fontSize() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->fontSize; } -void QtMaterialFlatButton::setHaloVisible(bool visible) +void FlatButton::setHaloVisible(bool visible) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->haloVisible = visible; update(); } -bool QtMaterialFlatButton::isHaloVisible() const +bool FlatButton::isHaloVisible() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->haloVisible; } -void QtMaterialFlatButton::setOverlayStyle(Material::OverlayStyle style) +void FlatButton::setOverlayStyle(Material::OverlayStyle style) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->overlayStyle = style; update(); } -Material::OverlayStyle QtMaterialFlatButton::overlayStyle() const +Material::OverlayStyle FlatButton::overlayStyle() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->overlayStyle; } -void QtMaterialFlatButton::setRippleStyle(Material::RippleStyle style) +void FlatButton::setRippleStyle(Material::RippleStyle style) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->rippleStyle = style; } -Material::RippleStyle QtMaterialFlatButton::rippleStyle() const +Material::RippleStyle FlatButton::rippleStyle() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->rippleStyle; } -void QtMaterialFlatButton::setIconPlacement(Material::ButtonIconPlacement placement) +void FlatButton::setIconPlacement(Material::ButtonIconPlacement placement) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->iconPlacement = placement; update(); } -Material::ButtonIconPlacement QtMaterialFlatButton::iconPlacement() const +Material::ButtonIconPlacement FlatButton::iconPlacement() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->iconPlacement; } -void QtMaterialFlatButton::setCornerRadius(qreal radius) +void FlatButton::setCornerRadius(qreal radius) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->cornerRadius = radius; updateClipPath(); update(); } -qreal QtMaterialFlatButton::cornerRadius() const +qreal FlatButton::cornerRadius() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->cornerRadius; } -void QtMaterialFlatButton::setBackgroundMode(Qt::BGMode mode) +void FlatButton::setBackgroundMode(Qt::BGMode mode) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->bgMode = mode; d->stateMachine->setupProperties(); } -Qt::BGMode QtMaterialFlatButton::backgroundMode() const +Qt::BGMode FlatButton::backgroundMode() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->bgMode; } -void QtMaterialFlatButton::setBaseOpacity(qreal opacity) +void FlatButton::setBaseOpacity(qreal opacity) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->baseOpacity = opacity; d->stateMachine->setupProperties(); } -qreal QtMaterialFlatButton::baseOpacity() const +qreal FlatButton::baseOpacity() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->baseOpacity; } -void QtMaterialFlatButton::setCheckable(bool value) +void FlatButton::setCheckable(bool value) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->stateMachine->updateCheckedStatus(); QPushButton::setCheckable(value); } -void QtMaterialFlatButton::setHasFixedRippleRadius(bool value) +void FlatButton::setHasFixedRippleRadius(bool value) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->useFixedRippleRadius = value; } -bool QtMaterialFlatButton::hasFixedRippleRadius() const +bool FlatButton::hasFixedRippleRadius() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->useFixedRippleRadius; } -void QtMaterialFlatButton::setFixedRippleRadius(qreal radius) +void FlatButton::setFixedRippleRadius(qreal radius) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->fixedRippleRadius = radius; setHasFixedRippleRadius(true); } -void QtMaterialFlatButton::setTextAlignment(Qt::Alignment alignment) +void FlatButton::setTextAlignment(Qt::Alignment alignment) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->textAlignment = alignment; } -Qt::Alignment QtMaterialFlatButton::textAlignment() const +Qt::Alignment FlatButton::textAlignment() const { - Q_D(const QtMaterialFlatButton); + Q_D(const FlatButton); return d->textAlignment; } @@ -458,7 +460,7 @@ Qt::Alignment QtMaterialFlatButton::textAlignment() const /*! * \reimp */ -QSize QtMaterialFlatButton::sizeHint() const +QSize FlatButton::sizeHint() const { ensurePolished(); @@ -467,13 +469,13 @@ QSize QtMaterialFlatButton::sizeHint() const int w = 20 + label.width(); int h = label.height(); if (!icon().isNull()) { - w += iconSize().width() + QtMaterialFlatButton::IconPadding; + w += iconSize().width() + FlatButton::IconPadding; h = qMax(h, iconSize().height()); } return QSize(w, 20 + h); } -QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidget *parent, Material::ButtonPreset preset) +FlatButton::FlatButton(FlatButtonPrivate &d,QWidget *parent, Material::ButtonPreset preset) : QPushButton(parent), d_ptr(&d) { @@ -485,9 +487,9 @@ QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidge /*! * \reimp */ -void QtMaterialFlatButton::checkStateSet() +void FlatButton::checkStateSet() { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); d->stateMachine->updateCheckedStatus(); @@ -497,9 +499,9 @@ void QtMaterialFlatButton::checkStateSet() /*! * \reimp */ -void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event) +void FlatButton::mousePressEvent(QMouseEvent *event) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); if (Material::NoRipple != d->rippleStyle) { @@ -518,7 +520,7 @@ void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event) radiusEndValue = static_cast(width())/2; } - QtMaterialRipple *ripple = new QtMaterialRipple(pos); + Ripple *ripple = new Ripple(pos); ripple->setRadiusEndValue(radiusEndValue); ripple->setOpacityStartValue(0.35); @@ -535,16 +537,16 @@ void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event) /*! * \reimp */ -void QtMaterialFlatButton::mouseReleaseEvent(QMouseEvent *event) +void FlatButton::mouseReleaseEvent(QMouseEvent *event) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); QPushButton::mouseReleaseEvent(event); d->stateMachine->updateCheckedStatus(); } -void QtMaterialFlatButton::resizeEvent(QResizeEvent *event) +void FlatButton::resizeEvent(QResizeEvent *event) { QPushButton::resizeEvent(event); @@ -554,11 +556,11 @@ void QtMaterialFlatButton::resizeEvent(QResizeEvent *event) /*! * \reimp */ -void QtMaterialFlatButton::paintEvent(QPaintEvent *event) +void FlatButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -586,9 +588,9 @@ void QtMaterialFlatButton::paintEvent(QPaintEvent *event) /*! * \internal */ -void QtMaterialFlatButton::paintBackground(QPainter *painter) +void FlatButton::paintBackground(QPainter *painter) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); const qreal overlayOpacity = d->stateMachine->overlayOpacity(); const qreal checkedProgress = d->stateMachine->checkedOverlayProgress(); @@ -640,9 +642,9 @@ void QtMaterialFlatButton::paintBackground(QPainter *painter) /*! * \internal */ -void QtMaterialFlatButton::paintHalo(QPainter *painter) +void FlatButton::paintHalo(QPainter *painter) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); if (!d->haloVisible) { return; @@ -669,9 +671,9 @@ void QtMaterialFlatButton::paintHalo(QPainter *painter) /*! * \internal */ -void QtMaterialFlatButton::paintForeground(QPainter *painter) +void FlatButton::paintForeground(QPainter *painter) { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); if (isEnabled()) { painter->setPen(foregroundColor()); @@ -729,9 +731,9 @@ void QtMaterialFlatButton::paintForeground(QPainter *painter) /*! * \internal */ -void QtMaterialFlatButton::updateClipPath() +void FlatButton::updateClipPath() { - Q_D(QtMaterialFlatButton); + Q_D(FlatButton); const qreal radius = d->cornerRadius; @@ -739,3 +741,4 @@ void QtMaterialFlatButton::updateClipPath() path.addRoundedRect(rect(), radius, radius); d->rippleOverlay->setClipPath(path); } +} diff --git a/components/qtmaterialflatbutton.h b/components/flatbutton.h similarity index 77% rename from components/qtmaterialflatbutton.h rename to components/flatbutton.h index a74ab6afb..554ac3908 100644 --- a/components/qtmaterialflatbutton.h +++ b/components/flatbutton.h @@ -1,13 +1,15 @@ -#ifndef QTMATERIALFLATBUTTON_H -#define QTMATERIALFLATBUTTON_H +#ifndef FLATBUTTON_H +#define FLATBUTTON_H #include #include -#include "lib/qtmaterialtheme.h" +#include "lib/theme.h" -class QtMaterialFlatButtonPrivate; +namespace md { -class QtMaterialFlatButton : public QPushButton +class FlatButtonPrivate; + +class FlatButton : public QPushButton { Q_OBJECT @@ -19,10 +21,10 @@ class QtMaterialFlatButton : public QPushButton Q_PROPERTY(qreal fontSize WRITE setFontSize READ fontSize) 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); - ~QtMaterialFlatButton(); + explicit FlatButton(QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + explicit FlatButton(const QString &text, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + FlatButton(const QString &text, Material::Role role, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + ~FlatButton(); void applyPreset(Material::ButtonPreset preset); @@ -88,7 +90,7 @@ class QtMaterialFlatButton : public QPushButton IconPadding = 12 }; - QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); + FlatButton(FlatButtonPrivate &d, QWidget *parent = 0, Material::ButtonPreset preset = Material::FlatPreset); void checkStateSet() Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; @@ -102,11 +104,13 @@ class QtMaterialFlatButton : public QPushButton virtual void updateClipPath(); - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialFlatButton) - Q_DECLARE_PRIVATE(QtMaterialFlatButton) + Q_DISABLE_COPY(FlatButton) + Q_DECLARE_PRIVATE(FlatButton) }; -#endif // QTMATERIALFLATBUTTON_H +} + +#endif // FLATBUTTON_H diff --git a/components/qtmaterialflatbutton_internal.cpp b/components/flatbutton_internal.cpp similarity index 79% rename from components/qtmaterialflatbutton_internal.cpp rename to components/flatbutton_internal.cpp index 0709a45f5..de0991c25 100644 --- a/components/qtmaterialflatbutton_internal.cpp +++ b/components/flatbutton_internal.cpp @@ -1,17 +1,13 @@ -#include "qtmaterialflatbutton_internal.h" -#include -#include -#include -#include -#include "qtmaterialflatbutton.h" -#include "lib/qtmaterialstatetransition.h" +#include "flatbutton_internal.h" +namespace md +{ /*! * \class QtMaterialFlatButtonStateMachine * \internal */ -QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFlatButton *parent) +FlatButtonStateMachine::FlatButtonStateMachine(FlatButton *parent) : QStateMachine(parent), m_button(parent), m_topLevelState(new QState(QState::ParallelStates)), @@ -42,10 +38,10 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla m_checkableState->setInitialState(parent->isChecked() ? m_checkedState : m_uncheckedState); - QtMaterialStateTransition *transition; + StateTransition *transition; QPropertyAnimation *animation; - transition = new QtMaterialStateTransition(FlatButtonCheckedTransition); + transition = new StateTransition(FlatButtonCheckedTransition); transition->setTargetState(m_checkedState); m_uncheckedState->addTransition(transition); @@ -53,7 +49,7 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla animation->setDuration(200); transition->addAnimation(animation); - transition = new QtMaterialStateTransition(FlatButtonUncheckedTransition); + transition = new StateTransition(FlatButtonUncheckedTransition); transition->setTargetState(m_uncheckedState); m_checkedState->addTransition(transition); @@ -70,7 +66,7 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla addTransition(m_button, QEvent::FocusIn, m_hoveredState, m_hoveredFocusedState); addTransition(m_button, QEvent::FocusOut, m_hoveredFocusedState, m_hoveredState); - transition = new QtMaterialStateTransition(FlatButtonPressedTransition); + transition = new StateTransition(FlatButtonPressedTransition); transition->setTargetState(m_pressedState); m_hoveredState->addTransition(transition); @@ -105,47 +101,47 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla m_haloAnimation->setLoopCount(-1); } -QtMaterialFlatButtonStateMachine::~QtMaterialFlatButtonStateMachine() +FlatButtonStateMachine::~FlatButtonStateMachine() { } -void QtMaterialFlatButtonStateMachine::setOverlayOpacity(qreal opacity) +void FlatButtonStateMachine::setOverlayOpacity(qreal opacity) { m_overlayOpacity = opacity; m_button->update(); } -void QtMaterialFlatButtonStateMachine::setCheckedOverlayProgress(qreal progress) +void FlatButtonStateMachine::setCheckedOverlayProgress(qreal progress) { m_checkedOverlayProgress = progress; m_button->update(); } -void QtMaterialFlatButtonStateMachine::setHaloOpacity(qreal opacity) +void FlatButtonStateMachine::setHaloOpacity(qreal opacity) { m_haloOpacity = opacity; m_button->update(); } -void QtMaterialFlatButtonStateMachine::setHaloSize(qreal size) +void FlatButtonStateMachine::setHaloSize(qreal size) { m_haloSize = size; m_button->update(); } -void QtMaterialFlatButtonStateMachine::setHaloScaleFactor(qreal factor) +void FlatButtonStateMachine::setHaloScaleFactor(qreal factor) { m_haloScaleFactor = factor; m_button->update(); } -void QtMaterialFlatButtonStateMachine::startAnimations() +void FlatButtonStateMachine::startAnimations() { m_haloAnimation->start(); start(); } -void QtMaterialFlatButtonStateMachine::setupProperties() +void FlatButtonStateMachine::setupProperties() { QColor overlayColor; @@ -173,33 +169,33 @@ void QtMaterialFlatButtonStateMachine::setupProperties() m_button->update(); } -void QtMaterialFlatButtonStateMachine::updateCheckedStatus() +void FlatButtonStateMachine::updateCheckedStatus() { const bool checked = m_button->isChecked(); if (m_wasChecked != checked) { m_wasChecked = checked; if (checked) { - postEvent(new QtMaterialStateTransitionEvent(FlatButtonCheckedTransition)); + postEvent(new StateTransitionEvent(FlatButtonCheckedTransition)); } else { - postEvent(new QtMaterialStateTransitionEvent(FlatButtonUncheckedTransition)); + postEvent(new StateTransitionEvent(FlatButtonUncheckedTransition)); } } } -bool QtMaterialFlatButtonStateMachine::eventFilter(QObject *watched, +bool FlatButtonStateMachine::eventFilter(QObject *watched, QEvent *event) { if (QEvent::FocusIn == event->type()) { QFocusEvent *focusEvent = static_cast(event); if (focusEvent && Qt::MouseFocusReason == focusEvent->reason()) { - postEvent(new QtMaterialStateTransitionEvent(FlatButtonPressedTransition)); + postEvent(new StateTransitionEvent(FlatButtonPressedTransition)); return true; } } return QStateMachine::eventFilter(watched, event); } -void QtMaterialFlatButtonStateMachine::addTransition(QObject *object, +void FlatButtonStateMachine::addTransition(QObject *object, QEvent::Type eventType, QState *fromState, QState *toState) @@ -207,7 +203,7 @@ void QtMaterialFlatButtonStateMachine::addTransition(QObject *object, addTransition(new QEventTransition(object, eventType), fromState, toState); } -void QtMaterialFlatButtonStateMachine::addTransition(QAbstractTransition *transition, +void FlatButtonStateMachine::addTransition(QAbstractTransition *transition, QState *fromState, QState *toState) { @@ -230,3 +226,5 @@ void QtMaterialFlatButtonStateMachine::addTransition(QAbstractTransition *transi fromState->addTransition(transition); } + +} diff --git a/components/qtmaterialflatbutton_internal.h b/components/flatbutton_internal.h similarity index 74% rename from components/qtmaterialflatbutton_internal.h rename to components/flatbutton_internal.h index ff93972b9..4e31a4b89 100644 --- a/components/qtmaterialflatbutton_internal.h +++ b/components/flatbutton_internal.h @@ -1,13 +1,21 @@ -#ifndef QTMATERIALFLATBUTTON_INTERNAL_H -#define QTMATERIALFLATBUTTON_INTERNAL_H +#ifndef FLATBUTTON_INTERNAL_H +#define FLATBUTTON_INTERNAL_H #include #include +#include +#include +#include +#include -class QtMaterialFlatButton; -class QSequentialAnimationGroup; +#include "flatbutton.h" +#include "lib/statetransition.h" -class QtMaterialFlatButtonStateMachine : public QStateMachine +namespace md +{ + +class FlatButton; +class FlatButtonStateMachine : public QStateMachine { Q_OBJECT @@ -18,8 +26,8 @@ class QtMaterialFlatButtonStateMachine : public QStateMachine Q_PROPERTY(qreal haloScaleFactor WRITE setHaloScaleFactor READ haloScaleFactor) public: - explicit QtMaterialFlatButtonStateMachine(QtMaterialFlatButton *parent); - ~QtMaterialFlatButtonStateMachine(); + explicit FlatButtonStateMachine(FlatButton *parent); + ~FlatButtonStateMachine(); void setOverlayOpacity(qreal opacity); inline qreal overlayOpacity() const; @@ -49,12 +57,12 @@ class QtMaterialFlatButtonStateMachine : public QStateMachine bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialFlatButtonStateMachine) + Q_DISABLE_COPY(FlatButtonStateMachine) void addTransition(QObject *object, QEvent::Type eventType, QState *fromState, QState *toState); void addTransition(QAbstractTransition *transition, QState *fromState, QState *toState); - QtMaterialFlatButton *const m_button; + FlatButton *const m_button; QState *const m_topLevelState; QState *const m_configState; QState *const m_checkableState; @@ -75,29 +83,30 @@ class QtMaterialFlatButtonStateMachine : public QStateMachine bool m_wasChecked; }; -inline qreal QtMaterialFlatButtonStateMachine::overlayOpacity() const +inline qreal FlatButtonStateMachine::overlayOpacity() const { return m_overlayOpacity; } -inline qreal QtMaterialFlatButtonStateMachine::checkedOverlayProgress() const +inline qreal FlatButtonStateMachine::checkedOverlayProgress() const { return m_checkedOverlayProgress; } -inline qreal QtMaterialFlatButtonStateMachine::haloOpacity() const +inline qreal FlatButtonStateMachine::haloOpacity() const { return m_haloOpacity; } -inline qreal QtMaterialFlatButtonStateMachine::haloSize() const +inline qreal FlatButtonStateMachine::haloSize() const { return m_haloSize; } -inline qreal QtMaterialFlatButtonStateMachine::haloScaleFactor() const +inline qreal FlatButtonStateMachine::haloScaleFactor() const { return m_haloScaleFactor; } +} -#endif // QTMATERIALFLATBUTTON_INTERNAL_H +#endif // FLATBUTTON_INTERNAL_H diff --git a/components/qtmaterialflatbutton_p.h b/components/flatbutton_p.h similarity index 62% rename from components/qtmaterialflatbutton_p.h rename to components/flatbutton_p.h index 1ab3d226f..1fa039407 100644 --- a/components/qtmaterialflatbutton_p.h +++ b/components/flatbutton_p.h @@ -1,28 +1,30 @@ -#ifndef QTMATERIALFLATBUTTON_P_H -#define QTMATERIALFLATBUTTON_P_H +#ifndef FLATBUTTON_P_H +#define FLATBUTTON_P_H #include #include -#include "lib/qtmaterialtheme.h" +#include "lib/theme.h" -class QtMaterialFlatButton; -class QtMaterialRippleOverlay; -class QtMaterialFlatButtonStateMachine; +namespace md +{ +class FlatButton; +class RippleOverlay; +class FlatButtonStateMachine; -class QtMaterialFlatButtonPrivate +class FlatButtonPrivate { - Q_DISABLE_COPY(QtMaterialFlatButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialFlatButton) + Q_DISABLE_COPY(FlatButtonPrivate) + Q_DECLARE_PUBLIC(FlatButton) public: - QtMaterialFlatButtonPrivate(QtMaterialFlatButton *q); - virtual ~QtMaterialFlatButtonPrivate(); + FlatButtonPrivate(FlatButton *q); + virtual ~FlatButtonPrivate(); void init(); - QtMaterialFlatButton *const q_ptr; - QtMaterialRippleOverlay *rippleOverlay; - QtMaterialFlatButtonStateMachine *stateMachine; + FlatButton *const q_ptr; + RippleOverlay *rippleOverlay; + FlatButtonStateMachine *stateMachine; Material::Role role; Material::RippleStyle rippleStyle; Material::ButtonIconPlacement iconPlacement; @@ -42,5 +44,6 @@ class QtMaterialFlatButtonPrivate bool useFixedRippleRadius; bool haloVisible; }; +} -#endif // QTMATERIALFLATBUTTON_P_H +#endif // FLATBUTTON_P_H diff --git a/fonts/Roboto/LICENSE.txt b/components/fonts/Roboto/LICENSE.txt similarity index 100% rename from fonts/Roboto/LICENSE.txt rename to components/fonts/Roboto/LICENSE.txt diff --git a/fonts/Roboto/Roboto-Black.ttf b/components/fonts/Roboto/Roboto-Black.ttf similarity index 100% rename from fonts/Roboto/Roboto-Black.ttf rename to components/fonts/Roboto/Roboto-Black.ttf diff --git a/fonts/Roboto/Roboto-BlackItalic.ttf b/components/fonts/Roboto/Roboto-BlackItalic.ttf similarity index 100% rename from fonts/Roboto/Roboto-BlackItalic.ttf rename to components/fonts/Roboto/Roboto-BlackItalic.ttf diff --git a/fonts/Roboto/Roboto-Bold.ttf b/components/fonts/Roboto/Roboto-Bold.ttf similarity index 100% rename from fonts/Roboto/Roboto-Bold.ttf rename to components/fonts/Roboto/Roboto-Bold.ttf diff --git a/fonts/Roboto/Roboto-BoldItalic.ttf b/components/fonts/Roboto/Roboto-BoldItalic.ttf similarity index 100% rename from fonts/Roboto/Roboto-BoldItalic.ttf rename to components/fonts/Roboto/Roboto-BoldItalic.ttf diff --git a/fonts/Roboto/Roboto-Italic.ttf b/components/fonts/Roboto/Roboto-Italic.ttf similarity index 100% rename from fonts/Roboto/Roboto-Italic.ttf rename to components/fonts/Roboto/Roboto-Italic.ttf diff --git a/fonts/Roboto/Roboto-Light.ttf b/components/fonts/Roboto/Roboto-Light.ttf similarity index 100% rename from fonts/Roboto/Roboto-Light.ttf rename to components/fonts/Roboto/Roboto-Light.ttf diff --git a/fonts/Roboto/Roboto-LightItalic.ttf b/components/fonts/Roboto/Roboto-LightItalic.ttf similarity index 100% rename from fonts/Roboto/Roboto-LightItalic.ttf rename to components/fonts/Roboto/Roboto-LightItalic.ttf diff --git a/fonts/Roboto/Roboto-Medium.ttf b/components/fonts/Roboto/Roboto-Medium.ttf similarity index 100% rename from fonts/Roboto/Roboto-Medium.ttf rename to components/fonts/Roboto/Roboto-Medium.ttf diff --git a/fonts/Roboto/Roboto-MediumItalic.ttf b/components/fonts/Roboto/Roboto-MediumItalic.ttf similarity index 100% rename from fonts/Roboto/Roboto-MediumItalic.ttf rename to components/fonts/Roboto/Roboto-MediumItalic.ttf diff --git a/fonts/Roboto/Roboto-Regular.ttf b/components/fonts/Roboto/Roboto-Regular.ttf similarity index 100% rename from fonts/Roboto/Roboto-Regular.ttf rename to components/fonts/Roboto/Roboto-Regular.ttf diff --git a/fonts/Roboto/Roboto-Thin.ttf b/components/fonts/Roboto/Roboto-Thin.ttf similarity index 100% rename from fonts/Roboto/Roboto-Thin.ttf rename to components/fonts/Roboto/Roboto-Thin.ttf diff --git a/fonts/Roboto/Roboto-ThinItalic.ttf b/components/fonts/Roboto/Roboto-ThinItalic.ttf similarity index 100% rename from fonts/Roboto/Roboto-ThinItalic.ttf rename to components/fonts/Roboto/Roboto-ThinItalic.ttf diff --git a/components/qtmaterialiconbutton.cpp b/components/iconbutton.cpp similarity index 57% rename from components/qtmaterialiconbutton.cpp rename to components/iconbutton.cpp index 525d6b206..e2375dc72 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/iconbutton.cpp @@ -1,43 +1,45 @@ -#include "qtmaterialiconbutton.h" -#include "qtmaterialiconbutton_p.h" +#include "iconbutton.h" +#include "iconbutton_p.h" #include #include -#include "lib/qtmaterialstyle.h" -#include "lib/qtmaterialrippleoverlay.h" +#include "lib/style.h" +#include "lib/rippleoverlay.h" +namespace md +{ /*! * \class QtMaterialIconButtonPrivate * \internal */ -QtMaterialIconButtonPrivate::QtMaterialIconButtonPrivate(QtMaterialIconButton *q) +IconButtonPrivate::IconButtonPrivate(IconButton *q) : q_ptr(q) { } -QtMaterialIconButtonPrivate::~QtMaterialIconButtonPrivate() +IconButtonPrivate::~IconButtonPrivate() { } -void QtMaterialIconButtonPrivate::init() +void IconButtonPrivate::init() { - Q_Q(QtMaterialIconButton); + Q_Q(IconButton); - rippleOverlay = new QtMaterialRippleOverlay(q->parentWidget()); + rippleOverlay = new RippleOverlay(q->parentWidget()); useThemeColors = true; rippleOverlay->installEventFilter(q); - q->setStyle(&QtMaterialStyle::instance()); + q->setStyle(&Style::instance()); QSizePolicy policy; policy.setWidthForHeight(true); q->setSizePolicy(policy); } -void QtMaterialIconButtonPrivate::updateRipple() +void IconButtonPrivate::updateRipple() { - Q_Q(QtMaterialIconButton); + Q_Q(IconButton); QRect r(q->rect()); r.setSize(QSize(q->width()*2, q->height()*2)); @@ -49,30 +51,30 @@ void QtMaterialIconButtonPrivate::updateRipple() * \class QtMaterialIconButton */ -QtMaterialIconButton::QtMaterialIconButton(const QIcon &icon, QWidget *parent) +IconButton::IconButton(const QIcon &icon, QWidget *parent) : QAbstractButton(parent), - d_ptr(new QtMaterialIconButtonPrivate(this)) + d_ptr(new IconButtonPrivate(this)) { d_func()->init(); setIcon(icon); } -QtMaterialIconButton::~QtMaterialIconButton() +IconButton::~IconButton() { } /*! * \reimp */ -QSize QtMaterialIconButton::sizeHint() const +QSize IconButton::sizeHint() const { return iconSize(); } -void QtMaterialIconButton::setUseThemeColors(bool value) +void IconButton::setUseThemeColors(bool value) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); if (d->useThemeColors == value) { return; @@ -82,16 +84,16 @@ void QtMaterialIconButton::setUseThemeColors(bool value) update(); } -bool QtMaterialIconButton::useThemeColors() const +bool IconButton::useThemeColors() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); return d->useThemeColors; } -void QtMaterialIconButton::setColor(const QColor &color) +void IconButton::setColor(const QColor &color) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->color = color; @@ -99,19 +101,19 @@ void QtMaterialIconButton::setColor(const QColor &color) update(); } -QColor QtMaterialIconButton::color() const +QColor IconButton::color() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); if (d->useThemeColors || !d->color.isValid()) { - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } return d->color; } -void QtMaterialIconButton::setDisabledColor(const QColor &color) +void IconButton::setDisabledColor(const QColor &color) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->disabledColor = color; @@ -119,17 +121,17 @@ void QtMaterialIconButton::setDisabledColor(const QColor &color) update(); } -QColor QtMaterialIconButton::disabledColor() const +QColor IconButton::disabledColor() const { - Q_D(const QtMaterialIconButton); + Q_D(const IconButton); if (d->useThemeColors || !d->disabledColor.isValid()) { - return QtMaterialStyle::instance().themeColor("disabled"); + return Style::instance().themeColor("disabled"); } return d->disabledColor; } -QtMaterialIconButton::QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent) +IconButton::IconButton(IconButtonPrivate &d, QWidget *parent) : QAbstractButton(parent), d_ptr(&d) { @@ -139,9 +141,9 @@ QtMaterialIconButton::QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidg /*! * \reimp */ -bool QtMaterialIconButton::event(QEvent *event) +bool IconButton::event(QEvent *event) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); switch (event->type()) { @@ -165,11 +167,11 @@ bool QtMaterialIconButton::event(QEvent *event) /*! * \reimp */ -bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) +bool IconButton::eventFilter(QObject *obj, QEvent *event) { if (QEvent::Resize == event->type()) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->updateRipple(); } @@ -179,9 +181,9 @@ bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event) /*! * \reimp */ -void QtMaterialIconButton::mousePressEvent(QMouseEvent *event) +void IconButton::mousePressEvent(QMouseEvent *event) { - Q_D(QtMaterialIconButton); + Q_D(IconButton); d->rippleOverlay->addRipple(QPoint(d->rippleOverlay->width(), d->rippleOverlay->height())/2, @@ -194,7 +196,7 @@ void QtMaterialIconButton::mousePressEvent(QMouseEvent *event) /*! * \reimp */ -void QtMaterialIconButton::paintEvent(QPaintEvent *event) +void IconButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -210,3 +212,5 @@ void QtMaterialIconButton::paintEvent(QPaintEvent *event) const qreal h = pixmap.height(); painter.drawPixmap(QRect((r.width()-w)/2, (r.height()-h)/2, w, h), pixmap); } + +} diff --git a/components/qtmaterialiconbutton.h b/components/iconbutton.h similarity index 53% rename from components/qtmaterialiconbutton.h rename to components/iconbutton.h index 5c2afc47b..f16d6ae5b 100644 --- a/components/qtmaterialiconbutton.h +++ b/components/iconbutton.h @@ -1,17 +1,20 @@ -#ifndef QTMATERIALICONBUTTON_H -#define QTMATERIALICONBUTTON_H +#ifndef ICONBUTTON_H +#define ICONBUTTON_H #include -class QtMaterialIconButtonPrivate; +namespace md +{ + +class IconButtonPrivate; -class QtMaterialIconButton : public QAbstractButton +class IconButton : public QAbstractButton { Q_OBJECT public: - explicit QtMaterialIconButton(const QIcon &icon, QWidget *parent = 0); - ~QtMaterialIconButton(); + explicit IconButton(const QIcon &icon, QWidget *parent = 0); + ~IconButton(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -25,18 +28,20 @@ class QtMaterialIconButton : public QAbstractButton QColor disabledColor() const; protected: - QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent = 0); + IconButton(IconButtonPrivate &d, QWidget *parent = 0); bool event(QEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialIconButton) - Q_DECLARE_PRIVATE(QtMaterialIconButton) + Q_DISABLE_COPY(IconButton) + Q_DECLARE_PRIVATE(IconButton) }; -#endif // QTMATERIALICONBUTTON_H +} + +#endif // ICONBUTTON_H diff --git a/components/iconbutton_p.h b/components/iconbutton_p.h new file mode 100644 index 000000000..ee27a0df4 --- /dev/null +++ b/components/iconbutton_p.h @@ -0,0 +1,33 @@ +#ifndef ICONBUTTON_P_H +#define ICONBUTTON_P_H + +#include +#include + +namespace md +{ +class IconButton; +class RippleOverlay; + +class IconButtonPrivate +{ + Q_DISABLE_COPY(IconButtonPrivate) + Q_DECLARE_PUBLIC(IconButton) + +public: + IconButtonPrivate(IconButton *q); + virtual ~IconButtonPrivate(); + + void init(); + void updateRipple(); + + IconButton *const q_ptr; + RippleOverlay *rippleOverlay; + QColor color; + QColor disabledColor; + bool useThemeColors; +}; + +} + +#endif // ICONBUTTON_P_H diff --git a/components/layouts/qtmaterialsnackbarlayout.cpp b/components/layouts/qtmaterialsnackbarlayout.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/layouts/qtmaterialsnackbarlayout.h b/components/layouts/qtmaterialsnackbarlayout.h deleted file mode 100644 index c194fec81..000000000 --- a/components/layouts/qtmaterialsnackbarlayout.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALSNACKBARLAYOUT_H -#define QTMATERIALSNACKBARLAYOUT_H - -#endif // QTMATERIALSNACKBARLAYOUT_H diff --git a/components/layouts/qtmaterialsnackbarlayout_p.h b/components/layouts/qtmaterialsnackbarlayout_p.h deleted file mode 100644 index 6c2dd5dcf..000000000 --- a/components/layouts/qtmaterialsnackbarlayout_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALSNACKBARLAYOUT_P_H -#define QTMATERIALSNACKBARLAYOUT_P_H - -#endif // QTMATERIALSNACKBARLAYOUT_P_H diff --git a/components/layouts/snackbarlayout.cpp b/components/layouts/snackbarlayout.cpp new file mode 100644 index 000000000..a18b06bb9 --- /dev/null +++ b/components/layouts/snackbarlayout.cpp @@ -0,0 +1,4 @@ +namespace md +{ + +} diff --git a/components/layouts/snackbarlayout.h b/components/layouts/snackbarlayout.h new file mode 100644 index 000000000..6a6dedc8a --- /dev/null +++ b/components/layouts/snackbarlayout.h @@ -0,0 +1,7 @@ +#ifndef SNACKBARLAYOUT_H +#define SNACKBARLAYOUT_H +namespace md +{ + +} +#endif // SNACKBARLAYOUT_H diff --git a/components/layouts/snackbarlayout_p.h b/components/layouts/snackbarlayout_p.h new file mode 100644 index 000000000..7aa4b1cb8 --- /dev/null +++ b/components/layouts/snackbarlayout_p.h @@ -0,0 +1,7 @@ +#ifndef SNACKBARLAYOUT_P_H +#define SNACKBARLAYOUT_P_H +namespace md +{ + +} +#endif // SNACKBARLAYOUT_P_H diff --git a/components/lib/qtmaterialcheckable.cpp b/components/lib/checkable.cpp similarity index 65% rename from components/lib/qtmaterialcheckable.cpp rename to components/lib/checkable.cpp index ee4e0bd88..2c778850f 100644 --- a/components/lib/qtmaterialcheckable.cpp +++ b/components/lib/checkable.cpp @@ -1,38 +1,33 @@ -#include "lib/qtmaterialcheckable.h" -#include "lib/qtmaterialcheckable_p.h" -#include -#include -#include -#include -#include -#include -#include -#include "lib/qtmaterialrippleoverlay.h" -#include "lib/qtmaterialripple.h" -#include "lib/qtmaterialstyle.h" -#include "lib/qtmaterialcheckable_internal.h" - +#include "lib/checkable.h" +#include "lib/checkable_p.h" +#include "lib/rippleoverlay.h" +#include "lib/ripple.h" +#include "lib/style.h" +#include "lib/checkable_internal.h" + +namespace md +{ /*! - * \class QtMaterialCheckablePrivate + * \class CheckablePrivate * \internal */ -QtMaterialCheckablePrivate::QtMaterialCheckablePrivate(QtMaterialCheckable *q) +CheckablePrivate::CheckablePrivate(Checkable *q) : q_ptr(q) { } -QtMaterialCheckablePrivate::~QtMaterialCheckablePrivate() +CheckablePrivate::~CheckablePrivate() { } -void QtMaterialCheckablePrivate::init() +void CheckablePrivate::init() { - Q_Q(QtMaterialCheckable); + Q_Q(Checkable); - rippleOverlay = new QtMaterialRippleOverlay; - checkedIcon = new QtMaterialCheckableIcon(QIcon(":/icons/icons/toggle/svg/production/ic_check_box_24px.svg"), q); - uncheckedIcon = new QtMaterialCheckableIcon(QIcon(":/icons/icons/toggle/svg/production/ic_check_box_outline_blank_24px.svg"), q); + rippleOverlay = new RippleOverlay; + checkedIcon = new CheckableIcon(QIcon(":/icons/icons/toggle/svg/production/ic_check_box_24px.svg"), q); + uncheckedIcon = new CheckableIcon(QIcon(":/icons/icons/toggle/svg/production/ic_check_box_outline_blank_24px.svg"), q); stateMachine = new QStateMachine(q); uncheckedState = new QState; checkedState = new QState; @@ -40,14 +35,14 @@ void QtMaterialCheckablePrivate::init() disabledCheckedState = new QState; uncheckedTransition = new QSignalTransition(q, SIGNAL(toggled(bool))); checkedTransition = new QSignalTransition(q, SIGNAL(toggled(bool))); - labelPosition = QtMaterialCheckable::LabelPositionRight; + labelPosition = Checkable::LabelPositionRight; useThemeColors = true; rippleOverlay->setParent(q->parentWidget()); rippleOverlay->installEventFilter(q); q->setCheckable(true); - q->setStyle(&QtMaterialStyle::instance()); + q->setStyle(&Style::instance()); q->setFont(QFont("Roboto", 11, QFont::Normal)); stateMachine->addState(uncheckedState); @@ -125,35 +120,35 @@ void QtMaterialCheckablePrivate::init() * \class QtMaterialCheckable */ -QtMaterialCheckable::QtMaterialCheckable(QWidget *parent) +Checkable::Checkable(QWidget *parent) : QAbstractButton(parent), - d_ptr(new QtMaterialCheckablePrivate(this)) + d_ptr(new CheckablePrivate(this)) { d_func()->init(); } -QtMaterialCheckable::~QtMaterialCheckable() +Checkable::~Checkable() { } -void QtMaterialCheckable::setLabelPosition(LabelPosition placement) +void Checkable::setLabelPosition(LabelPosition placement) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->labelPosition = placement; update(); } -QtMaterialCheckable::LabelPosition QtMaterialCheckable::labelPosition() const +Checkable::LabelPosition Checkable::labelPosition() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); return d->labelPosition; } -void QtMaterialCheckable::setUseThemeColors(bool value) +void Checkable::setUseThemeColors(bool value) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); if (d->useThemeColors == value) { return; @@ -163,16 +158,16 @@ void QtMaterialCheckable::setUseThemeColors(bool value) setupProperties(); } -bool QtMaterialCheckable::useThemeColors() const +bool Checkable::useThemeColors() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); return d->useThemeColors; } -void QtMaterialCheckable::setCheckedColor(const QColor &color) +void Checkable::setCheckedColor(const QColor &color) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->checkedColor = color; @@ -180,20 +175,20 @@ void QtMaterialCheckable::setCheckedColor(const QColor &color) setupProperties(); } -QColor QtMaterialCheckable::checkedColor() const +QColor Checkable::checkedColor() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); if (d->useThemeColors || !d->checkedColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->checkedColor; } } -void QtMaterialCheckable::setUncheckedColor(const QColor &color) +void Checkable::setUncheckedColor(const QColor &color) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->uncheckedColor = color; @@ -201,20 +196,20 @@ void QtMaterialCheckable::setUncheckedColor(const QColor &color) setupProperties(); } -QColor QtMaterialCheckable::uncheckedColor() const +QColor Checkable::uncheckedColor() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); if (d->useThemeColors || !d->uncheckedColor.isValid()) { - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } else { return d->uncheckedColor; } } -void QtMaterialCheckable::setTextColor(const QColor &color) +void Checkable::setTextColor(const QColor &color) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->textColor = color; @@ -222,20 +217,20 @@ void QtMaterialCheckable::setTextColor(const QColor &color) setupProperties(); } -QColor QtMaterialCheckable::textColor() const +QColor Checkable::textColor() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } else { return d->textColor; } } -void QtMaterialCheckable::setDisabledColor(const QColor &color) +void Checkable::setDisabledColor(const QColor &color) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->disabledColor = color; @@ -243,43 +238,43 @@ void QtMaterialCheckable::setDisabledColor(const QColor &color) setupProperties(); } -QColor QtMaterialCheckable::disabledColor() const +QColor Checkable::disabledColor() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); if (d->useThemeColors || !d->disabledColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent3"); + return Style::instance().themeColor("accent3"); } else { return d->disabledColor; } } -void QtMaterialCheckable::setCheckedIcon(const QIcon &icon) +void Checkable::setCheckedIcon(const QIcon &icon) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->checkedIcon->setIcon(icon); update(); } -QIcon QtMaterialCheckable::checkedIcon() const +QIcon Checkable::checkedIcon() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); return d->checkedIcon->icon(); } -void QtMaterialCheckable::setUncheckedIcon(const QIcon &icon) +void Checkable::setUncheckedIcon(const QIcon &icon) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->uncheckedIcon->setIcon(icon); update(); } -QIcon QtMaterialCheckable::uncheckedIcon() const +QIcon Checkable::uncheckedIcon() const { - Q_D(const QtMaterialCheckable); + Q_D(const Checkable); return d->uncheckedIcon->icon(); } @@ -287,7 +282,7 @@ QIcon QtMaterialCheckable::uncheckedIcon() const /*! * \reimp */ -QSize QtMaterialCheckable::sizeHint() const +QSize Checkable::sizeHint() const { if (text().isEmpty()) { return QSize(40, 40); @@ -295,7 +290,7 @@ QSize QtMaterialCheckable::sizeHint() const return QSize(fontMetrics().size(Qt::TextShowMnemonic, text()).width()+52, 40); } -QtMaterialCheckable::QtMaterialCheckable(QtMaterialCheckablePrivate &d, QWidget *parent) +Checkable::Checkable(CheckablePrivate &d, QWidget *parent) : QAbstractButton(parent), d_ptr(&d) { @@ -305,9 +300,9 @@ QtMaterialCheckable::QtMaterialCheckable(QtMaterialCheckablePrivate &d, QWidget /*! * \reimp */ -bool QtMaterialCheckable::event(QEvent *event) +bool Checkable::event(QEvent *event) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); switch (event->type()) { @@ -332,11 +327,11 @@ bool QtMaterialCheckable::event(QEvent *event) /*! * \reimp */ -bool QtMaterialCheckable::eventFilter(QObject *obj, QEvent *event) +bool Checkable::eventFilter(QObject *obj, QEvent *event) { if (QEvent::Resize == event->type()) { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8)); } @@ -346,21 +341,21 @@ bool QtMaterialCheckable::eventFilter(QObject *obj, QEvent *event) /*! * \reimp */ -void QtMaterialCheckable::mousePressEvent(QMouseEvent *event) +void Checkable::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialCheckable); + Q_D(Checkable); if (!isEnabled()) { return; } - QtMaterialRipple *ripple; - if (QtMaterialCheckable::LabelPositionLeft == d->labelPosition) { - ripple = new QtMaterialRipple(QPoint(width()-14, 28)); + Ripple *ripple; + if (Checkable::LabelPositionLeft == d->labelPosition) { + ripple = new Ripple(QPoint(width()-14, 28)); } else { - ripple = new QtMaterialRipple(QPoint(28, 28)); + ripple = new Ripple(QPoint(28, 28)); } ripple->setRadiusEndValue(22); ripple->setColor(isChecked() ? checkedColor() : uncheckedColor()); @@ -375,11 +370,11 @@ void QtMaterialCheckable::mousePressEvent(QMouseEvent *event) /*! * \reimp */ -void QtMaterialCheckable::paintEvent(QPaintEvent *event) +void Checkable::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialCheckable); + Q_D(Checkable); QPainter painter(this); @@ -387,16 +382,16 @@ void QtMaterialCheckable::paintEvent(QPaintEvent *event) pen.setColor(isEnabled() ? textColor() : disabledColor()); painter.setPen(pen); - if (QtMaterialCheckable::LabelPositionLeft == d->labelPosition) { + if (Checkable::LabelPositionLeft == d->labelPosition) { painter.drawText(4, 25, text()); } else { painter.drawText(48, 25, text()); } } -void QtMaterialCheckable::setupProperties() +void Checkable::setupProperties() { - Q_D(QtMaterialCheckable); + Q_D(Checkable); d->checkedState->assignProperty(d->checkedIcon, "color", checkedColor()); d->checkedState->assignProperty(d->uncheckedIcon, "color", checkedColor()); @@ -417,3 +412,5 @@ void QtMaterialCheckable::setupProperties() update(); } + +} diff --git a/components/lib/qtmaterialcheckable.h b/components/lib/checkable.h similarity index 70% rename from components/lib/qtmaterialcheckable.h rename to components/lib/checkable.h index c4cc57469..aa3b800e2 100644 --- a/components/lib/qtmaterialcheckable.h +++ b/components/lib/checkable.h @@ -1,11 +1,12 @@ -#ifndef QTMATERIALCHECKABLE_H -#define QTMATERIALCHECKABLE_H +#ifndef CHECKABLE_H +#define CHECKABLE_H #include +namespace md +{ +class CheckablePrivate; -class QtMaterialCheckablePrivate; - -class QtMaterialCheckable : public QAbstractButton +class Checkable : public QAbstractButton { Q_OBJECT @@ -15,8 +16,8 @@ class QtMaterialCheckable : public QAbstractButton LabelPositionRight, }; - explicit QtMaterialCheckable(QWidget *parent = 0); - ~QtMaterialCheckable(); + explicit Checkable(QWidget *parent = 0); + ~Checkable(); void setLabelPosition(LabelPosition placement); LabelPosition labelPosition() const; @@ -45,7 +46,7 @@ class QtMaterialCheckable : public QAbstractButton QSize sizeHint() const Q_DECL_OVERRIDE; protected: - QtMaterialCheckable(QtMaterialCheckablePrivate &d, QWidget *parent = 0); + Checkable(CheckablePrivate &d, QWidget *parent = 0); bool event(QEvent *event) Q_DECL_OVERRIDE; bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; @@ -54,11 +55,12 @@ class QtMaterialCheckable : public QAbstractButton virtual void setupProperties(); - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialCheckable) - Q_DECLARE_PRIVATE(QtMaterialCheckable) + Q_DISABLE_COPY(Checkable) + Q_DECLARE_PRIVATE(Checkable) }; +} -#endif // QTMATERIALCHECKABLE_H +#endif // CHECKABLE_H diff --git a/components/lib/qtmaterialcheckable_internal.cpp b/components/lib/checkable_internal.cpp similarity index 71% rename from components/lib/qtmaterialcheckable_internal.cpp rename to components/lib/checkable_internal.cpp index 4a7eb9a72..1977e0414 100644 --- a/components/lib/qtmaterialcheckable_internal.cpp +++ b/components/lib/checkable_internal.cpp @@ -1,15 +1,17 @@ -#include "lib/qtmaterialcheckable_internal.h" +#include "lib/checkable_internal.h" #include #include #include -#include "lib/qtmaterialcheckable.h" +#include "lib/checkable.h" +namespace md +{ /*! * \class QtMaterialCheckableIcon * \internal */ -QtMaterialCheckableIcon::QtMaterialCheckableIcon(const QIcon &icon, QtMaterialCheckable *parent) +CheckableIcon::CheckableIcon(const QIcon &icon, Checkable *parent) : QWidget(parent), m_checkable(parent), m_color(Qt::black), @@ -22,16 +24,16 @@ QtMaterialCheckableIcon::QtMaterialCheckableIcon(const QIcon &icon, QtMaterialCh setAttribute(Qt::WA_TransparentForMouseEvents); } -QtMaterialCheckableIcon::~QtMaterialCheckableIcon() +CheckableIcon::~CheckableIcon() { } -QSize QtMaterialCheckableIcon::sizeHint() const +QSize CheckableIcon::sizeHint() const { return QSize(m_iconSize, m_iconSize); } -void QtMaterialCheckableIcon::paintEvent(QPaintEvent *event) +void CheckableIcon::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -47,7 +49,7 @@ void QtMaterialCheckableIcon::paintEvent(QPaintEvent *event) const qreal z = m_iconSize/24; QTransform t; - if (QtMaterialCheckable::LabelPositionLeft == m_checkable->labelPosition()) { + if (Checkable::LabelPositionLeft == m_checkable->labelPosition()) { t.translate(p+width()-42, p); } else { t.translate(p, p); @@ -61,3 +63,5 @@ void QtMaterialCheckableIcon::paintEvent(QPaintEvent *event) painter.drawPixmap(0, 0, pixmap); } } + +} diff --git a/components/lib/qtmaterialcheckable_internal.h b/components/lib/checkable_internal.h similarity index 57% rename from components/lib/qtmaterialcheckable_internal.h rename to components/lib/checkable_internal.h index 3fb3d947d..1aa7d9808 100644 --- a/components/lib/qtmaterialcheckable_internal.h +++ b/components/lib/checkable_internal.h @@ -1,13 +1,15 @@ -#ifndef QTMATERIALCHECKABLE_INTERNAL_H -#define QTMATERIALCHECKABLE_INTERNAL_H +#ifndef CHECKABLE_INTERNAL_H +#define CHECKABLE_INTERNAL_H #include #include #include -class QtMaterialCheckable; +namespace md +{ +class Checkable; -class QtMaterialCheckableIcon : public QWidget +class CheckableIcon : public QWidget { Q_OBJECT @@ -16,8 +18,8 @@ class QtMaterialCheckableIcon : public QWidget Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: - QtMaterialCheckableIcon(const QIcon &icon, QtMaterialCheckable *parent); - ~QtMaterialCheckableIcon(); + CheckableIcon(const QIcon &icon, Checkable *parent); + ~CheckableIcon(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -37,57 +39,58 @@ class QtMaterialCheckableIcon : public QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialCheckableIcon) + Q_DISABLE_COPY(CheckableIcon) - QtMaterialCheckable *const m_checkable; + Checkable *const m_checkable; QColor m_color; QIcon m_icon; qreal m_iconSize; qreal m_opacity; }; -inline void QtMaterialCheckableIcon::setIcon(const QIcon &icon) +inline void CheckableIcon::setIcon(const QIcon &icon) { m_icon = icon; update(); } -inline QIcon QtMaterialCheckableIcon::icon() const +inline QIcon CheckableIcon::icon() const { return m_icon; } -inline void QtMaterialCheckableIcon::setColor(const QColor &color) +inline void CheckableIcon::setColor(const QColor &color) { m_color = color; update(); } -inline QColor QtMaterialCheckableIcon::color() const +inline QColor CheckableIcon::color() const { return m_color; } -inline void QtMaterialCheckableIcon::setIconSize(qreal size) +inline void CheckableIcon::setIconSize(qreal size) { m_iconSize = size; update(); } -inline qreal QtMaterialCheckableIcon::iconSize() const +inline qreal CheckableIcon::iconSize() const { return m_iconSize; } -inline void QtMaterialCheckableIcon::setOpacity(qreal opacity) +inline void CheckableIcon::setOpacity(qreal opacity) { m_opacity = opacity; update(); } -inline qreal QtMaterialCheckableIcon::opacity() const +inline qreal CheckableIcon::opacity() const { return m_opacity; } +} -#endif // QTMATERIALCHECKABLE_INTERNAL_H +#endif // CHECKABLE_INTERNAL_H diff --git a/components/lib/checkable_p.h b/components/lib/checkable_p.h new file mode 100644 index 000000000..5c8854774 --- /dev/null +++ b/components/lib/checkable_p.h @@ -0,0 +1,51 @@ +#ifndef CHECKABLE_P_H +#define CHECKABLE_P_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lib/checkable.h" + +namespace md +{ +class RippleOverlay; +class CheckableIcon; + +class CheckablePrivate +{ + Q_DISABLE_COPY(CheckablePrivate) + Q_DECLARE_PUBLIC(Checkable) + +public: + CheckablePrivate(Checkable *q); + virtual ~CheckablePrivate(); + + void init(); + + Checkable *const q_ptr; + RippleOverlay *rippleOverlay; + CheckableIcon *checkedIcon; + CheckableIcon *uncheckedIcon; + QStateMachine *stateMachine; + QState *uncheckedState; + QState *checkedState; + QState *disabledUncheckedState; + QState *disabledCheckedState; + QSignalTransition *uncheckedTransition; + QSignalTransition *checkedTransition; + Checkable::LabelPosition labelPosition; + QColor checkedColor; + QColor uncheckedColor; + QColor textColor; + QColor disabledColor; + bool useThemeColors; +}; +} + +#endif // CHECKABLE_P_H diff --git a/components/lib/qtmaterialoverlaywidget.cpp b/components/lib/overlaywidget.cpp similarity index 71% rename from components/lib/qtmaterialoverlaywidget.cpp rename to components/lib/overlaywidget.cpp index ec0e7fedb..1dd5deb1f 100644 --- a/components/lib/qtmaterialoverlaywidget.cpp +++ b/components/lib/overlaywidget.cpp @@ -1,12 +1,14 @@ -#include "lib/qtmaterialoverlaywidget.h" +#include "lib/overlaywidget.h" #include +namespace md +{ /*! - * \class QtMaterialOverlayWidget + * \class OverlayWidget * \internal */ -QtMaterialOverlayWidget::QtMaterialOverlayWidget(QWidget *parent) +OverlayWidget::OverlayWidget(QWidget *parent) : QWidget(parent) { if (parent) { @@ -14,14 +16,14 @@ QtMaterialOverlayWidget::QtMaterialOverlayWidget(QWidget *parent) } } -QtMaterialOverlayWidget::~QtMaterialOverlayWidget() +OverlayWidget::~OverlayWidget() { } /*! * \reimp */ -bool QtMaterialOverlayWidget::event(QEvent *event) +bool OverlayWidget::event(QEvent *event) { if (!parent()) { return QWidget::event(event); @@ -48,7 +50,7 @@ bool QtMaterialOverlayWidget::event(QEvent *event) /*! * \reimp */ -bool QtMaterialOverlayWidget::eventFilter(QObject *obj, QEvent *event) +bool OverlayWidget::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { @@ -62,7 +64,7 @@ bool QtMaterialOverlayWidget::eventFilter(QObject *obj, QEvent *event) return QWidget::eventFilter(obj, event); } -QRect QtMaterialOverlayWidget::overlayGeometry() const +QRect OverlayWidget::overlayGeometry() const { QWidget *widget = parentWidget(); if (!widget) { @@ -70,3 +72,5 @@ QRect QtMaterialOverlayWidget::overlayGeometry() const } return widget->rect(); } + +} diff --git a/components/lib/overlaywidget.h b/components/lib/overlaywidget.h new file mode 100644 index 000000000..3b6743b6a --- /dev/null +++ b/components/lib/overlaywidget.h @@ -0,0 +1,27 @@ +#ifndef OVERLAYWIDGET_H +#define OVERLAYWIDGET_H + +#include + +namespace md +{ +class OverlayWidget : public QWidget +{ + Q_OBJECT + +public: + explicit OverlayWidget(QWidget *parent = 0); + ~OverlayWidget(); + +protected: + bool event(QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; + + virtual QRect overlayGeometry() const; + +private: + Q_DISABLE_COPY(OverlayWidget) +}; +} + +#endif // OVERLAYWIDGET_H diff --git a/components/lib/qtmaterialcheckable_p.h b/components/lib/qtmaterialcheckable_p.h deleted file mode 100644 index e678df70f..000000000 --- a/components/lib/qtmaterialcheckable_p.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef QTMATERIALCHECKABLE_P_H -#define QTMATERIALCHECKABLE_P_H - -#include -#include "lib/qtmaterialcheckable.h" - -class QStateMachine; -class QState; -class QSignalTransition; -class QtMaterialRippleOverlay; -class QtMaterialCheckableIcon; - -class QtMaterialCheckablePrivate -{ - Q_DISABLE_COPY(QtMaterialCheckablePrivate) - Q_DECLARE_PUBLIC(QtMaterialCheckable) - -public: - QtMaterialCheckablePrivate(QtMaterialCheckable *q); - virtual ~QtMaterialCheckablePrivate(); - - void init(); - - QtMaterialCheckable *const q_ptr; - QtMaterialRippleOverlay *rippleOverlay; - QtMaterialCheckableIcon *checkedIcon; - QtMaterialCheckableIcon *uncheckedIcon; - QStateMachine *stateMachine; - QState *uncheckedState; - QState *checkedState; - QState *disabledUncheckedState; - QState *disabledCheckedState; - QSignalTransition *uncheckedTransition; - QSignalTransition *checkedTransition; - QtMaterialCheckable::LabelPosition labelPosition; - QColor checkedColor; - QColor uncheckedColor; - QColor textColor; - QColor disabledColor; - bool useThemeColors; -}; - -#endif // QTMATERIALCHECKABLE_P_H diff --git a/components/lib/qtmaterialoverlaywidget.h b/components/lib/qtmaterialoverlaywidget.h deleted file mode 100644 index 11acba020..000000000 --- a/components/lib/qtmaterialoverlaywidget.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QTMATERIALOVERLAYWIDGET_H -#define QTMATERIALOVERLAYWIDGET_H - -#include - -class QtMaterialOverlayWidget : public QWidget -{ - Q_OBJECT - -public: - explicit QtMaterialOverlayWidget(QWidget *parent = 0); - ~QtMaterialOverlayWidget(); - -protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; - - virtual QRect overlayGeometry() const; - -private: - Q_DISABLE_COPY(QtMaterialOverlayWidget) -}; - -#endif // QTMATERIALOVERLAYWIDGET_H diff --git a/components/lib/qtmaterialrippleoverlay.h b/components/lib/qtmaterialrippleoverlay.h deleted file mode 100644 index 436c2b932..000000000 --- a/components/lib/qtmaterialrippleoverlay.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef QTMATERIALRIPPLEOVERLAY_H -#define QTMATERIALRIPPLEOVERLAY_H - -#include -#include "lib/qtmaterialoverlaywidget.h" - -class QtMaterialRipple; - -class QtMaterialRippleOverlay : public QtMaterialOverlayWidget -{ - Q_OBJECT - -public: - explicit QtMaterialRippleOverlay(QWidget *parent = 0); - ~QtMaterialRippleOverlay(); - - void addRipple(QtMaterialRipple *ripple); - void addRipple(const QPoint &position, qreal radius = 300); - - void removeRipple(QtMaterialRipple *ripple); - - inline void setClipping(bool enable); - inline bool hasClipping() const; - - inline void setClipPath(const QPainterPath &path); - -protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - - inline QList ripples() const; - -private: - Q_DISABLE_COPY(QtMaterialRippleOverlay) - - void paintRipple(QPainter *painter, QtMaterialRipple *ripple); - - QList m_ripples; - QPainterPath m_clipPath; - bool m_useClip; -}; - -inline void QtMaterialRippleOverlay::setClipping(bool enable) -{ - m_useClip = enable; - update(); -} - -inline bool QtMaterialRippleOverlay::hasClipping() const -{ - return m_useClip; -} - -inline void QtMaterialRippleOverlay::setClipPath(const QPainterPath &path) -{ - m_clipPath = path; - update(); -} - -inline QList QtMaterialRippleOverlay::ripples() const -{ - return m_ripples; -} - -#endif // QTMATERIALRIPPLEOVERLAY_H diff --git a/components/lib/qtmaterialstatetransition.cpp b/components/lib/qtmaterialstatetransition.cpp deleted file mode 100644 index 75f1faf06..000000000 --- a/components/lib/qtmaterialstatetransition.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "lib/qtmaterialstatetransition.h" - -QtMaterialStateTransition::QtMaterialStateTransition(QtMaterialStateTransitionType type) - : m_type(type) -{ -} - -bool QtMaterialStateTransition::eventTest(QEvent *event) -{ - if (event->type() != QEvent::Type(QEvent::User + 1)) { - return false; - } - QtMaterialStateTransitionEvent *transition = static_cast(event); - return (m_type == transition->type); -} - -void QtMaterialStateTransition::onTransition(QEvent *) -{ -} diff --git a/components/lib/qtmaterialstatetransition.h b/components/lib/qtmaterialstatetransition.h deleted file mode 100644 index d5013022b..000000000 --- a/components/lib/qtmaterialstatetransition.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef QTMATERIALSTATETRANSITION_H -#define QTMATERIALSTATETRANSITION_H - -#include -#include "lib/qtmaterialstatetransitionevent.h" - -class QtMaterialStateTransition : public QAbstractTransition -{ - Q_OBJECT - -public: - QtMaterialStateTransition(QtMaterialStateTransitionType type); - -protected: - virtual bool eventTest(QEvent *event); - virtual void onTransition(QEvent *); - -private: - QtMaterialStateTransitionType m_type; -}; - -#endif // QTMATERIALSTATETRANSITION_H diff --git a/components/lib/qtmaterialstyle.cpp b/components/lib/qtmaterialstyle.cpp deleted file mode 100644 index 83bbab8ae..000000000 --- a/components/lib/qtmaterialstyle.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "lib/qtmaterialstyle.h" -#include -#include "lib/qtmaterialtheme.h" - -/*! - * \class QtMaterialStylePrivate - * \internal - */ - -QtMaterialStylePrivate::QtMaterialStylePrivate(QtMaterialStyle *q) - : q_ptr(q) -{ -} - -QtMaterialStylePrivate::~QtMaterialStylePrivate() -{ -} - -void QtMaterialStylePrivate::init() -{ - Q_Q(QtMaterialStyle); - - QFontDatabase::addApplicationFont(":/fonts/roboto_regular"); - QFontDatabase::addApplicationFont(":/fonts/roboto_medium"); - QFontDatabase::addApplicationFont(":/fonts/roboto_bold"); - - q->setTheme(new QtMaterialTheme); -} - -/*! - * \class QtMaterialStyle - * \internal - */ - -void QtMaterialStyle::setTheme(QtMaterialTheme *theme) -{ - Q_D(QtMaterialStyle); - - d->theme = theme; - theme->setParent(this); -} - -QColor QtMaterialStyle::themeColor(const QString &key) const -{ - Q_D(const QtMaterialStyle); - - Q_ASSERT(d->theme); - - return d->theme->getColor(key); -} - -QtMaterialStyle::QtMaterialStyle() - : QCommonStyle(), - d_ptr(new QtMaterialStylePrivate(this)) -{ - d_func()->init(); -} diff --git a/components/lib/qtmaterialstyle.h b/components/lib/qtmaterialstyle.h deleted file mode 100644 index e16289b0f..000000000 --- a/components/lib/qtmaterialstyle.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef QTMATERIALSTYLE_H -#define QTMATERIALSTYLE_H - -#include -#include "lib/qtmaterialstyle_p.h" - -#define MATERIAL_DISABLE_THEME_COLORS \ - if (d->useThemeColors == true) { d->useThemeColors = false; } - -class QtMaterialTheme; - -class QtMaterialStyle : public QCommonStyle -{ - Q_OBJECT - -public: - inline static QtMaterialStyle &instance(); - - void setTheme(QtMaterialTheme *theme); - QColor themeColor(const QString &key) const; - -protected: - const QScopedPointer d_ptr; - -private: - Q_DECLARE_PRIVATE(QtMaterialStyle) - - QtMaterialStyle(); - - QtMaterialStyle(QtMaterialStyle const &); - void operator=(QtMaterialStyle const &); -}; - -inline QtMaterialStyle &QtMaterialStyle::instance() -{ - static QtMaterialStyle instance; - return instance; -} - -#endif // QTMATERIALSTYLE_H diff --git a/components/lib/qtmaterialstyle_p.h b/components/lib/qtmaterialstyle_p.h deleted file mode 100644 index d59ca4198..000000000 --- a/components/lib/qtmaterialstyle_p.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QTMATERIALSTYLE_P_H -#define QTMATERIALSTYLE_P_H - -#include - -class QtMaterialStyle; -class QtMaterialTheme; - -class QtMaterialStylePrivate -{ - Q_DISABLE_COPY(QtMaterialStylePrivate) - Q_DECLARE_PUBLIC(QtMaterialStyle) - -public: - QtMaterialStylePrivate(QtMaterialStyle *q); - ~QtMaterialStylePrivate(); - - void init(); - - QtMaterialStyle *const q_ptr; - QtMaterialTheme *theme; -}; - -#endif // QTMATERIALSTYLE_P_H diff --git a/components/lib/qtmaterialtheme_p.h b/components/lib/qtmaterialtheme_p.h deleted file mode 100644 index d0ef17839..000000000 --- a/components/lib/qtmaterialtheme_p.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QTMATERIALTHEME_P_H -#define QTMATERIALTHEME_P_H - -#include -#include - -class QtMaterialTheme; - -class QtMaterialThemePrivate -{ - Q_DISABLE_COPY(QtMaterialThemePrivate) - Q_DECLARE_PUBLIC(QtMaterialTheme) - -public: - QtMaterialThemePrivate(QtMaterialTheme *q); - ~QtMaterialThemePrivate(); - - QColor rgba(int r, int g, int b, qreal a) const; - - QtMaterialTheme *const q_ptr; - QHash colors; -}; - -#endif // QTMATERIALTHEME_P_H diff --git a/components/lib/qtmaterialripple.cpp b/components/lib/ripple.cpp similarity index 72% rename from components/lib/qtmaterialripple.cpp rename to components/lib/ripple.cpp index 82125cbf8..6fcc6e7c1 100644 --- a/components/lib/qtmaterialripple.cpp +++ b/components/lib/ripple.cpp @@ -1,12 +1,14 @@ -#include "qtmaterialripple.h" -#include "lib/qtmaterialrippleoverlay.h" +#include "ripple.h" +#include "lib/rippleoverlay.h" +namespace md +{ /*! - * \class QtMaterialRipple + * \class Ripple * \internal */ -QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, QObject *parent) +Ripple::Ripple(const QPoint ¢er, QObject *parent) : QParallelAnimationGroup(parent), m_overlay(0), m_radiusAnimation(animate("radius")), @@ -18,8 +20,8 @@ QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, QObject *parent) init(); } -QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, - QtMaterialRippleOverlay *overlay, +Ripple::Ripple(const QPoint ¢er, + RippleOverlay *overlay, QObject *parent) : QParallelAnimationGroup(parent), m_overlay(overlay), @@ -32,11 +34,11 @@ QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, init(); } -QtMaterialRipple::~QtMaterialRipple() +Ripple::~Ripple() { } -void QtMaterialRipple::setRadius(qreal radius) +void Ripple::setRadius(qreal radius) { Q_ASSERT(m_overlay); @@ -47,7 +49,7 @@ void QtMaterialRipple::setRadius(qreal radius) m_overlay->update(); } -void QtMaterialRipple::setOpacity(qreal opacity) +void Ripple::setOpacity(qreal opacity) { Q_ASSERT(m_overlay); @@ -58,7 +60,7 @@ void QtMaterialRipple::setOpacity(qreal opacity) m_overlay->update(); } -void QtMaterialRipple::setColor(const QColor &color) +void Ripple::setColor(const QColor &color) { if (m_brush.color() == color) { return; @@ -70,7 +72,7 @@ void QtMaterialRipple::setColor(const QColor &color) } } -void QtMaterialRipple::setBrush(const QBrush &brush) +void Ripple::setBrush(const QBrush &brush) { m_brush = brush; @@ -79,7 +81,7 @@ void QtMaterialRipple::setBrush(const QBrush &brush) } } -void QtMaterialRipple::destroy() +void Ripple::destroy() { Q_ASSERT(m_overlay); @@ -89,7 +91,7 @@ void QtMaterialRipple::destroy() /*! * \internal */ -QPropertyAnimation *QtMaterialRipple::animate(const QByteArray &property, +QPropertyAnimation *Ripple::animate(const QByteArray &property, const QEasingCurve &easing, int duration) { @@ -105,7 +107,7 @@ QPropertyAnimation *QtMaterialRipple::animate(const QByteArray &property, /*! * \internal */ -void QtMaterialRipple::init() +void Ripple::init() { setOpacityStartValue(0.5); setOpacityEndValue(0); @@ -117,3 +119,5 @@ void QtMaterialRipple::init() connect(this, SIGNAL(finished()), this, SLOT(destroy())); } + +} diff --git a/components/lib/qtmaterialripple.h b/components/lib/ripple.h similarity index 61% rename from components/lib/qtmaterialripple.h rename to components/lib/ripple.h index d263c76fc..ac7ef6062 100644 --- a/components/lib/qtmaterialripple.h +++ b/components/lib/ripple.h @@ -1,5 +1,5 @@ -#ifndef QTMATERIALRIPPLE_H -#define QTMATERIALRIPPLE_H +#ifndef RIPPLE_H +#define RIPPLE_H #include #include @@ -7,9 +7,11 @@ #include #include -class QtMaterialRippleOverlay; +namespace md +{ +class RippleOverlay; -class QtMaterialRipple : public QParallelAnimationGroup +class Ripple : public QParallelAnimationGroup { Q_OBJECT @@ -17,11 +19,11 @@ class QtMaterialRipple : public QParallelAnimationGroup Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity) public: - explicit QtMaterialRipple(const QPoint ¢er, QObject *parent = 0); - QtMaterialRipple(const QPoint ¢er, QtMaterialRippleOverlay *overlay, QObject *parent = 0); - ~QtMaterialRipple(); + explicit Ripple(const QPoint ¢er, QObject *parent = 0); + Ripple(const QPoint ¢er, RippleOverlay *overlay, QObject *parent = 0); + ~Ripple(); - inline void setOverlay(QtMaterialRippleOverlay *overlay); + inline void setOverlay(RippleOverlay *overlay); void setRadius(qreal radius); inline qreal radius() const; @@ -50,7 +52,7 @@ protected slots: void destroy(); private: - Q_DISABLE_COPY(QtMaterialRipple) + Q_DISABLE_COPY(Ripple) QPropertyAnimation *animate(const QByteArray &property, const QEasingCurve &easing = QEasingCurve::OutQuad, @@ -58,7 +60,7 @@ protected slots: void init(); - QtMaterialRippleOverlay *m_overlay; + RippleOverlay *m_overlay; QPropertyAnimation *const m_radiusAnimation; QPropertyAnimation *const m_opacityAnimation; qreal m_radius; @@ -67,70 +69,71 @@ protected slots: QBrush m_brush; }; -inline void QtMaterialRipple::setOverlay(QtMaterialRippleOverlay *overlay) +inline void Ripple::setOverlay(RippleOverlay *overlay) { m_overlay = overlay; } -inline qreal QtMaterialRipple::radius() const +inline qreal Ripple::radius() const { return m_radius; } -inline qreal QtMaterialRipple::opacity() const +inline qreal Ripple::opacity() const { return m_opacity; } -inline QColor QtMaterialRipple::color() const +inline QColor Ripple::color() const { return m_brush.color(); } -inline QBrush QtMaterialRipple::brush() const +inline QBrush Ripple::brush() const { return m_brush; } -inline QPoint QtMaterialRipple::center() const +inline QPoint Ripple::center() const { return m_center; } -inline QPropertyAnimation *QtMaterialRipple::radiusAnimation() const +inline QPropertyAnimation *Ripple::radiusAnimation() const { return m_radiusAnimation; } -inline QPropertyAnimation *QtMaterialRipple::opacityAnimation() const +inline QPropertyAnimation *Ripple::opacityAnimation() const { return m_opacityAnimation; } -inline void QtMaterialRipple::setOpacityStartValue(qreal value) +inline void Ripple::setOpacityStartValue(qreal value) { m_opacityAnimation->setStartValue(value); } -inline void QtMaterialRipple::setOpacityEndValue(qreal value) +inline void Ripple::setOpacityEndValue(qreal value) { m_opacityAnimation->setEndValue(value); } -inline void QtMaterialRipple::setRadiusStartValue(qreal value) +inline void Ripple::setRadiusStartValue(qreal value) { m_radiusAnimation->setStartValue(value); } -inline void QtMaterialRipple::setRadiusEndValue(qreal value) +inline void Ripple::setRadiusEndValue(qreal value) { m_radiusAnimation->setEndValue(value); } -inline void QtMaterialRipple::setDuration(int msecs) +inline void Ripple::setDuration(int msecs) { m_radiusAnimation->setDuration(msecs); m_opacityAnimation->setDuration(msecs); } +} -#endif // QTMATERIALRIPPLE_H +#endif // RIPPLE_H diff --git a/components/lib/qtmaterialrippleoverlay.cpp b/components/lib/rippleoverlay.cpp similarity index 62% rename from components/lib/qtmaterialrippleoverlay.cpp rename to components/lib/rippleoverlay.cpp index 062d215bc..ec0fb0c68 100644 --- a/components/lib/qtmaterialrippleoverlay.cpp +++ b/components/lib/rippleoverlay.cpp @@ -1,25 +1,27 @@ -#include "lib/qtmaterialrippleoverlay.h" +#include "lib/rippleoverlay.h" #include -#include "lib/qtmaterialripple.h" +#include "lib/ripple.h" +namespace md +{ /*! * \class QtMaterialRippleOverlay * \internal */ -QtMaterialRippleOverlay::QtMaterialRippleOverlay(QWidget *parent) - : QtMaterialOverlayWidget(parent), +RippleOverlay::RippleOverlay(QWidget *parent) + : OverlayWidget(parent), m_useClip(false) { setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_NoSystemBackground); } -QtMaterialRippleOverlay::~QtMaterialRippleOverlay() +RippleOverlay::~RippleOverlay() { } -void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple) +void RippleOverlay::addRipple(Ripple *ripple) { ripple->setOverlay(this); m_ripples.push_back(ripple); @@ -29,14 +31,14 @@ void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple) connect(this, SIGNAL(destroyed(QObject*)), ripple, SLOT(deleteLater())); } -void QtMaterialRippleOverlay::addRipple(const QPoint &position, qreal radius) +void RippleOverlay::addRipple(const QPoint &position, qreal radius) { - QtMaterialRipple *ripple = new QtMaterialRipple(position); + Ripple *ripple = new Ripple(position); ripple->setRadiusEndValue(radius); addRipple(ripple); } -void QtMaterialRippleOverlay::removeRipple(QtMaterialRipple *ripple) +void RippleOverlay::removeRipple(Ripple *ripple) { if (m_ripples.removeOne(ripple)) { delete ripple; @@ -47,7 +49,7 @@ void QtMaterialRippleOverlay::removeRipple(QtMaterialRipple *ripple) /*! * \reimp */ -void QtMaterialRippleOverlay::paintEvent(QPaintEvent *event) +void RippleOverlay::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -59,13 +61,13 @@ void QtMaterialRippleOverlay::paintEvent(QPaintEvent *event) painter.setClipPath(m_clipPath); } - QList::const_iterator i; + QList::const_iterator i; for (i = m_ripples.begin(); i != m_ripples.end(); ++i) { paintRipple(&painter, *i); } } -void QtMaterialRippleOverlay::paintRipple(QPainter *painter, QtMaterialRipple *ripple) +void RippleOverlay::paintRipple(QPainter *painter, Ripple *ripple) { const qreal radius = ripple->radius(); const QPointF center = ripple->center(); @@ -73,3 +75,5 @@ void QtMaterialRippleOverlay::paintRipple(QPainter *painter, QtMaterialRipple *r painter->setBrush(ripple->brush()); painter->drawEllipse(center, radius, radius); } + +} diff --git a/components/lib/rippleoverlay.h b/components/lib/rippleoverlay.h new file mode 100644 index 000000000..d46e221ad --- /dev/null +++ b/components/lib/rippleoverlay.h @@ -0,0 +1,67 @@ +#ifndef RIPPLEOVERLAY_H +#define RIPPLEOVERLAY_H + +#include +#include "lib/overlaywidget.h" + +namespace md +{ +class Ripple; + +class RippleOverlay : public OverlayWidget +{ + Q_OBJECT + +public: + explicit RippleOverlay(QWidget *parent = 0); + ~RippleOverlay(); + + void addRipple(Ripple *ripple); + void addRipple(const QPoint &position, qreal radius = 300); + + void removeRipple(Ripple *ripple); + + inline void setClipping(bool enable); + inline bool hasClipping() const; + + inline void setClipPath(const QPainterPath &path); + +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + + inline QList ripples() const; + +private: + Q_DISABLE_COPY(RippleOverlay) + + void paintRipple(QPainter *painter, Ripple *ripple); + + QList m_ripples; + QPainterPath m_clipPath; + bool m_useClip; +}; + +inline void RippleOverlay::setClipping(bool enable) +{ + m_useClip = enable; + update(); +} + +inline bool RippleOverlay::hasClipping() const +{ + return m_useClip; +} + +inline void RippleOverlay::setClipPath(const QPainterPath &path) +{ + m_clipPath = path; + update(); +} + +inline QList RippleOverlay::ripples() const +{ + return m_ripples; +} +} + +#endif // RIPPLEOVERLAY_H diff --git a/components/lib/statetransition.cpp b/components/lib/statetransition.cpp new file mode 100644 index 000000000..3aea6fb86 --- /dev/null +++ b/components/lib/statetransition.cpp @@ -0,0 +1,22 @@ +#include "lib/statetransition.h" + +namespace md +{ +StateTransition::StateTransition(StateTransitionType type) + : m_type(type) +{ +} + +bool StateTransition::eventTest(QEvent *event) +{ + if (event->type() != QEvent::Type(QEvent::User + 1)) { + return false; + } + StateTransitionEvent *transition = static_cast(event); + return (m_type == transition->type); +} + +void StateTransition::onTransition(QEvent *) +{ +} +} diff --git a/components/lib/statetransition.h b/components/lib/statetransition.h new file mode 100644 index 000000000..883c19171 --- /dev/null +++ b/components/lib/statetransition.h @@ -0,0 +1,25 @@ +#ifndef STATETRANSITION_H +#define STATETRANSITION_H + +#include +#include "lib/statetransitionevent.h" + +namespace md +{ +class StateTransition : public QAbstractTransition +{ + Q_OBJECT + +public: + StateTransition(StateTransitionType type); + +protected: + virtual bool eventTest(QEvent *event); + virtual void onTransition(QEvent *); + +private: + StateTransitionType m_type; +}; +} + +#endif // STATETRANSITION_H diff --git a/components/lib/qtmaterialstatetransitionevent.h b/components/lib/statetransitionevent.h similarity index 67% rename from components/lib/qtmaterialstatetransitionevent.h rename to components/lib/statetransitionevent.h index 1c64ec623..2a9f51230 100644 --- a/components/lib/qtmaterialstatetransitionevent.h +++ b/components/lib/statetransitionevent.h @@ -1,9 +1,11 @@ -#ifndef QTMATERIALSTATETRANSITIONEVENT_H -#define QTMATERIALSTATETRANSITIONEVENT_H +#ifndef STATETRANSITIONEVENT_H +#define STATETRANSITIONEVENT_H #include -enum QtMaterialStateTransitionType { +namespace md +{ +enum StateTransitionType { // Snackbar SnackbarShowTransition = 1, SnackbarHideTransition, @@ -28,15 +30,16 @@ enum QtMaterialStateTransitionType { MaxTransitionType = 65535 }; -struct QtMaterialStateTransitionEvent : public QEvent +struct StateTransitionEvent : public QEvent { - QtMaterialStateTransitionEvent(QtMaterialStateTransitionType type) + StateTransitionEvent(StateTransitionType type) : QEvent(QEvent::Type(QEvent::User + 1)), type(type) { } - QtMaterialStateTransitionType type; + StateTransitionType type; }; +} -#endif // QTMATERIALSTATETRANSITIONEVENT_H +#endif // STATETRANSITIONEVENT_H diff --git a/components/lib/style.cpp b/components/lib/style.cpp new file mode 100644 index 000000000..3a817154b --- /dev/null +++ b/components/lib/style.cpp @@ -0,0 +1,60 @@ +#include "lib/style.h" +#include "lib/theme.h" + +namespace md +{ +/*! + * \class StylePrivate + * \internal + */ + +StylePrivate::StylePrivate(Style *q) + : q_ptr(q) +{ +} + +StylePrivate::~StylePrivate() +{ +} + +void StylePrivate::init() +{ + Q_Q(Style); + + QFontDatabase::addApplicationFont(":/fonts/fonts/roboto_regular"); + QFontDatabase::addApplicationFont(":/fonts/fonts/roboto_medium"); + QFontDatabase::addApplicationFont(":/fonts/fonts/roboto_bold"); + + q->setTheme(new Theme); +} + +/*! + * \class Style + * \internal + */ + +void Style::setTheme(Theme *theme) +{ + Q_D(Style); + + d->theme = theme; + theme->setParent(this); +} + +QColor Style::themeColor(const QString &key) const +{ + Q_D(const Style); + + Q_ASSERT(d->theme); + + return d->theme->getColor(key); +} + +Style::Style() + : QCommonStyle(), + d_ptr(new StylePrivate(this)) +{ + d_func()->init(); +} + +} diff --git a/components/lib/style.h b/components/lib/style.h new file mode 100644 index 000000000..6feb83beb --- /dev/null +++ b/components/lib/style.h @@ -0,0 +1,43 @@ +#ifndef STYLE_H +#define STYLE_H + +#include +#include "lib/style_p.h" + +#define MATERIAL_DISABLE_THEME_COLORS \ + if (d->useThemeColors == true) { d->useThemeColors = false; } + +namespace md +{ +class Theme; + +class Style : public QCommonStyle +{ + Q_OBJECT + +public: + inline static Style &instance(); + + void setTheme(Theme *theme); + QColor themeColor(const QString &key) const; + +protected: + const QScopedPointer d_ptr; + +private: + Q_DECLARE_PRIVATE(Style) + + Style(); + + Style(Style const &); + void operator=(Style const &); +}; + +inline Style &Style::instance() +{ + static Style instance; + return instance; +} +} + +#endif // STYLE_H diff --git a/components/lib/style_p.h b/components/lib/style_p.h new file mode 100644 index 000000000..8e93f973c --- /dev/null +++ b/components/lib/style_p.h @@ -0,0 +1,28 @@ +#ifndef STYLE_P_H +#define STYLE_P_H + +#include +#include + +namespace md +{ +class Style; +class Theme; + +class StylePrivate +{ + Q_DISABLE_COPY(StylePrivate) + Q_DECLARE_PUBLIC(Style) + +public: + StylePrivate(Style *q); + ~StylePrivate(); + + void init(); + + Style *const q_ptr; + Theme *theme; +}; +} + +#endif // STYLE_P_H diff --git a/components/lib/qtmaterialtheme.cpp b/components/lib/theme.cpp similarity index 89% rename from components/lib/qtmaterialtheme.cpp rename to components/lib/theme.cpp index 725c95480..e481774cc 100644 --- a/components/lib/qtmaterialtheme.cpp +++ b/components/lib/theme.cpp @@ -1,24 +1,23 @@ -#include "lib/qtmaterialtheme.h" -#include "lib/qtmaterialtheme_p.h" -#include -#include -#include - -/*!material - * \class QtMaterialThemePrivate +#include "lib/theme.h" +#include "lib/theme_p.h" + +namespace md +{ +/*! + * \class ThemePrivate * \internal */ -QtMaterialThemePrivate::QtMaterialThemePrivate(QtMaterialTheme *q) +ThemePrivate::ThemePrivate(Theme *q) : q_ptr(q) { } -QtMaterialThemePrivate::~QtMaterialThemePrivate() +ThemePrivate::~ThemePrivate() { } -QColor QtMaterialThemePrivate::rgba(int r, int g, int b, qreal a) const +QColor ThemePrivate::rgba(int r, int g, int b, qreal a) const { QColor color(r, g, b); color.setAlphaF(a); @@ -29,9 +28,9 @@ QColor QtMaterialThemePrivate::rgba(int r, int g, int b, qreal a) const * \class QtMaterialTheme */ -QtMaterialTheme::QtMaterialTheme(QObject *parent) +Theme::Theme(QObject *parent) : QObject(parent), - d_ptr(new QtMaterialThemePrivate(this)) + d_ptr(new ThemePrivate(this)) { setColor("primary1", Material::cyan500); setColor("primary2", Material::cyan700); @@ -48,13 +47,13 @@ QtMaterialTheme::QtMaterialTheme(QObject *parent) setColor("disabled3", Material::grey300); } -QtMaterialTheme::~QtMaterialTheme() +Theme::~Theme() { } -QColor QtMaterialTheme::getColor(const QString &key) const +QColor Theme::getColor(const QString &key) const { - Q_D(const QtMaterialTheme); + Q_D(const Theme); if (!d->colors.contains(key)) { qWarning() << "A theme color matching the key '" << key << "' could not be found."; @@ -63,16 +62,16 @@ QColor QtMaterialTheme::getColor(const QString &key) const return d->colors.value(key); } -void QtMaterialTheme::setColor(const QString &key, const QColor &color) +void Theme::setColor(const QString &key, const QColor &color) { - Q_D(QtMaterialTheme); + Q_D(Theme); d->colors.insert(key, color); } -void QtMaterialTheme::setColor(const QString &key, Material::Color color) +void Theme::setColor(const QString &key, Material::Color color) { - Q_D(QtMaterialTheme); + Q_D(Theme); static const QColor palette[] = { QColor("#ffebee"), QColor("#ffcdd2"), QColor("#ef9a9a"), QColor("#e57373"), @@ -153,7 +152,9 @@ void QtMaterialTheme::setColor(const QString &key, Material::Color color) d->colors.insert(key, palette[color]); } -QIcon QtMaterialTheme::icon(QString category, QString icon) +QIcon Theme::icon(QString category, QString icon) { return QIcon(":/icons/icons/" % category % "/svg/production/ic_" % icon % "_24px.svg"); } + +} diff --git a/components/lib/qtmaterialtheme.h b/components/lib/theme.h similarity index 94% rename from components/lib/qtmaterialtheme.h rename to components/lib/theme.h index fe4a11c82..9c25aacf5 100644 --- a/components/lib/qtmaterialtheme.h +++ b/components/lib/theme.h @@ -1,11 +1,13 @@ -#ifndef QTMATERIALTHEME_H -#define QTMATERIALTHEME_H +#ifndef THEME_H +#define THEME_H #include #include #include #include +namespace md +{ namespace Material { enum ButtonPreset { @@ -316,15 +318,15 @@ namespace Material }; } -class QtMaterialThemePrivate; +class ThemePrivate; -class QtMaterialTheme : public QObject +class Theme : public QObject { Q_OBJECT public: - explicit QtMaterialTheme(QObject *parent = 0); - ~QtMaterialTheme(); + explicit Theme(QObject *parent = 0); + ~Theme(); QColor getColor(const QString &key) const; @@ -334,11 +336,12 @@ class QtMaterialTheme : public QObject static QIcon icon(QString category, QString icon); protected: - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialTheme) - Q_DECLARE_PRIVATE(QtMaterialTheme) + Q_DISABLE_COPY(Theme) + Q_DECLARE_PRIVATE(Theme) }; +} -#endif // QTMATERIALTHEME_H +#endif // THEME_H diff --git a/components/lib/theme_p.h b/components/lib/theme_p.h new file mode 100644 index 000000000..cdaf8e986 --- /dev/null +++ b/components/lib/theme_p.h @@ -0,0 +1,30 @@ +#ifndef THEME_P_H +#define THEME_P_H + +#include +#include +#include +#include +#include + +namespace md +{ +class Theme; + +class ThemePrivate +{ + Q_DISABLE_COPY(ThemePrivate) + Q_DECLARE_PUBLIC(Theme) + +public: + ThemePrivate(Theme *q); + ~ThemePrivate(); + + QColor rgba(int r, int g, int b, qreal a) const; + + Theme *const q_ptr; + QHash colors; +}; +} + +#endif // THEME_P_H diff --git a/components/list.cpp b/components/list.cpp new file mode 100644 index 000000000..c6c6dedce --- /dev/null +++ b/components/list.cpp @@ -0,0 +1,2 @@ +#include "list.h" +#include "list_p.h" diff --git a/components/list.h b/components/list.h new file mode 100644 index 000000000..8b8d44318 --- /dev/null +++ b/components/list.h @@ -0,0 +1,4 @@ +#ifndef LIST_H +#define LIST_H + +#endif // LIST_H diff --git a/components/list_p.h b/components/list_p.h new file mode 100644 index 000000000..502ffed46 --- /dev/null +++ b/components/list_p.h @@ -0,0 +1,4 @@ +#ifndef LIST_P_H +#define LIST_P_H + +#endif // LIST_P_H diff --git a/components/listitem.cpp b/components/listitem.cpp new file mode 100644 index 000000000..4ebdbf13b --- /dev/null +++ b/components/listitem.cpp @@ -0,0 +1,2 @@ +#include "listitem.h" +#include "listitem_p.h" diff --git a/components/listitem.h b/components/listitem.h new file mode 100644 index 000000000..588e672a4 --- /dev/null +++ b/components/listitem.h @@ -0,0 +1,4 @@ +#ifndef LISTITEM_H +#define LISTITEM_H + +#endif // LISTITEM_H diff --git a/components/listitem_p.h b/components/listitem_p.h new file mode 100644 index 000000000..bc1b85a4f --- /dev/null +++ b/components/listitem_p.h @@ -0,0 +1,4 @@ +#ifndef LISTITEM_P_H +#define LISTITEM_P_H + +#endif // LISTITEM_P_H diff --git a/components/menu.cpp b/components/menu.cpp new file mode 100644 index 000000000..d43318003 --- /dev/null +++ b/components/menu.cpp @@ -0,0 +1,17 @@ +#include "menu.h" +#include "menu_p.h" + +namespace md +{ + +Menu::Menu(QWidget *parent) + : QWidget(parent) +{ +} + +Menu::~Menu() +{ +} + +} + diff --git a/components/menu.h b/components/menu.h new file mode 100644 index 000000000..c07f67a80 --- /dev/null +++ b/components/menu.h @@ -0,0 +1,18 @@ +#ifndef MENU_H +#define MENU_H + +#include + +namespace md +{ +class Menu : public QWidget +{ + Q_OBJECT + +public: + explicit Menu(QWidget *parent = 0); + ~Menu(); +}; +} + +#endif // MENU_H diff --git a/components/menu_internal.cpp b/components/menu_internal.cpp new file mode 100644 index 000000000..686a80245 --- /dev/null +++ b/components/menu_internal.cpp @@ -0,0 +1,6 @@ + + +namespace md +{ + +} diff --git a/components/menu_internal.h b/components/menu_internal.h new file mode 100644 index 000000000..0128af45f --- /dev/null +++ b/components/menu_internal.h @@ -0,0 +1,7 @@ +#ifndef MENU_INTERNAL_H +#define MENU_INTERNAL_H +namespace md +{ + +} +#endif // MENU_INTERNAL_H diff --git a/components/menu_p.h b/components/menu_p.h new file mode 100644 index 000000000..1226d2c82 --- /dev/null +++ b/components/menu_p.h @@ -0,0 +1,7 @@ +#ifndef MENU_P_H +#define MENU_P_H +namespace md +{ + +} +#endif // MENU_P_H diff --git a/components/paper.cpp b/components/paper.cpp new file mode 100644 index 000000000..f0c50928e --- /dev/null +++ b/components/paper.cpp @@ -0,0 +1,7 @@ +#include "paper.h" +#include "paper_p.h" + +namespace md +{ + +} diff --git a/components/paper.h b/components/paper.h new file mode 100644 index 000000000..0c9bfdf5b --- /dev/null +++ b/components/paper.h @@ -0,0 +1,7 @@ +#ifndef PAPER_H +#define PAPER_H +namespace md +{ + +} +#endif // PAPER_H diff --git a/components/paper_p.h b/components/paper_p.h new file mode 100644 index 000000000..7e53b7d66 --- /dev/null +++ b/components/paper_p.h @@ -0,0 +1,7 @@ +#ifndef PAPER_P_H +#define PAPER_P_H +namespace md +{ + +} +#endif // PAPER_P_H diff --git a/components/qtmaterialprogress.cpp b/components/progress.cpp similarity index 57% rename from components/qtmaterialprogress.cpp rename to components/progress.cpp index 03b15b2f0..16f53241f 100644 --- a/components/qtmaterialprogress.cpp +++ b/components/progress.cpp @@ -1,30 +1,32 @@ -#include "qtmaterialprogress.h" -#include "qtmaterialprogress_p.h" +#include "progress.h" +#include "progress_p.h" #include #include #include -#include "qtmaterialprogress_internal.h" -#include "lib/qtmaterialstyle.h" +#include "progress_internal.h" +#include "lib/style.h" +namespace md +{ /*! - * \class QtMaterialProgressPrivate + * \class ProgressBarPrivate * \internal */ -QtMaterialProgressPrivate::QtMaterialProgressPrivate(QtMaterialProgress *q) +ProgressBarPrivate::ProgressBarPrivate(ProgressBar *q) : q_ptr(q) { } -QtMaterialProgressPrivate::~QtMaterialProgressPrivate() +ProgressBarPrivate::~ProgressBarPrivate() { } -void QtMaterialProgressPrivate::init() +void ProgressBarPrivate::init() { - Q_Q(QtMaterialProgress); + Q_Q(ProgressBar); - delegate = new QtMaterialProgressDelegate(q); + delegate = new ProgressBarDelegate(q); progressType = Material::IndeterminateProgress; useThemeColors = true; @@ -46,35 +48,35 @@ void QtMaterialProgressPrivate::init() * \class QtMaterialProgress */ -QtMaterialProgress::QtMaterialProgress(QWidget *parent) +ProgressBar::ProgressBar(QWidget *parent) : QProgressBar(parent), - d_ptr(new QtMaterialProgressPrivate(this)) + d_ptr(new ProgressBarPrivate(this)) { d_func()->init(); } -QtMaterialProgress::~QtMaterialProgress() +ProgressBar::~ProgressBar() { } -void QtMaterialProgress::setProgressType(Material::ProgressType type) +void ProgressBar::setProgressType(Material::ProgressType type) { - Q_D(QtMaterialProgress); + Q_D(ProgressBar); d->progressType = type; update(); } -Material::ProgressType QtMaterialProgress::progressType() const +Material::ProgressType ProgressBar::progressType() const { - Q_D(const QtMaterialProgress); + Q_D(const ProgressBar); return d->progressType; } -void QtMaterialProgress::setUseThemeColors(bool state) +void ProgressBar::setUseThemeColors(bool state) { - Q_D(QtMaterialProgress); + Q_D(ProgressBar); if (d->useThemeColors == state) { return; @@ -84,16 +86,16 @@ void QtMaterialProgress::setUseThemeColors(bool state) update(); } -bool QtMaterialProgress::useThemeColors() const +bool ProgressBar::useThemeColors() const { - Q_D(const QtMaterialProgress); + Q_D(const ProgressBar); return d->useThemeColors; } -void QtMaterialProgress::setProgressColor(const QColor &color) +void ProgressBar::setProgressColor(const QColor &color) { - Q_D(QtMaterialProgress); + Q_D(ProgressBar); d->progressColor = color; @@ -101,20 +103,20 @@ void QtMaterialProgress::setProgressColor(const QColor &color) update(); } -QColor QtMaterialProgress::progressColor() const +QColor ProgressBar::progressColor() const { - Q_D(const QtMaterialProgress); + Q_D(const ProgressBar); if (d->useThemeColors || !d->progressColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->progressColor; } } -void QtMaterialProgress::setBackgroundColor(const QColor &color) +void ProgressBar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialProgress); + Q_D(ProgressBar); d->backgroundColor = color; @@ -122,12 +124,12 @@ void QtMaterialProgress::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialProgress::backgroundColor() const +QColor ProgressBar::backgroundColor() const { - Q_D(const QtMaterialProgress); + Q_D(const ProgressBar); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("border"); + return Style::instance().themeColor("border"); } else { return d->backgroundColor; } @@ -136,11 +138,11 @@ QColor QtMaterialProgress::backgroundColor() const /*! * \reimp */ -void QtMaterialProgress::paintEvent(QPaintEvent *event) +void ProgressBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialProgress); + Q_D(ProgressBar); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -148,7 +150,7 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event) QBrush brush; brush.setStyle(Qt::SolidPattern); brush.setColor(isEnabled() ? backgroundColor() - : QtMaterialStyle::instance().themeColor("disabled")); + : Style::instance().themeColor("disabled")); painter.setBrush(brush); painter.setPen(Qt::NoPen); @@ -171,3 +173,4 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event) } } } +} diff --git a/components/qtmaterialprogress.h b/components/progress.h similarity index 60% rename from components/qtmaterialprogress.h rename to components/progress.h index 0e69b1d3c..c8b65698c 100644 --- a/components/qtmaterialprogress.h +++ b/components/progress.h @@ -1,12 +1,15 @@ -#ifndef QTMATERIALPROGRESS_H -#define QTMATERIALPROGRESS_H +#ifndef PROGRESS_H +#define PROGRESS_H #include -#include "lib/qtmaterialtheme.h" +#include "lib/theme.h" -class QtMaterialProgressPrivate; +namespace md +{ + +class ProgressBarPrivate; -class QtMaterialProgress : public QProgressBar +class ProgressBar : public QProgressBar { Q_OBJECT @@ -14,8 +17,8 @@ class QtMaterialProgress : public QProgressBar Q_PROPERTY(QColor backgroundColor WRITE setProgressColor READ backgroundColor) public: - explicit QtMaterialProgress(QWidget *parent = 0); - ~QtMaterialProgress(); + explicit ProgressBar(QWidget *parent = 0); + ~ProgressBar(); void setProgressType(Material::ProgressType type); Material::ProgressType progressType() const; @@ -32,11 +35,11 @@ class QtMaterialProgress : public QProgressBar protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialProgress) - Q_DECLARE_PRIVATE(QtMaterialProgress) + Q_DISABLE_COPY(ProgressBar) + Q_DECLARE_PRIVATE(ProgressBar) }; - -#endif // QTMATERIALPROGRESS_H +} +#endif // PROGRESS_H diff --git a/components/progress_internal.cpp b/components/progress_internal.cpp new file mode 100644 index 000000000..9bd4211d4 --- /dev/null +++ b/components/progress_internal.cpp @@ -0,0 +1,21 @@ +#include "progress_internal.h" + +namespace md +{ +/*! + * \class QtMaterialProgressDelegate + * \internal + */ + +ProgressBarDelegate::ProgressBarDelegate(ProgressBar *parent) + : QObject(parent), + m_progress(parent), + m_offset(0) +{ + Q_ASSERT(parent); +} + +ProgressBarDelegate::~ProgressBarDelegate() +{ +} +} diff --git a/components/progress_internal.h b/components/progress_internal.h new file mode 100644 index 000000000..d474b5725 --- /dev/null +++ b/components/progress_internal.h @@ -0,0 +1,41 @@ +#ifndef PROGRESS_INTERNAL_H +#define PROGRESS_INTERNAL_H + +#include +#include "progress.h" + +namespace md +{ + +class ProgressBarDelegate : public QObject +{ + Q_OBJECT + + Q_PROPERTY(qreal offset WRITE setOffset READ offset) + +public: + ProgressBarDelegate(ProgressBar *parent); + ~ProgressBarDelegate(); + + inline void setOffset(qreal offset); + inline qreal offset() const; + +private: + Q_DISABLE_COPY(ProgressBarDelegate) + + ProgressBar *const m_progress; + qreal m_offset; +}; + +inline void ProgressBarDelegate::setOffset(qreal offset) +{ + m_offset = offset; + m_progress->update(); +} + +inline qreal ProgressBarDelegate::offset() const +{ + return m_offset; +} +} +#endif // PROGRESS_INTERNAL_H diff --git a/components/progress_p.h b/components/progress_p.h new file mode 100644 index 000000000..e9b97da2a --- /dev/null +++ b/components/progress_p.h @@ -0,0 +1,32 @@ +#ifndef PROGRESS_P_H +#define PROGRESS_P_H + +#include +#include +#include "lib/theme.h" +namespace md +{ + +class ProgressBar; +class ProgressBarDelegate; + +class ProgressBarPrivate +{ + Q_DISABLE_COPY(ProgressBarPrivate) + Q_DECLARE_PUBLIC(ProgressBar) + +public: + ProgressBarPrivate(ProgressBar *q); + ~ProgressBarPrivate(); + + void init(); + + ProgressBar *const q_ptr; + ProgressBarDelegate *delegate; + Material::ProgressType progressType; + QColor progressColor; + QColor backgroundColor; + bool useThemeColors; +}; +} +#endif // PROGRESS_P_H diff --git a/components/qtmaterialappbar_p.h b/components/qtmaterialappbar_p.h deleted file mode 100644 index 0586556b4..000000000 --- a/components/qtmaterialappbar_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef QTMATERIALAPPBAR_P_H -#define QTMATERIALAPPBAR_P_H - -#include -#include - -class QtMaterialAppBar; - -class QtMaterialAppBarPrivate -{ - Q_DISABLE_COPY(QtMaterialAppBarPrivate) - Q_DECLARE_PUBLIC(QtMaterialAppBar) - -public: - QtMaterialAppBarPrivate(QtMaterialAppBar *q); - ~QtMaterialAppBarPrivate(); - - void init(); - - QtMaterialAppBar *const q_ptr; - bool useThemeColors; - QColor foregroundColor; - QColor backgroundColor; -}; - -#endif // QTMATERIALAPPBAR_P_H diff --git a/components/qtmaterialautocomplete.h b/components/qtmaterialautocomplete.h deleted file mode 100644 index 8b4686129..000000000 --- a/components/qtmaterialautocomplete.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef QTMATERIALAUTOCOMPLETE_H -#define QTMATERIALAUTOCOMPLETE_H - -#include "qtmaterialtextfield.h" - -class QtMaterialAutoCompletePrivate; - -class QtMaterialAutoComplete : public QtMaterialTextField -{ - Q_OBJECT - -public: - explicit QtMaterialAutoComplete(QWidget *parent = 0); - ~QtMaterialAutoComplete(); - - void setDataSource(const QStringList &data); - -signals: - void itemSelected(QString); - -protected slots: - void updateResults(QString text); - -protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QtMaterialAutoComplete) - Q_DECLARE_PRIVATE(QtMaterialAutoComplete) -}; - -#endif // QTMATERIALAUTOCOMPLETE_H diff --git a/components/qtmaterialautocomplete_internal.h b/components/qtmaterialautocomplete_internal.h deleted file mode 100644 index 7e76bd520..000000000 --- a/components/qtmaterialautocomplete_internal.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QTMATERIALAUTOCOMPLETESTATEMACHINE_H -#define QTMATERIALAUTOCOMPLETESTATEMACHINE_H - -#include -#include "qtmaterialautocomplete.h" - -class QtMaterialAutoCompleteStateMachine : public QStateMachine -{ - Q_OBJECT - -public: - explicit QtMaterialAutoCompleteStateMachine(QWidget *menu); - ~QtMaterialAutoCompleteStateMachine(); - -signals: - void shouldOpen(); - void shouldClose(); - void shouldFade(); - -private: - Q_DISABLE_COPY(QtMaterialAutoCompleteStateMachine) - - QWidget *const m_menu; - QState *const m_closedState; - QState *const m_openState; - QState *const m_closingState; -}; - -#endif // QTMATERIALAUTOCOMPLETESTATEMACHINE_H diff --git a/components/qtmaterialautocomplete_p.h b/components/qtmaterialautocomplete_p.h deleted file mode 100644 index 4fd405be7..000000000 --- a/components/qtmaterialautocomplete_p.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QTMATERIALAUTOCOMPLETE_P_H -#define QTMATERIALAUTOCOMPLETE_P_H - -#include "qtmaterialtextfield_p.h" - -class QWidget; -class QVBoxLayout; -class QtMaterialAutoCompleteOverlay; -class QtMaterialAutoCompleteStateMachine; - -class QtMaterialAutoCompletePrivate : public QtMaterialTextFieldPrivate -{ - Q_DISABLE_COPY(QtMaterialAutoCompletePrivate) - Q_DECLARE_PUBLIC(QtMaterialAutoComplete) - -public: - QtMaterialAutoCompletePrivate(QtMaterialAutoComplete *q); - virtual ~QtMaterialAutoCompletePrivate(); - - void init(); - - QWidget *menu; - QWidget *frame; - QtMaterialAutoCompleteStateMachine *stateMachine; - QVBoxLayout *menuLayout; - QStringList dataSource; - int maxWidth; -}; - -#endif // QTMATERIALAUTOCOMPLETE_P_H diff --git a/components/qtmaterialavatar_p.h b/components/qtmaterialavatar_p.h deleted file mode 100644 index 44b378e10..000000000 --- a/components/qtmaterialavatar_p.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef QTMATERIALAVATAR_P_H -#define QTMATERIALAVATAR_P_H - -#include -#include -#include -#include -#include -#include -#include "lib/qtmaterialtheme.h" - -class QtMaterialAvatar; - -class QtMaterialAvatarPrivate -{ - Q_DISABLE_COPY(QtMaterialAvatarPrivate) - Q_DECLARE_PUBLIC(QtMaterialAvatar) - -public: - QtMaterialAvatarPrivate(QtMaterialAvatar *q); - ~QtMaterialAvatarPrivate(); - - void init(); - - QtMaterialAvatar *const q_ptr; - int size; - Material::AvatarType type; - QChar letter; - QImage image; - QIcon icon; - QPixmap pixmap; - bool useThemeColors; - QColor textColor; - QColor backgroundColor; -}; - -#endif // QTMATERIALAVATAR_P_H diff --git a/components/qtmaterialcheckbox.h b/components/qtmaterialcheckbox.h deleted file mode 100644 index 5aaa8f4dc..000000000 --- a/components/qtmaterialcheckbox.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef QTMATERIALCHECKBOX_H -#define QTMATERIALCHECKBOX_H - -#include "lib/qtmaterialcheckable.h" - -class QtMaterialCheckBoxPrivate; - -class QtMaterialCheckBox : public QtMaterialCheckable -{ - Q_OBJECT - -public: - explicit QtMaterialCheckBox(QWidget *parent = 0); - ~QtMaterialCheckBox(); - -private: - Q_DISABLE_COPY(QtMaterialCheckBox) - Q_DECLARE_PRIVATE(QtMaterialCheckBox) -}; - -#endif // QTMATERIALCHECKBOX_H diff --git a/components/qtmaterialcheckbox_p.h b/components/qtmaterialcheckbox_p.h deleted file mode 100644 index daa62d796..000000000 --- a/components/qtmaterialcheckbox_p.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QTMATERIALCHECKBOX_P_H -#define QTMATERIALCHECKBOX_P_H - -#include "lib/qtmaterialcheckable_p.h" - -class QtMaterialCheckBox; - -class QtMaterialCheckBoxPrivate : public QtMaterialCheckablePrivate -{ - Q_DISABLE_COPY(QtMaterialCheckBoxPrivate) - Q_DECLARE_PUBLIC(QtMaterialCheckBox) - -public: - QtMaterialCheckBoxPrivate(QtMaterialCheckBox *q); - ~QtMaterialCheckBoxPrivate(); - - void init(); -}; - -#endif // QTMATERIALCHECKBOX_P_H diff --git a/components/qtmaterialcircularprogress_internal.cpp b/components/qtmaterialcircularprogress_internal.cpp deleted file mode 100644 index b11a25f1d..000000000 --- a/components/qtmaterialcircularprogress_internal.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "qtmaterialcircularprogress_internal.h" - -/*! - * \class QtMaterialCircularProgressDelegate - * \internal - */ - -QtMaterialCircularProgressDelegate::QtMaterialCircularProgressDelegate(QtMaterialCircularProgress *parent) - : QObject(parent), - m_progress(parent), - m_dashOffset(0), - m_dashLength(89), - m_angle(0) -{ - Q_ASSERT(parent); -} - -QtMaterialCircularProgressDelegate::~QtMaterialCircularProgressDelegate() -{ -} diff --git a/components/qtmaterialcircularprogress_p.h b/components/qtmaterialcircularprogress_p.h deleted file mode 100644 index 451bc9c4b..000000000 --- a/components/qtmaterialcircularprogress_p.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QTMATERIALCIRCULARPROGRESS_P_H -#define QTMATERIALCIRCULARPROGRESS_P_H - -#include -#include "lib/qtmaterialtheme.h" - -class QtMaterialCircularProgress; -class QtMaterialCircularProgressDelegate; - -class QtMaterialCircularProgressPrivate -{ - Q_DISABLE_COPY(QtMaterialCircularProgressPrivate) - Q_DECLARE_PUBLIC(QtMaterialCircularProgress) - -public: - QtMaterialCircularProgressPrivate(QtMaterialCircularProgress *q); - ~QtMaterialCircularProgressPrivate(); - - void init(); - - QtMaterialCircularProgress *const q_ptr; - QtMaterialCircularProgressDelegate *delegate; - Material::ProgressType progressType; - QColor color; - qreal penWidth; - int size; - bool useThemeColors; -}; - -#endif // QTMATERIALCIRCULARPROGRESS_P_H diff --git a/components/qtmaterialdialog.h b/components/qtmaterialdialog.h deleted file mode 100644 index 822a5d9f6..000000000 --- a/components/qtmaterialdialog.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QTMATERIALDIALOG_H -#define QTMATERIALDIALOG_H - -#include -#include "lib/qtmaterialoverlaywidget.h" - -class QLayout; -class QtMaterialDialogPrivate; - -class QtMaterialDialog : public QtMaterialOverlayWidget -{ - Q_OBJECT - -public: - explicit QtMaterialDialog(QWidget *parent = 0); - ~QtMaterialDialog(); - - QLayout *windowLayout() const; - void setWindowLayout(QLayout *layout); - -public slots: - void showDialog(); - void hideDialog(); - -protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - - const QScopedPointer d_ptr; - -private: - Q_DISABLE_COPY(QtMaterialDialog) - Q_DECLARE_PRIVATE(QtMaterialDialog) -}; - -#endif // QTMATERIALDIALOG_H diff --git a/components/qtmaterialdialog_p.h b/components/qtmaterialdialog_p.h deleted file mode 100644 index b10088ee1..000000000 --- a/components/qtmaterialdialog_p.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QTMATERIALDIALOG_P_H -#define QTMATERIALDIALOG_P_H - -#include - -class QStateMachine; -class QtMaterialDialog; -class QStackedLayout; -class QtMaterialDialogWindow; -class QtMaterialDialogProxy; - -class QtMaterialDialogPrivate -{ - Q_DISABLE_COPY(QtMaterialDialogPrivate) - Q_DECLARE_PUBLIC(QtMaterialDialog) - -public: - QtMaterialDialogPrivate(QtMaterialDialog *q); - ~QtMaterialDialogPrivate(); - - void init(); - - QtMaterialDialog *const q_ptr; - QtMaterialDialogWindow *dialogWindow; - QStackedLayout *proxyStack; - QStateMachine *stateMachine; - QtMaterialDialogProxy *proxy; -}; - -#endif // QTMATERIALDIALOG_P_H diff --git a/components/qtmaterialdrawer_p.h b/components/qtmaterialdrawer_p.h deleted file mode 100644 index cdd064d12..000000000 --- a/components/qtmaterialdrawer_p.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DRAWER_P_H -#define DRAWER_P_H - -#include - -class QtMaterialDrawer; -class QtMaterialDrawerWidget; -class QtMaterialDrawerStateMachine; - -class QtMaterialDrawerPrivate -{ - Q_DISABLE_COPY(QtMaterialDrawerPrivate) - Q_DECLARE_PUBLIC(QtMaterialDrawer) - -public: - QtMaterialDrawerPrivate(QtMaterialDrawer *q); - ~QtMaterialDrawerPrivate(); - - void init(); - void setClosed(bool value = true); - - QtMaterialDrawer *const q_ptr; - QtMaterialDrawerWidget *widget; - QtMaterialDrawerStateMachine *stateMachine; - QWidget *window; - int width; - bool clickToClose; - bool autoRaise; - bool closed; - bool overlay; -}; - -#endif // DRAWER_P_H diff --git a/components/qtmaterialfab_p.h b/components/qtmaterialfab_p.h deleted file mode 100644 index fae2d3ae8..000000000 --- a/components/qtmaterialfab_p.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef QTMATERIALFAB_P_H -#define QTMATERIALFAB_P_H - -#include "qtmaterialraisedbutton_p.h" - -class QtMaterialFloatingActionButton; - -class QtMaterialFloatingActionButtonPrivate : public QtMaterialRaisedButtonPrivate -{ - Q_DISABLE_COPY(QtMaterialFloatingActionButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialFloatingActionButton) - -public: - enum { - DefaultDiameter = 56, - MiniDiameter = 40 - }; - - enum { - DefaultIconSize = 24, - MiniIconSize = 18 - }; - - QtMaterialFloatingActionButtonPrivate(QtMaterialFloatingActionButton *q); - ~QtMaterialFloatingActionButtonPrivate(); - - void init(); - QRect fabGeometry() const; - void setupProperties(); - - inline int diameter() const; - inline int iconSize() const; - - Qt::Corner corner; - bool mini; - int offsX; - int offsY; -}; - -inline int QtMaterialFloatingActionButtonPrivate::diameter() const -{ - return mini ? MiniDiameter : DefaultDiameter; -} - -inline int QtMaterialFloatingActionButtonPrivate::iconSize() const -{ - return mini ? MiniIconSize : DefaultIconSize; -} - -#endif // QTMATERIALFAB_P_H diff --git a/components/qtmaterialiconbutton_p.h b/components/qtmaterialiconbutton_p.h deleted file mode 100644 index a532abca6..000000000 --- a/components/qtmaterialiconbutton_p.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QTMATERIALICONBUTTON_P_H -#define QTMATERIALICONBUTTON_P_H - -#include - -class QtMaterialIconButton; -class QtMaterialRippleOverlay; -class QColor; - -class QtMaterialIconButtonPrivate -{ - Q_DISABLE_COPY(QtMaterialIconButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialIconButton) - -public: - QtMaterialIconButtonPrivate(QtMaterialIconButton *q); - virtual ~QtMaterialIconButtonPrivate(); - - void init(); - void updateRipple(); - - QtMaterialIconButton *const q_ptr; - QtMaterialRippleOverlay *rippleOverlay; - QColor color; - QColor disabledColor; - bool useThemeColors; -}; - -#endif // QTMATERIALICONBUTTON_P_H diff --git a/components/qtmateriallist.cpp b/components/qtmateriallist.cpp deleted file mode 100644 index e6b1aee44..000000000 --- a/components/qtmateriallist.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "qtmateriallist.h" -#include "qtmateriallist_p.h" diff --git a/components/qtmateriallist.h b/components/qtmateriallist.h deleted file mode 100644 index 7ace66ab0..000000000 --- a/components/qtmateriallist.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALLIST_H -#define QTMATERIALLIST_H - -#endif // QTMATERIALLIST_H diff --git a/components/qtmateriallist_p.h b/components/qtmateriallist_p.h deleted file mode 100644 index c92b2d641..000000000 --- a/components/qtmateriallist_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALLIST_P_H -#define QTMATERIALLIST_P_H - -#endif // QTMATERIALLIST_P_H diff --git a/components/qtmateriallistitem.cpp b/components/qtmateriallistitem.cpp deleted file mode 100644 index 67a7cd89e..000000000 --- a/components/qtmateriallistitem.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "qtmateriallistitem.h" -#include "qtmateriallistitem_p.h" diff --git a/components/qtmateriallistitem.h b/components/qtmateriallistitem.h deleted file mode 100644 index 9abc65bec..000000000 --- a/components/qtmateriallistitem.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALLISTITEM_H -#define QTMATERIALLISTITEM_H - -#endif // QTMATERIALLISTITEM_H diff --git a/components/qtmateriallistitem_p.h b/components/qtmateriallistitem_p.h deleted file mode 100644 index fb7ebd460..000000000 --- a/components/qtmateriallistitem_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALLISTITEM_P_H -#define QTMATERIALLISTITEM_P_H - -#endif // QTMATERIALLISTITEM_P_H diff --git a/components/qtmaterialmenu.cpp b/components/qtmaterialmenu.cpp deleted file mode 100644 index 5808a99e0..000000000 --- a/components/qtmaterialmenu.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "qtmaterialmenu.h" -#include "qtmaterialmenu_p.h" - -QtMaterialMenu::QtMaterialMenu(QWidget *parent) - : QWidget(parent) -{ -} - -QtMaterialMenu::~QtMaterialMenu() -{ -} diff --git a/components/qtmaterialmenu.h b/components/qtmaterialmenu.h deleted file mode 100644 index beb01b5b9..000000000 --- a/components/qtmaterialmenu.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef QTMATERIALMENU_H -#define QTMATERIALMENU_H - -#include - -class QtMaterialMenu : public QWidget -{ - Q_OBJECT - -public: - explicit QtMaterialMenu(QWidget *parent = 0); - ~QtMaterialMenu(); -}; - -#endif // QTMATERIALMENU_H diff --git a/components/qtmaterialmenu_internal.cpp b/components/qtmaterialmenu_internal.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/components/qtmaterialmenu_internal.h b/components/qtmaterialmenu_internal.h deleted file mode 100644 index fb792356d..000000000 --- a/components/qtmaterialmenu_internal.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALMENU_INTERNAL_H -#define QTMATERIALMENU_INTERNAL_H - -#endif // QTMATERIALMENU_INTERNAL_H diff --git a/components/qtmaterialmenu_p.h b/components/qtmaterialmenu_p.h deleted file mode 100644 index 1328bdca1..000000000 --- a/components/qtmaterialmenu_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALMENU_P_H -#define QTMATERIALMENU_P_H - -#endif // QTMATERIALMENU_P_H diff --git a/components/qtmaterialpaper.cpp b/components/qtmaterialpaper.cpp deleted file mode 100644 index ad7dfa093..000000000 --- a/components/qtmaterialpaper.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "qtmaterialpaper.h" -#include "qtmaterialpaper_p.h" diff --git a/components/qtmaterialpaper.h b/components/qtmaterialpaper.h deleted file mode 100644 index f305836bd..000000000 --- a/components/qtmaterialpaper.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALPAPER_H -#define QTMATERIALPAPER_H - -#endif // QTMATERIALPAPER_H diff --git a/components/qtmaterialpaper_p.h b/components/qtmaterialpaper_p.h deleted file mode 100644 index 65972a653..000000000 --- a/components/qtmaterialpaper_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALPAPER_P_H -#define QTMATERIALPAPER_P_H - -#endif // QTMATERIALPAPER_P_H diff --git a/components/qtmaterialprogress_internal.cpp b/components/qtmaterialprogress_internal.cpp deleted file mode 100644 index 0544baeba..000000000 --- a/components/qtmaterialprogress_internal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "qtmaterialprogress_internal.h" - -/*! - * \class QtMaterialProgressDelegate - * \internal - */ - -QtMaterialProgressDelegate::QtMaterialProgressDelegate(QtMaterialProgress *parent) - : QObject(parent), - m_progress(parent), - m_offset(0) -{ - Q_ASSERT(parent); -} - -QtMaterialProgressDelegate::~QtMaterialProgressDelegate() -{ -} diff --git a/components/qtmaterialprogress_internal.h b/components/qtmaterialprogress_internal.h deleted file mode 100644 index 811e3d6de..000000000 --- a/components/qtmaterialprogress_internal.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef QTMATERIALPROGRESS_INTERNAL_H -#define QTMATERIALPROGRESS_INTERNAL_H - -#include -#include "qtmaterialprogress.h" - -class QtMaterialProgressDelegate : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal offset WRITE setOffset READ offset) - -public: - QtMaterialProgressDelegate(QtMaterialProgress *parent); - ~QtMaterialProgressDelegate(); - - inline void setOffset(qreal offset); - inline qreal offset() const; - -private: - Q_DISABLE_COPY(QtMaterialProgressDelegate) - - QtMaterialProgress *const m_progress; - qreal m_offset; -}; - -inline void QtMaterialProgressDelegate::setOffset(qreal offset) -{ - m_offset = offset; - m_progress->update(); -} - -inline qreal QtMaterialProgressDelegate::offset() const -{ - return m_offset; -} - -#endif // QTMATERIALPROGRESS_INTERNAL_H diff --git a/components/qtmaterialprogress_p.h b/components/qtmaterialprogress_p.h deleted file mode 100644 index b55fb021c..000000000 --- a/components/qtmaterialprogress_p.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QTMATERIALPROGRESS_P_H -#define QTMATERIALPROGRESS_P_H - -#include -#include -#include "lib/qtmaterialtheme.h" - -class QtMaterialProgress; -class QtMaterialProgressDelegate; - -class QtMaterialProgressPrivate -{ - Q_DISABLE_COPY(QtMaterialProgressPrivate) - Q_DECLARE_PUBLIC(QtMaterialProgress) - -public: - QtMaterialProgressPrivate(QtMaterialProgress *q); - ~QtMaterialProgressPrivate(); - - void init(); - - QtMaterialProgress *const q_ptr; - QtMaterialProgressDelegate *delegate; - Material::ProgressType progressType; - QColor progressColor; - QColor backgroundColor; - bool useThemeColors; -}; - -#endif // QTMATERIALPROGRESS_P_H diff --git a/components/qtmaterialradiobutton.h b/components/qtmaterialradiobutton.h deleted file mode 100644 index adc535cc7..000000000 --- a/components/qtmaterialradiobutton.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QTMATERIALRADIOBUTTON_H -#define QTMATERIALRADIOBUTTON_H - -#include "lib/qtmaterialcheckable.h" - -class QtMaterialRadioButtonPrivate; - -class QtMaterialRadioButton : public QtMaterialCheckable -{ - Q_OBJECT - -public: - explicit QtMaterialRadioButton(QWidget *parent = 0); - ~QtMaterialRadioButton(); - -protected: - void setupProperties(); - -private: - Q_DISABLE_COPY(QtMaterialRadioButton) - Q_DECLARE_PRIVATE(QtMaterialRadioButton) -}; - -#endif // QTMATERIALRADIOBUTTON_H diff --git a/components/qtmaterialradiobutton_p.h b/components/qtmaterialradiobutton_p.h deleted file mode 100644 index 6bb954aa1..000000000 --- a/components/qtmaterialradiobutton_p.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef QTMATERIALRADIOBUTTON_P_H -#define QTMATERIALRADIOBUTTON_P_H - -#include "lib/qtmaterialcheckable_p.h" - -class QtMaterialRadioButton; - -class QtMaterialRadioButtonPrivate : public QtMaterialCheckablePrivate -{ - Q_DISABLE_COPY(QtMaterialRadioButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialRadioButton) - -public: - QtMaterialRadioButtonPrivate(QtMaterialRadioButton *q); - ~QtMaterialRadioButtonPrivate(); - - void init(); -}; - -#endif // QTMATERIALRADIOBUTTON_P_H diff --git a/components/qtmaterialraisedbutton.h b/components/qtmaterialraisedbutton.h deleted file mode 100644 index d8b4ef91e..000000000 --- a/components/qtmaterialraisedbutton.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef QTMATERIALRAISEDBUTTON_H -#define QTMATERIALRAISEDBUTTON_H - -#include "qtmaterialflatbutton.h" - -class QtMaterialRaisedButtonPrivate; - -class QtMaterialRaisedButton : public QtMaterialFlatButton -{ - Q_OBJECT - -public: - explicit QtMaterialRaisedButton(QWidget *parent = 0); - explicit QtMaterialRaisedButton(const QString &text, QWidget *parent = 0); - ~QtMaterialRaisedButton(); - -protected: - QtMaterialRaisedButton(QtMaterialRaisedButtonPrivate &d, QWidget *parent = 0); - - bool event(QEvent *event) Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QtMaterialRaisedButton) - Q_DECLARE_PRIVATE(QtMaterialRaisedButton) -}; - -#endif // QTMATERIALRAISEDBUTTON_H diff --git a/components/qtmaterialraisedbutton_p.h b/components/qtmaterialraisedbutton_p.h deleted file mode 100644 index 12df43c82..000000000 --- a/components/qtmaterialraisedbutton_p.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef QTMATERIALRAISEDBUTTON_P_H -#define QTMATERIALRAISEDBUTTON_P_H - -#include "qtmaterialflatbutton_p.h" - -class QStateMachine; -class QState; -class QGraphicsDropShadowEffect; -class QtMaterialRaisedButton; - -class QtMaterialRaisedButtonPrivate : public QtMaterialFlatButtonPrivate -{ - Q_DISABLE_COPY(QtMaterialRaisedButtonPrivate) - Q_DECLARE_PUBLIC(QtMaterialRaisedButton) - -public: - QtMaterialRaisedButtonPrivate(QtMaterialRaisedButton *q); - ~QtMaterialRaisedButtonPrivate(); - - void init(); - - QStateMachine *shadowStateMachine; - QState *normalState; - QState *pressedState; - QGraphicsDropShadowEffect *effect; -}; - -#endif // QTMATERIALRAISEDBUTTON_P_H diff --git a/components/qtmaterialscrollbar_internal.h b/components/qtmaterialscrollbar_internal.h deleted file mode 100644 index 7b1cc92ac..000000000 --- a/components/qtmaterialscrollbar_internal.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef QTMATERIALSCROLLBAR_INTERNAL_H -#define QTMATERIALSCROLLBAR_INTERNAL_H - -#include -#include "qtmaterialscrollbar.h" - -class QtMaterialScrollBarStateMachine : public QStateMachine -{ - Q_OBJECT - - Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity) - -public: - QtMaterialScrollBarStateMachine(QtMaterialScrollBar *parent); - ~QtMaterialScrollBarStateMachine(); - - inline void setOpacity(qreal opacity); - inline qreal opacity() const; - -private: - Q_DISABLE_COPY(QtMaterialScrollBarStateMachine) - - QtMaterialScrollBar *const m_scrollBar; - QState *const m_focusState; - QState *const m_blurState; - qreal m_opacity; -}; - -inline void QtMaterialScrollBarStateMachine::setOpacity(qreal opacity) -{ - m_opacity = opacity; - m_scrollBar->update(); -} - -inline qreal QtMaterialScrollBarStateMachine::opacity() const -{ - return m_opacity; -} - -#endif // QTMATERIALSCROLLBAR_INTERNAL_H diff --git a/components/qtmaterialscrollbar_p.h b/components/qtmaterialscrollbar_p.h deleted file mode 100644 index 1d22cc06b..000000000 --- a/components/qtmaterialscrollbar_p.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QTMATERIALSCROLLBAR_P_H -#define QTMATERIALSCROLLBAR_P_H - -#include -#include - -class QtMaterialScrollBar; -class QtMaterialScrollBarStateMachine; - -class QtMaterialScrollBarPrivate -{ - Q_DISABLE_COPY(QtMaterialScrollBarPrivate) - Q_DECLARE_PUBLIC(QtMaterialScrollBar) - -public: - QtMaterialScrollBarPrivate(QtMaterialScrollBar *q); - ~QtMaterialScrollBarPrivate(); - - void init(); - - QtMaterialScrollBar *const q_ptr; - QtMaterialScrollBarStateMachine *stateMachine; - QColor backgroundColor; - QColor sliderColor; - QColor canvasColor; - bool hideOnMouseOut; - bool useThemeColors; -}; - -#endif // QTMATERIALSCROLLBAR_P_H diff --git a/components/qtmaterialsnackbar_p.h b/components/qtmaterialsnackbar_p.h deleted file mode 100644 index 39501fd25..000000000 --- a/components/qtmaterialsnackbar_p.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef QTMATERIALSNACKBAR_P_H -#define QTMATERIALSNACKBAR_P_H - -#include -#include - -class QtMaterialSnackbar; -class QtMaterialSnackbarStateMachine; - -class QtMaterialSnackbarPrivate -{ - Q_DISABLE_COPY(QtMaterialSnackbarPrivate) - Q_DECLARE_PUBLIC(QtMaterialSnackbar) - -public: - QtMaterialSnackbarPrivate(QtMaterialSnackbar *q); - ~QtMaterialSnackbarPrivate(); - - void init(); - - QtMaterialSnackbar *const q_ptr; - QtMaterialSnackbarStateMachine *stateMachine; - QColor backgroundColor; - QColor textColor; - qreal bgOpacity; - QList messages; - int duration; - int boxWidth; - bool clickDismiss; - bool useThemeColors; -}; - -#endif // QTMATERIALSNACKBAR_P_H diff --git a/components/qtmaterialtable.cpp b/components/qtmaterialtable.cpp deleted file mode 100644 index 171c04aa6..000000000 --- a/components/qtmaterialtable.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "qtmaterialtable.h" -#include "qtmaterialtable_p.h" diff --git a/components/qtmaterialtable.h b/components/qtmaterialtable.h deleted file mode 100644 index b8953fab9..000000000 --- a/components/qtmaterialtable.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALTABLE_H -#define QTMATERIALTABLE_H - -#endif // QTMATERIALTABLE_H diff --git a/components/qtmaterialtable_p.h b/components/qtmaterialtable_p.h deleted file mode 100644 index d3232a0f4..000000000 --- a/components/qtmaterialtable_p.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef QTMATERIALTABLE_P_H -#define QTMATERIALTABLE_P_H - -#endif // QTMATERIALTABLE_P_H diff --git a/components/qtmaterialtabs.cpp b/components/qtmaterialtabs.cpp deleted file mode 100644 index dbc55bdbd..000000000 --- a/components/qtmaterialtabs.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include "qtmaterialtabs.h" -#include "qtmaterialtabs_p.h" -#include -#include "qtmaterialtabs_internal.h" -#include "lib/qtmaterialstyle.h" - -/*! - * \QtMaterialTabsPrivate - * \internal - */ - -QtMaterialTabsPrivate::QtMaterialTabsPrivate(QtMaterialTabs *q) - : q_ptr(q) -{ -} - -QtMaterialTabsPrivate::~QtMaterialTabsPrivate() -{ -} - -void QtMaterialTabsPrivate::QtMaterialTabsPrivate::init() -{ - Q_Q(QtMaterialTabs); - - inkBar = new QtMaterialTabsInkBar(q); - tabLayout = new QHBoxLayout; - rippleStyle = Material::CenteredRipple; - tab = -1; - showHalo = true; - useThemeColors = true; - - q->setLayout(tabLayout); - q->setStyle(&QtMaterialStyle::instance()); - - tabLayout->setSpacing(0); - tabLayout->setMargin(0); -} - -/*! - * \QtMaterialTabs - */ - -QtMaterialTabs::QtMaterialTabs(QWidget *parent) - : QWidget(parent), - d_ptr(new QtMaterialTabsPrivate(this)) -{ - d_func()->init(); -} - -QtMaterialTabs::~QtMaterialTabs() -{ -} - -void QtMaterialTabs::setUseThemeColors(bool value) -{ - Q_D(QtMaterialTabs); - - d->useThemeColors = value; -} - -bool QtMaterialTabs::useThemeColors() const -{ - Q_D(const QtMaterialTabs); - - return d->useThemeColors; -} - -void QtMaterialTabs::setHaloVisible(bool value) -{ - Q_D(QtMaterialTabs); - - d->showHalo = value; - updateTabs(); -} - -bool QtMaterialTabs::isHaloVisible() const -{ - Q_D(const QtMaterialTabs); - - return d->showHalo; -} - -void QtMaterialTabs::setRippleStyle(Material::RippleStyle style) -{ - Q_D(QtMaterialTabs); - - d->rippleStyle = style; - updateTabs(); -} - -Material::RippleStyle QtMaterialTabs::rippleStyle() const -{ - Q_D(const QtMaterialTabs); - - return d->rippleStyle; -} - -void QtMaterialTabs::setInkColor(const QColor &color) -{ - Q_D(QtMaterialTabs); - - d->inkColor = color; - - MATERIAL_DISABLE_THEME_COLORS - d->inkBar->update(); - update(); -} - -QColor QtMaterialTabs::inkColor() const -{ - Q_D(const QtMaterialTabs); - - if (d->useThemeColors || !d->inkColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent1"); - } else { - return d->inkColor; - } -} - -void QtMaterialTabs::setBackgroundColor(const QColor &color) -{ - Q_D(QtMaterialTabs); - - d->backgroundColor = color; - - MATERIAL_DISABLE_THEME_COLORS - updateTabs(); - update(); -} - -QColor QtMaterialTabs::backgroundColor() const -{ - Q_D(const QtMaterialTabs); - - if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); - } else { - return d->backgroundColor; - } -} - -void QtMaterialTabs::setTextColor(const QColor &color) -{ - Q_D(QtMaterialTabs); - - d->textColor = color; - - MATERIAL_DISABLE_THEME_COLORS - updateTabs(); - update(); -} - -QColor QtMaterialTabs::textColor() const -{ - Q_D(const QtMaterialTabs); - - if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("canvas"); - } else { - return d->textColor; - } -} - -void QtMaterialTabs::setCurrentTab(QtMaterialTab *tab) -{ - Q_D(QtMaterialTabs); - - setCurrentTab(d->tabLayout->indexOf(tab)); -} - -void QtMaterialTabs::setCurrentTab(int index) -{ - Q_D(QtMaterialTabs); - - setTabActive(d->tab, false); - d->tab = index; - setTabActive(index, true); - d->inkBar->animate(); - - emit currentChanged(index); -} - -void QtMaterialTabs::addTab(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->addWidget(tab); - - if (-1 == d->tab) { - d->tab = 0; - d->inkBar->refreshGeometry(); - d->inkBar->raise(); - tab->setActive(true); - } -} - -int QtMaterialTabs::currentIndex() const -{ - Q_D(const QtMaterialTabs); - - return d->tab; -} - -void QtMaterialTabs::setTabActive(int index, bool active) -{ - Q_D(QtMaterialTabs); - - QtMaterialTab *tab; - - if (index > -1) { - tab = static_cast(d->tabLayout->itemAt(index)->widget()); - if (tab) { - tab->setActive(active); - } - } -} - -void QtMaterialTabs::updateTabs() -{ - Q_D(QtMaterialTabs); - - QtMaterialTab *tab; - for (int i = 0; i < d->tabLayout->count(); ++i) { - QLayoutItem *item = d->tabLayout->itemAt(i); - if ((tab = static_cast(item->widget()))) { - tab->setRippleStyle(d->rippleStyle); - tab->setHaloVisible(d->showHalo); - tab->setBackgroundColor(backgroundColor()); - tab->setForegroundColor(textColor()); - } - } -} diff --git a/components/qtmaterialtabs_p.h b/components/qtmaterialtabs_p.h deleted file mode 100644 index 1f32b04ed..000000000 --- a/components/qtmaterialtabs_p.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef QTMATERIALTABS_P_H -#define QTMATERIALTABS_P_H - -#include -#include "lib/qtmaterialtheme.h" - -class QHBoxLayout; -class QtMaterialTabs; -class QtMaterialTabsInkBar; - -class QtMaterialTabsPrivate -{ - Q_DISABLE_COPY(QtMaterialTabsPrivate) - Q_DECLARE_PUBLIC(QtMaterialTabs) - -public: - QtMaterialTabsPrivate(QtMaterialTabs *q); - ~QtMaterialTabsPrivate(); - - void init(); - - QtMaterialTabs *const q_ptr; - QtMaterialTabsInkBar *inkBar; - QHBoxLayout *tabLayout; - Material::RippleStyle rippleStyle; - QColor inkColor; - QColor backgroundColor; - QColor textColor; - int tab; - bool showHalo; - bool useThemeColors; -}; - -#endif // QTMATERIALTABS_P_H diff --git a/components/qtmaterialtextfield_p.h b/components/qtmaterialtextfield_p.h deleted file mode 100644 index 9e8c83540..000000000 --- a/components/qtmaterialtextfield_p.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QTMATERIALTEXTFIELD_P_H -#define QTMATERIALTEXTFIELD_P_H - -#include -#include - -class QtMaterialTextField; -class QtMaterialTextFieldStateMachine; -class QtMaterialTextFieldLabel; - -class QtMaterialTextFieldPrivate -{ - Q_DISABLE_COPY(QtMaterialTextFieldPrivate) - Q_DECLARE_PUBLIC(QtMaterialTextField) - -public: - QtMaterialTextFieldPrivate(QtMaterialTextField *q); - virtual ~QtMaterialTextFieldPrivate(); - - void init(); - - QtMaterialTextField *const q_ptr; - QtMaterialTextFieldStateMachine *stateMachine; - QtMaterialTextFieldLabel *label; - QColor textColor; - QColor labelColor; - QColor inkColor; - QColor inputLineColor; - QString labelString; - qreal labelFontSize; - bool showLabel; - bool showInputLine; - bool useThemeColors; -}; - -#endif // QTMATERIALTEXTFIELD_P_H diff --git a/components/qtmaterialtoggle_p.h b/components/qtmaterialtoggle_p.h deleted file mode 100644 index f50d5b35b..000000000 --- a/components/qtmaterialtoggle_p.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef QTMATERIALTOGGLE_P_H -#define QTMATERIALTOGGLE_P_H - -#include - -class QStateMachine; -class QState; -class QColor; -class QtMaterialToggle; -class QtMaterialToggleTrack; -class QtMaterialToggleThumb; -class QtMaterialToggleRippleOverlay; - -class QtMaterialTogglePrivate -{ - Q_DISABLE_COPY(QtMaterialTogglePrivate) - Q_DECLARE_PUBLIC(QtMaterialToggle) - -public: - QtMaterialTogglePrivate(QtMaterialToggle *q); - ~QtMaterialTogglePrivate(); - - void init(); - void setupProperties(); - - QtMaterialToggle *const q_ptr; - QtMaterialToggleTrack *track; - QtMaterialToggleThumb *thumb; - QtMaterialToggleRippleOverlay *rippleOverlay; - QStateMachine *stateMachine; - QState *offState; - QState *onState; - Qt::Orientation orientation; - QColor disabledColor; - QColor activeColor; - QColor inactiveColor; - QColor trackColor; - bool useThemeColors; -}; - -#endif // QTMATERIALTOGGLE_P_H diff --git a/components/qtmaterialradiobutton.cpp b/components/radiobutton.cpp similarity index 74% rename from components/qtmaterialradiobutton.cpp rename to components/radiobutton.cpp index 86427c787..d2f067d20 100644 --- a/components/qtmaterialradiobutton.cpp +++ b/components/radiobutton.cpp @@ -1,28 +1,26 @@ -#include "qtmaterialradiobutton.h" -#include "qtmaterialradiobutton_p.h" -#include -#include -#include -#include -#include "lib/qtmaterialcheckable_internal.h" +#include "radiobutton.h" +#include "radiobutton_p.h" +#include "lib/checkable_internal.h" +namespace md +{ /*! - * \class QtMaterialRadioButtonPrivate + * \class RadioButtonPrivate * \internal */ -QtMaterialRadioButtonPrivate::QtMaterialRadioButtonPrivate(QtMaterialRadioButton *q) - : QtMaterialCheckablePrivate(q) +RadioButtonPrivate::RadioButtonPrivate(RadioButton *q) + : CheckablePrivate(q) { } -QtMaterialRadioButtonPrivate::~QtMaterialRadioButtonPrivate() +RadioButtonPrivate::~RadioButtonPrivate() { } -void QtMaterialRadioButtonPrivate::init() +void RadioButtonPrivate::init() { - Q_Q(QtMaterialRadioButton); + Q_Q(RadioButton); q->setAutoExclusive(true); @@ -78,23 +76,24 @@ void QtMaterialRadioButtonPrivate::init() * \class QtMaterialRadioButton */ -QtMaterialRadioButton::QtMaterialRadioButton(QWidget *parent) - : QtMaterialCheckable(*new QtMaterialRadioButtonPrivate(this), parent) +RadioButton::RadioButton(QWidget *parent) + : Checkable(*new RadioButtonPrivate(this), parent) { d_func()->init(); } -QtMaterialRadioButton::~QtMaterialRadioButton() +RadioButton::~RadioButton() { } -void QtMaterialRadioButton::setupProperties() +void RadioButton::setupProperties() { - QtMaterialCheckable::setupProperties(); + Checkable::setupProperties(); - Q_D(QtMaterialRadioButton); + Q_D(RadioButton); d->checkedState->assignProperty(d->checkedIcon, "color", checkedColor()); d->checkedState->assignProperty(d->uncheckedIcon, "color", uncheckedColor()); d->uncheckedState->assignProperty(d->uncheckedIcon, "color", uncheckedColor()); } +} diff --git a/components/radiobutton.h b/components/radiobutton.h new file mode 100644 index 000000000..a63cbdc53 --- /dev/null +++ b/components/radiobutton.h @@ -0,0 +1,27 @@ +#ifndef RADIOBUTTON_H +#define RADIOBUTTON_H + +#include "lib/checkable.h" + +namespace md +{ + +class RadioButtonPrivate; + +class RadioButton : public Checkable +{ + Q_OBJECT + +public: + explicit RadioButton(QWidget *parent = 0); + ~RadioButton(); + +protected: + void setupProperties(); + +private: + Q_DISABLE_COPY(RadioButton) + Q_DECLARE_PRIVATE(RadioButton) +}; +} +#endif // RADIOBUTTON_H diff --git a/components/radiobutton_p.h b/components/radiobutton_p.h new file mode 100644 index 000000000..fb087a2d5 --- /dev/null +++ b/components/radiobutton_p.h @@ -0,0 +1,29 @@ +#ifndef RADIOBUTTON_P_H +#define RADIOBUTTON_P_H + +#include +#include +#include +#include + +#include "radiobutton.h" +#include "lib/checkable_p.h" + +namespace md +{ + +class RadioButton; + +class RadioButtonPrivate : public CheckablePrivate +{ + Q_DISABLE_COPY(RadioButtonPrivate) + Q_DECLARE_PUBLIC(RadioButton) + +public: + RadioButtonPrivate(RadioButton *q); + ~RadioButtonPrivate(); + + void init(); +}; +} +#endif // RADIOBUTTON_P_H diff --git a/components/qtmaterialraisedbutton.cpp b/components/raisedbutton.cpp similarity index 67% rename from components/qtmaterialraisedbutton.cpp rename to components/raisedbutton.cpp index 1607c7072..1f15f8db8 100644 --- a/components/qtmaterialraisedbutton.cpp +++ b/components/raisedbutton.cpp @@ -1,9 +1,7 @@ -#include "qtmaterialraisedbutton.h" -#include "qtmaterialraisedbutton_p.h" -#include -#include -#include -#include +#include "raisedbutton_p.h" + +namespace md +{ /*! * \class QtMaterialRaisedButtonPrivate @@ -13,24 +11,24 @@ /*! * \internal */ -QtMaterialRaisedButtonPrivate::QtMaterialRaisedButtonPrivate(QtMaterialRaisedButton *q) - : QtMaterialFlatButtonPrivate(q) +RaisedButtonPrivate::RaisedButtonPrivate(RaisedButton *q) + : FlatButtonPrivate(q) { } /*! * \internal */ -QtMaterialRaisedButtonPrivate::~QtMaterialRaisedButtonPrivate() +RaisedButtonPrivate::~RaisedButtonPrivate() { } /*! * \internal */ -void QtMaterialRaisedButtonPrivate::init() +void RaisedButtonPrivate::init() { - Q_Q(QtMaterialRaisedButton); + Q_Q(RaisedButton); shadowStateMachine = new QStateMachine(q); normalState = new QState; @@ -87,33 +85,33 @@ void QtMaterialRaisedButtonPrivate::init() * \class QtMaterialRaisedButton */ -QtMaterialRaisedButton::QtMaterialRaisedButton(QWidget *parent) - : QtMaterialFlatButton(*new QtMaterialRaisedButtonPrivate(this), parent) +RaisedButton::RaisedButton(QWidget *parent) + : FlatButton(*new RaisedButtonPrivate(this), parent) { d_func()->init(); } -QtMaterialRaisedButton::QtMaterialRaisedButton(const QString &text, QWidget *parent) - : QtMaterialFlatButton(*new QtMaterialRaisedButtonPrivate(this), parent) +RaisedButton::RaisedButton(const QString &text, QWidget *parent) + : FlatButton(*new RaisedButtonPrivate(this), parent) { d_func()->init(); setText(text); } -QtMaterialRaisedButton::~QtMaterialRaisedButton() +RaisedButton::~RaisedButton() { } -QtMaterialRaisedButton::QtMaterialRaisedButton(QtMaterialRaisedButtonPrivate &d, QWidget *parent) - : QtMaterialFlatButton(d, parent) +RaisedButton::RaisedButton(RaisedButtonPrivate &d, QWidget *parent) + : FlatButton(d, parent) { d_func()->init(); } -bool QtMaterialRaisedButton::event(QEvent *event) +bool RaisedButton::event(QEvent *event) { - Q_D(QtMaterialRaisedButton); + Q_D(RaisedButton); if (QEvent::EnabledChange == event->type()) { if (isEnabled()) { @@ -124,5 +122,6 @@ bool QtMaterialRaisedButton::event(QEvent *event) d->effect->setEnabled(false); } } - return QtMaterialFlatButton::event(event); + return FlatButton::event(event); +} } diff --git a/components/raisedbutton.h b/components/raisedbutton.h new file mode 100644 index 000000000..0836aaa81 --- /dev/null +++ b/components/raisedbutton.h @@ -0,0 +1,30 @@ +#ifndef RAISEDBUTTON_H +#define RAISEDBUTTON_H + +#include "flatbutton.h" + +namespace md +{ + +class RaisedButtonPrivate; + +class RaisedButton : public FlatButton +{ + Q_OBJECT + +public: + explicit RaisedButton(QWidget *parent = 0); + explicit RaisedButton(const QString &text, QWidget *parent = 0); + ~RaisedButton(); + +protected: + RaisedButton(RaisedButtonPrivate &d, QWidget *parent = 0); + + bool event(QEvent *event) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(RaisedButton) + Q_DECLARE_PRIVATE(RaisedButton) +}; +} +#endif // RAISEDBUTTON_H diff --git a/components/raisedbutton_p.h b/components/raisedbutton_p.h new file mode 100644 index 000000000..40b0ea13d --- /dev/null +++ b/components/raisedbutton_p.h @@ -0,0 +1,34 @@ +#ifndef RAISEDBUTTON_P_H +#define RAISEDBUTTON_P_H + +#include +#include +#include +#include + +#include "flatbutton_p.h" +#include "raisedbutton.h" + +namespace md +{ + +class RaisedButton; + +class RaisedButtonPrivate : public FlatButtonPrivate +{ + Q_DISABLE_COPY(RaisedButtonPrivate) + Q_DECLARE_PUBLIC(RaisedButton) + +public: + RaisedButtonPrivate(RaisedButton *q); + ~RaisedButtonPrivate(); + + void init(); + + QStateMachine *shadowStateMachine; + QState *normalState; + QState *pressedState; + QGraphicsDropShadowEffect *effect; +}; +} +#endif // RAISEDBUTTON_P_H diff --git a/components/resources.qrc b/components/resources.qrc index 605bd1a05..1ff57241a 100644 --- a/components/resources.qrc +++ b/components/resources.qrc @@ -1,11 +1,17 @@ - ../fonts/Roboto/Roboto-Black.ttf - ../fonts/Roboto/Roboto-Bold.ttf - ../fonts/Roboto/Roboto-Medium.ttf - ../fonts/Roboto/Roboto-Regular.ttf - ../fonts/Roboto/Roboto-Light.ttf - ../fonts/Roboto/Roboto-Thin.ttf + fonts/Roboto/Roboto-Black.ttf + fonts/Roboto/Roboto-BlackItalic.ttf + fonts/Roboto/Roboto-Bold.ttf + fonts/Roboto/Roboto-BoldItalic.ttf + fonts/Roboto/Roboto-Italic.ttf + fonts/Roboto/Roboto-Light.ttf + fonts/Roboto/Roboto-LightItalic.ttf + fonts/Roboto/Roboto-Medium.ttf + fonts/Roboto/Roboto-MediumItalic.ttf + fonts/Roboto/Roboto-Regular.ttf + fonts/Roboto/Roboto-Thin.ttf + fonts/Roboto/Roboto-ThinItalic.ttf icons/communication/svg/production/ic_message_24px.svg diff --git a/components/qtmaterialscrollbar.cpp b/components/scrollbar.cpp similarity index 59% rename from components/qtmaterialscrollbar.cpp rename to components/scrollbar.cpp index bb44820f9..8b5ae5750 100644 --- a/components/qtmaterialscrollbar.cpp +++ b/components/scrollbar.cpp @@ -1,35 +1,32 @@ -#include "qtmaterialscrollbar.h" -#include "qtmaterialscrollbar_p.h" -#include -#include -#include -#include "qtmaterialscrollbar_internal.h" -#include "lib/qtmaterialstyle.h" +#include "scrollbar.h" + +namespace md +{ /*! * \class QtMaterialScrollBarPrivate * \internal */ -QtMaterialScrollBarPrivate::QtMaterialScrollBarPrivate(QtMaterialScrollBar *q) +ScrollBarPrivate::ScrollBarPrivate(ScrollBar *q) : q_ptr(q) { } -QtMaterialScrollBarPrivate::~QtMaterialScrollBarPrivate() +ScrollBarPrivate::~ScrollBarPrivate() { } -void QtMaterialScrollBarPrivate::init() +void ScrollBarPrivate::init() { - Q_Q(QtMaterialScrollBar); + Q_Q(ScrollBar); - stateMachine = new QtMaterialScrollBarStateMachine(q); + stateMachine = new ScrollBarStateMachine(q); hideOnMouseOut = true; useThemeColors = true; q->setMouseTracking(true); - q->setStyle(&QtMaterialStyle::instance()); + q->setStyle(&Style::instance()); q->setStyleSheet("QScrollBar:vertical { margin: 0; }" "QScrollBar::add-line:vertical { height: 0; margin: 0; }" "QScrollBar::sub-line:vertical { height: 0; margin: 0; }"); @@ -41,21 +38,21 @@ void QtMaterialScrollBarPrivate::init() * \class QtMaterialScrollBar */ -QtMaterialScrollBar::QtMaterialScrollBar(QWidget *parent) +ScrollBar::ScrollBar(QWidget *parent) : QScrollBar(parent), - d_ptr(new QtMaterialScrollBarPrivate(this)) + d_ptr(new ScrollBarPrivate(this)) { d_func()->init(); } -QtMaterialScrollBar::~QtMaterialScrollBar() +ScrollBar::~ScrollBar() { } /*! * \reimp */ -QSize QtMaterialScrollBar::sizeHint() const +QSize ScrollBar::sizeHint() const { if (Qt::Horizontal == orientation()) { return QSize(1, 10); @@ -64,9 +61,9 @@ QSize QtMaterialScrollBar::sizeHint() const } } -void QtMaterialScrollBar::setUseThemeColors(bool value) +void ScrollBar::setUseThemeColors(bool value) { - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); if (d->useThemeColors == value) { return; @@ -76,16 +73,16 @@ void QtMaterialScrollBar::setUseThemeColors(bool value) update(); } -bool QtMaterialScrollBar::useThemeColors() const +bool ScrollBar::useThemeColors() const { - Q_D(const QtMaterialScrollBar); + Q_D(const ScrollBar); return d->useThemeColors; } -void QtMaterialScrollBar::setCanvasColor(const QColor &color) +void ScrollBar::setCanvasColor(const QColor &color) { - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); d->canvasColor = color; @@ -93,9 +90,9 @@ void QtMaterialScrollBar::setCanvasColor(const QColor &color) update(); } -QColor QtMaterialScrollBar::canvasColor() const +QColor ScrollBar::canvasColor() const { - Q_D(const QtMaterialScrollBar); + Q_D(const ScrollBar); if (d->useThemeColors || !d->canvasColor.isValid()) { return parentWidget()->palette().color(backgroundRole()); @@ -104,9 +101,9 @@ QColor QtMaterialScrollBar::canvasColor() const } } -void QtMaterialScrollBar::setBackgroundColor(const QColor &color) +void ScrollBar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); d->backgroundColor = color; @@ -114,20 +111,20 @@ void QtMaterialScrollBar::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialScrollBar::backgroundColor() const +QColor ScrollBar::backgroundColor() const { - Q_D(const QtMaterialScrollBar); + Q_D(const ScrollBar); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("border"); + return Style::instance().themeColor("border"); } else { return d->backgroundColor; } } -void QtMaterialScrollBar::setSliderColor(const QColor &color) +void ScrollBar::setSliderColor(const QColor &color) { - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); d->sliderColor = color; @@ -135,28 +132,28 @@ void QtMaterialScrollBar::setSliderColor(const QColor &color) update(); } -QColor QtMaterialScrollBar::sliderColor() const +QColor ScrollBar::sliderColor() const { - Q_D(const QtMaterialScrollBar); + Q_D(const ScrollBar); if (d->useThemeColors || !d->sliderColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->sliderColor; } } -void QtMaterialScrollBar::setHideOnMouseOut(bool value) +void ScrollBar::setHideOnMouseOut(bool value) { - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); d->hideOnMouseOut = value; update(); } -bool QtMaterialScrollBar::hideOnMouseOut() const +bool ScrollBar::hideOnMouseOut() const { - Q_D(const QtMaterialScrollBar); + Q_D(const ScrollBar); return d->hideOnMouseOut; } @@ -164,11 +161,11 @@ bool QtMaterialScrollBar::hideOnMouseOut() const /*! * \reimp */ -void QtMaterialScrollBar::paintEvent(QPaintEvent *event) +void ScrollBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialScrollBar); + Q_D(ScrollBar); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); @@ -210,3 +207,4 @@ void QtMaterialScrollBar::paintEvent(QPaintEvent *event) painter.drawRoundedRect(handle, 9, 9); } +} diff --git a/components/qtmaterialscrollbar.h b/components/scrollbar.h similarity index 63% rename from components/qtmaterialscrollbar.h rename to components/scrollbar.h index 591c9f171..e44dfc3e1 100644 --- a/components/qtmaterialscrollbar.h +++ b/components/scrollbar.h @@ -1,11 +1,21 @@ -#ifndef QTMATERIALSCROLLBAR_H -#define QTMATERIALSCROLLBAR_H +#ifndef SCROLLBAR_H +#define SCROLLBAR_H #include +#include +#include +#include -class QtMaterialScrollBarPrivate; +#include "scrollbar_p.h" +#include "scrollbar_internal.h" +#include "lib/style.h" -class QtMaterialScrollBar : public QScrollBar +namespace md +{ + +class ScrollBarPrivate; + +class ScrollBar : public QScrollBar { Q_OBJECT @@ -14,8 +24,8 @@ class QtMaterialScrollBar : public QScrollBar Q_PROPERTY(QColor sliderColor WRITE setSliderColor READ sliderColor) public: - explicit QtMaterialScrollBar(QWidget *parent = 0); - ~QtMaterialScrollBar(); + explicit ScrollBar(QWidget *parent = 0); + ~ScrollBar(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -37,11 +47,11 @@ class QtMaterialScrollBar : public QScrollBar protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialScrollBar) - Q_DECLARE_PRIVATE(QtMaterialScrollBar) + Q_DISABLE_COPY(ScrollBar) + Q_DECLARE_PRIVATE(ScrollBar) }; - -#endif // QTMATERIALSCROLLBAR_H +} +#endif // SCROLLBAR_H diff --git a/components/qtmaterialscrollbar_internal.cpp b/components/scrollbar_internal.cpp similarity index 83% rename from components/qtmaterialscrollbar_internal.cpp rename to components/scrollbar_internal.cpp index 248d91ad8..f1c67d9a5 100644 --- a/components/qtmaterialscrollbar_internal.cpp +++ b/components/scrollbar_internal.cpp @@ -1,6 +1,8 @@ -#include "qtmaterialscrollbar_internal.h" +#include "scrollbar_internal.h" #include #include +namespace md +{ /*! * \class QtMaterialScrollBarStateMachine @@ -10,7 +12,7 @@ /*! * \internal */ -QtMaterialScrollBarStateMachine::QtMaterialScrollBarStateMachine(QtMaterialScrollBar *parent) +ScrollBarStateMachine::ScrollBarStateMachine(ScrollBar *parent) : QStateMachine(parent), m_scrollBar(parent), m_focusState(new QState), @@ -46,6 +48,7 @@ QtMaterialScrollBarStateMachine::QtMaterialScrollBarStateMachine(QtMaterialScrol /*! * \internal */ -QtMaterialScrollBarStateMachine::~QtMaterialScrollBarStateMachine() +ScrollBarStateMachine::~ScrollBarStateMachine() { } +} diff --git a/components/scrollbar_internal.h b/components/scrollbar_internal.h new file mode 100644 index 000000000..1a1619486 --- /dev/null +++ b/components/scrollbar_internal.h @@ -0,0 +1,45 @@ +#ifndef SCROLLBAR_INTERNAL_H +#define SCROLLBAR_INTERNAL_H + +#include +#include "scrollbar.h" + +namespace md +{ + +class ScrollBar; + +class ScrollBarStateMachine : public QStateMachine +{ + Q_OBJECT + + Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity) + +public: + ScrollBarStateMachine(ScrollBar *parent); + ~ScrollBarStateMachine(); + + inline void setOpacity(qreal opacity); + inline qreal opacity() const; + +private: + Q_DISABLE_COPY(ScrollBarStateMachine) + + ScrollBar *const m_scrollBar; + QState *const m_focusState; + QState *const m_blurState; + qreal m_opacity; +}; + +inline void ScrollBarStateMachine::setOpacity(qreal opacity) +{ + m_opacity = opacity; +// m_scrollBar->update(); // FIXME: incomplete type 'class md::ScrollBar' +} + +inline qreal ScrollBarStateMachine::opacity() const +{ + return m_opacity; +} +} +#endif // SCROLLBAR_INTERNAL_H diff --git a/components/scrollbar_p.h b/components/scrollbar_p.h new file mode 100644 index 000000000..08277714b --- /dev/null +++ b/components/scrollbar_p.h @@ -0,0 +1,33 @@ +#ifndef SCROLLBAR_P_H +#define SCROLLBAR_P_H + +#include +#include + +namespace md +{ + +class ScrollBar; +class ScrollBarStateMachine; + +class ScrollBarPrivate +{ + Q_DISABLE_COPY(ScrollBarPrivate) + Q_DECLARE_PUBLIC(ScrollBar) + +public: + ScrollBarPrivate(ScrollBar *q); + ~ScrollBarPrivate(); + + void init(); + + ScrollBar *const q_ptr; + ScrollBarStateMachine *stateMachine; + QColor backgroundColor; + QColor sliderColor; + QColor canvasColor; + bool hideOnMouseOut; + bool useThemeColors; +}; +} +#endif // SCROLLBAR_P_H diff --git a/components/qtmaterialslider.cpp b/components/slider.cpp similarity index 65% rename from components/qtmaterialslider.cpp rename to components/slider.cpp index a0d17dc12..1dd4c061b 100644 --- a/components/qtmaterialslider.cpp +++ b/components/slider.cpp @@ -1,32 +1,35 @@ -#include "qtmaterialslider.h" -#include "qtmaterialslider_p.h" +#include "slider.h" +#include "slider_p.h" #include #include -#include "qtmaterialslider_internal.h" -#include "lib/qtmaterialstyle.h" -#include "lib/qtmaterialstatetransitionevent.h" +#include "slider_internal.h" +#include "lib/style.h" +#include "lib/statetransitionevent.h" + +namespace md +{ /*! * \class QtMaterialSliderPrivate * \internal */ -QtMaterialSliderPrivate::QtMaterialSliderPrivate(QtMaterialSlider *q) +SliderPrivate::SliderPrivate(Slider *q) : q_ptr(q) { } -QtMaterialSliderPrivate::~QtMaterialSliderPrivate() +SliderPrivate::~SliderPrivate() { } -void QtMaterialSliderPrivate::init() +void SliderPrivate::init() { - Q_Q(QtMaterialSlider); + Q_Q(Slider); - thumb = new QtMaterialSliderThumb(q); - track = new QtMaterialSliderTrack(thumb, q); - stateMachine = new QtMaterialSliderStateMachine(q, thumb, track); + thumb = new SliderThumb(q); + track = new SliderTrack(thumb, q); + stateMachine = new SliderStateMachine(q, thumb, track); stepTo = 0; oldValue = q->value(); trackWidth = 2; @@ -55,9 +58,9 @@ void QtMaterialSliderPrivate::init() QCoreApplication::processEvents(); } -QRectF QtMaterialSliderPrivate::trackBoundingRect() const +QRectF SliderPrivate::trackBoundingRect() const { - Q_Q(const QtMaterialSlider); + Q_Q(const Slider); qreal hw = static_cast(trackWidth)/2; @@ -68,9 +71,9 @@ QRectF QtMaterialSliderPrivate::trackBoundingRect() const q->height() - QT_MATERIAL_SLIDER_MARGIN*2); } -QRectF QtMaterialSliderPrivate::thumbBoundingRect() const +QRectF SliderPrivate::thumbBoundingRect() const { - Q_Q(const QtMaterialSlider); + Q_Q(const Slider); return Qt::Horizontal == q->orientation() ? QRectF(thumb->offset(), q->height()/2 - QT_MATERIAL_SLIDER_MARGIN, @@ -79,9 +82,9 @@ QRectF QtMaterialSliderPrivate::thumbBoundingRect() const QT_MATERIAL_SLIDER_MARGIN*2, QT_MATERIAL_SLIDER_MARGIN*2); } -int QtMaterialSliderPrivate::valueFromPosition(const QPoint &pos) const +int SliderPrivate::valueFromPosition(const QPoint &pos) const { - Q_Q(const QtMaterialSlider); + Q_Q(const Slider); const int position = Qt::Horizontal == q->orientation() ? pos.x() : pos.y(); @@ -89,7 +92,7 @@ int QtMaterialSliderPrivate::valueFromPosition(const QPoint &pos) const ? q->width() - QT_MATERIAL_SLIDER_MARGIN*2 : q->height() - QT_MATERIAL_SLIDER_MARGIN*2; - return QtMaterialStyle::sliderValueFromPosition( + return Style::sliderValueFromPosition( q->minimum(), q->maximum(), position - QT_MATERIAL_SLIDER_MARGIN, @@ -97,9 +100,9 @@ int QtMaterialSliderPrivate::valueFromPosition(const QPoint &pos) const q->invertedAppearance()); } -void QtMaterialSliderPrivate::setHovered(bool status) +void SliderPrivate::setHovered(bool status) { - Q_Q(QtMaterialSlider); + Q_Q(Slider); if (hover == status) { return; @@ -109,9 +112,9 @@ void QtMaterialSliderPrivate::setHovered(bool status) if (!q->hasFocus()) { if (status) { - stateMachine->postEvent(new QtMaterialStateTransitionEvent(SliderNoFocusMouseEnter)); + stateMachine->postEvent(new StateTransitionEvent(SliderNoFocusMouseEnter)); } else { - stateMachine->postEvent(new QtMaterialStateTransitionEvent(SliderNoFocusMouseLeave)); + stateMachine->postEvent(new StateTransitionEvent(SliderNoFocusMouseLeave)); } } @@ -122,20 +125,20 @@ void QtMaterialSliderPrivate::setHovered(bool status) * \class QtMaterialSlider */ -QtMaterialSlider::QtMaterialSlider(QWidget *parent) +Slider::Slider(QWidget *parent) : QAbstractSlider(parent), - d_ptr(new QtMaterialSliderPrivate(this)) + d_ptr(new SliderPrivate(this)) { d_func()->init(); } -QtMaterialSlider::~QtMaterialSlider() +Slider::~Slider() { } -void QtMaterialSlider::setUseThemeColors(bool value) +void Slider::setUseThemeColors(bool value) { - Q_D(QtMaterialSlider); + Q_D(Slider); if (d->useThemeColors == value) { return; @@ -145,16 +148,16 @@ void QtMaterialSlider::setUseThemeColors(bool value) d->stateMachine->setupProperties(); } -bool QtMaterialSlider::useThemeColors() const +bool Slider::useThemeColors() const { - Q_D(const QtMaterialSlider); + Q_D(const Slider); return d->useThemeColors; } -void QtMaterialSlider::setThumbColor(const QColor &color) +void Slider::setThumbColor(const QColor &color) { - Q_D(QtMaterialSlider); + Q_D(Slider); d->thumbColor = color; @@ -163,20 +166,20 @@ void QtMaterialSlider::setThumbColor(const QColor &color) update(); } -QColor QtMaterialSlider::thumbColor() const +QColor Slider::thumbColor() const { - Q_D(const QtMaterialSlider); + Q_D(const Slider); if (d->useThemeColors || !d->thumbColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->thumbColor; } } -void QtMaterialSlider::setTrackColor(const QColor &color) +void Slider::setTrackColor(const QColor &color) { - Q_D(QtMaterialSlider); + Q_D(Slider); d->trackColor = color; @@ -185,20 +188,20 @@ void QtMaterialSlider::setTrackColor(const QColor &color) update(); } -QColor QtMaterialSlider::trackColor() const +QColor Slider::trackColor() const { - Q_D(const QtMaterialSlider); + Q_D(const Slider); if (d->useThemeColors || !d->trackColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent3"); + return Style::instance().themeColor("accent3"); } else { return d->trackColor; } } -void QtMaterialSlider::setDisabledColor(const QColor &color) +void Slider::setDisabledColor(const QColor &color) { - Q_D(QtMaterialSlider); + Q_D(Slider); d->disabledColor = color; @@ -207,27 +210,27 @@ void QtMaterialSlider::setDisabledColor(const QColor &color) update(); } -QColor QtMaterialSlider::disabledColor() const +QColor Slider::disabledColor() const { - Q_D(const QtMaterialSlider); + Q_D(const Slider); if (d->useThemeColors || !d->disabledColor.isValid()) { - return QtMaterialStyle::instance().themeColor("disabled"); + return Style::instance().themeColor("disabled"); } else { return d->disabledColor; } } -void QtMaterialSlider::setPageStepMode(bool pageStep) +void Slider::setPageStepMode(bool pageStep) { - Q_D(QtMaterialSlider); + Q_D(Slider); d->pageStepMode = pageStep; } -bool QtMaterialSlider::pageStepMode() const +bool Slider::pageStepMode() const { - Q_D(const QtMaterialSlider); + Q_D(const Slider); return d->pageStepMode; } @@ -235,14 +238,14 @@ bool QtMaterialSlider::pageStepMode() const /*! * \remip */ -QSize QtMaterialSlider::minimumSizeHint() const +QSize Slider::minimumSizeHint() const { return Qt::Horizontal == orientation() ? QSize(130, 34) : QSize(34, 130); } -void QtMaterialSlider::setInvertedAppearance(bool value) +void Slider::setInvertedAppearance(bool value) { QAbstractSlider::setInvertedAppearance(value); @@ -252,9 +255,9 @@ void QtMaterialSlider::setInvertedAppearance(bool value) /*! * \remip */ -void QtMaterialSlider::sliderChange(SliderChange change) +void Slider::sliderChange(SliderChange change) { - Q_D(QtMaterialSlider); + Q_D(Slider); if (SliderOrientationChange == change) { @@ -268,12 +271,12 @@ void QtMaterialSlider::sliderChange(SliderChange change) { if (minimum() == value()) { triggerAction(SliderToMinimum); - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SliderChangedToMinimum)); + d->stateMachine->postEvent(new StateTransitionEvent(SliderChangedToMinimum)); } else if (maximum() == value()) { triggerAction(SliderToMaximum); } if (minimum() == d->oldValue) { - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SliderChangedFromMinimum)); + d->stateMachine->postEvent(new StateTransitionEvent(SliderChangedFromMinimum)); } d->oldValue = value(); } @@ -286,9 +289,9 @@ void QtMaterialSlider::sliderChange(SliderChange change) /*! * \remip */ -void QtMaterialSlider::mouseMoveEvent(QMouseEvent *event) +void Slider::mouseMoveEvent(QMouseEvent *event) { - Q_D(QtMaterialSlider); + Q_D(Slider); if (isSliderDown()) { @@ -320,9 +323,9 @@ void QtMaterialSlider::mouseMoveEvent(QMouseEvent *event) /*! * \remip */ -void QtMaterialSlider::mousePressEvent(QMouseEvent *event) +void Slider::mousePressEvent(QMouseEvent *event) { - Q_D(QtMaterialSlider); + Q_D(Slider); const QPoint pos = event->pos(); @@ -355,9 +358,9 @@ void QtMaterialSlider::mousePressEvent(QMouseEvent *event) /*! * \remip */ -void QtMaterialSlider::mouseReleaseEvent(QMouseEvent *event) +void Slider::mouseReleaseEvent(QMouseEvent *event) { - Q_D(QtMaterialSlider); + Q_D(Slider); if (isSliderDown()) { setSliderDown(false); @@ -372,9 +375,9 @@ void QtMaterialSlider::mouseReleaseEvent(QMouseEvent *event) /*! * \remip */ -void QtMaterialSlider::leaveEvent(QEvent *event) +void Slider::leaveEvent(QEvent *event) { - Q_D(QtMaterialSlider); + Q_D(Slider); if (d->hoverTrack) { d->hoverTrack = false; @@ -390,11 +393,11 @@ void QtMaterialSlider::leaveEvent(QEvent *event) QAbstractSlider::leaveEvent(event); } -void QtMaterialSlider::updateThumbOffset() +void Slider::updateThumbOffset() { - Q_D(QtMaterialSlider); + Q_D(Slider); - const int offset = QtMaterialStyle::sliderPositionFromValue( + const int offset = Style::sliderPositionFromValue( minimum(), maximum(), sliderPosition(), @@ -405,3 +408,4 @@ void QtMaterialSlider::updateThumbOffset() d->thumb->setOffset(offset); } +} diff --git a/components/qtmaterialslider.h b/components/slider.h similarity index 76% rename from components/qtmaterialslider.h rename to components/slider.h index f8e642d8c..9de580972 100644 --- a/components/qtmaterialslider.h +++ b/components/slider.h @@ -1,14 +1,17 @@ -#ifndef QTMATERIALSLIDER_H -#define QTMATERIALSLIDER_H +#ifndef SLIDER_H +#define SLIDER_H #include #include #define QT_MATERIAL_SLIDER_MARGIN 30 -class QtMaterialSliderPrivate; +namespace md +{ + +class SliderPrivate; -class QtMaterialSlider : public QAbstractSlider +class Slider : public QAbstractSlider { Q_OBJECT @@ -17,8 +20,8 @@ class QtMaterialSlider : public QAbstractSlider Q_PROPERTY(QColor disabledColor WRITE setDisabledColor READ disabledColor) public: - explicit QtMaterialSlider(QWidget *parent = 0); - ~QtMaterialSlider(); + explicit Slider(QWidget *parent = 0); + ~Slider(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -48,11 +51,11 @@ class QtMaterialSlider : public QAbstractSlider void updateThumbOffset(); - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialSlider) - Q_DECLARE_PRIVATE(QtMaterialSlider) + Q_DISABLE_COPY(Slider) + Q_DECLARE_PRIVATE(Slider) }; - -#endif // QTMATERIALSLIDER_H +} +#endif // SLIDER_H diff --git a/components/qtmaterialslider_internal.cpp b/components/slider_internal.cpp similarity index 88% rename from components/qtmaterialslider_internal.cpp rename to components/slider_internal.cpp index fd2d50bf8..0b8c58fde 100644 --- a/components/qtmaterialslider_internal.cpp +++ b/components/slider_internal.cpp @@ -1,23 +1,25 @@ -#include "qtmaterialslider_internal.h" +#include "slider_internal.h" #include #include #include #include #include #include -#include "qtmaterialslider.h" -#include "lib/qtmaterialstyle.h" -#include "lib/qtmaterialstatetransition.h" +#include "slider.h" +#include "lib/style.h" +#include "lib/statetransition.h" +namespace md +{ /*! * \class QtMaterialSliderStateMachine * \internal */ -QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( - QtMaterialSlider *slider, - QtMaterialSliderThumb *thumb, - QtMaterialSliderTrack *track) +SliderStateMachine::SliderStateMachine( + Slider *slider, + SliderThumb *thumb, + SliderTrack *track) : QStateMachine(slider), m_slider(slider), m_thumb(thumb), @@ -50,12 +52,12 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( m_slidingState->assignProperty(thumb, "diameter", 17); QAbstractTransition *transition; - QtMaterialStateTransition *customTransition; + StateTransition *customTransition; QPropertyAnimation *animation; // Show halo on mouse enter - customTransition = new QtMaterialStateTransition(SliderNoFocusMouseEnter); + customTransition = new StateTransition(SliderNoFocusMouseEnter); customTransition->setTargetState(m_focusState); animation = new QPropertyAnimation(thumb, "haloSize", this); @@ -88,7 +90,7 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( // Hide halo on mouse leave, except if widget has focus - customTransition = new QtMaterialStateTransition(SliderNoFocusMouseLeave); + customTransition = new StateTransition(SliderNoFocusMouseLeave); customTransition->setTargetState(m_inactiveState); animation = new QPropertyAnimation(thumb, "haloSize", this); @@ -152,7 +154,7 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( m_sndState->setInitialState(m_minState); - customTransition = new QtMaterialStateTransition(SliderChangedFromMinimum); + customTransition = new StateTransition(SliderChangedFromMinimum); customTransition->setTargetState(m_normalState); animation = new QPropertyAnimation(thumb, "fillColor", this); @@ -173,7 +175,7 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( m_minState->addTransition(customTransition); - customTransition = new QtMaterialStateTransition(SliderChangedToMinimum); + customTransition = new StateTransition(SliderChangedToMinimum); customTransition->setTargetState(m_minState); animation = new QPropertyAnimation(thumb, "fillColor", this); @@ -197,11 +199,11 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine( setupProperties(); } -QtMaterialSliderStateMachine::~QtMaterialSliderStateMachine() +SliderStateMachine::~SliderStateMachine() { } -void QtMaterialSliderStateMachine::setupProperties() +void SliderStateMachine::setupProperties() { QColor trackColor = m_slider->trackColor(); QColor thumbColor = m_slider->thumbColor(); @@ -233,8 +235,8 @@ void QtMaterialSliderStateMachine::setupProperties() * \internal */ -QtMaterialSliderThumb::QtMaterialSliderThumb(QtMaterialSlider *slider) - : QtMaterialOverlayWidget(slider->parentWidget()), +SliderThumb::SliderThumb(Slider *slider) + : OverlayWidget(slider->parentWidget()), m_slider(slider), m_diameter(11), m_borderWidth(2), @@ -246,20 +248,20 @@ QtMaterialSliderThumb::QtMaterialSliderThumb(QtMaterialSlider *slider) setAttribute(Qt::WA_TransparentForMouseEvents, true); } -QtMaterialSliderThumb::~QtMaterialSliderThumb() +SliderThumb::~SliderThumb() { } -bool QtMaterialSliderThumb::eventFilter(QObject *obj, QEvent *event) +bool SliderThumb::eventFilter(QObject *obj, QEvent *event) { if (QEvent::ParentChange == event->type()) { setParent(m_slider->parentWidget()); } - return QtMaterialOverlayWidget::eventFilter(obj, event); + return OverlayWidget::eventFilter(obj, event); } -void QtMaterialSliderThumb::paintEvent(QPaintEvent *event) +void SliderThumb::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -325,8 +327,8 @@ void QtMaterialSliderThumb::paintEvent(QPaintEvent *event) * \internal */ -QtMaterialSliderTrack::QtMaterialSliderTrack(QtMaterialSliderThumb *thumb, QtMaterialSlider *slider) - : QtMaterialOverlayWidget(slider->parentWidget()), +SliderTrack::SliderTrack(SliderThumb *thumb, Slider *slider) + : OverlayWidget(slider->parentWidget()), m_slider(slider), m_thumb(thumb), m_trackWidth(2) @@ -338,20 +340,20 @@ QtMaterialSliderTrack::QtMaterialSliderTrack(QtMaterialSliderThumb *thumb, QtMat connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(update())); } -QtMaterialSliderTrack::~QtMaterialSliderTrack() +SliderTrack::~SliderTrack() { } -bool QtMaterialSliderTrack::eventFilter(QObject *obj, QEvent *event) +bool SliderTrack::eventFilter(QObject *obj, QEvent *event) { if (QEvent::ParentChange == event->type()) { setParent(m_slider->parentWidget()); } - return QtMaterialOverlayWidget::eventFilter(obj, event); + return OverlayWidget::eventFilter(obj, event); } -void QtMaterialSliderTrack::paintEvent(QPaintEvent *event) +void SliderTrack::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -406,3 +408,4 @@ void QtMaterialSliderTrack::paintEvent(QPaintEvent *event) painter.fillRect(bgRect, bg); painter.fillRect(fgRect, fg); } +} diff --git a/components/qtmaterialslider_internal.h b/components/slider_internal.h similarity index 58% rename from components/qtmaterialslider_internal.h rename to components/slider_internal.h index 6f2649e8e..1f189808a 100644 --- a/components/qtmaterialslider_internal.h +++ b/components/slider_internal.h @@ -1,31 +1,33 @@ -#ifndef QTMATERIALSLIDER_INTERNAL_H -#define QTMATERIALSLIDER_INTERNAL_H +#ifndef SLIDER_INTERNAL_H +#define SLIDER_INTERNAL_H #include -#include "lib/qtmaterialoverlaywidget.h" +#include "lib/overlaywidget.h" +namespace md +{ -class QtMaterialSlider; -class QtMaterialSliderThumb; -class QtMaterialSliderTrack; +class Slider; +class SliderThumb; +class SliderTrack; -class QtMaterialSliderStateMachine : public QStateMachine +class SliderStateMachine : public QStateMachine { Q_OBJECT public: - QtMaterialSliderStateMachine(QtMaterialSlider *slider, - QtMaterialSliderThumb *thumb, - QtMaterialSliderTrack *track); - ~QtMaterialSliderStateMachine(); + SliderStateMachine(Slider *slider, + SliderThumb *thumb, + SliderTrack *track); + ~SliderStateMachine(); void setupProperties(); private: - Q_DISABLE_COPY(QtMaterialSliderStateMachine) + Q_DISABLE_COPY(SliderStateMachine) - QtMaterialSlider *const m_slider; - QtMaterialSliderThumb *const m_thumb; - QtMaterialSliderTrack *const m_track; + Slider *const m_slider; + SliderThumb *const m_thumb; + SliderTrack *const m_track; QState *const m_topState; QState *const m_fstState; QState *const m_sndState; @@ -38,7 +40,7 @@ class QtMaterialSliderStateMachine : public QStateMachine QState *const m_normalState; }; -class QtMaterialSliderThumb : public QtMaterialOverlayWidget +class SliderThumb : public OverlayWidget { Q_OBJECT @@ -50,8 +52,8 @@ class QtMaterialSliderThumb : public QtMaterialOverlayWidget Q_PROPERTY(QColor haloColor WRITE setHaloColor READ haloColor) public: - explicit QtMaterialSliderThumb(QtMaterialSlider *slider); - ~QtMaterialSliderThumb(); + explicit SliderThumb(Slider *slider); + ~SliderThumb(); inline void setDiameter(qreal diameter); inline qreal diameter() const; @@ -79,9 +81,9 @@ class QtMaterialSliderThumb : public QtMaterialOverlayWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialSliderThumb) + Q_DISABLE_COPY(SliderThumb) - const QtMaterialSlider *const m_slider; + const Slider *const m_slider; QColor m_borderColor; QColor m_fillColor; QColor m_haloColor; @@ -91,92 +93,92 @@ class QtMaterialSliderThumb : public QtMaterialOverlayWidget int m_offset; }; -inline void QtMaterialSliderThumb::setDiameter(qreal diameter) +inline void SliderThumb::setDiameter(qreal diameter) { m_diameter = diameter; update(); } -inline qreal QtMaterialSliderThumb::diameter() const +inline qreal SliderThumb::diameter() const { return m_diameter; } -inline void QtMaterialSliderThumb::setBorderWidth(qreal width) +inline void SliderThumb::setBorderWidth(qreal width) { m_borderWidth = width; update(); } -inline qreal QtMaterialSliderThumb::borderWidth() const +inline qreal SliderThumb::borderWidth() const { return m_borderWidth; } -inline void QtMaterialSliderThumb::setBorderColor(const QColor &color) +inline void SliderThumb::setBorderColor(const QColor &color) { m_borderColor = color; update(); } -inline QColor QtMaterialSliderThumb::borderColor() const +inline QColor SliderThumb::borderColor() const { return m_borderColor; } -inline void QtMaterialSliderThumb::setFillColor(const QColor &color) +inline void SliderThumb::setFillColor(const QColor &color) { m_fillColor = color; update(); } -inline QColor QtMaterialSliderThumb::fillColor() const +inline QColor SliderThumb::fillColor() const { return m_fillColor; } -inline void QtMaterialSliderThumb::setHaloSize(qreal size) +inline void SliderThumb::setHaloSize(qreal size) { m_haloSize = size; update(); } -inline qreal QtMaterialSliderThumb::haloSize() const +inline qreal SliderThumb::haloSize() const { return m_haloSize; } -inline void QtMaterialSliderThumb::setHaloColor(const QColor &color) +inline void SliderThumb::setHaloColor(const QColor &color) { m_haloColor = color; update(); } -inline QColor QtMaterialSliderThumb::haloColor() const +inline QColor SliderThumb::haloColor() const { return m_haloColor; } -inline void QtMaterialSliderThumb::setOffset(int offset) +inline void SliderThumb::setOffset(int offset) { m_offset = offset; update(); } -inline int QtMaterialSliderThumb::offset() const +inline int SliderThumb::offset() const { return m_offset; } -class QtMaterialSliderTrack : public QtMaterialOverlayWidget +class SliderTrack : public OverlayWidget { Q_OBJECT Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor) public: - explicit QtMaterialSliderTrack(QtMaterialSliderThumb *thumb, QtMaterialSlider *slider); - ~QtMaterialSliderTrack(); + explicit SliderTrack(SliderThumb *thumb, Slider *slider); + ~SliderTrack(); inline void setFillColor(const QColor &color); inline QColor fillColor() const; @@ -189,34 +191,34 @@ class QtMaterialSliderTrack : public QtMaterialOverlayWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialSliderTrack) + Q_DISABLE_COPY(SliderTrack) - const QtMaterialSlider *const m_slider; - QtMaterialSliderThumb *const m_thumb; + const Slider *const m_slider; + SliderThumb *const m_thumb; QColor m_fillColor; int m_trackWidth; }; -inline void QtMaterialSliderTrack::setFillColor(const QColor &color) +inline void SliderTrack::setFillColor(const QColor &color) { m_fillColor = color; update(); } -inline QColor QtMaterialSliderTrack::fillColor() const +inline QColor SliderTrack::fillColor() const { return m_fillColor; } -void QtMaterialSliderTrack::setTrackWidth(int width) +void SliderTrack::setTrackWidth(int width) { m_trackWidth = width; update(); } -int QtMaterialSliderTrack::trackWidth() const +int SliderTrack::trackWidth() const { return m_trackWidth; } - -#endif // QTMATERIALSLIDER_INTERNAL_H +} +#endif // SLIDER_INTERNAL_H diff --git a/components/qtmaterialslider_p.h b/components/slider_p.h similarity index 58% rename from components/qtmaterialslider_p.h rename to components/slider_p.h index ff6b7ca2b..313d67f30 100644 --- a/components/qtmaterialslider_p.h +++ b/components/slider_p.h @@ -1,23 +1,26 @@ -#ifndef QTMATERIALSLIDER_P_H -#define QTMATERIALSLIDER_P_H +#ifndef SLIDER_P_H +#define SLIDER_P_H #include #include #include -class QtMaterialSlider; -class QtMaterialSliderThumb; -class QtMaterialSliderTrack; -class QtMaterialSliderStateMachine; +namespace md +{ + +class Slider; +class SliderThumb; +class SliderTrack; +class SliderStateMachine; -class QtMaterialSliderPrivate +class SliderPrivate { - Q_DISABLE_COPY(QtMaterialSliderPrivate) - Q_DECLARE_PUBLIC(QtMaterialSlider) + Q_DISABLE_COPY(SliderPrivate) + Q_DECLARE_PUBLIC(Slider) public: - QtMaterialSliderPrivate(QtMaterialSlider *q); - ~QtMaterialSliderPrivate(); + SliderPrivate(Slider *q); + ~SliderPrivate(); void init(); @@ -28,10 +31,10 @@ class QtMaterialSliderPrivate void setHovered(bool status); - QtMaterialSlider *const q_ptr; - QtMaterialSliderThumb *thumb; - QtMaterialSliderTrack *track; - QtMaterialSliderStateMachine *stateMachine; + Slider *const q_ptr; + SliderThumb *thumb; + SliderTrack *track; + SliderStateMachine *stateMachine; QColor thumbColor; QColor trackColor; QColor disabledColor; @@ -45,5 +48,5 @@ class QtMaterialSliderPrivate bool pageStepMode; bool useThemeColors; }; - -#endif // QTMATERIALSLIDER_P_H +} +#endif // SLIDER_P_H diff --git a/components/qtmaterialsnackbar.cpp b/components/snackbar.cpp similarity index 52% rename from components/qtmaterialsnackbar.cpp rename to components/snackbar.cpp index 323ff20fe..3d76201b7 100644 --- a/components/qtmaterialsnackbar.cpp +++ b/components/snackbar.cpp @@ -1,31 +1,33 @@ -#include "qtmaterialsnackbar.h" -#include "qtmaterialsnackbar_p.h" +#include "snackbar.h" +#include "snackbar_p.h" #include #include -#include "qtmaterialsnackbar_internal.h" -#include "lib/qtmaterialstyle.h" -#include "lib/qtmaterialstatetransition.h" +#include "snackbar_internal.h" +#include "lib/style.h" +#include "lib/statetransition.h" #include +namespace md +{ /*! * \class QtMaterialSnackbarPrivate * \internal */ -QtMaterialSnackbarPrivate::QtMaterialSnackbarPrivate(QtMaterialSnackbar *q) +SnackBarPrivate::SnackBarPrivate(SnackBar *q) : q_ptr(q) { } -QtMaterialSnackbarPrivate::~QtMaterialSnackbarPrivate() +SnackBarPrivate::~SnackBarPrivate() { } -void QtMaterialSnackbarPrivate::init() +void SnackBarPrivate::init() { - Q_Q(QtMaterialSnackbar); + Q_Q(SnackBar); - stateMachine = new QtMaterialSnackbarStateMachine(q); + stateMachine = new SnackBarStateMachine(q); bgOpacity = 0.9; duration = 3000; boxWidth = 300; @@ -46,34 +48,34 @@ void QtMaterialSnackbarPrivate::init() * \class QtMaterialSnackbar */ -QtMaterialSnackbar::QtMaterialSnackbar(QWidget *parent) - : QtMaterialOverlayWidget(parent), - d_ptr(new QtMaterialSnackbarPrivate(this)) +SnackBar::SnackBar(QWidget *parent) + : OverlayWidget(parent), + d_ptr(new SnackBarPrivate(this)) { d_func()->init(); } -QtMaterialSnackbar::~QtMaterialSnackbar() +SnackBar::~SnackBar() { } -void QtMaterialSnackbar::setAutoHideDuration(int duration) +void SnackBar::setAutoHideDuration(int duration) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->duration = duration; } -int QtMaterialSnackbar::autoHideDuration() const +int SnackBar::autoHideDuration() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); return d->duration; } -void QtMaterialSnackbar::setUseThemeColors(bool value) +void SnackBar::setUseThemeColors(bool value) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); if (d->useThemeColors == value) { return; @@ -83,16 +85,16 @@ void QtMaterialSnackbar::setUseThemeColors(bool value) update(); } -bool QtMaterialSnackbar::useThemeColors() const +bool SnackBar::useThemeColors() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); return d->useThemeColors; } -void QtMaterialSnackbar::setBackgroundColor(const QColor &color) +void SnackBar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->backgroundColor = color; @@ -100,35 +102,35 @@ void QtMaterialSnackbar::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialSnackbar::backgroundColor() const +QColor SnackBar::backgroundColor() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); if (d->useThemeColors || !d->backgroundColor.isValid()) { - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } else { return d->backgroundColor; } } -void QtMaterialSnackbar::setBackgroundOpacity(qreal opacity) +void SnackBar::setBackgroundOpacity(qreal opacity) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->bgOpacity = opacity; update(); } -qreal QtMaterialSnackbar::backgroundOpacity() const +qreal SnackBar::backgroundOpacity() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); return d->bgOpacity; } -void QtMaterialSnackbar::setTextColor(const QColor &color) +void SnackBar::setTextColor(const QColor &color) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->textColor = color; @@ -136,18 +138,18 @@ void QtMaterialSnackbar::setTextColor(const QColor &color) update(); } -QColor QtMaterialSnackbar::textColor() const +QColor SnackBar::textColor() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("canvas"); + return Style::instance().themeColor("canvas"); } else { return d->textColor; } } -void QtMaterialSnackbar::setFontSize(qreal size) +void SnackBar::setFontSize(qreal size) { QFont f(font()); f.setPointSizeF(size); @@ -156,52 +158,52 @@ void QtMaterialSnackbar::setFontSize(qreal size) update(); } -qreal QtMaterialSnackbar::fontSize() const +qreal SnackBar::fontSize() const { return font().pointSizeF(); } -void QtMaterialSnackbar::setBoxWidth(int width) +void SnackBar::setBoxWidth(int width) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->boxWidth = width; update(); } -int QtMaterialSnackbar::boxWidth() const +int SnackBar::boxWidth() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); return d->boxWidth; } -void QtMaterialSnackbar::setClickToDismissMode(bool value) +void SnackBar::setClickToDismissMode(bool value) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->clickDismiss = value; } -bool QtMaterialSnackbar::clickToDismissMode() const +bool SnackBar::clickToDismissMode() const { - Q_D(const QtMaterialSnackbar); + Q_D(const SnackBar); return d->clickDismiss; } -void QtMaterialSnackbar::addMessage(const QString &message) +void SnackBar::addMessage(const QString &message) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); d->messages.push_back(message); - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SnackbarShowTransition)); + d->stateMachine->postEvent(new StateTransitionEvent(SnackbarShowTransition)); raise(); } -void QtMaterialSnackbar::addInstantMessage(const QString &message) +void SnackBar::addInstantMessage(const QString &message) { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); if (d->messages.isEmpty()) { d->messages.push_back(message); @@ -212,9 +214,9 @@ void QtMaterialSnackbar::addInstantMessage(const QString &message) d->stateMachine->progress(); } -void QtMaterialSnackbar::dequeue() +void SnackBar::dequeue() { - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); if (d->messages.isEmpty()) { return; @@ -223,17 +225,17 @@ void QtMaterialSnackbar::dequeue() d->messages.removeFirst(); if (!d->messages.isEmpty()) { - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SnackbarNextTransition)); + d->stateMachine->postEvent(new StateTransitionEvent(SnackbarNextTransition)); } else { - d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SnackbarWaitTransition)); + d->stateMachine->postEvent(new StateTransitionEvent(SnackbarWaitTransition)); } } -void QtMaterialSnackbar::paintEvent(QPaintEvent *event) +void SnackBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) - Q_D(QtMaterialSnackbar); + Q_D(SnackBar); if (d->messages.isEmpty()) { return; @@ -268,3 +270,4 @@ void QtMaterialSnackbar::paintEvent(QPaintEvent *event) painter.setPen(textColor()); painter.drawText(br, Qt::AlignHCenter | Qt::AlignTop | Qt::TextWordWrap, message); } +} diff --git a/components/qtmaterialsnackbar.h b/components/snackbar.h similarity index 66% rename from components/qtmaterialsnackbar.h rename to components/snackbar.h index 6d9474001..c20f06bb6 100644 --- a/components/qtmaterialsnackbar.h +++ b/components/snackbar.h @@ -1,17 +1,20 @@ -#ifndef QTMATERIALSNACKBAR_H -#define QTMATERIALSNACKBAR_H +#ifndef SNACKBAR_H +#define SNACKBAR_H -#include "lib/qtmaterialoverlaywidget.h" +#include "lib/overlaywidget.h" -class QtMaterialSnackbarPrivate; +namespace md +{ + +class SnackBarPrivate; -class QtMaterialSnackbar : public QtMaterialOverlayWidget +class SnackBar : public OverlayWidget { Q_OBJECT public: - explicit QtMaterialSnackbar(QWidget *parent = 0); - ~QtMaterialSnackbar(); + explicit SnackBar(QWidget *parent = 0); + ~SnackBar(); void setAutoHideDuration(int duration); int autoHideDuration() const; @@ -47,11 +50,11 @@ protected slots: protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialSnackbar) - Q_DECLARE_PRIVATE(QtMaterialSnackbar) + Q_DISABLE_COPY(SnackBar) + Q_DECLARE_PRIVATE(SnackBar) }; - -#endif // QTMATERIALSNACKBAR_H +} +#endif // SNACKBAR_H diff --git a/components/qtmaterialsnackbar_internal.cpp b/components/snackbar_internal.cpp similarity index 67% rename from components/qtmaterialsnackbar_internal.cpp rename to components/snackbar_internal.cpp index 9e6167d76..8d298d2a7 100644 --- a/components/qtmaterialsnackbar_internal.cpp +++ b/components/snackbar_internal.cpp @@ -1,10 +1,12 @@ -#include "qtmaterialsnackbar_internal.h" +#include "snackbar_internal.h" #include -#include "qtmaterialsnackbar.h" -#include "lib/qtmaterialstatetransition.h" +#include "snackbar.h" +#include "lib/statetransition.h" #include +namespace md +{ -QtMaterialSnackbarStateMachine::QtMaterialSnackbarStateMachine(QtMaterialSnackbar *parent) +SnackBarStateMachine::SnackBarStateMachine(SnackBar *parent) : QStateMachine(parent), m_snackbar(parent) { @@ -20,25 +22,25 @@ QtMaterialSnackbarStateMachine::QtMaterialSnackbarStateMachine(QtMaterialSnackba setInitialState(hiddenState); - QtMaterialStateTransition *transition; + StateTransition *transition; - transition = new QtMaterialStateTransition(SnackbarShowTransition); + transition = new StateTransition(SnackbarShowTransition); transition->setTargetState(visibleState); hiddenState->addTransition(transition); - transition = new QtMaterialStateTransition(SnackbarHideTransition); + transition = new StateTransition(SnackbarHideTransition); transition->setTargetState(visibleState); hiddenState->addTransition(transition); - transition = new QtMaterialStateTransition(SnackbarHideTransition); + transition = new StateTransition(SnackbarHideTransition); transition->setTargetState(finalState); visibleState->addTransition(transition); - transition = new QtMaterialStateTransition(SnackbarWaitTransition); + transition = new StateTransition(SnackbarWaitTransition); transition->setTargetState(hiddenState); finalState->addTransition(transition); - transition = new QtMaterialStateTransition(SnackbarNextTransition); + transition = new StateTransition(SnackbarNextTransition); transition->setTargetState(visibleState); finalState->addTransition(transition); @@ -63,11 +65,11 @@ QtMaterialSnackbarStateMachine::QtMaterialSnackbarStateMachine(QtMaterialSnackba m_snackbar->installEventFilter(this); } -QtMaterialSnackbarStateMachine::~QtMaterialSnackbarStateMachine() +SnackBarStateMachine::~SnackBarStateMachine() { } -bool QtMaterialSnackbarStateMachine::eventFilter(QObject *watched, QEvent *event) +bool SnackBarStateMachine::eventFilter(QObject *watched, QEvent *event) { if (QEvent::MouseButtonPress == event->type() && m_snackbar->clickToDismissMode()) { progress(); @@ -75,25 +77,26 @@ bool QtMaterialSnackbarStateMachine::eventFilter(QObject *watched, QEvent *event return QStateMachine::eventFilter(watched, event); } -void QtMaterialSnackbarStateMachine::setOffset(qreal offset) +void SnackBarStateMachine::setOffset(qreal offset) { m_offset = offset; m_snackbar->update(); } -void QtMaterialSnackbarStateMachine::progress() +void SnackBarStateMachine::progress() { m_timer.stop(); - postEvent(new QtMaterialStateTransitionEvent(SnackbarHideTransition)); + postEvent(new StateTransitionEvent(SnackbarHideTransition)); if (m_snackbar->clickToDismissMode()) { m_snackbar->setAttribute(Qt::WA_TransparentForMouseEvents, true); } } -void QtMaterialSnackbarStateMachine::snackbarShown() +void SnackBarStateMachine::snackbarShown() { m_timer.start(m_snackbar->autoHideDuration()); if (m_snackbar->clickToDismissMode()) { m_snackbar->setAttribute(Qt::WA_TransparentForMouseEvents, false); } } +} diff --git a/components/qtmaterialsnackbar_internal.h b/components/snackbar_internal.h similarity index 51% rename from components/qtmaterialsnackbar_internal.h rename to components/snackbar_internal.h index 117a8e557..da0ed5c68 100644 --- a/components/qtmaterialsnackbar_internal.h +++ b/components/snackbar_internal.h @@ -1,20 +1,23 @@ -#ifndef QTMATERIALSNACKBAR_INTERNAL_H -#define QTMATERIALSNACKBAR_INTERNAL_H +#ifndef SNACKBAR_INTERNAL_H +#define SNACKBAR_INTERNAL_H #include #include -class QtMaterialSnackbar; +namespace md +{ + +class SnackBar; -class QtMaterialSnackbarStateMachine : public QStateMachine +class SnackBarStateMachine : public QStateMachine { Q_OBJECT Q_PROPERTY(qreal offset WRITE setOffset READ offset) public: - QtMaterialSnackbarStateMachine(QtMaterialSnackbar *parent); - ~QtMaterialSnackbarStateMachine(); + SnackBarStateMachine(SnackBar *parent); + ~SnackBarStateMachine(); void setOffset(qreal offset); inline qreal offset() const; @@ -29,16 +32,16 @@ protected slots: bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialSnackbarStateMachine) + Q_DISABLE_COPY(SnackBarStateMachine) - QtMaterialSnackbar *const m_snackbar; + SnackBar *const m_snackbar; QTimer m_timer; qreal m_offset; }; -inline qreal QtMaterialSnackbarStateMachine::offset() const +inline qreal SnackBarStateMachine::offset() const { return m_offset; } - -#endif // QTMATERIALSNACKBAR_INTERNAL_H +} +#endif // SNACKBAR_INTERNAL_H diff --git a/components/snackbar_p.h b/components/snackbar_p.h new file mode 100644 index 000000000..6a5bcba99 --- /dev/null +++ b/components/snackbar_p.h @@ -0,0 +1,36 @@ +#ifndef SNACKBAR_P_H +#define SNACKBAR_P_H + +#include +#include + +namespace md +{ + +class SnackBar; +class SnackBarStateMachine; + +class SnackBarPrivate +{ + Q_DISABLE_COPY(SnackBarPrivate) + Q_DECLARE_PUBLIC(SnackBar) + +public: + SnackBarPrivate(SnackBar *q); + ~SnackBarPrivate(); + + void init(); + + SnackBar *const q_ptr; + SnackBarStateMachine *stateMachine; + QColor backgroundColor; + QColor textColor; + qreal bgOpacity; + QList messages; + int duration; + int boxWidth; + bool clickDismiss; + bool useThemeColors; +}; +} +#endif // SNACKBAR_P_H diff --git a/components/table.cpp b/components/table.cpp new file mode 100644 index 000000000..691d8965d --- /dev/null +++ b/components/table.cpp @@ -0,0 +1,6 @@ +#include "table.h" +#include "table_p.h" +namespace md +{ + +} diff --git a/components/table.h b/components/table.h new file mode 100644 index 000000000..66bf702d1 --- /dev/null +++ b/components/table.h @@ -0,0 +1,7 @@ +#ifndef TABLE_H +#define TABLE_H +namespace md +{ + +} +#endif // TABLE_H diff --git a/components/table_p.h b/components/table_p.h new file mode 100644 index 000000000..21164ce60 --- /dev/null +++ b/components/table_p.h @@ -0,0 +1,7 @@ +#ifndef TABLE_P_H +#define TABLE_P_H +namespace md +{ + +} +#endif // TABLE_P_H diff --git a/components/tabs.cpp b/components/tabs.cpp new file mode 100644 index 000000000..3f17457d7 --- /dev/null +++ b/components/tabs.cpp @@ -0,0 +1,243 @@ +#include "tabs.h" + +namespace md +{ + +/*! + * \TabsPrivate + * \internal + */ + +TabsPrivate::TabsPrivate(Tabs *q) + : q_ptr(q) +{ +} + +TabsPrivate::~TabsPrivate() +{ +} + +void TabsPrivate::TabsPrivate::init() +{ + Q_Q(Tabs); + + inkBar = new TabsInkBar(q); + tabLayout = new QHBoxLayout; + rippleStyle = Material::CenteredRipple; + tab = -1; + showHalo = true; + useThemeColors = true; + + q->setLayout(tabLayout); + q->setStyle(&Style::instance()); + + tabLayout->setSpacing(0); + +// tabLayout->setMargin(0); // FIXME: throwing an error +} + +/*! + * \QtMaterialTabs + */ + +Tabs::Tabs(QWidget *parent) + : QWidget(parent), + d_ptr(new TabsPrivate(this)) +{ + d_func()->init(); +} + +Tabs::~Tabs() +{ +} + +void Tabs::setUseThemeColors(bool value) +{ + Q_D(Tabs); + + d->useThemeColors = value; +} + +bool Tabs::useThemeColors() const +{ + Q_D(const Tabs); + + return d->useThemeColors; +} + +void Tabs::setHaloVisible(bool value) +{ + Q_D(Tabs); + + d->showHalo = value; + updateTabs(); +} + +bool Tabs::isHaloVisible() const +{ + Q_D(const Tabs); + + return d->showHalo; +} + +void Tabs::setRippleStyle(Material::RippleStyle style) +{ + Q_D(Tabs); + + d->rippleStyle = style; + updateTabs(); +} + +Material::RippleStyle Tabs::rippleStyle() const +{ + Q_D(const Tabs); + + return d->rippleStyle; +} + +void Tabs::setInkColor(const QColor &color) +{ + Q_D(Tabs); + + d->inkColor = color; + + MATERIAL_DISABLE_THEME_COLORS + d->inkBar->update(); + update(); +} + +QColor Tabs::inkColor() const +{ + Q_D(const Tabs); + + if (d->useThemeColors || !d->inkColor.isValid()) { + return Style::instance().themeColor("accent1"); + } else { + return d->inkColor; + } +} + +void Tabs::setBackgroundColor(const QColor &color) +{ + Q_D(Tabs); + + d->backgroundColor = color; + + MATERIAL_DISABLE_THEME_COLORS + updateTabs(); + update(); +} + +QColor Tabs::backgroundColor() const +{ + Q_D(const Tabs); + + if (d->useThemeColors || !d->backgroundColor.isValid()) { + return Style::instance().themeColor("primary1"); + } else { + return d->backgroundColor; + } +} + +void Tabs::setTextColor(const QColor &color) +{ + Q_D(Tabs); + + d->textColor = color; + + MATERIAL_DISABLE_THEME_COLORS + updateTabs(); + update(); +} + +QColor Tabs::textColor() const +{ + Q_D(const Tabs); + + if (d->useThemeColors || !d->textColor.isValid()) { + return Style::instance().themeColor("canvas"); + } else { + return d->textColor; + } +} + +void Tabs::setCurrentTab(Tab *tab) +{ + Q_D(Tabs); + + setCurrentTab(d->tabLayout->indexOf(tab)); +} + +void Tabs::setCurrentTab(int index) +{ + Q_D(Tabs); + + setTabActive(d->tab, false); + d->tab = index; + setTabActive(index, true); + d->inkBar->animate(); + + emit currentChanged(index); +} + +void Tabs::addTab(const QString &text, const QIcon &icon) +{ + Q_D(Tabs); + + Tab *tab = new Tab(this); + tab->setText(text); + tab->setHaloVisible(isHaloVisible()); + tab->setRippleStyle(rippleStyle()); + + if (!icon.isNull()) { + tab->setIcon(icon); + tab->setIconSize(QSize(22, 22)); + } + + d->tabLayout->addWidget(tab); + + if (-1 == d->tab) { + d->tab = 0; + d->inkBar->refreshGeometry(); + d->inkBar->raise(); + tab->setActive(true); + } +} + +int Tabs::currentIndex() const +{ + Q_D(const Tabs); + + return d->tab; +} + +void Tabs::setTabActive(int index, bool active) +{ + Q_D(Tabs); + + Tab *tab; + + if (index > -1) { + tab = static_cast(d->tabLayout->itemAt(index)->widget()); + if (tab) { + tab->setActive(active); + } + } +} + +void Tabs::updateTabs() +{ + Q_D(Tabs); + + Tab *tab; + for (int i = 0; i < d->tabLayout->count(); ++i) { + QLayoutItem *item = d->tabLayout->itemAt(i); + if ((tab = static_cast(item->widget()))) { + tab->setRippleStyle(d->rippleStyle); + tab->setHaloVisible(d->showHalo); + tab->setBackgroundColor(backgroundColor()); + tab->setForegroundColor(textColor()); + } + } +} +} diff --git a/components/qtmaterialtabs.h b/components/tabs.h similarity index 65% rename from components/qtmaterialtabs.h rename to components/tabs.h index 11a122ee8..e050ff96d 100644 --- a/components/qtmaterialtabs.h +++ b/components/tabs.h @@ -1,20 +1,28 @@ -#ifndef QTMATERIALTABS_H -#define QTMATERIALTABS_H +#ifndef TABS_H +#define TABS_H #include +#include #include -#include "lib/qtmaterialtheme.h" -class QtMaterialTabsPrivate; -class QtMaterialTab; +#include "tabs_p.h" +#include "tabs_internal.h" +#include "lib/style.h" +#include "lib/theme.h" -class QtMaterialTabs : public QWidget +namespace md +{ + +class TabsPrivate; +class Tab; + +class Tabs : public QWidget { Q_OBJECT public: - explicit QtMaterialTabs(QWidget *parent = 0); - ~QtMaterialTabs(); + explicit Tabs(QWidget *parent = 0); + ~Tabs(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -36,7 +44,7 @@ class QtMaterialTabs : public QWidget void addTab(const QString &text, const QIcon &icon = QIcon()); - void setCurrentTab(QtMaterialTab *tab); + void setCurrentTab(Tab *tab); void setCurrentTab(int index); int currentIndex() const; @@ -48,11 +56,11 @@ class QtMaterialTabs : public QWidget void setTabActive(int index, bool active = true); void updateTabs(); - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialTabs) - Q_DECLARE_PRIVATE(QtMaterialTabs) + Q_DISABLE_COPY(Tabs) + Q_DECLARE_PRIVATE(Tabs) }; - -#endif // QTMATERIALTABS_H +} +#endif // TABS_H diff --git a/components/qtmaterialtabs_internal.cpp b/components/tabs_internal.cpp similarity index 77% rename from components/qtmaterialtabs_internal.cpp rename to components/tabs_internal.cpp index e952c0254..dd1072d4f 100644 --- a/components/qtmaterialtabs_internal.cpp +++ b/components/tabs_internal.cpp @@ -1,19 +1,15 @@ -#include "qtmaterialtabs_internal.h" -#include -#include -#include -#include -#include -#include "qtmaterialtabs.h" -#include +#include "tabs_internal.h" + +namespace md +{ /*! * \class QtMaterialTabsInkBar * \internal */ -QtMaterialTabsInkBar::QtMaterialTabsInkBar(QtMaterialTabs *parent) - : QtMaterialOverlayWidget(parent), +TabsInkBar::TabsInkBar(Tabs *parent) + : OverlayWidget(parent), m_tabs(parent), m_animation(new QPropertyAnimation(parent)), m_tween(0) @@ -31,11 +27,11 @@ QtMaterialTabsInkBar::QtMaterialTabsInkBar(QtMaterialTabs *parent) setAttribute(Qt::WA_NoSystemBackground); } -QtMaterialTabsInkBar::~QtMaterialTabsInkBar() +TabsInkBar::~TabsInkBar() { } -void QtMaterialTabsInkBar::refreshGeometry() +void TabsInkBar::refreshGeometry() { QLayoutItem *item = m_tabs->layout()->itemAt(m_tabs->currentIndex()); @@ -55,7 +51,7 @@ void QtMaterialTabsInkBar::refreshGeometry() } } -void QtMaterialTabsInkBar::animate() +void TabsInkBar::animate() { raise(); @@ -67,7 +63,7 @@ void QtMaterialTabsInkBar::animate() m_animation->start(); } -bool QtMaterialTabsInkBar::eventFilter(QObject *obj, QEvent *event) +bool TabsInkBar::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { @@ -80,10 +76,10 @@ bool QtMaterialTabsInkBar::eventFilter(QObject *obj, QEvent *event) default: break; } - return QtMaterialOverlayWidget::eventFilter(obj, event); + return OverlayWidget::eventFilter(obj, event); } -void QtMaterialTabsInkBar::paintEvent(QPaintEvent *event) +void TabsInkBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -98,8 +94,8 @@ void QtMaterialTabsInkBar::paintEvent(QPaintEvent *event) * \internal */ -QtMaterialTab::QtMaterialTab(QtMaterialTabs *parent) - : QtMaterialFlatButton(parent), +Tab::Tab(Tabs *parent) + : FlatButton(parent), m_tabs(parent), m_active(false) { @@ -119,25 +115,25 @@ QtMaterialTab::QtMaterialTab(QtMaterialTabs *parent) connect(this, SIGNAL(clicked(bool)), this, SLOT(activateTab())); } -QtMaterialTab::~QtMaterialTab() +Tab::~Tab() { } -QSize QtMaterialTab::sizeHint() const +QSize Tab::sizeHint() const { if (icon().isNull()) { - return QtMaterialFlatButton::sizeHint(); + return FlatButton::sizeHint(); } else { return QSize(40, iconSize().height()+46); } } -void QtMaterialTab::activateTab() +void Tab::activateTab() { m_tabs->setCurrentTab(this); } -void QtMaterialTab::paintForeground(QPainter *painter) +void Tab::paintForeground(QPainter *painter) { painter->setPen(foregroundColor()); @@ -176,3 +172,4 @@ void QtMaterialTab::paintForeground(QPainter *painter) painter->fillRect(rect(), overlay); } } +} diff --git a/components/qtmaterialtabs_internal.h b/components/tabs_internal.h similarity index 54% rename from components/qtmaterialtabs_internal.h rename to components/tabs_internal.h index 75dc03478..82f0305dc 100644 --- a/components/qtmaterialtabs_internal.h +++ b/components/tabs_internal.h @@ -1,21 +1,31 @@ -#ifndef QTMATERIALTABS_INTERNAL_H -#define QTMATERIALTABS_INTERNAL_H +#ifndef TABS_INTERNAL_H +#define TABS_INTERNAL_H -#include "lib/qtmaterialoverlaywidget.h" -#include "qtmaterialflatbutton.h" +#include +#include +#include +#include +#include +#include -class QPropertyAnimation; -class QtMaterialTabs; +#include "tabs.h" +#include "lib/overlaywidget.h" +#include "flatbutton.h" -class QtMaterialTabsInkBar : public QtMaterialOverlayWidget +namespace md +{ + +class Tabs; + +class TabsInkBar : public OverlayWidget { Q_OBJECT Q_PROPERTY(qreal tweenValue WRITE setTweenValue READ tweenValue) public: - QtMaterialTabsInkBar(QtMaterialTabs *parent); - ~QtMaterialTabsInkBar(); + TabsInkBar(Tabs *parent); + ~TabsInkBar(); inline void setTweenValue(qreal value); inline qreal tweenValue() const; @@ -28,33 +38,33 @@ class QtMaterialTabsInkBar : public QtMaterialOverlayWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialTabsInkBar) + Q_DISABLE_COPY(TabsInkBar) - QtMaterialTabs *const m_tabs; + Tabs *const m_tabs; QPropertyAnimation *const m_animation; QRect m_geometry; QRect m_previousGeometry; qreal m_tween; }; -inline void QtMaterialTabsInkBar::setTweenValue(qreal value) +inline void TabsInkBar::setTweenValue(qreal value) { m_tween = value; refreshGeometry(); } -inline qreal QtMaterialTabsInkBar::tweenValue() const +inline qreal TabsInkBar::tweenValue() const { return m_tween; } -class QtMaterialTab : public QtMaterialFlatButton +class Tab : public FlatButton { Q_OBJECT public: - explicit QtMaterialTab(QtMaterialTabs *parent); - ~QtMaterialTab(); + explicit Tab(Tabs *parent); + ~Tab(); inline void setActive(bool state); inline bool isActive() const; @@ -68,21 +78,21 @@ protected slots: void paintForeground(QPainter *painter) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialTab) + Q_DISABLE_COPY(Tab) - QtMaterialTabs *const m_tabs; + Tabs *const m_tabs; bool m_active; }; -inline void QtMaterialTab::setActive(bool state) +inline void Tab::setActive(bool state) { m_active = state; update(); } -inline bool QtMaterialTab::isActive() const +inline bool Tab::isActive() const { return m_active; } - -#endif // QTMATERIALTABS_INTERNAL_H +} +#endif // TABS_INTERNAL_H diff --git a/components/tabs_p.h b/components/tabs_p.h new file mode 100644 index 000000000..aabf8618a --- /dev/null +++ b/components/tabs_p.h @@ -0,0 +1,38 @@ +#ifndef TABS_P_H +#define TABS_P_H + +#include +#include + +#include "lib/theme.h" + +namespace md +{ + +class Tabs; +class TabsInkBar; + +class TabsPrivate +{ + Q_DISABLE_COPY(TabsPrivate) + Q_DECLARE_PUBLIC(Tabs) + +public: + TabsPrivate(Tabs *q); + ~TabsPrivate(); + + void init(); + + Tabs *const q_ptr; + TabsInkBar *inkBar; + QHBoxLayout *tabLayout; + Material::RippleStyle rippleStyle; + QColor inkColor; + QColor backgroundColor; + QColor textColor; + int tab; + bool showHalo; + bool useThemeColors; +}; +} +#endif // TABS_P_H diff --git a/components/qtmaterialtextfield.cpp b/components/textfield.cpp similarity index 59% rename from components/qtmaterialtextfield.cpp rename to components/textfield.cpp index 080da8291..9c26f88ba 100644 --- a/components/qtmaterialtextfield.cpp +++ b/components/textfield.cpp @@ -1,30 +1,32 @@ -#include "qtmaterialtextfield.h" -#include "qtmaterialtextfield_p.h" +#include "textfield.h" +#include "textfield_p.h" #include #include -#include "qtmaterialtextfield_internal.h" -#include "lib/qtmaterialstyle.h" +#include "textfield_internal.h" +#include "lib/style.h" #include +namespace md +{ /*! * \class QtMaterialTextFieldPrivate * \internal */ -QtMaterialTextFieldPrivate::QtMaterialTextFieldPrivate(QtMaterialTextField *q) +TextFieldPrivate::TextFieldPrivate(TextField *q) : q_ptr(q) { } -QtMaterialTextFieldPrivate::~QtMaterialTextFieldPrivate() +TextFieldPrivate::~TextFieldPrivate() { } -void QtMaterialTextFieldPrivate::init() +void TextFieldPrivate::init() { - Q_Q(QtMaterialTextField); + Q_Q(TextField); - stateMachine = new QtMaterialTextFieldStateMachine(q); + stateMachine = new TextFieldStateMachine(q); label = 0; labelFontSize = 9.5; showLabel = false; @@ -32,7 +34,7 @@ void QtMaterialTextFieldPrivate::init() useThemeColors = true; q->setFrame(false); - q->setStyle(&QtMaterialStyle::instance()); + q->setStyle(&Style::instance()); q->setAttribute(Qt::WA_Hover); q->setMouseTracking(true); q->setTextMargins(0, 2, 0, 4); @@ -47,20 +49,20 @@ void QtMaterialTextFieldPrivate::init() * \class QtMaterialTextField */ -QtMaterialTextField::QtMaterialTextField(QWidget *parent) +TextField::TextField(QWidget *parent) : QLineEdit(parent), - d_ptr(new QtMaterialTextFieldPrivate(this)) + d_ptr(new TextFieldPrivate(this)) { d_func()->init(); } -QtMaterialTextField::~QtMaterialTextField() +TextField::~TextField() { } -void QtMaterialTextField::setUseThemeColors(bool value) +void TextField::setUseThemeColors(bool value) { - Q_D(QtMaterialTextField); + Q_D(TextField); if (d->useThemeColors == value) { return; @@ -70,16 +72,16 @@ void QtMaterialTextField::setUseThemeColors(bool value) d->stateMachine->setupProperties(); } -bool QtMaterialTextField::useThemeColors() const +bool TextField::useThemeColors() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); return d->useThemeColors; } -void QtMaterialTextField::setShowLabel(bool value) +void TextField::setShowLabel(bool value) { - Q_D(QtMaterialTextField); + Q_D(TextField); if (d->showLabel == value) { return; @@ -88,7 +90,7 @@ void QtMaterialTextField::setShowLabel(bool value) d->showLabel = value; if (!d->label && value) { - d->label = new QtMaterialTextFieldLabel(this); + d->label = new TextFieldLabel(this); d->stateMachine->setLabel(d->label); } @@ -99,16 +101,16 @@ void QtMaterialTextField::setShowLabel(bool value) } } -bool QtMaterialTextField::hasLabel() const +bool TextField::hasLabel() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); return d->showLabel; } -void QtMaterialTextField::setLabelFontSize(qreal size) +void TextField::setLabelFontSize(qreal size) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->labelFontSize = size; @@ -121,32 +123,32 @@ void QtMaterialTextField::setLabelFontSize(qreal size) } } -qreal QtMaterialTextField::labelFontSize() const +qreal TextField::labelFontSize() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); return d->labelFontSize; } -void QtMaterialTextField::setLabel(const QString &label) +void TextField::setLabel(const QString &label) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->labelString = label; setShowLabel(true); d->label->update(); } -QString QtMaterialTextField::label() const +QString TextField::label() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); return d->labelString; } -void QtMaterialTextField::setTextColor(const QColor &color) +void TextField::setTextColor(const QColor &color) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->textColor = color; setStyleSheet(QString("QLineEdit { color: %1; }").arg(color.name())); @@ -155,20 +157,20 @@ void QtMaterialTextField::setTextColor(const QColor &color) d->stateMachine->setupProperties(); } -QColor QtMaterialTextField::textColor() const +QColor TextField::textColor() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); if (d->useThemeColors || !d->textColor.isValid()) { - return QtMaterialStyle::instance().themeColor("text"); + return Style::instance().themeColor("text"); } else { return d->textColor; } } -void QtMaterialTextField::setLabelColor(const QColor &color) +void TextField::setLabelColor(const QColor &color) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->labelColor = color; @@ -176,20 +178,20 @@ void QtMaterialTextField::setLabelColor(const QColor &color) d->stateMachine->setupProperties(); } -QColor QtMaterialTextField::labelColor() const +QColor TextField::labelColor() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); if (d->useThemeColors || !d->labelColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent3"); + return Style::instance().themeColor("accent3"); } else { return d->labelColor; } } -void QtMaterialTextField::setInkColor(const QColor &color) +void TextField::setInkColor(const QColor &color) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->inkColor = color; @@ -197,20 +199,20 @@ void QtMaterialTextField::setInkColor(const QColor &color) d->stateMachine->setupProperties(); } -QColor QtMaterialTextField::inkColor() const +QColor TextField::inkColor() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); if (d->useThemeColors || !d->inkColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->inkColor; } } -void QtMaterialTextField::setInputLineColor(const QColor &color) +void TextField::setInputLineColor(const QColor &color) { - Q_D(QtMaterialTextField); + Q_D(TextField); d->inputLineColor = color; @@ -218,20 +220,20 @@ void QtMaterialTextField::setInputLineColor(const QColor &color) d->stateMachine->setupProperties(); } -QColor QtMaterialTextField::inputLineColor() const +QColor TextField::inputLineColor() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); if (d->useThemeColors || !d->inputLineColor.isValid()) { - return QtMaterialStyle::instance().themeColor("border"); + return Style::instance().themeColor("border"); } else { return d->inputLineColor; } } -void QtMaterialTextField::setShowInputLine(bool value) +void TextField::setShowInputLine(bool value) { - Q_D(QtMaterialTextField); + Q_D(TextField); if (d->showInputLine == value) { return; @@ -241,14 +243,14 @@ void QtMaterialTextField::setShowInputLine(bool value) update(); } -bool QtMaterialTextField::hasInputLine() const +bool TextField::hasInputLine() const { - Q_D(const QtMaterialTextField); + Q_D(const TextField); return d->showInputLine; } -QtMaterialTextField::QtMaterialTextField(QtMaterialTextFieldPrivate &d, QWidget *parent) +TextField::TextField(TextFieldPrivate &d, QWidget *parent) : QLineEdit(parent), d_ptr(&d) { @@ -258,9 +260,9 @@ QtMaterialTextField::QtMaterialTextField(QtMaterialTextFieldPrivate &d, QWidget /*! * \reimp */ -bool QtMaterialTextField::event(QEvent *event) +bool TextField::event(QEvent *event) { - Q_D(QtMaterialTextField); + Q_D(TextField); switch (event->type()) { @@ -279,9 +281,9 @@ bool QtMaterialTextField::event(QEvent *event) /*! * \reimp */ -void QtMaterialTextField::paintEvent(QPaintEvent *event) +void TextField::paintEvent(QPaintEvent *event) { - Q_D(QtMaterialTextField); + Q_D(TextField); QLineEdit::paintEvent(event); @@ -324,3 +326,4 @@ void QtMaterialTextField::paintEvent(QPaintEvent *event) } } } +} diff --git a/components/qtmaterialtextfield.h b/components/textfield.h similarity index 69% rename from components/qtmaterialtextfield.h rename to components/textfield.h index dead5cc49..625774dfd 100644 --- a/components/qtmaterialtextfield.h +++ b/components/textfield.h @@ -1,12 +1,15 @@ -#ifndef QTMATERIALTEXTFIELD_H -#define QTMATERIALTEXTFIELD_H +#ifndef TEXTFIELD_H +#define TEXTFIELD_H #include #include -class QtMaterialTextFieldPrivate; +namespace md +{ + +class TextFieldPrivate; -class QtMaterialTextField : public QLineEdit +class TextField : public QLineEdit { Q_OBJECT @@ -15,8 +18,8 @@ class QtMaterialTextField : public QLineEdit Q_PROPERTY(QColor inputLineColor WRITE setInputLineColor READ inputLineColor) public: - explicit QtMaterialTextField(QWidget *parent = 0); - ~QtMaterialTextField(); + explicit TextField(QWidget *parent = 0); + ~TextField(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -46,16 +49,16 @@ class QtMaterialTextField : public QLineEdit bool hasInputLine() const; protected: - QtMaterialTextField(QtMaterialTextFieldPrivate &d, QWidget *parent = 0); + TextField(TextFieldPrivate &d, QWidget *parent = 0); bool event(QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialTextField) - Q_DECLARE_PRIVATE(QtMaterialTextField) + Q_DISABLE_COPY(TextField) + Q_DECLARE_PRIVATE(TextField) }; - -#endif // QTMATERIALTEXTFIELD_H +} +#endif // TEXTFIELD_H diff --git a/components/qtmaterialtextfield_internal.cpp b/components/textfield_internal.cpp similarity index 84% rename from components/qtmaterialtextfield_internal.cpp rename to components/textfield_internal.cpp index b8b4ce7ff..bb57c3639 100644 --- a/components/qtmaterialtextfield_internal.cpp +++ b/components/textfield_internal.cpp @@ -1,15 +1,14 @@ -#include "qtmaterialtextfield_internal.h" -#include -#include -#include -#include "qtmaterialtextfield.h" +#include "textfield_internal.h" + +namespace md +{ /*! - * \class QtMaterialTextFieldStateMachine + * \class TextFieldStateMachine * \internal */ -QtMaterialTextFieldStateMachine::QtMaterialTextFieldStateMachine(QtMaterialTextField *parent) +TextFieldStateMachine::TextFieldStateMachine(TextField *parent) : QStateMachine(parent), m_textField(parent), m_normalState(new QState), @@ -55,11 +54,11 @@ QtMaterialTextFieldStateMachine::QtMaterialTextFieldStateMachine(QtMaterialTextF connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupProperties())); } -QtMaterialTextFieldStateMachine::~QtMaterialTextFieldStateMachine() +TextFieldStateMachine::~TextFieldStateMachine() { } -void QtMaterialTextFieldStateMachine::setLabel(QtMaterialTextFieldLabel *label) +void TextFieldStateMachine::setLabel(TextFieldLabel *label) { if (m_label) { delete m_label; @@ -92,7 +91,7 @@ void QtMaterialTextFieldStateMachine::setLabel(QtMaterialTextFieldLabel *label) setupProperties(); } -void QtMaterialTextFieldStateMachine::setupProperties() +void TextFieldStateMachine::setupProperties() { if (m_label) { @@ -123,7 +122,7 @@ void QtMaterialTextFieldStateMachine::setupProperties() * \internal */ -QtMaterialTextFieldLabel::QtMaterialTextFieldLabel(QtMaterialTextField *parent) +TextFieldLabel::TextFieldLabel(TextField *parent) : QWidget(parent), m_textField(parent), m_scale(1), @@ -138,14 +137,14 @@ QtMaterialTextFieldLabel::QtMaterialTextFieldLabel(QtMaterialTextField *parent) setFont(font); } -QtMaterialTextFieldLabel::~QtMaterialTextFieldLabel() +TextFieldLabel::~TextFieldLabel() { } /*! * \reimp */ -void QtMaterialTextFieldLabel::paintEvent(QPaintEvent *event) +void TextFieldLabel::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -162,3 +161,4 @@ void QtMaterialTextFieldLabel::paintEvent(QPaintEvent *event) QPointF pos(2+m_posX, height()-36+m_posY); painter.drawText(pos.x(), pos.y(), m_textField->label()); } +} diff --git a/components/qtmaterialtextfield_internal.h b/components/textfield_internal.h similarity index 53% rename from components/qtmaterialtextfield_internal.h rename to components/textfield_internal.h index e510287a1..49d86649f 100644 --- a/components/qtmaterialtextfield_internal.h +++ b/components/textfield_internal.h @@ -1,24 +1,30 @@ -#ifndef QTMATERIALTEXTFIELD_INTERNAL_H -#define QTMATERIALTEXTFIELD_INTERNAL_H +#ifndef TEXTFIELD_INTERNAL_H +#define TEXTFIELD_INTERNAL_H -#include #include -#include "qtmaterialtextfield.h" +#include +#include +#include +#include -class QPropertyAnimation; -class QtMaterialTextFieldLabel; +#include "textfield.h" -class QtMaterialTextFieldStateMachine : public QStateMachine +namespace md +{ + +class TextFieldLabel; + +class TextFieldStateMachine : public QStateMachine { Q_OBJECT Q_PROPERTY(qreal progress WRITE setProgress READ progress) public: - QtMaterialTextFieldStateMachine(QtMaterialTextField *parent); - ~QtMaterialTextFieldStateMachine(); + TextFieldStateMachine(TextField *parent); + ~TextFieldStateMachine(); - void setLabel(QtMaterialTextFieldLabel *label); + void setLabel(TextFieldLabel *label); inline void setProgress(qreal progress); inline qreal progress() const; @@ -27,29 +33,29 @@ public slots: void setupProperties(); private: - Q_DISABLE_COPY(QtMaterialTextFieldStateMachine) + Q_DISABLE_COPY(TextFieldStateMachine) - QtMaterialTextField *const m_textField; + TextField *const m_textField; QState *const m_normalState; QState *const m_focusedState; - QtMaterialTextFieldLabel *m_label; + TextFieldLabel *m_label; QPropertyAnimation *m_offsetAnimation; QPropertyAnimation *m_colorAnimation; qreal m_progress; }; -inline void QtMaterialTextFieldStateMachine::setProgress(qreal progress) +inline void TextFieldStateMachine::setProgress(qreal progress) { m_progress = progress; m_textField->update(); } -inline qreal QtMaterialTextFieldStateMachine::progress() const +inline qreal TextFieldStateMachine::progress() const { return m_progress; } -class QtMaterialTextFieldLabel : public QWidget +class TextFieldLabel : public QWidget { Q_OBJECT @@ -58,8 +64,8 @@ class QtMaterialTextFieldLabel : public QWidget Q_PROPERTY(QColor color WRITE setColor READ color) public: - QtMaterialTextFieldLabel(QtMaterialTextField *parent); - ~QtMaterialTextFieldLabel(); + TextFieldLabel(TextField *parent); + ~TextFieldLabel(); inline void setScale(qreal scale); inline qreal scale() const; @@ -74,47 +80,47 @@ class QtMaterialTextFieldLabel : public QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialTextFieldLabel) + Q_DISABLE_COPY(TextFieldLabel) - QtMaterialTextField *const m_textField; + TextField *const m_textField; qreal m_scale; qreal m_posX; qreal m_posY; QColor m_color; }; -inline void QtMaterialTextFieldLabel::setScale(qreal scale) +inline void TextFieldLabel::setScale(qreal scale) { m_scale = scale; update(); } -inline qreal QtMaterialTextFieldLabel::scale() const +inline qreal TextFieldLabel::scale() const { return m_scale; } -inline void QtMaterialTextFieldLabel::setOffset(const QPointF &pos) +inline void TextFieldLabel::setOffset(const QPointF &pos) { m_posX = pos.x(); m_posY = pos.y(); update(); } -inline QPointF QtMaterialTextFieldLabel::offset() const +inline QPointF TextFieldLabel::offset() const { return QPointF(m_posX, m_posY); } -inline void QtMaterialTextFieldLabel::setColor(const QColor &color) +inline void TextFieldLabel::setColor(const QColor &color) { m_color = color; update(); } -inline QColor QtMaterialTextFieldLabel::color() const +inline QColor TextFieldLabel::color() const { return m_color; } - -#endif // QTMATERIALTEXTFIELD_INTERNAL_H +} +#endif // TEXTFIELD_INTERNAL_H diff --git a/components/textfield_p.h b/components/textfield_p.h new file mode 100644 index 000000000..bfa4d01c2 --- /dev/null +++ b/components/textfield_p.h @@ -0,0 +1,39 @@ +#ifndef TEXTFIELD_P_H +#define TEXTFIELD_P_H + +#include +#include + +namespace md +{ +class TextField; +class TextFieldStateMachine; +class TextFieldLabel; + +class TextFieldPrivate +{ + Q_DISABLE_COPY(TextFieldPrivate) + Q_DECLARE_PUBLIC(TextField) + +public: + TextFieldPrivate(TextField *q); + virtual ~TextFieldPrivate(); + + void init(); + + TextField *const q_ptr; + TextFieldStateMachine *stateMachine; + TextFieldLabel *label; + QColor textColor; + QColor labelColor; + QColor inkColor; + QColor inputLineColor; + QString labelString; + qreal labelFontSize; + bool showLabel; + bool showInputLine; + bool useThemeColors; +}; +} + +#endif // TEXTFIELD_P_H diff --git a/components/qtmaterialtoggle.cpp b/components/toggle.cpp similarity index 67% rename from components/qtmaterialtoggle.cpp rename to components/toggle.cpp index 6d11fc986..a76727d29 100644 --- a/components/qtmaterialtoggle.cpp +++ b/components/toggle.cpp @@ -1,33 +1,33 @@ -#include "qtmaterialtoggle.h" -#include "qtmaterialtoggle_p.h" -#include -#include -#include -#include -#include "qtmaterialtoggle_internal.h" -#include "lib/qtmaterialstyle.h" +#include "toggle.h" + +#include "toggle_p.h" +#include "toggle_internal.h" +#include "lib/style.h" + +namespace md +{ /*! * \class QtMaterialTogglePrivate * \internal */ -QtMaterialTogglePrivate::QtMaterialTogglePrivate(QtMaterialToggle *q) +TogglePrivate::TogglePrivate(Toggle *q) : q_ptr(q) { } -QtMaterialTogglePrivate::~QtMaterialTogglePrivate() +TogglePrivate::~TogglePrivate() { } -void QtMaterialTogglePrivate::init() +void TogglePrivate::init() { - Q_Q(QtMaterialToggle); + Q_Q(Toggle); - track = new QtMaterialToggleTrack(q); - thumb = new QtMaterialToggleThumb(q); - rippleOverlay = new QtMaterialToggleRippleOverlay(thumb, track, q); + track = new ToggleTrack(q); + thumb = new ToggleThumb(q); + rippleOverlay = new ToggleRippleOverlay(thumb, track, q); stateMachine = new QStateMachine(q); offState = new QState; onState = new QState; @@ -106,9 +106,9 @@ void QtMaterialTogglePrivate::init() QCoreApplication::processEvents(); } -void QtMaterialTogglePrivate::setupProperties() +void TogglePrivate::setupProperties() { - Q_Q(QtMaterialToggle); + Q_Q(Toggle); if (q->isEnabled()) { const qreal shift = thumb->shift(); @@ -134,35 +134,35 @@ void QtMaterialTogglePrivate::setupProperties() * \class QtMaterialToggle */ -QtMaterialToggle::QtMaterialToggle(QWidget *parent) +Toggle::Toggle(QWidget *parent) : QAbstractButton(parent), - d_ptr(new QtMaterialTogglePrivate(this)) + d_ptr(new TogglePrivate(this)) { d_func()->init(); } -QtMaterialToggle::~QtMaterialToggle() +Toggle::~Toggle() { } -void QtMaterialToggle::setUseThemeColors(bool value) +void Toggle::setUseThemeColors(bool value) { - Q_D(QtMaterialToggle); + Q_D(Toggle); d->useThemeColors = value; d->setupProperties(); } -bool QtMaterialToggle::useThemeColors() const +bool Toggle::useThemeColors() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); return d->useThemeColors; } -void QtMaterialToggle::setDisabledColor(const QColor &color) +void Toggle::setDisabledColor(const QColor &color) { - Q_D(QtMaterialToggle); + Q_D(Toggle); d->disabledColor = color; @@ -170,20 +170,20 @@ void QtMaterialToggle::setDisabledColor(const QColor &color) d->setupProperties(); } -QColor QtMaterialToggle::disabledColor() const +QColor Toggle::disabledColor() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); if (d->useThemeColors || !d->disabledColor.isValid()) { - return QtMaterialStyle::instance().themeColor("disabled"); + return Style::instance().themeColor("disabled"); } else { return d->disabledColor; } } -void QtMaterialToggle::setActiveColor(const QColor &color) +void Toggle::setActiveColor(const QColor &color) { - Q_D(QtMaterialToggle); + Q_D(Toggle); d->activeColor = color; @@ -191,20 +191,20 @@ void QtMaterialToggle::setActiveColor(const QColor &color) d->setupProperties(); } -QColor QtMaterialToggle::activeColor() const +QColor Toggle::activeColor() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); if (d->useThemeColors || !d->activeColor.isValid()) { - return QtMaterialStyle::instance().themeColor("primary1"); + return Style::instance().themeColor("primary1"); } else { return d->activeColor; } } -void QtMaterialToggle::setInactiveColor(const QColor &color) +void Toggle::setInactiveColor(const QColor &color) { - Q_D(QtMaterialToggle); + Q_D(Toggle); d->inactiveColor = color; @@ -212,20 +212,20 @@ void QtMaterialToggle::setInactiveColor(const QColor &color) d->setupProperties(); } -QColor QtMaterialToggle::inactiveColor() const +QColor Toggle::inactiveColor() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); if (d->useThemeColors || !d->inactiveColor.isValid()) { - return QtMaterialStyle::instance().themeColor("canvas"); + return Style::instance().themeColor("canvas"); } else { return d->inactiveColor; } } -void QtMaterialToggle::setTrackColor(const QColor &color) +void Toggle::setTrackColor(const QColor &color) { - Q_D(QtMaterialToggle); + Q_D(Toggle); d->trackColor = color; @@ -233,20 +233,20 @@ void QtMaterialToggle::setTrackColor(const QColor &color) d->setupProperties(); } -QColor QtMaterialToggle::trackColor() const +QColor Toggle::trackColor() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); if (d->useThemeColors || !d->trackColor.isValid()) { - return QtMaterialStyle::instance().themeColor("accent3"); + return Style::instance().themeColor("accent3"); } else { return d->trackColor; } } -void QtMaterialToggle::setOrientation(Qt::Orientation orientation) +void Toggle::setOrientation(Qt::Orientation orientation) { - Q_D(QtMaterialToggle); + Q_D(Toggle); if (d->orientation == orientation) { return; @@ -256,25 +256,25 @@ void QtMaterialToggle::setOrientation(Qt::Orientation orientation) updateGeometry(); } -Qt::Orientation QtMaterialToggle::orientation() const +Qt::Orientation Toggle::orientation() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); return d->orientation; } -QSize QtMaterialToggle::sizeHint() const +QSize Toggle::sizeHint() const { - Q_D(const QtMaterialToggle); + Q_D(const Toggle); return Qt::Horizontal == d->orientation ? QSize(64, 48) : QSize(48, 64); } -bool QtMaterialToggle::event(QEvent *event) +bool Toggle::event(QEvent *event) { - Q_D(QtMaterialToggle); + Q_D(Toggle); switch (event->type()) { @@ -292,7 +292,8 @@ bool QtMaterialToggle::event(QEvent *event) return QAbstractButton::event(event); } -void QtMaterialToggle::paintEvent(QPaintEvent *event) +void Toggle::paintEvent(QPaintEvent *event) { Q_UNUSED(event) } +} diff --git a/components/qtmaterialtoggle.h b/components/toggle.h similarity index 73% rename from components/qtmaterialtoggle.h rename to components/toggle.h index 5d5a55701..46edf79a8 100644 --- a/components/qtmaterialtoggle.h +++ b/components/toggle.h @@ -1,11 +1,14 @@ -#ifndef QTMATERIALTOGGLE_H -#define QTMATERIALTOGGLE_H +#ifndef TOGGLE_H +#define TOGGLE_H #include -class QtMaterialTogglePrivate; +namespace md +{ + +class TogglePrivate; -class QtMaterialToggle : public QAbstractButton +class Toggle : public QAbstractButton { Q_OBJECT @@ -15,8 +18,8 @@ class QtMaterialToggle : public QAbstractButton Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor) public: - explicit QtMaterialToggle(QWidget *parent = 0); - ~QtMaterialToggle(); + explicit Toggle(QWidget *parent = 0); + ~Toggle(); void setUseThemeColors(bool value); bool useThemeColors() const; @@ -42,11 +45,11 @@ class QtMaterialToggle : public QAbstractButton bool event(QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialToggle) - Q_DECLARE_PRIVATE(QtMaterialToggle) + Q_DISABLE_COPY(Toggle) + Q_DECLARE_PRIVATE(Toggle) }; - -#endif // QTMATERIALTOGGLE_H +} +#endif // TOGGLE_H diff --git a/components/qtmaterialtoggle_internal.cpp b/components/toggle_internal.cpp similarity index 72% rename from components/qtmaterialtoggle_internal.cpp rename to components/toggle_internal.cpp index 9bcf82325..8970f65c0 100644 --- a/components/qtmaterialtoggle_internal.cpp +++ b/components/toggle_internal.cpp @@ -1,20 +1,21 @@ -#include "qtmaterialtoggle_internal.h" -#include -#include -#include -#include "qtmaterialtoggle.h" -#include "lib/qtmaterialripple.h" +#include "toggle_internal.h" + +#include "toggle.h" +#include "lib/ripple.h" + +namespace md +{ /*! * \class QtMaterialToggleRippleOverlay * \internal */ -QtMaterialToggleRippleOverlay::QtMaterialToggleRippleOverlay( - QtMaterialToggleThumb *thumb, - QtMaterialToggleTrack *track, - QtMaterialToggle *parent) - : QtMaterialRippleOverlay(parent->parentWidget()), +ToggleRippleOverlay::ToggleRippleOverlay( + ToggleThumb *thumb, + ToggleTrack *track, + Toggle *parent) + : RippleOverlay(parent->parentWidget()), m_toggle(parent), m_thumb(thumb), m_track(track) @@ -24,11 +25,11 @@ QtMaterialToggleRippleOverlay::QtMaterialToggleRippleOverlay( thumb->installEventFilter(this); } -QtMaterialToggleRippleOverlay::~QtMaterialToggleRippleOverlay() +ToggleRippleOverlay::~ToggleRippleOverlay() { } -void QtMaterialToggleRippleOverlay::addToggleRipple() +void ToggleRippleOverlay::addToggleRipple() { if (!m_toggle->isEnabled()) { return; @@ -44,7 +45,7 @@ void QtMaterialToggleRippleOverlay::addToggleRipple() w = m_thumb->width()/2+10; } - QtMaterialRipple *ripple = new QtMaterialRipple(QPoint(10+t, 20+t)); + Ripple *ripple = new Ripple(QPoint(10+t, 20+t)); ripple->setColor(m_track->trackColor()); ripple->setRadiusEndValue(w); ripple->setOpacityStartValue(0.8); @@ -52,21 +53,21 @@ void QtMaterialToggleRippleOverlay::addToggleRipple() addRipple(ripple); } -bool QtMaterialToggleRippleOverlay::eventFilter(QObject *obj, QEvent *event) +bool ToggleRippleOverlay::eventFilter(QObject *obj, QEvent *event) { if (QEvent::Paint == event->type()) { setGeometry(overlayGeometry()); - QList::const_iterator i; - QList items = ripples(); + QList::const_iterator i; + QList items = ripples(); QColor color = m_track->trackColor(); for (i = items.begin(); i != items.end(); ++i) { (*i)->setColor(color); } } - return QtMaterialRippleOverlay::eventFilter(obj, event); + return RippleOverlay::eventFilter(obj, event); } -QRect QtMaterialToggleRippleOverlay::overlayGeometry() const +QRect ToggleRippleOverlay::overlayGeometry() const { const qreal offset = m_thumb->offset(); if (Qt::Horizontal == m_toggle->orientation()) { @@ -81,7 +82,7 @@ QRect QtMaterialToggleRippleOverlay::overlayGeometry() const * \internal */ -QtMaterialToggleThumb::QtMaterialToggleThumb(QtMaterialToggle *parent) +ToggleThumb::ToggleThumb(Toggle *parent) : QWidget(parent), m_toggle(parent), m_shift(0), @@ -98,11 +99,11 @@ QtMaterialToggleThumb::QtMaterialToggleThumb(QtMaterialToggle *parent) parent->installEventFilter(this); } -QtMaterialToggleThumb::~QtMaterialToggleThumb() +ToggleThumb::~ToggleThumb() { } -void QtMaterialToggleThumb::setShift(qreal shift) +void ToggleThumb::setShift(qreal shift) { if (m_shift == shift) { return; @@ -112,7 +113,7 @@ void QtMaterialToggleThumb::setShift(qreal shift) updateOffset(); } -bool QtMaterialToggleThumb::eventFilter(QObject *obj, QEvent *event) +bool ToggleThumb::eventFilter(QObject *obj, QEvent *event) { const QEvent::Type type = event->type(); @@ -124,7 +125,7 @@ bool QtMaterialToggleThumb::eventFilter(QObject *obj, QEvent *event) return QWidget::eventFilter(obj, event); } -void QtMaterialToggleThumb::paintEvent(QPaintEvent *event) +void ToggleThumb::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -158,7 +159,7 @@ void QtMaterialToggleThumb::paintEvent(QPaintEvent *event) } } -void QtMaterialToggleThumb::updateOffset() +void ToggleThumb::updateOffset() { const QSize s(Qt::Horizontal == m_toggle->orientation() ? size() : size().transposed()); @@ -171,7 +172,7 @@ void QtMaterialToggleThumb::updateOffset() * \internal */ -QtMaterialToggleTrack::QtMaterialToggleTrack(QtMaterialToggle *parent) +ToggleTrack::ToggleTrack(Toggle *parent) : QWidget(parent), m_toggle(parent) { @@ -180,17 +181,17 @@ QtMaterialToggleTrack::QtMaterialToggleTrack(QtMaterialToggle *parent) parent->installEventFilter(this); } -QtMaterialToggleTrack::~QtMaterialToggleTrack() +ToggleTrack::~ToggleTrack() { } -void QtMaterialToggleTrack::setTrackColor(const QColor &color) +void ToggleTrack::setTrackColor(const QColor &color) { m_trackColor = color; update(); } -bool QtMaterialToggleTrack::eventFilter(QObject *obj, QEvent *event) +bool ToggleTrack::eventFilter(QObject *obj, QEvent *event) { const QEvent::Type type = event->type(); @@ -200,7 +201,7 @@ bool QtMaterialToggleTrack::eventFilter(QObject *obj, QEvent *event) return QWidget::eventFilter(obj, event); } -void QtMaterialToggleTrack::paintEvent(QPaintEvent *event) +void ToggleTrack::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -229,3 +230,4 @@ void QtMaterialToggleTrack::paintEvent(QPaintEvent *event) painter.drawRoundedRect(r.adjusted(4, 14, -4, -14), w/2-4, w/2-4); } } +} diff --git a/components/qtmaterialtoggle_internal.h b/components/toggle_internal.h similarity index 50% rename from components/qtmaterialtoggle_internal.h rename to components/toggle_internal.h index 079e36990..d18ea8072 100644 --- a/components/qtmaterialtoggle_internal.h +++ b/components/toggle_internal.h @@ -1,22 +1,29 @@ -#ifndef QTMATERIALTOGGLE_INTERNAL_H -#define QTMATERIALTOGGLE_INTERNAL_H +#ifndef TOGGLE_INTERNAL_H +#define TOGGLE_INTERNAL_H #include -#include "lib/qtmaterialrippleoverlay.h" +#include +#include +#include -class QtMaterialToggle; -class QtMaterialToggleThumb; -class QtMaterialToggleTrack; +#include "lib/rippleoverlay.h" -class QtMaterialToggleRippleOverlay : public QtMaterialRippleOverlay +namespace md +{ + +class Toggle; +class ToggleThumb; +class ToggleTrack; + +class ToggleRippleOverlay : public RippleOverlay { Q_OBJECT public: - QtMaterialToggleRippleOverlay(QtMaterialToggleThumb *thumb, - QtMaterialToggleTrack *track, - QtMaterialToggle *parent); - ~QtMaterialToggleRippleOverlay(); + ToggleRippleOverlay(ToggleThumb *thumb, + ToggleTrack *track, + Toggle *parent); + ~ToggleRippleOverlay(); protected slots: void addToggleRipple(); @@ -26,14 +33,14 @@ protected slots: QRect overlayGeometry() const Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialToggleRippleOverlay) + Q_DISABLE_COPY(ToggleRippleOverlay) - QtMaterialToggle *const m_toggle; - QtMaterialToggleThumb *const m_thumb; - QtMaterialToggleTrack *const m_track; + Toggle *const m_toggle; + ToggleThumb *const m_thumb; + ToggleTrack *const m_track; }; -class QtMaterialToggleThumb : public QWidget +class ToggleThumb : public QWidget { Q_OBJECT @@ -41,8 +48,8 @@ class QtMaterialToggleThumb : public QWidget Q_PROPERTY(QColor thumbColor WRITE setThumbColor READ thumbColor) public: - QtMaterialToggleThumb(QtMaterialToggle *parent); - ~QtMaterialToggleThumb(); + ToggleThumb(Toggle *parent); + ~ToggleThumb(); void setShift(qreal shift); inline qreal shift() const; @@ -57,46 +64,46 @@ class QtMaterialToggleThumb : public QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialToggleThumb) + Q_DISABLE_COPY(ToggleThumb) void updateOffset(); - QtMaterialToggle *const m_toggle; + Toggle *const m_toggle; QColor m_thumbColor; qreal m_shift; qreal m_offset; }; -inline qreal QtMaterialToggleThumb::shift() const +inline qreal ToggleThumb::shift() const { return m_shift; } -inline qreal QtMaterialToggleThumb::offset() const +inline qreal ToggleThumb::offset() const { return m_offset; } -inline void QtMaterialToggleThumb::setThumbColor(const QColor &color) +inline void ToggleThumb::setThumbColor(const QColor &color) { m_thumbColor = color; update(); } -inline QColor QtMaterialToggleThumb::thumbColor() const +inline QColor ToggleThumb::thumbColor() const { return m_thumbColor; } -class QtMaterialToggleTrack : public QWidget +class ToggleTrack : public QWidget { Q_OBJECT Q_PROPERTY(QColor trackColor WRITE setTrackColor READ trackColor) public: - QtMaterialToggleTrack(QtMaterialToggle *parent); - ~QtMaterialToggleTrack(); + ToggleTrack(Toggle *parent); + ~ToggleTrack(); void setTrackColor(const QColor &color); inline QColor trackColor() const; @@ -106,15 +113,15 @@ class QtMaterialToggleTrack : public QWidget void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: - Q_DISABLE_COPY(QtMaterialToggleTrack) + Q_DISABLE_COPY(ToggleTrack) - QtMaterialToggle *const m_toggle; + Toggle *const m_toggle; QColor m_trackColor; }; -inline QColor QtMaterialToggleTrack::trackColor() const +inline QColor ToggleTrack::trackColor() const { return m_trackColor; } - -#endif // QTMATERIALTOGGLE_INTERNAL_H +} +#endif // TOGGLE_INTERNAL_H diff --git a/components/toggle_p.h b/components/toggle_p.h new file mode 100644 index 000000000..941a75c32 --- /dev/null +++ b/components/toggle_p.h @@ -0,0 +1,45 @@ +#ifndef TOGGLE_P_H +#define TOGGLE_P_H + +#include +#include +#include +#include +#include + +namespace md +{ + +class Toggle; +class ToggleTrack; +class ToggleThumb; +class ToggleRippleOverlay; + +class TogglePrivate +{ + Q_DISABLE_COPY(TogglePrivate) + Q_DECLARE_PUBLIC(Toggle) + +public: + TogglePrivate(Toggle *q); + ~TogglePrivate(); + + void init(); + void setupProperties(); + + Toggle *const q_ptr; + ToggleTrack *track; + ToggleThumb *thumb; + ToggleRippleOverlay *rippleOverlay; + QStateMachine *stateMachine; + QState *offState; + QState *onState; + Qt::Orientation orientation; + QColor disabledColor; + QColor activeColor; + QColor inactiveColor; + QColor trackColor; + bool useThemeColors; +}; +} +#endif // TOGGLE_P_H diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..3022a7ff9 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,133 @@ +cmake_minimum_required(VERSION 3.5) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS StateMachine REQUIRED) + +# Add executable called "examples" that is built from the source files +# "*.cpp". The extensions are automatically found. +# add_executable (examples) + +set(PROJECT_SOURCES + #sources + main.cpp + mainwindow.cpp + avatarsettingseditor.cpp + badgesettingseditor.cpp + checkboxsettingseditor.cpp + fabsettingseditor.cpp + raisedbuttonsettingseditor.cpp + flatbuttonsettingseditor.cpp + iconbuttonsettingseditor.cpp + progresssettingseditor.cpp + circularprogresssettingseditor.cpp + slidersettingseditor.cpp + radiobuttonsettingseditor.cpp + togglesettingseditor.cpp + textfieldsettingseditor.cpp + tabssettingseditor.cpp + snackbarsettingseditor.cpp + dialogsettingseditor.cpp + drawersettingseditor.cpp + scrollbarsettingseditor.cpp + appbarsettingseditor.cpp + autocompletesettingseditor.cpp + menusettingseditor.cpp + # Headers + mainwindow.h + avatarsettingseditor.h + badgesettingseditor.h + checkboxsettingseditor.h + fabsettingseditor.h + raisedbuttonsettingseditor.h + flatbuttonsettingseditor.h + iconbuttonsettingseditor.h + progresssettingseditor.h + circularprogresssettingseditor.h + slidersettingseditor.h + radiobuttonsettingseditor.h + togglesettingseditor.h + textfieldsettingseditor.h + tabssettingseditor.h + snackbarsettingseditor.h + dialogsettingseditor.h + drawersettingseditor.h + scrollbarsettingseditor.h + appbarsettingseditor.h + autocompletesettingseditor.h + menusettingseditor.h + # Forms + avatarsettingsform.ui + badgesettingsform.ui + checkboxsettingsform.ui + fabsettingsform.ui + flatbuttonsettingsform.ui + iconbuttonsettingsform.ui + progresssettingsform.ui + circularprogresssettingsform.ui + slidersettingsform.ui + snackbarsettingsform.ui + radiobuttonsettingsform.ui + togglesettingsform.ui + textfieldsettingsform.ui + tabssettingsform.ui + dialogsettingsform.ui + drawersettingsform.ui + scrollbarsettingsform.ui + appbarsettingsform.ui +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(examples MANUAL_FINALIZATION ${PROJECT_SOURCES}) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET examples APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR +# ${CMAKE_CURRENT_SOURCE_DIR}/android) +# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(examples SHARED ${PROJECT_SOURCES}) +# Define properties for Android with Qt 5 after find_package() calls as: +# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(examples ${PROJECT_SOURCES}) + endif() +endif() + +target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Core) +target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Gui) +target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) +target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Core5Compat) +target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::StateMachine) + + +# Link the executable to the 'components' library. Since the 'components' library has +# public include directories we will use those link directories when building +# examples +target_link_libraries(examples LINK_PUBLIC components) + + +set_target_properties(examples PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/examples) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(examples) +endif() diff --git a/examples/appbarsettingseditor.cpp b/examples/appbarsettingseditor.cpp index 5f2ce00af..89d780347 100644 --- a/examples/appbarsettingseditor.cpp +++ b/examples/appbarsettingseditor.cpp @@ -1,18 +1,13 @@ #include "appbarsettingseditor.h" -#include -#include -#include -#include -#include AppBarSettingsEditor::AppBarSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::AppBarSettingsForm), - m_appBar(new QtMaterialAppBar) + m_appBar(new AppBar) { QLabel *label = new QLabel("Inbox"); label->setAttribute(Qt::WA_TranslucentBackground); - label->setForegroundRole(QPalette::Foreground); +// label->setForegroundRole(QPalette::Foreground); // FIXME: palette ? foreground ! label->setContentsMargins(6, 0, 0, 0); QPalette palette = label->palette(); @@ -21,7 +16,7 @@ AppBarSettingsEditor::AppBarSettingsEditor(QWidget *parent) label->setFont(QFont("Roboto", 18, QFont::Normal)); - QtMaterialIconButton *button = new QtMaterialIconButton(QtMaterialTheme::icon("navigation", "menu")); + IconButton *button = new IconButton(Theme::icon("navigation", "menu")); button->setIconSize(QSize(24, 24)); m_appBar->appBarLayout()->addWidget(button); m_appBar->appBarLayout()->addWidget(label); diff --git a/examples/appbarsettingseditor.h b/examples/appbarsettingseditor.h index b2eb88252..6c5beca93 100644 --- a/examples/appbarsettingseditor.h +++ b/examples/appbarsettingseditor.h @@ -2,9 +2,17 @@ #define APPBARSETTINGSEDITOR_H #include +#include +#include +#include + +#include +#include +#include + #include "ui_appbarsettingsform.h" -class QtMaterialAppBar; +using namespace md; class AppBarSettingsEditor : public QWidget { @@ -21,7 +29,7 @@ protected slots: private: Ui::AppBarSettingsForm *const ui; - QtMaterialAppBar *const m_appBar; + AppBar *const m_appBar; }; #endif // APPBARSETTINGSEDITOR_H diff --git a/examples/autocompletesettingseditor.cpp b/examples/autocompletesettingseditor.cpp index 0c8dedeca..d101670d3 100644 --- a/examples/autocompletesettingseditor.cpp +++ b/examples/autocompletesettingseditor.cpp @@ -1,12 +1,9 @@ #include "autocompletesettingseditor.h" -#include -#include -#include AutoCompleteSettingsEditor::AutoCompleteSettingsEditor(QWidget *parent) : QWidget(parent), //ui(new Ui::AutoCompleteSettingsForm), - m_autocomplete(new QtMaterialAutoComplete) + m_autocomplete(new AutoComplete) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/autocompletesettingseditor.h b/examples/autocompletesettingseditor.h index b6c57433f..44be9b300 100644 --- a/examples/autocompletesettingseditor.h +++ b/examples/autocompletesettingseditor.h @@ -4,9 +4,14 @@ #include //#include "ui_autocompletesettingsform.h" -#include "lib/qtmaterialoverlaywidget.h" +#include +#include +#include + +#include +#include "lib/overlaywidget.h" -class QtMaterialAutoComplete; +using namespace md; class AutoCompleteSettingsEditor : public QWidget { @@ -23,7 +28,7 @@ protected slots: private: //Ui::AutoCompleteSettingsForm *const ui; - QtMaterialAutoComplete *const m_autocomplete; + AutoComplete *const m_autocomplete; }; #endif // AUTOCOMPLETESETTINGSEDITOR_H diff --git a/examples/avatarsettingseditor.cpp b/examples/avatarsettingseditor.cpp index 17204802f..a2f58ce32 100644 --- a/examples/avatarsettingseditor.cpp +++ b/examples/avatarsettingseditor.cpp @@ -1,12 +1,9 @@ #include "avatarsettingseditor.h" -#include -#include -#include AvatarSettingsEditor::AvatarSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::AvatarSettingsForm), - m_avatar(new QtMaterialAvatar(QChar('X'))) + m_avatar(new Avatar(QChar('X'))) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); @@ -73,10 +70,11 @@ void AvatarSettingsEditor::updateWidget() m_avatar->setLetter(QChar('X')); break; case 1: - m_avatar->setImage(QImage(":/images/assets/sikh.jpg")); + qDebug()<setImage(QImage(QDir::currentPath()+"/assets/sikh.jpg")); break; case 2: - m_avatar->setIcon(QtMaterialTheme::icon("communication", "message")); + m_avatar->setIcon(Theme::icon("communication", "message")); break; default: break; diff --git a/examples/avatarsettingseditor.h b/examples/avatarsettingseditor.h index c9bc00956..5a909d2b4 100644 --- a/examples/avatarsettingseditor.h +++ b/examples/avatarsettingseditor.h @@ -2,9 +2,15 @@ #define AVATARSETTINGSEDITOR_H #include +#include +#include + +#include +#include + #include "ui_avatarsettingsform.h" -class QtMaterialAvatar; +using namespace md; class AvatarSettingsEditor : public QWidget { @@ -21,7 +27,7 @@ protected slots: private: Ui::AvatarSettingsForm *const ui; - QtMaterialAvatar *const m_avatar; + Avatar *const m_avatar; }; #endif // AVATARSETTINGSEDITOR_H diff --git a/examples/badgesettingseditor.cpp b/examples/badgesettingseditor.cpp index 4b5214682..bdf4f2292 100644 --- a/examples/badgesettingseditor.cpp +++ b/examples/badgesettingseditor.cpp @@ -1,13 +1,10 @@ #include "badgesettingseditor.h" -#include -#include -#include BadgeSettingsEditor::BadgeSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::BadgeSettingsForm), - m_avatar(new QtMaterialAvatar(QImage(":/images/assets/sikh.jpg"))), - m_badge(new QtMaterialBadge) + m_avatar(new Avatar(QImage(QDir::currentPath()+"/assets/sikh.jpg"))), + m_badge(new Badge) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); @@ -73,7 +70,7 @@ void BadgeSettingsEditor::updateWidget() m_badge->setText("3"); break; case 1: - m_badge->setIcon(QIcon(QtMaterialTheme::icon("communication", "message"))); + m_badge->setIcon(QIcon(Theme::icon("communication", "message"))); break; default: break; diff --git a/examples/badgesettingseditor.h b/examples/badgesettingseditor.h index 8f748083b..26446000d 100644 --- a/examples/badgesettingseditor.h +++ b/examples/badgesettingseditor.h @@ -2,10 +2,15 @@ #define BADGESETTINGSEDITOR_H #include +#include +#include + +#include +#include + #include "ui_badgesettingsform.h" -class QtMaterialAvatar; -class QtMaterialBadge; +using namespace md; class BadgeSettingsEditor : public QWidget { @@ -22,8 +27,8 @@ protected slots: private: Ui::BadgeSettingsForm *const ui; - QtMaterialAvatar *const m_avatar; - QtMaterialBadge *const m_badge; + Avatar *const m_avatar; + Badge *const m_badge; }; #endif // BADGESETTINGSEDITOR_H diff --git a/examples/checkboxsettingseditor.cpp b/examples/checkboxsettingseditor.cpp index 2e4037dd3..6ade78ca9 100644 --- a/examples/checkboxsettingseditor.cpp +++ b/examples/checkboxsettingseditor.cpp @@ -1,12 +1,9 @@ #include "checkboxsettingseditor.h" -#include -#include -#include CheckBoxSettingsEditor::CheckBoxSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::CheckBoxSettingsForm), - m_checkBox(new QtMaterialCheckBox) + m_checkBox(new CheckBox) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); @@ -52,10 +49,10 @@ void CheckBoxSettingsEditor::setupForm() { switch (m_checkBox->labelPosition()) { - case QtMaterialCheckable::LabelPositionLeft: + case Checkable::LabelPositionLeft: ui->labelPositionComboBox->setCurrentIndex(0); break; - case QtMaterialCheckable::LabelPositionRight: + case Checkable::LabelPositionRight: ui->labelPositionComboBox->setCurrentIndex(1); break; default: @@ -73,10 +70,10 @@ void CheckBoxSettingsEditor::updateWidget() switch (ui->labelPositionComboBox->currentIndex()) { case 0: - m_checkBox->setLabelPosition(QtMaterialCheckable::LabelPositionLeft); + m_checkBox->setLabelPosition(Checkable::LabelPositionLeft); break; case 1: - m_checkBox->setLabelPosition(QtMaterialCheckable::LabelPositionRight); + m_checkBox->setLabelPosition(Checkable::LabelPositionRight); break; default: break; diff --git a/examples/checkboxsettingseditor.h b/examples/checkboxsettingseditor.h index 445636790..78243ece0 100644 --- a/examples/checkboxsettingseditor.h +++ b/examples/checkboxsettingseditor.h @@ -2,9 +2,14 @@ #define CHECKBOXSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_checkboxsettingsform.h" -class QtMaterialCheckable; +using namespace md; class CheckBoxSettingsEditor : public QWidget { @@ -21,7 +26,7 @@ protected slots: private: Ui::CheckBoxSettingsForm *const ui; - QtMaterialCheckable *const m_checkBox; + Checkable *const m_checkBox; }; #endif // CHECKBOXSETTINGSEDITOR_H diff --git a/examples/circularprogresssettingseditor.cpp b/examples/circularprogresssettingseditor.cpp index 8c049fcd7..976f962db 100644 --- a/examples/circularprogresssettingseditor.cpp +++ b/examples/circularprogresssettingseditor.cpp @@ -1,12 +1,9 @@ #include "circularprogresssettingseditor.h" -#include -#include -#include CircularProgressSettingsEditor::CircularProgressSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::CircularProgressSettingsForm), - m_progress(new QtMaterialCircularProgress) + m_progress(new CircularProgress) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/circularprogresssettingseditor.h b/examples/circularprogresssettingseditor.h index 507798969..28c58b5cd 100644 --- a/examples/circularprogresssettingseditor.h +++ b/examples/circularprogresssettingseditor.h @@ -2,9 +2,14 @@ #define CIRCULARPROGRESSSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_circularprogresssettingsform.h" -class QtMaterialCircularProgress; +using namespace md; class CircularProgressSettingsEditor : public QWidget { @@ -21,7 +26,7 @@ protected slots: private: Ui::CircularProgressSettingsForm *const ui; - QtMaterialCircularProgress *const m_progress; + CircularProgress *const m_progress; }; #endif // CIRCULARPROGRESSSETTINGSEDITOR_H diff --git a/examples/dialogsettingseditor.cpp b/examples/dialogsettingseditor.cpp index f4e4916ae..8b350dd27 100644 --- a/examples/dialogsettingseditor.cpp +++ b/examples/dialogsettingseditor.cpp @@ -1,13 +1,9 @@ #include "dialogsettingseditor.h" -#include -#include -#include -#include DialogSettingsEditor::DialogSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::DialogSettingsForm), - m_dialog(new QtMaterialDialog) + m_dialog(new Dialog) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); @@ -32,7 +28,7 @@ DialogSettingsEditor::DialogSettingsEditor(QWidget *parent) QVBoxLayout *dialogWidgetLayout = new QVBoxLayout; dialogWidget->setLayout(dialogWidgetLayout); - QtMaterialFlatButton *closeButton = new QtMaterialFlatButton("Close"); + FlatButton *closeButton = new FlatButton("Close"); dialogWidgetLayout->addWidget(closeButton); dialogWidgetLayout->setAlignment(closeButton, Qt::AlignBottom | Qt::AlignCenter); diff --git a/examples/dialogsettingseditor.h b/examples/dialogsettingseditor.h index f92204621..357f36813 100644 --- a/examples/dialogsettingseditor.h +++ b/examples/dialogsettingseditor.h @@ -2,9 +2,15 @@ #define DIALOGSETTINGSEDITOR_H #include +#include +#include +#include + +#include + #include "ui_dialogsettingsform.h" -class QtMaterialDialog; +using namespace md; class DialogSettingsEditor : public QWidget { @@ -20,7 +26,7 @@ protected slots: private: Ui::DialogSettingsForm *const ui; - QtMaterialDialog *const m_dialog; + Dialog *const m_dialog; }; #endif // DIALOGSETTINGSEDITOR_H diff --git a/examples/drawersettingseditor.cpp b/examples/drawersettingseditor.cpp index dc515b75a..f9b2d71f7 100644 --- a/examples/drawersettingseditor.cpp +++ b/examples/drawersettingseditor.cpp @@ -1,12 +1,9 @@ #include "drawersettingseditor.h" -#include -#include -#include DrawerSettingsEditor::DrawerSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::DrawerSettingsForm), - m_drawer(new QtMaterialDrawer) + m_drawer(new Drawer) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/drawersettingseditor.h b/examples/drawersettingseditor.h index 45f21af1f..2aeaf95a9 100644 --- a/examples/drawersettingseditor.h +++ b/examples/drawersettingseditor.h @@ -2,9 +2,14 @@ #define DRAWERSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_drawersettingsform.h" -class QtMaterialDrawer; +using namespace md; class DrawerSettingsEditor : public QWidget { @@ -20,7 +25,7 @@ protected slots: private: Ui::DrawerSettingsForm *const ui; - QtMaterialDrawer *const m_drawer; + Drawer *const m_drawer; }; #endif // DRAWERSETTINGSEDITOR_H diff --git a/examples/examples.pro b/examples/examples.pro deleted file mode 100644 index 35d2438ca..000000000 --- a/examples/examples.pro +++ /dev/null @@ -1,75 +0,0 @@ -QT += core gui widgets -TEMPLATE = app -CONFIG += c++11 -SOURCES = mainwindow.cpp \ - main.cpp \ - avatarsettingseditor.cpp \ - badgesettingseditor.cpp \ - checkboxsettingseditor.cpp \ - fabsettingseditor.cpp \ - raisedbuttonsettingseditor.cpp \ - flatbuttonsettingseditor.cpp \ - iconbuttonsettingseditor.cpp \ - progresssettingseditor.cpp \ - circularprogresssettingseditor.cpp \ - slidersettingseditor.cpp \ - radiobuttonsettingseditor.cpp \ - togglesettingseditor.cpp \ - textfieldsettingseditor.cpp \ - tabssettingseditor.cpp \ - snackbarsettingseditor.cpp \ - dialogsettingseditor.cpp \ - drawersettingseditor.cpp \ - scrollbarsettingseditor.cpp \ - appbarsettingseditor.cpp \ - autocompletesettingseditor.cpp \ - menusettingseditor.cpp -HEADERS = mainwindow.h \ - avatarsettingseditor.h \ - badgesettingseditor.h \ - checkboxsettingseditor.h \ - fabsettingseditor.h \ - raisedbuttonsettingseditor.h \ - flatbuttonsettingseditor.h \ - iconbuttonsettingseditor.h \ - progresssettingseditor.h \ - circularprogresssettingseditor.h \ - slidersettingseditor.h \ - radiobuttonsettingseditor.h \ - togglesettingseditor.h \ - textfieldsettingseditor.h \ - tabssettingseditor.h \ - snackbarsettingseditor.h \ - dialogsettingseditor.h \ - drawersettingseditor.h \ - scrollbarsettingseditor.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 \ - badgesettingsform.ui \ - checkboxsettingsform.ui \ - fabsettingsform.ui \ - flatbuttonsettingsform.ui \ - iconbuttonsettingsform.ui \ - progresssettingsform.ui \ - circularprogresssettingsform.ui \ - slidersettingsform.ui \ - snackbarsettingsform.ui \ - radiobuttonsettingsform.ui \ - togglesettingsform.ui \ - textfieldsettingsform.ui \ - tabssettingsform.ui \ - dialogsettingsform.ui \ - drawersettingsform.ui \ - scrollbarsettingsform.ui \ - appbarsettingsform.ui diff --git a/examples/examples.qrc b/examples/examples.qrc deleted file mode 100644 index e6bff79b1..000000000 --- a/examples/examples.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - assets/uxceo-128.jpg - assets/sikh.jpg - - diff --git a/examples/fabsettingseditor.cpp b/examples/fabsettingseditor.cpp index efbceed64..cc5c54094 100644 --- a/examples/fabsettingseditor.cpp +++ b/examples/fabsettingseditor.cpp @@ -1,13 +1,9 @@ #include "fabsettingseditor.h" -#include -#include -#include -#include FloatingActionButtonSettingsEditor::FloatingActionButtonSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::FloatingActionButtonSettingsForm), - m_fab(new QtMaterialFloatingActionButton(QtMaterialTheme::icon("toggle", "star"))) + m_fab(new FloatingActionButton(Theme::icon("toggle", "star"))) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/fabsettingseditor.h b/examples/fabsettingseditor.h index 2d815f41e..5fcf434a9 100644 --- a/examples/fabsettingseditor.h +++ b/examples/fabsettingseditor.h @@ -2,9 +2,15 @@ #define FABSETTINGSEDITOR_H #include +#include +#include +#include + +#include + #include "ui_fabsettingsform.h" -class QtMaterialFloatingActionButton; +using namespace md; class FloatingActionButtonSettingsEditor : public QWidget { @@ -21,7 +27,7 @@ protected slots: private: Ui::FloatingActionButtonSettingsForm *const ui; - QtMaterialFloatingActionButton *const m_fab; + FloatingActionButton *const m_fab; }; #endif // FABSETTINGSEDITOR_H diff --git a/examples/flatbuttonsettingseditor.cpp b/examples/flatbuttonsettingseditor.cpp index 6b620ccc5..eaf1723c7 100644 --- a/examples/flatbuttonsettingseditor.cpp +++ b/examples/flatbuttonsettingseditor.cpp @@ -1,12 +1,9 @@ #include "flatbuttonsettingseditor.h" -#include -#include -#include FlatButtonSettingsEditor::FlatButtonSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::FlatButtonSettingsForm), - m_button(new QtMaterialFlatButton("I'm flat")) + m_button(new FlatButton("I'm flat")) { init(); } @@ -16,7 +13,7 @@ FlatButtonSettingsEditor::~FlatButtonSettingsEditor() delete ui; } -FlatButtonSettingsEditor::FlatButtonSettingsEditor(QtMaterialFlatButton *button, QWidget *parent) +FlatButtonSettingsEditor::FlatButtonSettingsEditor(FlatButton *button, QWidget *parent) : QWidget(parent), ui(new Ui::FlatButtonSettingsForm), m_button(button) @@ -180,7 +177,7 @@ void FlatButtonSettingsEditor::updateWidget() m_button->setCheckable(ui->checkableCheckBox->isChecked()); m_button->setChecked(ui->checkedCheckBox->isChecked()); m_button->setHaloVisible(ui->showHaloCheckBox->isChecked()); - m_button->setIcon(ui->iconCheckBox->isChecked() ? QtMaterialTheme::icon("toggle", "star") + m_button->setIcon(ui->iconCheckBox->isChecked() ? Theme::icon("toggle", "star") : QIcon()); m_button->setUseThemeColors(ui->useThemeColorsCheckBox->isChecked()); m_button->setBackgroundMode(ui->transparentCheckBox->isChecked() diff --git a/examples/flatbuttonsettingseditor.h b/examples/flatbuttonsettingseditor.h index 0ec4fd273..56f2f2dba 100644 --- a/examples/flatbuttonsettingseditor.h +++ b/examples/flatbuttonsettingseditor.h @@ -2,9 +2,14 @@ #define FLATBUTTONSETTINGSMANAGER_H #include +#include +#include + +#include + #include "ui_flatbuttonsettingsform.h" -class QtMaterialFlatButton; +using namespace md; class FlatButtonSettingsEditor : public QWidget { @@ -15,7 +20,7 @@ class FlatButtonSettingsEditor : public QWidget ~FlatButtonSettingsEditor(); protected: - explicit FlatButtonSettingsEditor(QtMaterialFlatButton *button, QWidget *parent = 0); + explicit FlatButtonSettingsEditor(FlatButton *button, QWidget *parent = 0); Ui::FlatButtonSettingsForm *const ui; @@ -29,7 +34,7 @@ protected slots: private: void init(); - QtMaterialFlatButton *const m_button; + FlatButton *const m_button; }; #endif // FLATBUTTONSETTINGSMANAGER_H diff --git a/examples/iconbuttonsettingseditor.cpp b/examples/iconbuttonsettingseditor.cpp index 4dbc51861..4a67ca4cd 100644 --- a/examples/iconbuttonsettingseditor.cpp +++ b/examples/iconbuttonsettingseditor.cpp @@ -1,12 +1,9 @@ #include "iconbuttonsettingseditor.h" -#include -#include -#include IconButtonSettingsEditor::IconButtonSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::IconButtonSettingsForm), - m_button(new QtMaterialIconButton(QtMaterialTheme::icon("toggle", "star"))) + m_button(new IconButton(Theme::icon("toggle", "star"))) { init(); } @@ -16,7 +13,7 @@ IconButtonSettingsEditor::~IconButtonSettingsEditor() delete ui; } -IconButtonSettingsEditor::IconButtonSettingsEditor(QtMaterialIconButton *button, QWidget *parent) +IconButtonSettingsEditor::IconButtonSettingsEditor(IconButton *button, QWidget *parent) : QWidget(parent), ui(new Ui::IconButtonSettingsForm), m_button(button) diff --git a/examples/iconbuttonsettingseditor.h b/examples/iconbuttonsettingseditor.h index d8758f85b..9ef9e2670 100644 --- a/examples/iconbuttonsettingseditor.h +++ b/examples/iconbuttonsettingseditor.h @@ -2,9 +2,14 @@ #define ICONBUTTONSETTINGSMANAGER_H #include +#include + +#include +#include + #include "ui_iconbuttonsettingsform.h" -class QtMaterialIconButton; +using namespace md; class IconButtonSettingsEditor : public QWidget { @@ -15,7 +20,7 @@ class IconButtonSettingsEditor : public QWidget ~IconButtonSettingsEditor(); protected: - explicit IconButtonSettingsEditor(QtMaterialIconButton *button, QWidget *parent = 0); + explicit IconButtonSettingsEditor(IconButton *button, QWidget *parent = 0); Ui::IconButtonSettingsForm *const ui; @@ -27,7 +32,7 @@ protected slots: private: void init(); - QtMaterialIconButton *const m_button; + IconButton *const m_button; }; #endif // ICONBUTTONSETTINGSMANAGER_H diff --git a/examples/main.cpp b/examples/main.cpp index 38f87613e..95b0f6fd4 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -4,9 +4,7 @@ int main(int argc, char *argv[]) { - QApplication a(argc, argv); - - Q_INIT_RESOURCE(resources); + QApplication a(argc, argv); MainWindow window; window.show(); diff --git a/examples/mainwindow.cpp b/examples/mainwindow.cpp index cc4992e45..3567e1b66 100644 --- a/examples/mainwindow.cpp +++ b/examples/mainwindow.cpp @@ -1,32 +1,9 @@ #include "mainwindow.h" -#include -#include -#include -#include "avatarsettingseditor.h" -#include "badgesettingseditor.h" -#include "checkboxsettingseditor.h" -#include "fabsettingseditor.h" -#include "raisedbuttonsettingseditor.h" -#include "flatbuttonsettingseditor.h" -#include "iconbuttonsettingseditor.h" -#include "progresssettingseditor.h" -#include "circularprogresssettingseditor.h" -#include "slidersettingseditor.h" -#include "radiobuttonsettingseditor.h" -#include "togglesettingseditor.h" -#include "textfieldsettingseditor.h" -#include "tabssettingseditor.h" -#include "snackbarsettingseditor.h" -#include "dialogsettingseditor.h" -#include "drawersettingseditor.h" -#include "scrollbarsettingseditor.h" -#include "appbarsettingseditor.h" -#include "autocompletesettingseditor.h" -#include "menusettingseditor.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + this->showMaximized(); QWidget *widget = new QWidget; QHBoxLayout *layout = new QHBoxLayout; @@ -64,9 +41,9 @@ MainWindow::MainWindow(QWidget *parent) AutoCompleteSettingsEditor *autocomplete = new AutoCompleteSettingsEditor; MenuSettingsEditor *menu = new MenuSettingsEditor; + stack->addWidget(avatar); stack->addWidget(appBar); stack->addWidget(autocomplete); - stack->addWidget(avatar); stack->addWidget(badge); stack->addWidget(checkbox); stack->addWidget(circularProgress); @@ -86,9 +63,10 @@ MainWindow::MainWindow(QWidget *parent) stack->addWidget(textField); stack->addWidget(toggle); + + list->addItem("Avatar"); list->addItem("App Bar"); list->addItem("Auto Complete"); - list->addItem("Avatar"); list->addItem("Badge"); list->addItem("Checkbox"); list->addItem("Circular Progress"); diff --git a/examples/mainwindow.h b/examples/mainwindow.h index 1f39a8c16..eaf1c9bbe 100644 --- a/examples/mainwindow.h +++ b/examples/mainwindow.h @@ -2,6 +2,31 @@ #define MAINWINDOW_H #include +#include +#include +#include + +#include "avatarsettingseditor.h" +#include "badgesettingseditor.h" +#include "checkboxsettingseditor.h" +#include "fabsettingseditor.h" +#include "raisedbuttonsettingseditor.h" +#include "flatbuttonsettingseditor.h" +#include "iconbuttonsettingseditor.h" +#include "progresssettingseditor.h" +#include "circularprogresssettingseditor.h" +#include "slidersettingseditor.h" +#include "radiobuttonsettingseditor.h" +#include "togglesettingseditor.h" +#include "textfieldsettingseditor.h" +#include "tabssettingseditor.h" +#include "snackbarsettingseditor.h" +#include "dialogsettingseditor.h" +#include "drawersettingseditor.h" +#include "scrollbarsettingseditor.h" +#include "appbarsettingseditor.h" +#include "autocompletesettingseditor.h" +#include "menusettingseditor.h" class MainWindow : public QMainWindow { diff --git a/examples/menusettingseditor.cpp b/examples/menusettingseditor.cpp index fcf5c6579..e406feb37 100644 --- a/examples/menusettingseditor.cpp +++ b/examples/menusettingseditor.cpp @@ -1,12 +1,9 @@ #include "menusettingseditor.h" -#include -#include -#include MenuSettingsEditor::MenuSettingsEditor(QWidget *parent) : QWidget(parent), //ui(new Ui::MenuSettingsForm), - m_menu(new QtMaterialMenu) + m_menu(new Menu) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/menusettingseditor.h b/examples/menusettingseditor.h index bed5c41f3..1a64f5418 100644 --- a/examples/menusettingseditor.h +++ b/examples/menusettingseditor.h @@ -2,11 +2,15 @@ #define MENUSETTINGSEDITOR_H #include -//#include "ui_menusettingsform.h" +#include +#include + +#include +#include "lib/overlaywidget.h" -#include "lib/qtmaterialoverlaywidget.h" +//#include "ui_menusettingsform.h" -class QtMaterialMenu; +using namespace md; class MenuSettingsEditor : public QWidget { @@ -23,7 +27,7 @@ protected slots: private: //Ui::MenuSettingsForm *const ui; - QtMaterialMenu *const m_menu; + Menu *const m_menu; }; #endif // MENUSETTINGSEDITOR_H diff --git a/examples/progresssettingseditor.cpp b/examples/progresssettingseditor.cpp index 401eb5770..57e5cde34 100644 --- a/examples/progresssettingseditor.cpp +++ b/examples/progresssettingseditor.cpp @@ -1,12 +1,9 @@ #include "progresssettingseditor.h" -#include -#include -#include ProgressSettingsEditor::ProgressSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::ProgressSettingsForm), - m_progress(new QtMaterialProgress) + m_progress(new ProgressBar) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/progresssettingseditor.h b/examples/progresssettingseditor.h index bc5bbaa5b..d0d89bf50 100644 --- a/examples/progresssettingseditor.h +++ b/examples/progresssettingseditor.h @@ -2,9 +2,14 @@ #define PROGRESSSETTINGSEDITOR_H #include +#include + +#include +#include + #include "ui_progresssettingsform.h" -class QtMaterialProgress; +using namespace md; class ProgressSettingsEditor : public QWidget { @@ -21,7 +26,7 @@ protected slots: private: Ui::ProgressSettingsForm *const ui; - QtMaterialProgress *const m_progress; + ProgressBar *const m_progress; }; #endif // PROGRESSSETTINGSEDITOR_H diff --git a/examples/radiobuttonsettingseditor.cpp b/examples/radiobuttonsettingseditor.cpp index 2a039ce50..51b1129a8 100644 --- a/examples/radiobuttonsettingseditor.cpp +++ b/examples/radiobuttonsettingseditor.cpp @@ -1,15 +1,11 @@ #include "radiobuttonsettingseditor.h" -#include -#include -#include -#include RadioButtonSettingsEditor::RadioButtonSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::RadioButtonSettingsForm), - m_radioButton1(new QtMaterialRadioButton), - m_radioButton2(new QtMaterialRadioButton), - m_radioButton3(new QtMaterialRadioButton) + m_radioButton1(new RadioButton), + m_radioButton2(new RadioButton), + m_radioButton3(new RadioButton) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); @@ -47,7 +43,7 @@ RadioButtonSettingsEditor::RadioButtonSettingsEditor(QWidget *parent) layout->setAlignment(Qt::AlignCenter); - layout->setMargin(0); +// layout->setMargin(0); // FIXME: ??? layout->setSpacing(0); setupForm(); @@ -72,10 +68,10 @@ void RadioButtonSettingsEditor::setupForm() { switch (m_radioButton1->labelPosition()) { - case QtMaterialCheckable::LabelPositionLeft: + case Checkable::LabelPositionLeft: ui->labelPositionComboBox_2->setCurrentIndex(0); break; - case QtMaterialCheckable::LabelPositionRight: + case Checkable::LabelPositionRight: ui->labelPositionComboBox_2->setCurrentIndex(1); break; default: @@ -92,14 +88,14 @@ void RadioButtonSettingsEditor::updateWidget() switch (ui->labelPositionComboBox_2->currentIndex()) { case 0: - m_radioButton1->setLabelPosition(QtMaterialCheckable::LabelPositionLeft); - m_radioButton2->setLabelPosition(QtMaterialCheckable::LabelPositionLeft); - m_radioButton3->setLabelPosition(QtMaterialCheckable::LabelPositionLeft); + m_radioButton1->setLabelPosition(Checkable::LabelPositionLeft); + m_radioButton2->setLabelPosition(Checkable::LabelPositionLeft); + m_radioButton3->setLabelPosition(Checkable::LabelPositionLeft); break; case 1: - m_radioButton1->setLabelPosition(QtMaterialCheckable::LabelPositionRight); - m_radioButton2->setLabelPosition(QtMaterialCheckable::LabelPositionRight); - m_radioButton3->setLabelPosition(QtMaterialCheckable::LabelPositionRight); + m_radioButton1->setLabelPosition(Checkable::LabelPositionRight); + m_radioButton2->setLabelPosition(Checkable::LabelPositionRight); + m_radioButton3->setLabelPosition(Checkable::LabelPositionRight); break; default: break; diff --git a/examples/radiobuttonsettingseditor.h b/examples/radiobuttonsettingseditor.h index 76ad852b4..1a3f9d4ee 100644 --- a/examples/radiobuttonsettingseditor.h +++ b/examples/radiobuttonsettingseditor.h @@ -2,10 +2,15 @@ #define RADIOBUTTONSETTINGSEDITOR_H #include +#include +#include +#include + +#include + #include "ui_radiobuttonsettingsform.h" -class QtMaterialRadioButton; -class RadioButton; +using namespace md; class RadioButtonSettingsEditor : public QWidget { @@ -22,9 +27,9 @@ protected slots: private: Ui::RadioButtonSettingsForm *const ui; - QtMaterialRadioButton *const m_radioButton1; - QtMaterialRadioButton *const m_radioButton2; - QtMaterialRadioButton *const m_radioButton3; + RadioButton *const m_radioButton1; + RadioButton *const m_radioButton2; + RadioButton *const m_radioButton3; }; #endif // RADIOBUTTONSETTINGSEDITOR_H diff --git a/examples/raisedbuttonsettingseditor.cpp b/examples/raisedbuttonsettingseditor.cpp index 3dc41e00e..fc79b2e0a 100644 --- a/examples/raisedbuttonsettingseditor.cpp +++ b/examples/raisedbuttonsettingseditor.cpp @@ -1,8 +1,7 @@ #include "raisedbuttonsettingseditor.h" -#include RaisedButtonSettingsEditor::RaisedButtonSettingsEditor(QWidget *parent) - : FlatButtonSettingsEditor(new QtMaterialRaisedButton("Rise up"), parent) + : FlatButtonSettingsEditor(new RaisedButton("Rise up"), parent) { ui->transparentCheckBox->setDisabled(true); ui->defaultPresetPushButton->setDisabled(true); diff --git a/examples/raisedbuttonsettingseditor.h b/examples/raisedbuttonsettingseditor.h index 250acd07e..95babf356 100644 --- a/examples/raisedbuttonsettingseditor.h +++ b/examples/raisedbuttonsettingseditor.h @@ -1,8 +1,11 @@ #ifndef RAISEDBUTTONSETTINGSEDITOR_H #define RAISEDBUTTONSETTINGSEDITOR_H +#include #include "flatbuttonsettingseditor.h" +using namespace md; + class RaisedButtonSettingsEditor : public FlatButtonSettingsEditor { Q_OBJECT diff --git a/examples/scrollbarsettingseditor.cpp b/examples/scrollbarsettingseditor.cpp index b02944c32..fdd5d81a8 100644 --- a/examples/scrollbarsettingseditor.cpp +++ b/examples/scrollbarsettingseditor.cpp @@ -1,14 +1,10 @@ #include "scrollbarsettingseditor.h" -#include -#include -#include -#include ScrollBarSettingsEditor::ScrollBarSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::ScrollBarSettingsForm), - m_verticalScrollbar(new QtMaterialScrollBar), - m_horizontalScrollbar(new QtMaterialScrollBar) + m_verticalScrollbar(new ScrollBar), + m_horizontalScrollbar(new ScrollBar) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/scrollbarsettingseditor.h b/examples/scrollbarsettingseditor.h index fd7453957..3b6fced5d 100644 --- a/examples/scrollbarsettingseditor.h +++ b/examples/scrollbarsettingseditor.h @@ -2,9 +2,15 @@ #define SCROLLBARSETTINGSEDITOR_H #include +#include +#include +#include + +#include + #include "ui_scrollbarsettingsform.h" -class QtMaterialScrollBar; +using namespace md; class ScrollBarSettingsEditor : public QWidget { @@ -20,8 +26,8 @@ protected slots: private: Ui::ScrollBarSettingsForm *const ui; - QtMaterialScrollBar *const m_verticalScrollbar; - QtMaterialScrollBar *const m_horizontalScrollbar; + ScrollBar *const m_verticalScrollbar; + ScrollBar *const m_horizontalScrollbar; }; #endif // SCROLLBARSETTINGSEDITOR_H diff --git a/examples/slidersettingseditor.cpp b/examples/slidersettingseditor.cpp index 2911fdb7b..fd3ca735c 100644 --- a/examples/slidersettingseditor.cpp +++ b/examples/slidersettingseditor.cpp @@ -1,12 +1,9 @@ #include "slidersettingseditor.h" -#include -#include -#include SliderSettingsEditor::SliderSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SliderSettingsForm), - m_slider(new QtMaterialSlider) + m_slider(new Slider) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/slidersettingseditor.h b/examples/slidersettingseditor.h index 11e1a851f..0bb69d91f 100644 --- a/examples/slidersettingseditor.h +++ b/examples/slidersettingseditor.h @@ -2,9 +2,14 @@ #define SLIDERSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_slidersettingsform.h" -class QtMaterialSlider; +using namespace md; class SliderSettingsEditor : public QWidget { @@ -20,7 +25,7 @@ protected slots: private: Ui::SliderSettingsForm *const ui; - QtMaterialSlider *const m_slider; + Slider *const m_slider; }; #endif // SLIDERSETTINGSEDITOR_H diff --git a/examples/snackbarsettingseditor.cpp b/examples/snackbarsettingseditor.cpp index 0a9dcca3a..bd348646b 100644 --- a/examples/snackbarsettingseditor.cpp +++ b/examples/snackbarsettingseditor.cpp @@ -1,12 +1,9 @@ #include "snackbarsettingseditor.h" -#include -#include -#include SnackbarSettingsEditor::SnackbarSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::SnackbarSettingsForm), - m_snackbar(new QtMaterialSnackbar) + m_snackbar(new SnackBar) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/snackbarsettingseditor.h b/examples/snackbarsettingseditor.h index 2e4eb0d95..01d02dba6 100644 --- a/examples/snackbarsettingseditor.h +++ b/examples/snackbarsettingseditor.h @@ -2,9 +2,14 @@ #define SNACKBARSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_snackbarsettingsform.h" -class QtMaterialSnackbar; +using namespace md; class SnackbarSettingsEditor : public QWidget { @@ -21,7 +26,7 @@ protected slots: private: Ui::SnackbarSettingsForm *const ui; - QtMaterialSnackbar *const m_snackbar; + SnackBar *const m_snackbar; }; #endif // SNACKBARSETTINGSEDITOR_H diff --git a/examples/tabssettingseditor.cpp b/examples/tabssettingseditor.cpp index 9b53a1d78..04f4c299a 100644 --- a/examples/tabssettingseditor.cpp +++ b/examples/tabssettingseditor.cpp @@ -1,12 +1,9 @@ #include "tabssettingseditor.h" -#include -#include -#include TabsSettingsEditor::TabsSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::TabsSettingsForm), - m_tabs(new QtMaterialTabs) + m_tabs(new Tabs) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/tabssettingseditor.h b/examples/tabssettingseditor.h index 7bf3e9785..02fa82176 100644 --- a/examples/tabssettingseditor.h +++ b/examples/tabssettingseditor.h @@ -2,9 +2,14 @@ #define TABSSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_tabssettingsform.h" -class QtMaterialTabs; +using namespace md; class TabsSettingsEditor : public QWidget { @@ -20,7 +25,7 @@ protected slots: private: Ui::TabsSettingsForm *const ui; - QtMaterialTabs *const m_tabs; + Tabs *const m_tabs; }; #endif // TABSSETTINGSEDITOR_H diff --git a/examples/textfieldsettingseditor.cpp b/examples/textfieldsettingseditor.cpp index 2b7fa8d79..d56a085c9 100644 --- a/examples/textfieldsettingseditor.cpp +++ b/examples/textfieldsettingseditor.cpp @@ -1,12 +1,9 @@ #include "textfieldsettingseditor.h" -#include -#include -#include TextFieldSettingsEditor::TextFieldSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::TextFieldSettingsForm), - m_textField(new QtMaterialTextField) + m_textField(new TextField) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/textfieldsettingseditor.h b/examples/textfieldsettingseditor.h index 57f0d0f3f..90bd4b64a 100644 --- a/examples/textfieldsettingseditor.h +++ b/examples/textfieldsettingseditor.h @@ -2,9 +2,14 @@ #define TEXTFIELDSETTINGSEDITOR_H #include +#include +#include + +#include + #include "ui_textfieldsettingsform.h" -class QtMaterialTextField; +using namespace md; class TextFieldSettingsEditor : public QWidget { @@ -22,7 +27,7 @@ protected slots: private: Ui::TextFieldSettingsForm *const ui; - QtMaterialTextField *const m_textField; + TextField *const m_textField; }; #endif // TEXTFIELDSETTINGSEDITOR_H diff --git a/examples/togglesettingseditor.cpp b/examples/togglesettingseditor.cpp index 36fe97822..39d51bc46 100644 --- a/examples/togglesettingseditor.cpp +++ b/examples/togglesettingseditor.cpp @@ -1,11 +1,9 @@ #include "togglesettingseditor.h" -#include -#include ToggleSettingsEditor::ToggleSettingsEditor(QWidget *parent) : QWidget(parent), ui(new Ui::ToggleSettingsForm), - m_toggle(new QtMaterialToggle) + m_toggle(new Toggle) { QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); diff --git a/examples/togglesettingseditor.h b/examples/togglesettingseditor.h index a74553e47..e5e20fd73 100644 --- a/examples/togglesettingseditor.h +++ b/examples/togglesettingseditor.h @@ -2,9 +2,13 @@ #define TOGGLESETTINGSEDITOR_H #include +#include + +#include + #include "ui_togglesettingsform.h" -class QtMaterialToggle; +using namespace md; class ToggleSettingsEditor : public QWidget { @@ -21,7 +25,7 @@ protected slots: private: Ui::ToggleSettingsForm *const ui; - QtMaterialToggle *const m_toggle; + Toggle *const m_toggle; }; #endif // TOGGLESETTINGSEDITOR_H diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro deleted file mode 100644 index 5654f10a8..000000000 --- a/qt-material-widgets.pro +++ /dev/null @@ -1,17 +0,0 @@ -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = qt-material-widgets -TEMPLATE = subdirs -SUBDIRS = components examples -CONFIG += ordered - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked as deprecated (the exact warnings -# 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