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