diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..01f6ee801
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,196 @@
+---
+# 语言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto
+Language: Cpp
+# BasedOnStyle: LLVM
+# 访问说明符(public、private等)的偏移
+AccessModifierOffset: -4
+# 开括号(开圆括号、开尖括号、开方括号)后的对齐: Align, DontAlign, AlwaysBreak(总是在开括号后换行)
+AlignAfterOpenBracket: Align
+# 连续赋值时,对齐所有等号
+AlignConsecutiveAssignments: false
+# 连续声明时,对齐所有声明的变量名
+AlignConsecutiveDeclarations: false
+
+AlignEscapedNewlines: Right
+
+# 左对齐逃脱换行(使用反斜杠换行)的反斜杠
+#AlignEscapedNewlinesLeft: true
+# 水平对齐二元和三元表达式的操作数
+AlignOperands: true
+# 对齐连续的尾随的注释
+AlignTrailingComments: true
+
+# 允许函数声明的所有参数在放在下一行
+AllowAllParametersOfDeclarationOnNextLine: true
+# 允许短的块放在同一行
+AllowShortBlocksOnASingleLine: false
+# 允许短的case标签放在同一行
+AllowShortCaseLabelsOnASingleLine: false
+# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All
+AllowShortFunctionsOnASingleLine: Inline
+# 允许短的if语句保持在同一行
+AllowShortIfStatementsOnASingleLine: false
+# 允许短的循环保持在同一行
+AllowShortLoopsOnASingleLine: false
+
+# 总是在定义返回类型后换行(deprecated)
+AlwaysBreakAfterDefinitionReturnType: None
+# 总是在返回类型后换行: None, All, TopLevel(顶级函数,不包括在类中的函数),
+# AllDefinitions(所有的定义,不包括声明), TopLevelDefinitions(所有的顶级函数的定义)
+AlwaysBreakAfterReturnType: None
+# 总是在多行string字面量前换行
+AlwaysBreakBeforeMultilineStrings: false
+# 总是在template声明后换行
+AlwaysBreakTemplateDeclarations: false
+# false表示函数实参要么都在同一行,要么都各自一行
+BinPackArguments: false
+# false表示所有形参要么都在同一行,要么都各自一行
+BinPackParameters: false
+# 大括号换行,只有当BreakBeforeBraces设置为Custom时才有效
+BraceWrapping:
+ # class定义后面
+ AfterClass: true
+ # 控制语句后面
+ AfterControlStatement: false
+ # enum定义后面
+ AfterEnum: false
+ # 函数定义后面
+ AfterFunction: true
+ # 命名空间定义后面
+ AfterNamespace: false
+ # ObjC定义后面
+ AfterObjCDeclaration: false
+ # struct定义后面
+ AfterStruct: true
+ # union定义后面
+ AfterUnion: true
+
+ AfterExternBlock: false
+ # catch之前
+ BeforeCatch: false
+ # else之前
+ BeforeElse: false
+ # 缩进大括号
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+
+# 在二元运算符前换行: None(在操作符后换行), NonAssignment(在非赋值的操作符前换行), All(在操作符前换行)
+BreakBeforeBinaryOperators: None
+# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似),
+# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似),
+# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom
+# 注:这里认为语句块也属于函数
+BreakBeforeBraces: Custom
+# 在三元运算符前换行
+BreakBeforeTernaryOperators: false
+
+# 在构造函数的初始化列表的逗号前换行
+BreakConstructorInitializersBeforeComma: true
+BreakConstructorInitializers: BeforeColon
+# 每行字符的限制,0表示没有限制
+ColumnLimit: 130
+# 描述具有特殊意义的注释的正则表达式,它不应该被分割为多行或以其它方式改变
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+# 构造函数的初始化列表要么都在同一行,要么都各自一行
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+# 构造函数的初始化列表的缩进宽度
+ConstructorInitializerIndentWidth: 4
+# 延续的行的缩进宽度
+ContinuationIndentWidth: 4
+# 去除C++11的列表初始化的大括号{后和}前的空格
+Cpp11BracedListStyle: true
+# 继承最常用的指针和引用的对齐方式
+DerivePointerAlignment: false
+# 关闭格式化
+DisableFormat: false
+# 自动检测函数的调用和定义是否被格式为每行一个参数(Experimental)
+ExperimentalAutoDetectBinPacking: false
+# 需要被解读为foreach循环而不是函数调用的宏
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+# 对#include进行排序,匹配了某正则表达式的#include拥有对应的优先级,匹配不到的则默认优先级为INT_MAX(优先级越小排序越靠前),
+# 可以定义负数优先级从而保证某些#include永远在最前面
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ - Regex: '^(<|"(gtest|isl|json)/)'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 1
+# 缩进case标签
+IndentCaseLabels: true
+
+IndentPPDirectives: AfterHash
+# 缩进宽度
+IndentWidth: 4
+# 函数返回类型换行时,缩进函数声明或函数定义的函数名
+IndentWrappedFunctionNames: false
+# 保留在块开始处的空行
+KeepEmptyLinesAtTheStartOfBlocks: false
+# 开始一个块的宏的正则表达式
+MacroBlockBegin: ''
+# 结束一个块的宏的正则表达式
+MacroBlockEnd: ''
+# 连续空行的最大数量
+MaxEmptyLinesToKeep: 1
+# 命名空间的缩进: None, Inner(缩进嵌套的命名空间中的内容), All
+NamespaceIndentation: Inner
+# 使用ObjC块时缩进宽度
+ObjCBlockIndentWidth: 4
+# 在ObjC的@property后添加一个空格
+ObjCSpaceAfterProperty: false
+# 在ObjC的protocol列表前添加一个空格
+ObjCSpaceBeforeProtocolList: true
+
+
+# 在call(后对函数调用换行的penalty
+PenaltyBreakBeforeFirstCallParameter: 19
+# 在一个注释中引入换行的penalty
+PenaltyBreakComment: 300
+# 第一次在<<前换行的penalty
+PenaltyBreakFirstLessLess: 120
+# 在一个字符串字面量中引入换行的penalty
+PenaltyBreakString: 1000
+# 对于每个在行字符数限制之外的字符的penalty
+PenaltyExcessCharacter: 1000000
+# 将函数的返回类型放到它自己的行的penalty
+PenaltyReturnTypeOnItsOwnLine: 60
+
+# 指针和引用的对齐: Left, Right, Middle
+PointerAlignment: Right
+# 允许重新排版注释
+ReflowComments: true
+# 允许排序#include
+SortIncludes: true
+
+# 在C风格类型转换后添加空格
+SpaceAfterCStyleCast: false
+
+SpaceAfterTemplateKeyword: true
+
+# 在赋值运算符之前添加空格
+SpaceBeforeAssignmentOperators: true
+# 开圆括号之前添加一个空格: Never, ControlStatements, Always
+SpaceBeforeParens: ControlStatements
+# 在空的圆括号中添加空格
+SpaceInEmptyParentheses: false
+# 在尾随的评论前添加的空格数(只适用于//)
+SpacesBeforeTrailingComments: 2
+# 在尖括号的<后和>前添加空格
+SpacesInAngles: false
+# 在容器(ObjC和JavaScript的数组和字典等)字面量中添加空格
+SpacesInContainerLiterals: false
+# 在C风格类型转换的括号中添加空格
+SpacesInCStyleCastParentheses: false
+# 在圆括号的(后和)前添加空格
+SpacesInParentheses: false
+# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响
+SpacesInSquareBrackets: false
+# 标准: Cpp03, Cpp11, Auto
+Standard: Auto
+# tab宽度
+TabWidth: 4
+# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always
+UseTab: Never
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 75c107bcc..b4da253be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
*.pro.user
+build
+.cache
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..2f2f7caf8
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,6 @@
+project(qt-material-widgets)
+cmake_minimum_required(VERSION 3.22)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+add_subdirectory(examples)
+add_subdirectory(components)
diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
new file mode 100644
index 000000000..44bb9529c
--- /dev/null
+++ b/CMakeLists.txt.user
@@ -0,0 +1,322 @@
+
+
+
+
+
+ EnvironmentId
+ {d2b00d11-c185-4f43-9d72-0d9e9d9ad5bb}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ false
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+
+ 0
+ true
+
+ true
+ Builtin.BuildSystem
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 4
+
+
+
+ true
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop
+ Desktop
+ {2ebfeb06-0a8a-455d-9f68-fc633ebb7f9a}
+ 0
+ 0
+ 0
+
+ Debug
+ -DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_BUILD_TYPE:STRING=Debug
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
+ /home/cht/git/build-qt-material-widgets-Desktop-Debug
+
+
+
+ all
+
+ true
+ Build
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+ clean
+
+ true
+ Build
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ Release
+ -DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_BUILD_TYPE:STRING=Release
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
+ /home/cht/git/build-qt-material-widgets-Desktop-Release
+
+
+
+ all
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+ clean
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ RelWithDebInfo
+ -DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
+ /home/cht/git/build-qt-material-widgets-Desktop-RelWithDebInfo
+
+
+
+ all
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+ clean
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release with Debug Information
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ MinSizeRel
+ -DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake
+-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}
+-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}
+-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}
+ /home/cht/git/build-qt-material-widgets-Desktop-MinSizeRel
+
+
+
+ all
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+ clean
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Minimum Size Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+ 4
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ true
+
+ 2
+
+ examples
+ CMakeProjectManager.CMakeRunConfiguration.examples
+ examples
+ false
+ true
+ true
+ false
+ true
+ /home/cht/git/build-qt-material-widgets-Desktop-Debug/examples
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/README.md b/README.md
index c73eed0dd..501441016 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
YouTube video preview [available here](http://www.youtube.com/watch?v=21UMeNVBPU4).
+
diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt
new file mode 100644
index 000000000..8f2fc18f0
--- /dev/null
+++ b/components/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(
+ components
+ VERSION 0.1
+ LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+find_package(Qt5 REQUIRED COMPONENTS Core)
+find_package(Qt5 REQUIRED COMPONENTS Widgets)
+
+file(GLOB THELIB "materiallib/*")
+file(GLOB COMPONENTSHEADER "*.h")
+file(GLOB COMPONENTSSOURCE "*.cpp")
+file(GLOB HEADER "../include/qmetarial/*")
+file(GLOB HEADER2 "../include/qmetarial/lib/*")
+
+set(RCC_FILES resources.qrc)
+add_library(
+ ${PROJECT_NAME} STATIC ${THELIB} ${COMPONENTSHEADER} ${COMPONENTSSOURCE}
+ ${RCC_FILES} ${HEADER} ${HEADER2})
+target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets)
+target_include_directories(${PROJECT_NAME} PUBLIC ../include/qmetarial/)
+target_link_directories(${PROJECT_NAME} PUBLIC .)
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/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/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.cpp b/components/lib/qtmaterialoverlaywidget.cpp
deleted file mode 100644
index ec0e7fedb..000000000
--- a/components/lib/qtmaterialoverlaywidget.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "lib/qtmaterialoverlaywidget.h"
-#include
-
-/*!
- * \class QtMaterialOverlayWidget
- * \internal
- */
-
-QtMaterialOverlayWidget::QtMaterialOverlayWidget(QWidget *parent)
- : QWidget(parent)
-{
- if (parent) {
- parent->installEventFilter(this);
- }
-}
-
-QtMaterialOverlayWidget::~QtMaterialOverlayWidget()
-{
-}
-
-/*!
- * \reimp
- */
-bool QtMaterialOverlayWidget::event(QEvent *event)
-{
- if (!parent()) {
- return QWidget::event(event);
- }
- switch (event->type())
- {
- case QEvent::ParentChange:
- {
- parent()->installEventFilter(this);
- setGeometry(overlayGeometry());
- break;
- }
- case QEvent::ParentAboutToChange:
- {
- parent()->removeEventFilter(this);
- break;
- }
- default:
- break;
- }
- return QWidget::event(event);
-}
-
-/*!
- * \reimp
- */
-bool QtMaterialOverlayWidget::eventFilter(QObject *obj, QEvent *event)
-{
- switch (event->type())
- {
- case QEvent::Move:
- case QEvent::Resize:
- setGeometry(overlayGeometry());
- break;
- default:
- break;
- }
- return QWidget::eventFilter(obj, event);
-}
-
-QRect QtMaterialOverlayWidget::overlayGeometry() const
-{
- QWidget *widget = parentWidget();
- if (!widget) {
- return QRect();
- }
- return widget->rect();
-}
diff --git a/components/lib/qtmaterialtheme.cpp b/components/lib/qtmaterialtheme.cpp
deleted file mode 100644
index 725c95480..000000000
--- a/components/lib/qtmaterialtheme.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-#include "lib/qtmaterialtheme.h"
-#include "lib/qtmaterialtheme_p.h"
-#include
-#include
-#include
-
-/*!material
- * \class QtMaterialThemePrivate
- * \internal
- */
-
-QtMaterialThemePrivate::QtMaterialThemePrivate(QtMaterialTheme *q)
- : q_ptr(q)
-{
-}
-
-QtMaterialThemePrivate::~QtMaterialThemePrivate()
-{
-}
-
-QColor QtMaterialThemePrivate::rgba(int r, int g, int b, qreal a) const
-{
- QColor color(r, g, b);
- color.setAlphaF(a);
- return color;
-}
-
-/*!
- * \class QtMaterialTheme
- */
-
-QtMaterialTheme::QtMaterialTheme(QObject *parent)
- : QObject(parent),
- d_ptr(new QtMaterialThemePrivate(this))
-{
- setColor("primary1", Material::cyan500);
- setColor("primary2", Material::cyan700);
- setColor("primary3", Material::lightBlack);
- setColor("accent1", Material::pinkA200);
- setColor("accent2", Material::grey100);
- setColor("accent3", Material::grey500);
- setColor("text", Material::darkBlack);
- setColor("alternateText", Material::white);
- setColor("canvas", Material::white);
- setColor("border", Material::grey300);
- setColor("disabled", Material::minBlack);
- setColor("disabled2", Material::faintBlack);
- setColor("disabled3", Material::grey300);
-}
-
-QtMaterialTheme::~QtMaterialTheme()
-{
-}
-
-QColor QtMaterialTheme::getColor(const QString &key) const
-{
- Q_D(const QtMaterialTheme);
-
- if (!d->colors.contains(key)) {
- qWarning() << "A theme color matching the key '" << key << "' could not be found.";
- return QColor();
- }
- return d->colors.value(key);
-}
-
-void QtMaterialTheme::setColor(const QString &key, const QColor &color)
-{
- Q_D(QtMaterialTheme);
-
- d->colors.insert(key, color);
-}
-
-void QtMaterialTheme::setColor(const QString &key, Material::Color color)
-{
- Q_D(QtMaterialTheme);
-
- static const QColor palette[] = {
- QColor("#ffebee"), QColor("#ffcdd2"), QColor("#ef9a9a"), QColor("#e57373"),
- QColor("#ef5350"), QColor("#f44336"), QColor("#e53935"), QColor("#d32f2f"),
- QColor("#c62828"), QColor("#b71c1c"), QColor("#ff8a80"), QColor("#ff5252"),
- QColor("#ff1744"), QColor("#d50000"), QColor("#fce4ec"), QColor("#f8bbd0"),
- QColor("#f48fb1"), QColor("#f06292"), QColor("#ec407a"), QColor("#e91e63"),
- QColor("#d81b60"), QColor("#c2185b"), QColor("#ad1457"), QColor("#880e4f"),
- QColor("#ff80ab"), QColor("#ff4081"), QColor("#f50057"), QColor("#c51162"),
- QColor("#f3e5f5"), QColor("#e1bee7"), QColor("#ce93d8"), QColor("#ba68c8"),
- QColor("#ab47bc"), QColor("#9c27b0"), QColor("#8e24aa"), QColor("#7b1fa2"),
- QColor("#6a1b9a"), QColor("#4a148c"), QColor("#ea80fc"), QColor("#e040fb"),
- QColor("#d500f9"), QColor("#aa00ff"), QColor("#ede7f6"), QColor("#d1c4e9"),
- QColor("#b39ddb"), QColor("#9575cd"), QColor("#7e57c2"), QColor("#673ab7"),
- QColor("#5e35b1"), QColor("#512da8"), QColor("#4527a0"), QColor("#311b92"),
- QColor("#b388ff"), QColor("#7c4dff"), QColor("#651fff"), QColor("#6200ea"),
- QColor("#e8eaf6"), QColor("#c5cae9"), QColor("#9fa8da"), QColor("#7986cb"),
- QColor("#5c6bc0"), QColor("#3f51b5"), QColor("#3949ab"), QColor("#303f9f"),
- QColor("#283593"), QColor("#1a237e"), QColor("#8c9eff"), QColor("#536dfe"),
- QColor("#3d5afe"), QColor("#304ffe"), QColor("#e3f2fd"), QColor("#bbdefb"),
- QColor("#90caf9"), QColor("#64b5f6"), QColor("#42a5f5"), QColor("#2196f3"),
- QColor("#1e88e5"), QColor("#1976d2"), QColor("#1565c0"), QColor("#0d47a1"),
- QColor("#82b1ff"), QColor("#448aff"), QColor("#2979ff"), QColor("#2962ff"),
- QColor("#e1f5fe"), QColor("#b3e5fc"), QColor("#81d4fa"), QColor("#4fc3f7"),
- QColor("#29b6f6"), QColor("#03a9f4"), QColor("#039be5"), QColor("#0288d1"),
- QColor("#0277bd"), QColor("#01579b"), QColor("#80d8ff"), QColor("#40c4ff"),
- QColor("#00b0ff"), QColor("#0091ea"), QColor("#e0f7fa"), QColor("#b2ebf2"),
- QColor("#80deea"), QColor("#4dd0e1"), QColor("#26c6da"), QColor("#00bcd4"),
- QColor("#00acc1"), QColor("#0097a7"), QColor("#00838f"), QColor("#006064"),
- QColor("#84ffff"), QColor("#18ffff"), QColor("#00e5ff"), QColor("#00b8d4"),
- QColor("#e0f2f1"), QColor("#b2dfdb"), QColor("#80cbc4"), QColor("#4db6ac"),
- QColor("#26a69a"), QColor("#009688"), QColor("#00897b"), QColor("#00796b"),
- QColor("#00695c"), QColor("#004d40"), QColor("#a7ffeb"), QColor("#64ffda"),
- QColor("#1de9b6"), QColor("#00bfa5"), QColor("#e8f5e9"), QColor("#c8e6c9"),
- QColor("#a5d6a7"), QColor("#81c784"), QColor("#66bb6a"), QColor("#4caf50"),
- QColor("#43a047"), QColor("#388e3c"), QColor("#2e7d32"), QColor("#1b5e20"),
- QColor("#b9f6ca"), QColor("#69f0ae"), QColor("#00e676"), QColor("#00c853"),
- QColor("#f1f8e9"), QColor("#dcedc8"), QColor("#c5e1a5"), QColor("#aed581"),
- QColor("#9ccc65"), QColor("#8bc34a"), QColor("#7cb342"), QColor("#689f38"),
- QColor("#558b2f"), QColor("#33691e"), QColor("#ccff90"), QColor("#b2ff59"),
- QColor("#76ff03"), QColor("#64dd17"), QColor("#f9fbe7"), QColor("#f0f4c3"),
- QColor("#e6ee9c"), QColor("#dce775"), QColor("#d4e157"), QColor("#cddc39"),
- QColor("#c0ca33"), QColor("#afb42b"), QColor("#9e9d24"), QColor("#827717"),
- QColor("#f4ff81"), QColor("#eeff41"), QColor("#c6ff00"), QColor("#aeea00"),
- QColor("#fffde7"), QColor("#fff9c4"), QColor("#fff59d"), QColor("#fff176"),
- QColor("#ffee58"), QColor("#ffeb3b"), QColor("#fdd835"), QColor("#fbc02d"),
- QColor("#f9a825"), QColor("#f57f17"), QColor("#ffff8d"), QColor("#ffff00"),
- QColor("#ffea00"), QColor("#ffd600"), QColor("#fff8e1"), QColor("#ffecb3"),
- QColor("#ffe082"), QColor("#ffd54f"), QColor("#ffca28"), QColor("#ffc107"),
- QColor("#ffb300"), QColor("#ffa000"), QColor("#ff8f00"), QColor("#ff6f00"),
- QColor("#ffe57f"), QColor("#ffd740"), QColor("#ffc400"), QColor("#ffab00"),
- QColor("#fff3e0"), QColor("#ffe0b2"), QColor("#ffcc80"), QColor("#ffb74d"),
- QColor("#ffa726"), QColor("#ff9800"), QColor("#fb8c00"), QColor("#f57c00"),
- QColor("#ef6c00"), QColor("#e65100"), QColor("#ffd180"), QColor("#ffab40"),
- QColor("#ff9100"), QColor("#ff6d00"), QColor("#fbe9e7"), QColor("#ffccbc"),
- QColor("#ffab91"), QColor("#ff8a65"), QColor("#ff7043"), QColor("#ff5722"),
- QColor("#f4511e"), QColor("#e64a19"), QColor("#d84315"), QColor("#bf360c"),
- QColor("#ff9e80"), QColor("#ff6e40"), QColor("#ff3d00"), QColor("#dd2c00"),
- QColor("#efebe9"), QColor("#d7ccc8"), QColor("#bcaaa4"), QColor("#a1887f"),
- QColor("#8d6e63"), QColor("#795548"), QColor("#6d4c41"), QColor("#5d4037"),
- QColor("#4e342e"), QColor("#3e2723"), QColor("#eceff1"), QColor("#cfd8dc"),
- QColor("#b0bec5"), QColor("#90a4ae"), QColor("#78909c"), QColor("#607d8b"),
- QColor("#546e7a"), QColor("#455a64"), QColor("#37474f"), QColor("#263238"),
- QColor("#fafafa"), QColor("#f5f5f5"), QColor("#eeeeee"), QColor("#e0e0e0"),
- QColor("#bdbdbd"), QColor("#9e9e9e"), QColor("#757575"), QColor("#616161"),
- QColor("#424242"), QColor("#212121"), QColor("#000000"), QColor("#ffffff"),
- d->rgba(0, 0, 0, 0),
- d->rgba(0, 0, 0, 1),
- d->rgba(0, 0, 0, 0.87),
- d->rgba(0, 0, 0, 0.54),
- d->rgba(0, 0, 0, 0.26),
- d->rgba(0, 0, 0, 0.12),
- d->rgba(255, 255, 255, 1),
- d->rgba(255, 255, 255, 0.87),
- d->rgba(255, 255, 255, 0.54)
- };
-
- d->colors.insert(key, palette[color]);
-}
-
-QIcon QtMaterialTheme::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/qtmaterialtheme.h
deleted file mode 100644
index fe4a11c82..000000000
--- a/components/lib/qtmaterialtheme.h
+++ /dev/null
@@ -1,344 +0,0 @@
-#ifndef QTMATERIALTHEME_H
-#define QTMATERIALTHEME_H
-
-#include
-#include
-#include
-#include
-
-namespace Material
-{
- enum ButtonPreset {
- FlatPreset,
- CheckablePreset
- };
-
- enum RippleStyle {
- CenteredRipple,
- PositionedRipple,
- NoRipple
- };
-
- enum OverlayStyle {
- NoOverlay,
- TintedOverlay,
- GrayOverlay
- };
-
- enum Role {
- Default,
- Primary,
- Secondary
- };
-
- enum ButtonIconPlacement {
- LeftIcon,
- RightIcon
- };
-
- enum ProgressType {
- DeterminateProgress,
- IndeterminateProgress
- };
-
- enum AvatarType {
- ImageAvatar,
- IconAvatar,
- LetterAvatar
- };
-
- enum Color {
- red50,
- red100,
- red200,
- red300,
- red400,
- red500,
- red600,
- red700,
- red800,
- red900,
- redA100,
- redA200,
- redA400,
- redA700,
- pink50,
- pink100,
- pink200,
- pink300,
- pink400,
- pink500,
- pink600,
- pink700,
- pink800,
- pink900,
- pinkA100,
- pinkA200,
- pinkA400,
- pinkA700,
- purple50,
- purple100,
- purple200,
- purple300,
- purple400,
- purple500,
- purple600,
- purple700,
- purple800,
- purple900,
- purpleA100,
- purpleA200,
- purpleA400,
- purpleA700,
- deepPurple50,
- deepPurple100,
- deepPurple200,
- deepPurple300,
- deepPurple400,
- deepPurple500,
- deepPurple600,
- deepPurple700,
- deepPurple800,
- deepPurple900,
- deepPurpleA100,
- deepPurpleA200,
- deepPurpleA400,
- deepPurpleA700,
- indigo50,
- indigo100,
- indigo200,
- indigo300,
- indigo400,
- indigo500,
- indigo600,
- indigo700,
- indigo800,
- indigo900,
- indigoA100,
- indigoA200,
- indigoA400,
- indigoA700,
- blue50,
- blue100,
- blue200,
- blue300,
- blue400,
- blue500,
- blue600,
- blue700,
- blue800,
- blue900,
- blueA100,
- blueA200,
- blueA400,
- blueA700,
- lightBlue50,
- lightBlue100,
- lightBlue200,
- lightBlue300,
- lightBlue400,
- lightBlue500,
- lightBlue600,
- lightBlue700,
- lightBlue800,
- lightBlue900,
- lightBlueA100,
- lightBlueA200,
- lightBlueA400,
- lightBlueA700,
- cyan50,
- cyan100,
- cyan200,
- cyan300,
- cyan400,
- cyan500,
- cyan600,
- cyan700,
- cyan800,
- cyan900,
- cyanA100,
- cyanA200,
- cyanA400,
- cyanA700,
- teal50,
- teal100,
- teal200,
- teal300,
- teal400,
- teal500,
- teal600,
- teal700,
- teal800,
- teal900,
- tealA100,
- tealA200,
- tealA400,
- tealA700,
- green50,
- green100,
- green200,
- green300,
- green400,
- green500,
- green600,
- green700,
- green800,
- green900,
- greenA100,
- greenA200,
- greenA400,
- greenA700,
- lightGreen50,
- lightGreen100,
- lightGreen200,
- lightGreen300,
- lightGreen400,
- lightGreen500,
- lightGreen600,
- lightGreen700,
- lightGreen800,
- lightGreen900,
- lightGreenA100,
- lightGreenA200,
- lightGreenA400,
- lightGreenA700,
- lime50,
- lime100,
- lime200,
- lime300,
- lime400,
- lime500,
- lime600,
- lime700,
- lime800,
- lime900,
- limeA100,
- limeA200,
- limeA400,
- limeA700,
- yellow50,
- yellow100,
- yellow200,
- yellow300,
- yellow400,
- yellow500,
- yellow600,
- yellow700,
- yellow800,
- yellow900,
- yellowA100,
- yellowA200,
- yellowA400,
- yellowA700,
- amber50,
- amber100,
- amber200,
- amber300,
- amber400,
- amber500,
- amber600,
- amber700,
- amber800,
- amber900,
- amberA100,
- amberA200,
- amberA400,
- amberA700,
- orange50,
- orange100,
- orange200,
- orange300,
- orange400,
- orange500,
- orange600,
- orange700,
- orange800,
- orange900,
- orangeA100,
- orangeA200,
- orangeA400,
- orangeA700,
- deepOrange50,
- deepOrange100,
- deepOrange200,
- deepOrange300,
- deepOrange400,
- deepOrange500,
- deepOrange600,
- deepOrange700,
- deepOrange800,
- deepOrange900,
- deepOrangeA100,
- deepOrangeA200,
- deepOrangeA400,
- deepOrangeA700,
- brown50,
- brown100,
- brown200,
- brown300,
- brown400,
- brown500,
- brown600,
- brown700,
- brown800,
- brown900,
- blueGrey50,
- blueGrey100,
- blueGrey200,
- blueGrey300,
- blueGrey400,
- blueGrey500,
- blueGrey600,
- blueGrey700,
- blueGrey800,
- blueGrey900,
- grey50,
- grey100,
- grey200,
- grey300,
- grey400,
- grey500,
- grey600,
- grey700,
- grey800,
- grey900,
- black,
- white,
- transparent,
- fullBlack,
- darkBlack,
- lightBlack,
- minBlack,
- faintBlack,
- fullWhite,
- darkWhite,
- lightWhite
- };
-}
-
-class QtMaterialThemePrivate;
-
-class QtMaterialTheme : public QObject
-{
- Q_OBJECT
-
-public:
- explicit QtMaterialTheme(QObject *parent = 0);
- ~QtMaterialTheme();
-
- QColor getColor(const QString &key) const;
-
- void setColor(const QString &key, const QColor &color);
- void setColor(const QString &key, Material::Color color);
-
- static QIcon icon(QString category, QString icon);
-
-protected:
- const QScopedPointer d_ptr;
-
-private:
- Q_DISABLE_COPY(QtMaterialTheme)
- Q_DECLARE_PRIVATE(QtMaterialTheme)
-};
-
-#endif // QTMATERIALTHEME_H
diff --git a/components/lib/qtmaterialcheckable.cpp b/components/materiallib/qtmaterialcheckable.cpp
similarity index 81%
rename from components/lib/qtmaterialcheckable.cpp
rename to components/materiallib/qtmaterialcheckable.cpp
index ee4e0bd88..c50230b80 100644
--- a/components/lib/qtmaterialcheckable.cpp
+++ b/components/materiallib/qtmaterialcheckable.cpp
@@ -1,20 +1,22 @@
-#include "lib/qtmaterialcheckable.h"
-#include "lib/qtmaterialcheckable_p.h"
-#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+
+#include "qtmaterialcheckable_p.h"
+
#include
#include
-#include "lib/qtmaterialrippleoverlay.h"
-#include "lib/qtmaterialripple.h"
-#include "lib/qtmaterialstyle.h"
-#include "lib/qtmaterialcheckable_internal.h"
+#include
+#include
+#include
+#include
+#include
/*!
- * \class QtMaterialCheckablePrivate
- * \internal
+ * @class QtMaterialCheckablePrivate
+ * @internal
*/
QtMaterialCheckablePrivate::QtMaterialCheckablePrivate(QtMaterialCheckable *q)
@@ -22,26 +24,25 @@ QtMaterialCheckablePrivate::QtMaterialCheckablePrivate(QtMaterialCheckable *q)
{
}
-QtMaterialCheckablePrivate::~QtMaterialCheckablePrivate()
-{
-}
+QtMaterialCheckablePrivate::~QtMaterialCheckablePrivate() {}
void QtMaterialCheckablePrivate::init()
{
Q_Q(QtMaterialCheckable);
- 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);
- stateMachine = new QStateMachine(q);
- uncheckedState = new QState;
- checkedState = new QState;
+ 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);
+ stateMachine = new QStateMachine(q);
+ uncheckedState = new QState;
+ checkedState = new QState;
disabledUncheckedState = new QState;
- disabledCheckedState = new QState;
- uncheckedTransition = new QSignalTransition(q, SIGNAL(toggled(bool)));
- checkedTransition = new QSignalTransition(q, SIGNAL(toggled(bool)));
- labelPosition = QtMaterialCheckable::LabelPositionRight;
- useThemeColors = true;
+ disabledCheckedState = new QState;
+ uncheckedTransition = new QSignalTransition(q, SIGNAL(toggled(bool)));
+ checkedTransition = new QSignalTransition(q, SIGNAL(toggled(bool)));
+ labelPosition = QtMaterialCheckable::LabelPositionRight;
+ useThemeColors = true;
rippleOverlay->setParent(q->parentWidget());
rippleOverlay->installEventFilter(q);
@@ -122,19 +123,17 @@ void QtMaterialCheckablePrivate::init()
}
/*!
- * \class QtMaterialCheckable
+ * @class QtMaterialCheckable
*/
QtMaterialCheckable::QtMaterialCheckable(QWidget *parent)
- : QAbstractButton(parent),
- d_ptr(new QtMaterialCheckablePrivate(this))
+ : QAbstractButton(parent)
+ , d_ptr(new QtMaterialCheckablePrivate(this))
{
d_func()->init();
}
-QtMaterialCheckable::~QtMaterialCheckable()
-{
-}
+QtMaterialCheckable::~QtMaterialCheckable() {}
void QtMaterialCheckable::setLabelPosition(LabelPosition placement)
{
@@ -285,57 +284,55 @@ QIcon QtMaterialCheckable::uncheckedIcon() const
}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialCheckable::sizeHint() const
{
if (text().isEmpty()) {
return QSize(40, 40);
}
- return QSize(fontMetrics().size(Qt::TextShowMnemonic, text()).width()+52, 40);
+ return QSize(fontMetrics().size(Qt::TextShowMnemonic, text()).width() + 52, 40);
}
QtMaterialCheckable::QtMaterialCheckable(QtMaterialCheckablePrivate &d, QWidget *parent)
- : QAbstractButton(parent),
- d_ptr(&d)
+ : QAbstractButton(parent)
+ , d_ptr(&d)
{
d_func()->init();
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialCheckable::event(QEvent *event)
{
Q_D(QtMaterialCheckable);
- switch (event->type())
- {
- case QEvent::Resize:
- case QEvent::Move:
- d->checkedIcon->setGeometry(rect());
- d->uncheckedIcon->setGeometry(rect());
- d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8));
- break;
- case QEvent::ParentChange:
- QWidget *widget;
- if ((widget = parentWidget())) {
- d->rippleOverlay->setParent(widget);
- }
- break;
- default:
- break;
+ switch (event->type()) {
+ case QEvent::Resize:
+ case QEvent::Move:
+ d->checkedIcon->setGeometry(rect());
+ d->uncheckedIcon->setGeometry(rect());
+ d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8));
+ break;
+ case QEvent::ParentChange:
+ QWidget *widget;
+ if ((widget = parentWidget())) {
+ d->rippleOverlay->setParent(widget);
+ }
+ break;
+ default:
+ break;
}
return QAbstractButton::event(event);
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialCheckable::eventFilter(QObject *obj, QEvent *event)
{
- if (QEvent::Resize == event->type())
- {
+ if (QEvent::Resize == event->type()) {
Q_D(QtMaterialCheckable);
d->rippleOverlay->setGeometry(geometry().adjusted(-8, -8, 8, 8));
@@ -344,7 +341,7 @@ bool QtMaterialCheckable::eventFilter(QObject *obj, QEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialCheckable::mousePressEvent(QMouseEvent *event)
{
@@ -358,9 +355,9 @@ void QtMaterialCheckable::mousePressEvent(QMouseEvent *event)
QtMaterialRipple *ripple;
if (QtMaterialCheckable::LabelPositionLeft == d->labelPosition) {
- ripple = new QtMaterialRipple(QPoint(width()-14, 28));
+ ripple = new QtMaterialRipple(QPoint(width() - 14, 28));
} else {
- ripple = new QtMaterialRipple(QPoint(28, 28));
+ ripple = new QtMaterialRipple(QPoint(28, 28));
}
ripple->setRadiusEndValue(22);
ripple->setColor(isChecked() ? checkedColor() : uncheckedColor());
@@ -373,7 +370,7 @@ void QtMaterialCheckable::mousePressEvent(QMouseEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialCheckable::paintEvent(QPaintEvent *event)
{
diff --git a/components/lib/qtmaterialcheckable_internal.cpp b/components/materiallib/qtmaterialcheckable_internal.cpp
similarity index 66%
rename from components/lib/qtmaterialcheckable_internal.cpp
rename to components/materiallib/qtmaterialcheckable_internal.cpp
index 4a7eb9a72..a36f6ad18 100644
--- a/components/lib/qtmaterialcheckable_internal.cpp
+++ b/components/materiallib/qtmaterialcheckable_internal.cpp
@@ -1,30 +1,29 @@
-#include "lib/qtmaterialcheckable_internal.h"
-#include
+#include "materiallib/qtmaterialcheckable_internal.h"
+#include
+
#include
+#include
#include
-#include "lib/qtmaterialcheckable.h"
/*!
- * \class QtMaterialCheckableIcon
- * \internal
+ * @class QtMaterialCheckableIcon
+ * @internal
*/
QtMaterialCheckableIcon::QtMaterialCheckableIcon(const QIcon &icon, QtMaterialCheckable *parent)
- : QWidget(parent),
- m_checkable(parent),
- m_color(Qt::black),
- m_icon(icon),
- m_iconSize(24),
- m_opacity(1.0)
+ : QWidget(parent)
+ , m_checkable(parent)
+ , m_color(Qt::black)
+ , m_icon(icon)
+ , m_iconSize(24)
+ , m_opacity(1.0)
{
Q_ASSERT(parent);
setAttribute(Qt::WA_TransparentForMouseEvents);
}
-QtMaterialCheckableIcon::~QtMaterialCheckableIcon()
-{
-}
+QtMaterialCheckableIcon::~QtMaterialCheckableIcon() {}
QSize QtMaterialCheckableIcon::sizeHint() const
{
@@ -41,14 +40,13 @@ void QtMaterialCheckableIcon::paintEvent(QPaintEvent *event)
QPixmap pixmap = icon().pixmap(24, 24);
- if (!pixmap.isNull())
- {
- const qreal p = static_cast((height())-m_iconSize)/2;
- const qreal z = m_iconSize/24;
+ if (!pixmap.isNull()) {
+ const qreal p = static_cast((height()) - m_iconSize) / 2;
+ const qreal z = m_iconSize / 24;
QTransform t;
if (QtMaterialCheckable::LabelPositionLeft == m_checkable->labelPosition()) {
- t.translate(p+width()-42, p);
+ t.translate(p + width() - 42, p);
} else {
t.translate(p, p);
}
diff --git a/components/lib/qtmaterialcheckable_internal.h b/components/materiallib/qtmaterialcheckable_internal.h
similarity index 89%
rename from components/lib/qtmaterialcheckable_internal.h
rename to components/materiallib/qtmaterialcheckable_internal.h
index 3fb3d947d..be107f532 100644
--- a/components/lib/qtmaterialcheckable_internal.h
+++ b/components/materiallib/qtmaterialcheckable_internal.h
@@ -1,9 +1,9 @@
#ifndef QTMATERIALCHECKABLE_INTERNAL_H
#define QTMATERIALCHECKABLE_INTERNAL_H
-#include
#include
#include
+#include
class QtMaterialCheckable;
@@ -40,10 +40,10 @@ class QtMaterialCheckableIcon : public QWidget
Q_DISABLE_COPY(QtMaterialCheckableIcon)
QtMaterialCheckable *const m_checkable;
- QColor m_color;
- QIcon m_icon;
- qreal m_iconSize;
- qreal m_opacity;
+ QColor m_color;
+ QIcon m_icon;
+ qreal m_iconSize;
+ qreal m_opacity;
};
inline void QtMaterialCheckableIcon::setIcon(const QIcon &icon)
@@ -90,4 +90,4 @@ inline qreal QtMaterialCheckableIcon::opacity() const
return m_opacity;
}
-#endif // QTMATERIALCHECKABLE_INTERNAL_H
+#endif // QTMATERIALCHECKABLE_INTERNAL_H
diff --git a/components/materiallib/qtmaterialcheckable_p.h b/components/materiallib/qtmaterialcheckable_p.h
new file mode 100644
index 000000000..50fba2cc6
--- /dev/null
+++ b/components/materiallib/qtmaterialcheckable_p.h
@@ -0,0 +1,43 @@
+#ifndef QTMATERIALCHECKABLE_P_H
+#define QTMATERIALCHECKABLE_P_H
+
+#include
+#include
+
+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/materiallib/qtmaterialoverlaywidget.cpp b/components/materiallib/qtmaterialoverlaywidget.cpp
new file mode 100644
index 000000000..9ef3647e8
--- /dev/null
+++ b/components/materiallib/qtmaterialoverlaywidget.cpp
@@ -0,0 +1,66 @@
+#include
+#include
+
+/*!
+ * @class QtMaterialOverlayWidget
+ * @internal
+ */
+
+QtMaterialOverlayWidget::QtMaterialOverlayWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ if (parent) {
+ parent->installEventFilter(this);
+ }
+}
+
+QtMaterialOverlayWidget::~QtMaterialOverlayWidget() {}
+
+/*!
+ * @reimp
+ */
+bool QtMaterialOverlayWidget::event(QEvent *event)
+{
+ if (!parent()) {
+ return QWidget::event(event);
+ }
+ switch (event->type()) {
+ case QEvent::ParentChange: {
+ parent()->installEventFilter(this);
+ setGeometry(overlayGeometry());
+ break;
+ }
+ case QEvent::ParentAboutToChange: {
+ parent()->removeEventFilter(this);
+ break;
+ }
+ default:
+ break;
+ }
+ return QWidget::event(event);
+}
+
+/*!
+ * @reimp
+ */
+bool QtMaterialOverlayWidget::eventFilter(QObject *obj, QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::Move:
+ case QEvent::Resize:
+ setGeometry(overlayGeometry());
+ break;
+ default:
+ break;
+ }
+ return QWidget::eventFilter(obj, event);
+}
+
+QRect QtMaterialOverlayWidget::overlayGeometry() const
+{
+ QWidget *widget = parentWidget();
+ if (!widget) {
+ return QRect();
+ }
+ return widget->rect();
+}
diff --git a/components/lib/qtmaterialripple.cpp b/components/materiallib/qtmaterialripple.cpp
similarity index 63%
rename from components/lib/qtmaterialripple.cpp
rename to components/materiallib/qtmaterialripple.cpp
index 82125cbf8..cab5b2a9a 100644
--- a/components/lib/qtmaterialripple.cpp
+++ b/components/materiallib/qtmaterialripple.cpp
@@ -1,40 +1,36 @@
-#include "qtmaterialripple.h"
-#include "lib/qtmaterialrippleoverlay.h"
+#include
+#include
/*!
- * \class QtMaterialRipple
- * \internal
+ * @class QtMaterialRipple
+ * @internal
*/
QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, QObject *parent)
- : QParallelAnimationGroup(parent),
- m_overlay(0),
- m_radiusAnimation(animate("radius")),
- m_opacityAnimation(animate("opacity")),
- m_radius(0),
- m_opacity(0),
- m_center(center)
+ : QParallelAnimationGroup(parent)
+ , m_overlay(0)
+ , m_radiusAnimation(animate("radius"))
+ , m_opacityAnimation(animate("opacity"))
+ , m_radius(0)
+ , m_opacity(0)
+ , m_center(center)
{
init();
}
-QtMaterialRipple::QtMaterialRipple(const QPoint ¢er,
- QtMaterialRippleOverlay *overlay,
- QObject *parent)
- : QParallelAnimationGroup(parent),
- m_overlay(overlay),
- m_radiusAnimation(animate("radius")),
- m_opacityAnimation(animate("opacity")),
- m_radius(0),
- m_opacity(0),
- m_center(center)
+QtMaterialRipple::QtMaterialRipple(const QPoint ¢er, QtMaterialRippleOverlay *overlay, QObject *parent)
+ : QParallelAnimationGroup(parent)
+ , m_overlay(overlay)
+ , m_radiusAnimation(animate("radius"))
+ , m_opacityAnimation(animate("opacity"))
+ , m_radius(0)
+ , m_opacity(0)
+ , m_center(center)
{
init();
}
-QtMaterialRipple::~QtMaterialRipple()
-{
-}
+QtMaterialRipple::~QtMaterialRipple() {}
void QtMaterialRipple::setRadius(qreal radius)
{
@@ -89,9 +85,7 @@ void QtMaterialRipple::destroy()
/*!
* \internal
*/
-QPropertyAnimation *QtMaterialRipple::animate(const QByteArray &property,
- const QEasingCurve &easing,
- int duration)
+QPropertyAnimation *QtMaterialRipple::animate(const QByteArray &property, const QEasingCurve &easing, int duration)
{
QPropertyAnimation *animation = new QPropertyAnimation;
animation->setTargetObject(this);
diff --git a/components/lib/qtmaterialrippleoverlay.cpp b/components/materiallib/qtmaterialrippleoverlay.cpp
similarity index 78%
rename from components/lib/qtmaterialrippleoverlay.cpp
rename to components/materiallib/qtmaterialrippleoverlay.cpp
index 062d215bc..e887b37f8 100644
--- a/components/lib/qtmaterialrippleoverlay.cpp
+++ b/components/materiallib/qtmaterialrippleoverlay.cpp
@@ -1,23 +1,21 @@
-#include "lib/qtmaterialrippleoverlay.h"
+#include
+#include
#include
-#include "lib/qtmaterialripple.h"
/*!
- * \class QtMaterialRippleOverlay
- * \internal
+ * @class QtMaterialRippleOverlay
+ * @internal
*/
QtMaterialRippleOverlay::QtMaterialRippleOverlay(QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- m_useClip(false)
+ : QtMaterialOverlayWidget(parent)
+ , m_useClip(false)
{
setAttribute(Qt::WA_TransparentForMouseEvents);
setAttribute(Qt::WA_NoSystemBackground);
}
-QtMaterialRippleOverlay::~QtMaterialRippleOverlay()
-{
-}
+QtMaterialRippleOverlay::~QtMaterialRippleOverlay() {}
void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple)
{
@@ -25,8 +23,8 @@ void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple)
m_ripples.push_back(ripple);
ripple->start();
- connect(this, SIGNAL(destroyed(QObject*)), ripple, SLOT(stop()));
- connect(this, SIGNAL(destroyed(QObject*)), ripple, SLOT(deleteLater()));
+ connect(this, SIGNAL(destroyed(QObject *)), ripple, SLOT(stop()));
+ connect(this, SIGNAL(destroyed(QObject *)), ripple, SLOT(deleteLater()));
}
void QtMaterialRippleOverlay::addRipple(const QPoint &position, qreal radius)
@@ -45,7 +43,7 @@ void QtMaterialRippleOverlay::removeRipple(QtMaterialRipple *ripple)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialRippleOverlay::paintEvent(QPaintEvent *event)
{
diff --git a/components/lib/qtmaterialstatetransition.cpp b/components/materiallib/qtmaterialstatetransition.cpp
similarity index 79%
rename from components/lib/qtmaterialstatetransition.cpp
rename to components/materiallib/qtmaterialstatetransition.cpp
index 75f1faf06..99cf2467c 100644
--- a/components/lib/qtmaterialstatetransition.cpp
+++ b/components/materiallib/qtmaterialstatetransition.cpp
@@ -1,4 +1,4 @@
-#include "lib/qtmaterialstatetransition.h"
+#include
QtMaterialStateTransition::QtMaterialStateTransition(QtMaterialStateTransitionType type)
: m_type(type)
@@ -14,6 +14,4 @@ bool QtMaterialStateTransition::eventTest(QEvent *event)
return (m_type == transition->type);
}
-void QtMaterialStateTransition::onTransition(QEvent *)
-{
-}
+void QtMaterialStateTransition::onTransition(QEvent *) {}
diff --git a/components/lib/qtmaterialstyle.cpp b/components/materiallib/qtmaterialstyle.cpp
similarity index 73%
rename from components/lib/qtmaterialstyle.cpp
rename to components/materiallib/qtmaterialstyle.cpp
index 83bbab8ae..4461b9bf7 100644
--- a/components/lib/qtmaterialstyle.cpp
+++ b/components/materiallib/qtmaterialstyle.cpp
@@ -1,10 +1,10 @@
-#include "lib/qtmaterialstyle.h"
#include
-#include "lib/qtmaterialtheme.h"
+#include
+#include
/*!
- * \class QtMaterialStylePrivate
- * \internal
+ * @class QtMaterialStylePrivate
+ * @internal
*/
QtMaterialStylePrivate::QtMaterialStylePrivate(QtMaterialStyle *q)
@@ -12,9 +12,7 @@ QtMaterialStylePrivate::QtMaterialStylePrivate(QtMaterialStyle *q)
{
}
-QtMaterialStylePrivate::~QtMaterialStylePrivate()
-{
-}
+QtMaterialStylePrivate::~QtMaterialStylePrivate() {}
void QtMaterialStylePrivate::init()
{
@@ -28,8 +26,8 @@ void QtMaterialStylePrivate::init()
}
/*!
- * \class QtMaterialStyle
- * \internal
+ * @class QtMaterialStyle
+ * @internal
*/
void QtMaterialStyle::setTheme(QtMaterialTheme *theme)
@@ -50,8 +48,8 @@ QColor QtMaterialStyle::themeColor(const QString &key) const
}
QtMaterialStyle::QtMaterialStyle()
- : QCommonStyle(),
- d_ptr(new QtMaterialStylePrivate(this))
+ : QCommonStyle()
+ , d_ptr(new QtMaterialStylePrivate(this))
{
d_func()->init();
}
diff --git a/components/lib/qtmaterialstyle_p.h b/components/materiallib/qtmaterialstyle_p.h
similarity index 92%
rename from components/lib/qtmaterialstyle_p.h
rename to components/materiallib/qtmaterialstyle_p.h
index d59ca4198..e96e1cd5e 100644
--- a/components/lib/qtmaterialstyle_p.h
+++ b/components/materiallib/qtmaterialstyle_p.h
@@ -21,4 +21,4 @@ class QtMaterialStylePrivate
QtMaterialTheme *theme;
};
-#endif // QTMATERIALSTYLE_P_H
+#endif // QTMATERIALSTYLE_P_H
diff --git a/components/materiallib/qtmaterialtheme.cpp b/components/materiallib/qtmaterialtheme.cpp
new file mode 100644
index 000000000..980e41f4b
--- /dev/null
+++ b/components/materiallib/qtmaterialtheme.cpp
@@ -0,0 +1,150 @@
+#include
+
+#include "qtmaterialtheme_p.h"
+
+#include
+#include
+#include
+
+/*!material
+ * @class QtMaterialThemePrivate
+ * @internal
+ */
+
+QtMaterialThemePrivate::QtMaterialThemePrivate(QtMaterialTheme *q)
+ : q_ptr(q)
+{
+}
+
+QtMaterialThemePrivate::~QtMaterialThemePrivate() {}
+
+QColor QtMaterialThemePrivate::rgba(int r, int g, int b, qreal a) const
+{
+ QColor color(r, g, b);
+ color.setAlphaF(a);
+ return color;
+}
+
+/*!
+ * @class QtMaterialTheme
+ */
+
+QtMaterialTheme::QtMaterialTheme(QObject *parent)
+ : QObject(parent)
+ , d_ptr(new QtMaterialThemePrivate(this))
+{
+ setColor("primary1", Material::cyan500);
+ setColor("primary2", Material::cyan700);
+ setColor("primary3", Material::lightBlack);
+ setColor("accent1", Material::pinkA200);
+ setColor("accent2", Material::grey100);
+ setColor("accent3", Material::grey500);
+ setColor("text", Material::darkBlack);
+ setColor("alternateText", Material::white);
+ setColor("canvas", Material::white);
+ setColor("border", Material::grey300);
+ setColor("disabled", Material::minBlack);
+ setColor("disabled2", Material::faintBlack);
+ setColor("disabled3", Material::grey300);
+}
+
+QtMaterialTheme::~QtMaterialTheme() {}
+
+QColor QtMaterialTheme::getColor(const QString &key) const
+{
+ Q_D(const QtMaterialTheme);
+
+ if (!d->colors.contains(key)) {
+ qWarning() << "A theme color matching the key '" << key << "' could not be found.";
+ return QColor();
+ }
+ return d->colors.value(key);
+}
+
+void QtMaterialTheme::setColor(const QString &key, const QColor &color)
+{
+ Q_D(QtMaterialTheme);
+
+ d->colors.insert(key, color);
+}
+
+void QtMaterialTheme::setColor(const QString &key, Material::Color color)
+{
+ Q_D(QtMaterialTheme);
+
+ static const QColor palette[] = {
+ QColor("#ffebee"), QColor("#ffcdd2"), QColor("#ef9a9a"), QColor("#e57373"),
+ QColor("#ef5350"), QColor("#f44336"), QColor("#e53935"), QColor("#d32f2f"),
+ QColor("#c62828"), QColor("#b71c1c"), QColor("#ff8a80"), QColor("#ff5252"),
+ QColor("#ff1744"), QColor("#d50000"), QColor("#fce4ec"), QColor("#f8bbd0"),
+ QColor("#f48fb1"), QColor("#f06292"), QColor("#ec407a"), QColor("#e91e63"),
+ QColor("#d81b60"), QColor("#c2185b"), QColor("#ad1457"), QColor("#880e4f"),
+ QColor("#ff80ab"), QColor("#ff4081"), QColor("#f50057"), QColor("#c51162"),
+ QColor("#f3e5f5"), QColor("#e1bee7"), QColor("#ce93d8"), QColor("#ba68c8"),
+ QColor("#ab47bc"), QColor("#9c27b0"), QColor("#8e24aa"), QColor("#7b1fa2"),
+ QColor("#6a1b9a"), QColor("#4a148c"), QColor("#ea80fc"), QColor("#e040fb"),
+ QColor("#d500f9"), QColor("#aa00ff"), QColor("#ede7f6"), QColor("#d1c4e9"),
+ QColor("#b39ddb"), QColor("#9575cd"), QColor("#7e57c2"), QColor("#673ab7"),
+ QColor("#5e35b1"), QColor("#512da8"), QColor("#4527a0"), QColor("#311b92"),
+ QColor("#b388ff"), QColor("#7c4dff"), QColor("#651fff"), QColor("#6200ea"),
+ QColor("#e8eaf6"), QColor("#c5cae9"), QColor("#9fa8da"), QColor("#7986cb"),
+ QColor("#5c6bc0"), QColor("#3f51b5"), QColor("#3949ab"), QColor("#303f9f"),
+ QColor("#283593"), QColor("#1a237e"), QColor("#8c9eff"), QColor("#536dfe"),
+ QColor("#3d5afe"), QColor("#304ffe"), QColor("#e3f2fd"), QColor("#bbdefb"),
+ QColor("#90caf9"), QColor("#64b5f6"), QColor("#42a5f5"), QColor("#2196f3"),
+ QColor("#1e88e5"), QColor("#1976d2"), QColor("#1565c0"), QColor("#0d47a1"),
+ QColor("#82b1ff"), QColor("#448aff"), QColor("#2979ff"), QColor("#2962ff"),
+ QColor("#e1f5fe"), QColor("#b3e5fc"), QColor("#81d4fa"), QColor("#4fc3f7"),
+ QColor("#29b6f6"), QColor("#03a9f4"), QColor("#039be5"), QColor("#0288d1"),
+ QColor("#0277bd"), QColor("#01579b"), QColor("#80d8ff"), QColor("#40c4ff"),
+ QColor("#00b0ff"), QColor("#0091ea"), QColor("#e0f7fa"), QColor("#b2ebf2"),
+ QColor("#80deea"), QColor("#4dd0e1"), QColor("#26c6da"), QColor("#00bcd4"),
+ QColor("#00acc1"), QColor("#0097a7"), QColor("#00838f"), QColor("#006064"),
+ QColor("#84ffff"), QColor("#18ffff"), QColor("#00e5ff"), QColor("#00b8d4"),
+ QColor("#e0f2f1"), QColor("#b2dfdb"), QColor("#80cbc4"), QColor("#4db6ac"),
+ QColor("#26a69a"), QColor("#009688"), QColor("#00897b"), QColor("#00796b"),
+ QColor("#00695c"), QColor("#004d40"), QColor("#a7ffeb"), QColor("#64ffda"),
+ QColor("#1de9b6"), QColor("#00bfa5"), QColor("#e8f5e9"), QColor("#c8e6c9"),
+ QColor("#a5d6a7"), QColor("#81c784"), QColor("#66bb6a"), QColor("#4caf50"),
+ QColor("#43a047"), QColor("#388e3c"), QColor("#2e7d32"), QColor("#1b5e20"),
+ QColor("#b9f6ca"), QColor("#69f0ae"), QColor("#00e676"), QColor("#00c853"),
+ QColor("#f1f8e9"), QColor("#dcedc8"), QColor("#c5e1a5"), QColor("#aed581"),
+ QColor("#9ccc65"), QColor("#8bc34a"), QColor("#7cb342"), QColor("#689f38"),
+ QColor("#558b2f"), QColor("#33691e"), QColor("#ccff90"), QColor("#b2ff59"),
+ QColor("#76ff03"), QColor("#64dd17"), QColor("#f9fbe7"), QColor("#f0f4c3"),
+ QColor("#e6ee9c"), QColor("#dce775"), QColor("#d4e157"), QColor("#cddc39"),
+ QColor("#c0ca33"), QColor("#afb42b"), QColor("#9e9d24"), QColor("#827717"),
+ QColor("#f4ff81"), QColor("#eeff41"), QColor("#c6ff00"), QColor("#aeea00"),
+ QColor("#fffde7"), QColor("#fff9c4"), QColor("#fff59d"), QColor("#fff176"),
+ QColor("#ffee58"), QColor("#ffeb3b"), QColor("#fdd835"), QColor("#fbc02d"),
+ QColor("#f9a825"), QColor("#f57f17"), QColor("#ffff8d"), QColor("#ffff00"),
+ QColor("#ffea00"), QColor("#ffd600"), QColor("#fff8e1"), QColor("#ffecb3"),
+ QColor("#ffe082"), QColor("#ffd54f"), QColor("#ffca28"), QColor("#ffc107"),
+ QColor("#ffb300"), QColor("#ffa000"), QColor("#ff8f00"), QColor("#ff6f00"),
+ QColor("#ffe57f"), QColor("#ffd740"), QColor("#ffc400"), QColor("#ffab00"),
+ QColor("#fff3e0"), QColor("#ffe0b2"), QColor("#ffcc80"), QColor("#ffb74d"),
+ QColor("#ffa726"), QColor("#ff9800"), QColor("#fb8c00"), QColor("#f57c00"),
+ QColor("#ef6c00"), QColor("#e65100"), QColor("#ffd180"), QColor("#ffab40"),
+ QColor("#ff9100"), QColor("#ff6d00"), QColor("#fbe9e7"), QColor("#ffccbc"),
+ QColor("#ffab91"), QColor("#ff8a65"), QColor("#ff7043"), QColor("#ff5722"),
+ QColor("#f4511e"), QColor("#e64a19"), QColor("#d84315"), QColor("#bf360c"),
+ QColor("#ff9e80"), QColor("#ff6e40"), QColor("#ff3d00"), QColor("#dd2c00"),
+ QColor("#efebe9"), QColor("#d7ccc8"), QColor("#bcaaa4"), QColor("#a1887f"),
+ QColor("#8d6e63"), QColor("#795548"), QColor("#6d4c41"), QColor("#5d4037"),
+ QColor("#4e342e"), QColor("#3e2723"), QColor("#eceff1"), QColor("#cfd8dc"),
+ QColor("#b0bec5"), QColor("#90a4ae"), QColor("#78909c"), QColor("#607d8b"),
+ QColor("#546e7a"), QColor("#455a64"), QColor("#37474f"), QColor("#263238"),
+ QColor("#fafafa"), QColor("#f5f5f5"), QColor("#eeeeee"), QColor("#e0e0e0"),
+ QColor("#bdbdbd"), QColor("#9e9e9e"), QColor("#757575"), QColor("#616161"),
+ QColor("#424242"), QColor("#212121"), QColor("#000000"), QColor("#ffffff"),
+ d->rgba(0, 0, 0, 0), d->rgba(0, 0, 0, 1), d->rgba(0, 0, 0, 0.87), d->rgba(0, 0, 0, 0.54),
+ d->rgba(0, 0, 0, 0.26), d->rgba(0, 0, 0, 0.12), d->rgba(255, 255, 255, 1), d->rgba(255, 255, 255, 0.87),
+ d->rgba(255, 255, 255, 0.54)};
+
+ d->colors.insert(key, palette[color]);
+}
+
+QIcon QtMaterialTheme::icon(QString category, QString icon)
+{
+ return QIcon(":/icons/icons/" % category % "/svg/production/ic_" % icon % "_24px.svg");
+}
diff --git a/components/lib/qtmaterialtheme_p.h b/components/materiallib/qtmaterialtheme_p.h
similarity index 93%
rename from components/lib/qtmaterialtheme_p.h
rename to components/materiallib/qtmaterialtheme_p.h
index d0ef17839..85b619b7c 100644
--- a/components/lib/qtmaterialtheme_p.h
+++ b/components/materiallib/qtmaterialtheme_p.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALTHEME_P_H
#define QTMATERIALTHEME_P_H
-#include
#include
+#include
class QtMaterialTheme;
@@ -21,4 +21,4 @@ class QtMaterialThemePrivate
QHash colors;
};
-#endif // QTMATERIALTHEME_P_H
+#endif // QTMATERIALTHEME_P_H
diff --git a/components/qtmaterialappbar.cpp b/components/qtmaterialappbar.cpp
index 2170ca496..62e307baa 100644
--- a/components/qtmaterialappbar.cpp
+++ b/components/qtmaterialappbar.cpp
@@ -1,16 +1,16 @@
#include "qtmaterialappbar.h"
+#include "lib/qtmaterialstyle.h"
#include "qtmaterialappbar_p.h"
-#include
#include
-#include "lib/qtmaterialstyle.h"
+#include
/*!
- * \class QtMaterialAppBarPrivate
- * \internal
+ * @class QtMaterialAppBarPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q)
: q_ptr(q)
@@ -18,14 +18,12 @@ QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q)
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate()
-{
-}
+QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialAppBarPrivate::init()
{
@@ -45,19 +43,17 @@ void QtMaterialAppBarPrivate::init()
}
/*!
- * \class QtMaterialAppBar
+ * @class QtMaterialAppBar
*/
QtMaterialAppBar::QtMaterialAppBar(QWidget *parent)
- : QWidget(parent),
- d_ptr(new QtMaterialAppBarPrivate(this))
+ : QWidget(parent)
+ , d_ptr(new QtMaterialAppBarPrivate(this))
{
d_func()->init();
}
-QtMaterialAppBar::~QtMaterialAppBar()
-{
-}
+QtMaterialAppBar::~QtMaterialAppBar() {}
QSize QtMaterialAppBar::sizeHint() const
{
diff --git a/components/qtmaterialappbar_p.h b/components/qtmaterialappbar_p.h
index 0586556b4..c4895a6bf 100644
--- a/components/qtmaterialappbar_p.h
+++ b/components/qtmaterialappbar_p.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALAPPBAR_P_H
#define QTMATERIALAPPBAR_P_H
-#include
#include
+#include
class QtMaterialAppBar;
@@ -18,9 +18,9 @@ class QtMaterialAppBarPrivate
void init();
QtMaterialAppBar *const q_ptr;
- bool useThemeColors;
- QColor foregroundColor;
- QColor backgroundColor;
+ bool useThemeColors;
+ QColor foregroundColor;
+ QColor backgroundColor;
};
-#endif // QTMATERIALAPPBAR_P_H
+#endif // QTMATERIALAPPBAR_P_H
diff --git a/components/qtmaterialautocomplete.cpp b/components/qtmaterialautocomplete.cpp
index df006a68a..bf58f1392 100644
--- a/components/qtmaterialautocomplete.cpp
+++ b/components/qtmaterialautocomplete.cpp
@@ -1,46 +1,45 @@
#include "qtmaterialautocomplete.h"
+#include "qtmaterialautocomplete_internal.h"
#include "qtmaterialautocomplete_p.h"
-#include
-#include
+#include "qtmaterialflatbutton.h"
+#include
#include
-#include
#include
-#include
-#include "qtmaterialautocomplete_internal.h"
-#include "qtmaterialflatbutton.h"
+#include
+#include
+#include
/*!
- * \class QtMaterialAutoCompletePrivate
- * \internal
+ * @class QtMaterialAutoCompletePrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialAutoCompletePrivate::QtMaterialAutoCompletePrivate(QtMaterialAutoComplete *q)
: QtMaterialTextFieldPrivate(q)
+ , q_ptr(q)
{
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialAutoCompletePrivate::~QtMaterialAutoCompletePrivate()
-{
-}
+QtMaterialAutoCompletePrivate::~QtMaterialAutoCompletePrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialAutoCompletePrivate::init()
{
Q_Q(QtMaterialAutoComplete);
- menu = new QWidget;
- frame = new QWidget;
+ menu = new QWidget;
+ frame = new QWidget;
stateMachine = new QtMaterialAutoCompleteStateMachine(menu);
- menuLayout = new QVBoxLayout;
- maxWidth = 0;
+ menuLayout = new QVBoxLayout;
+ maxWidth = 0;
menu->setParent(q->parentWidget());
frame->setParent(q->parentWidget());
@@ -68,7 +67,7 @@ void QtMaterialAutoCompletePrivate::init()
}
/*!
- * \class QtMaterialAutoComplete
+ * @class QtMaterialAutoComplete
*/
QtMaterialAutoComplete::QtMaterialAutoComplete(QWidget *parent)
@@ -77,9 +76,7 @@ QtMaterialAutoComplete::QtMaterialAutoComplete(QWidget *parent)
d_func()->init();
}
-QtMaterialAutoComplete::~QtMaterialAutoComplete()
-{
-}
+QtMaterialAutoComplete::~QtMaterialAutoComplete() {}
void QtMaterialAutoComplete::setDataSource(const QStringList &data)
{
@@ -151,7 +148,7 @@ void QtMaterialAutoComplete::updateResults(QString text)
emit d->stateMachine->shouldOpen();
}
- d->menu->setFixedHeight(results.length()*50);
+ d->menu->setFixedHeight(results.length() * 50);
d->menu->setFixedWidth(qMax(d->maxWidth + 24, width()));
d->menu->update();
}
@@ -160,23 +157,22 @@ bool QtMaterialAutoComplete::QtMaterialAutoComplete::event(QEvent *event)
{
Q_D(QtMaterialAutoComplete);
- switch (event->type())
- {
- case QEvent::Move:
- case QEvent::Resize: {
- d->menu->move(pos() + QPoint(0, height() + 6));
- break;
- }
- case QEvent::ParentChange: {
- QWidget *widget = static_cast(parent());
- if (widget) {
- d->menu->setParent(widget);
- d->frame->setParent(widget);
+ switch (event->type()) {
+ case QEvent::Move:
+ case QEvent::Resize: {
+ d->menu->move(pos() + QPoint(0, height() + 6));
+ break;
}
- break;
- }
- default:
- break;
+ case QEvent::ParentChange: {
+ QWidget *widget = static_cast(parent());
+ if (widget) {
+ d->menu->setParent(widget);
+ d->frame->setParent(widget);
+ }
+ break;
+ }
+ default:
+ break;
}
return QtMaterialTextField::event(event);
}
@@ -185,57 +181,49 @@ bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event)
{
Q_D(QtMaterialAutoComplete);
- if (d->frame == watched)
- {
- switch (event->type())
- {
- case QEvent::Paint: {
- QPainter painter(d->frame);
- painter.fillRect(d->frame->rect(), Qt::white);
- break;
- }
- default:
- break;
- }
- }
- else if (d->menu == watched)
- {
- switch (event->type())
- {
- case QEvent::Resize:
- case QEvent::Move: {
- d->frame->setGeometry(d->menu->geometry());
- break;
- }
- case QEvent::Show: {
- d->frame->show();
- d->menu->raise();
- break;
- }
- case QEvent::Hide: {
- d->frame->hide();
- break;
- }
- default:
- break;
+ if (d->frame == watched) {
+ switch (event->type()) {
+ case QEvent::Paint: {
+ QPainter painter(d->frame);
+ painter.fillRect(d->frame->rect(), Qt::white);
+ break;
+ }
+ default:
+ break;
}
- }
- else
- {
- switch (event->type())
- {
- case QEvent::MouseButtonPress: {
- emit d->stateMachine->shouldFade();
- QtMaterialFlatButton *widget;
- if ((widget = static_cast(watched))) {
- QString text(widget->text());
- setText(text);
- emit itemSelected(text);
+ } else if (d->menu == watched) {
+ switch (event->type()) {
+ case QEvent::Resize:
+ case QEvent::Move: {
+ d->frame->setGeometry(d->menu->geometry());
+ break;
}
- break;
+ case QEvent::Show: {
+ d->frame->show();
+ d->menu->raise();
+ break;
+ }
+ case QEvent::Hide: {
+ d->frame->hide();
+ break;
+ }
+ default:
+ break;
}
- default:
- break;
+ } else {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress: {
+ emit d->stateMachine->shouldFade();
+ QtMaterialFlatButton *widget;
+ if ((widget = static_cast(watched))) {
+ QString text(widget->text());
+ setText(text);
+ emit itemSelected(text);
+ }
+ break;
+ }
+ default:
+ break;
}
}
return QtMaterialTextField::eventFilter(watched, event);
diff --git a/components/qtmaterialautocomplete_internal.cpp b/components/qtmaterialautocomplete_internal.cpp
index e01848d8c..c342b6540 100644
--- a/components/qtmaterialautocomplete_internal.cpp
+++ b/components/qtmaterialautocomplete_internal.cpp
@@ -1,23 +1,23 @@
#include "qtmaterialautocomplete_internal.h"
-#include
+#include
#include
+#include
#include
-#include
/*!
- * \class QtMaterialAutoCompleteStateMachine
- * \internal
+ * @class QtMaterialAutoCompleteStateMachine
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialAutoCompleteStateMachine::QtMaterialAutoCompleteStateMachine(QWidget *menu)
- : QStateMachine(menu),
- m_menu(menu),
- m_closedState(new QState),
- m_openState(new QState),
- m_closingState(new QState)
+ : QStateMachine(menu)
+ , m_menu(menu)
+ , m_closedState(new QState)
+ , m_openState(new QState)
+ , m_closingState(new QState)
{
Q_ASSERT(menu);
@@ -62,8 +62,6 @@ QtMaterialAutoCompleteStateMachine::QtMaterialAutoCompleteStateMachine(QWidget *
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialAutoCompleteStateMachine::~QtMaterialAutoCompleteStateMachine()
-{
-}
+QtMaterialAutoCompleteStateMachine::~QtMaterialAutoCompleteStateMachine() {}
diff --git a/components/qtmaterialautocomplete_internal.h b/components/qtmaterialautocomplete_internal.h
index 7e76bd520..382c6cd3c 100644
--- a/components/qtmaterialautocomplete_internal.h
+++ b/components/qtmaterialautocomplete_internal.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALAUTOCOMPLETESTATEMACHINE_H
#define QTMATERIALAUTOCOMPLETESTATEMACHINE_H
-#include
#include "qtmaterialautocomplete.h"
+#include
class QtMaterialAutoCompleteStateMachine : public QStateMachine
{
@@ -21,9 +21,9 @@ class QtMaterialAutoCompleteStateMachine : public QStateMachine
Q_DISABLE_COPY(QtMaterialAutoCompleteStateMachine)
QWidget *const m_menu;
- QState *const m_closedState;
- QState *const m_openState;
- QState *const m_closingState;
+ QState *const m_closedState;
+ QState *const m_openState;
+ QState *const m_closingState;
};
-#endif // QTMATERIALAUTOCOMPLETESTATEMACHINE_H
+#endif // QTMATERIALAUTOCOMPLETESTATEMACHINE_H
diff --git a/components/qtmaterialautocomplete_p.h b/components/qtmaterialautocomplete_p.h
index 4fd405be7..4e99d7c02 100644
--- a/components/qtmaterialautocomplete_p.h
+++ b/components/qtmaterialautocomplete_p.h
@@ -7,7 +7,7 @@ class QWidget;
class QVBoxLayout;
class QtMaterialAutoCompleteOverlay;
class QtMaterialAutoCompleteStateMachine;
-
+class QtMaterialAutoComplete;
class QtMaterialAutoCompletePrivate : public QtMaterialTextFieldPrivate
{
Q_DISABLE_COPY(QtMaterialAutoCompletePrivate)
@@ -19,12 +19,13 @@ class QtMaterialAutoCompletePrivate : public QtMaterialTextFieldPrivate
void init();
- QWidget *menu;
- QWidget *frame;
+ QtMaterialAutoComplete *const q_ptr;
+ QWidget *menu;
+ QWidget *frame;
QtMaterialAutoCompleteStateMachine *stateMachine;
- QVBoxLayout *menuLayout;
- QStringList dataSource;
- int maxWidth;
+ QVBoxLayout *menuLayout;
+ QStringList dataSource;
+ int maxWidth;
};
-#endif // QTMATERIALAUTOCOMPLETE_P_H
+#endif // QTMATERIALAUTOCOMPLETE_P_H
diff --git a/components/qtmaterialavatar.cpp b/components/qtmaterialavatar.cpp
index e769f8f56..399716aba 100644
--- a/components/qtmaterialavatar.cpp
+++ b/components/qtmaterialavatar.cpp
@@ -1,16 +1,16 @@
#include "qtmaterialavatar.h"
+#include "lib/qtmaterialstyle.h"
#include "qtmaterialavatar_p.h"
#include
#include
-#include "lib/qtmaterialstyle.h"
/*!
- * \class QtMaterialAvatarPrivate
- * \internal
+ * @class QtMaterialAvatarPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialAvatarPrivate::QtMaterialAvatarPrivate(QtMaterialAvatar *q)
: q_ptr(q)
@@ -18,46 +18,43 @@ QtMaterialAvatarPrivate::QtMaterialAvatarPrivate(QtMaterialAvatar *q)
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialAvatarPrivate::~QtMaterialAvatarPrivate()
-{
-}
+QtMaterialAvatarPrivate::~QtMaterialAvatarPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialAvatarPrivate::init()
{
Q_Q(QtMaterialAvatar);
- size = 40;
- type = Material::LetterAvatar;
+ size = 40;
+ type = Material::LetterAvatar;
useThemeColors = true;
QFont font(q->font());
font.setPointSizeF(16);
q->setFont(font);
- QSizePolicy policy(QSizePolicy::MinimumExpanding,
- QSizePolicy::MinimumExpanding);
+ QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
q->setSizePolicy(policy);
}
/*!
- * \class QtMaterialAvatar
+ * @class QtMaterialAvatar
*/
QtMaterialAvatar::QtMaterialAvatar(QWidget *parent)
- : QWidget(parent),
- d_ptr(new QtMaterialAvatarPrivate(this))
+ : QWidget(parent)
+ , d_ptr(new QtMaterialAvatarPrivate(this))
{
d_func()->init();
}
QtMaterialAvatar::QtMaterialAvatar(const QIcon &icon, QWidget *parent)
- : QWidget(parent),
- d_ptr(new QtMaterialAvatarPrivate(this))
+ : QWidget(parent)
+ , d_ptr(new QtMaterialAvatarPrivate(this))
{
d_func()->init();
@@ -65,8 +62,8 @@ QtMaterialAvatar::QtMaterialAvatar(const QIcon &icon, QWidget *parent)
}
QtMaterialAvatar::QtMaterialAvatar(const QChar &letter, QWidget *parent)
- : QWidget(parent),
- d_ptr(new QtMaterialAvatarPrivate(this))
+ : QWidget(parent)
+ , d_ptr(new QtMaterialAvatarPrivate(this))
{
d_func()->init();
@@ -74,17 +71,15 @@ QtMaterialAvatar::QtMaterialAvatar(const QChar &letter, QWidget *parent)
}
QtMaterialAvatar::QtMaterialAvatar(const QImage &image, QWidget *parent)
- : QWidget(parent),
- d_ptr(new QtMaterialAvatarPrivate(this))
+ : QWidget(parent)
+ , d_ptr(new QtMaterialAvatarPrivate(this))
{
d_func()->init();
setImage(image);
}
-QtMaterialAvatar::~QtMaterialAvatar()
-{
-}
+QtMaterialAvatar::~QtMaterialAvatar() {}
void QtMaterialAvatar::setUseThemeColors(bool value)
{
@@ -131,7 +126,7 @@ void QtMaterialAvatar::setBackgroundColor(const QColor &color)
Q_D(QtMaterialAvatar);
d->backgroundColor = color;
-
+
MATERIAL_DISABLE_THEME_COLORS
update();
}
@@ -148,13 +143,13 @@ QColor QtMaterialAvatar::backgroundColor() const
}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialAvatar::sizeHint() const
{
Q_D(const QtMaterialAvatar);
- return QSize(d->size+2, d->size+2);
+ return QSize(d->size + 2, d->size + 2);
}
void QtMaterialAvatar::setSize(int size)
@@ -164,13 +159,11 @@ void QtMaterialAvatar::setSize(int size)
d->size = size;
if (!d->image.isNull()) {
- d->pixmap = QPixmap::fromImage(d->image.scaled(d->size, d->size,
- Qt::IgnoreAspectRatio,
- Qt::SmoothTransformation));
+ d->pixmap = QPixmap::fromImage(d->image.scaled(d->size, d->size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
QFont f(font());
- f.setPointSizeF(size*16/40);
+ f.setPointSizeF(size * 16.0 / 40.0);
setFont(f);
update();
@@ -199,9 +192,7 @@ void QtMaterialAvatar::setImage(const QImage &image)
d->image = image;
d->type = Material::ImageAvatar;
- d->pixmap = QPixmap::fromImage(image.scaled(d->size, d->size,
- Qt::IgnoreAspectRatio,
- Qt::SmoothTransformation));
+ d->pixmap = QPixmap::fromImage(image.scaled(d->size, d->size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
update();
}
@@ -222,7 +213,7 @@ Material::AvatarType QtMaterialAvatar::type() const
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialAvatar::paintEvent(QPaintEvent *event)
{
@@ -234,61 +225,52 @@ void QtMaterialAvatar::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing);
QRect r = rect();
- const qreal hs = d->size/2;
+ const qreal hs = d->size / 2.0;
- if (!isEnabled())
- {
+ if (!isEnabled()) {
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(QtMaterialStyle::instance().themeColor("disabled"));
painter.setPen(Qt::NoPen);
painter.setBrush(brush);
- painter.drawEllipse(QRectF((width()-d->size)/2, (height()-d->size)/2,
- d->size, d->size));
+ painter.drawEllipse(QRectF((width() - d->size) / 2.0, (height() - d->size) / 2.0, d->size, d->size));
return;
}
- if (Material::ImageAvatar != d->type)
- {
+ if (Material::ImageAvatar != d->type) {
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(backgroundColor());
painter.setPen(Qt::NoPen);
painter.setBrush(brush);
- painter.drawEllipse(QRectF((width()-d->size)/2, (height()-d->size)/2,
- d->size, d->size));
+ painter.drawEllipse(QRectF((width() - d->size) / 2.0, (height() - d->size) / 2.0, d->size, d->size));
}
- switch (d->type)
- {
- case Material::ImageAvatar:
- {
- QPainterPath path;
- path.addEllipse(width()/2-hs, height()/2-hs, d->size, d->size);
- painter.setClipPath(path);
-
- painter.drawPixmap(QRect(width()/2-hs, height()/2-hs, d->size, d->size),
- d->pixmap);
- break;
- }
- case Material::IconAvatar:
- {
- QRect iconGeometry((width()-hs)/2, (height()-hs)/2, hs, hs);
- QPixmap pixmap = d->icon.pixmap(hs, hs);
- QPainter icon(&pixmap);
- icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
- icon.fillRect(pixmap.rect(), textColor());
- painter.drawPixmap(iconGeometry, pixmap);
- break;
- }
- case Material::LetterAvatar:
- {
- painter.setPen(textColor());
- painter.setBrush(Qt::NoBrush);
- painter.drawText(r, Qt::AlignCenter, QString(d->letter));
- break;
- }
- default:
- break;
+ switch (d->type) {
+ case Material::ImageAvatar: {
+ QPainterPath path;
+ path.addEllipse(width() / 2.0 - hs, height() / 2.0 - hs, d->size, d->size);
+ painter.setClipPath(path);
+
+ painter.drawPixmap(QRect(width() / 2.0 - hs, height() / 2.0 - hs, d->size, d->size), d->pixmap);
+ break;
+ }
+ case Material::IconAvatar: {
+ QRect iconGeometry((width() - hs) / 2, (height() - hs) / 2, hs, hs);
+ QPixmap pixmap = d->icon.pixmap(hs, hs);
+ QPainter icon(&pixmap);
+ icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
+ icon.fillRect(pixmap.rect(), textColor());
+ painter.drawPixmap(iconGeometry, pixmap);
+ break;
+ }
+ case Material::LetterAvatar: {
+ painter.setPen(textColor());
+ painter.setBrush(Qt::NoBrush);
+ painter.drawText(r, Qt::AlignCenter, QString(d->letter));
+ break;
+ }
+ default:
+ break;
}
}
diff --git a/components/qtmaterialavatar_p.h b/components/qtmaterialavatar_p.h
index 44b378e10..bc3ce671b 100644
--- a/components/qtmaterialavatar_p.h
+++ b/components/qtmaterialavatar_p.h
@@ -1,13 +1,13 @@
#ifndef QTMATERIALAVATAR_P_H
#define QTMATERIALAVATAR_P_H
-#include
+#include "lib/qtmaterialtheme.h"
#include
-#include
+#include
#include
+#include
#include
-#include
-#include "lib/qtmaterialtheme.h"
+#include
class QtMaterialAvatar;
@@ -23,15 +23,15 @@ class QtMaterialAvatarPrivate
void init();
QtMaterialAvatar *const q_ptr;
- int size;
- Material::AvatarType type;
- QChar letter;
- QImage image;
- QIcon icon;
- QPixmap pixmap;
- bool useThemeColors;
- QColor textColor;
- QColor backgroundColor;
+ int size;
+ Material::AvatarType type;
+ QChar letter;
+ QImage image;
+ QIcon icon;
+ QPixmap pixmap;
+ bool useThemeColors;
+ QColor textColor;
+ QColor backgroundColor;
};
-#endif // QTMATERIALAVATAR_P_H
+#endif // QTMATERIALAVATAR_P_H
diff --git a/components/qtmaterialbadge.cpp b/components/qtmaterialbadge.cpp
index b30aa95ba..75e590207 100644
--- a/components/qtmaterialbadge.cpp
+++ b/components/qtmaterialbadge.cpp
@@ -1,15 +1,15 @@
#include "qtmaterialbadge.h"
+#include "lib/qtmaterialstyle.h"
#include "qtmaterialbadge_p.h"
#include
-#include "lib/qtmaterialstyle.h"
/*!
- * \class QtMaterialBadgePrivate
- * \internal
+ * @class QtMaterialBadgePrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialBadgePrivate::QtMaterialBadgePrivate(QtMaterialBadge *q)
: q_ptr(q)
@@ -17,22 +17,20 @@ QtMaterialBadgePrivate::QtMaterialBadgePrivate(QtMaterialBadge *q)
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialBadgePrivate::~QtMaterialBadgePrivate()
-{
-}
+QtMaterialBadgePrivate::~QtMaterialBadgePrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialBadgePrivate::init()
{
Q_Q(QtMaterialBadge);
- x = 0;
- y = 0;
- padding = 10;
+ x = 0;
+ y = 0;
+ padding = 10;
useThemeColors = true;
q->setAttribute(Qt::WA_TransparentForMouseEvents);
@@ -50,15 +48,15 @@ void QtMaterialBadgePrivate::init()
*/
QtMaterialBadge::QtMaterialBadge(QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- d_ptr(new QtMaterialBadgePrivate(this))
+ : QtMaterialOverlayWidget(parent)
+ , d_ptr(new QtMaterialBadgePrivate(this))
{
d_func()->init();
}
QtMaterialBadge::QtMaterialBadge(const QIcon &icon, QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- d_ptr(new QtMaterialBadgePrivate(this))
+ : QtMaterialOverlayWidget(parent)
+ , d_ptr(new QtMaterialBadgePrivate(this))
{
d_func()->init();
@@ -66,17 +64,15 @@ QtMaterialBadge::QtMaterialBadge(const QIcon &icon, QWidget *parent)
}
QtMaterialBadge::QtMaterialBadge(const QString &text, QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- d_ptr(new QtMaterialBadgePrivate(this))
+ : QtMaterialOverlayWidget(parent)
+ , d_ptr(new QtMaterialBadgePrivate(this))
{
d_func()->init();
setText(text);
}
-QtMaterialBadge::~QtMaterialBadge()
-{
-}
+QtMaterialBadge::~QtMaterialBadge() {}
void QtMaterialBadge::setUseThemeColors(bool value)
{
@@ -196,7 +192,7 @@ qreal QtMaterialBadge::relativeYPosition() const
QSize QtMaterialBadge::sizeHint() const
{
const int s = getDiameter();
- return QSize(s+4, s+4);
+ return QSize(s + 4, s + 4);
}
void QtMaterialBadge::setIcon(const QIcon &icon)
@@ -252,25 +248,21 @@ void QtMaterialBadge::paintEvent(QPaintEvent *event)
QBrush brush;
brush.setStyle(Qt::SolidPattern);
- brush.setColor(isEnabled() ? backgroundColor()
- : QtMaterialStyle::instance().themeColor("disabled"));
+ brush.setColor(isEnabled() ? backgroundColor() : QtMaterialStyle::instance().themeColor("disabled"));
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
const int s = getDiameter();
QRectF r(0, 0, s, s);
- r.translate(QPointF((width()-s), (height()-s))/2);
+ r.translate(QPointF((width() - s), (height() - s)) / 2);
- if (d->icon.isNull())
- {
+ if (d->icon.isNull()) {
painter.drawEllipse(r);
painter.setPen(textColor());
painter.setBrush(Qt::NoBrush);
painter.drawText(r.translated(0, -0.5), Qt::AlignCenter, d->text);
- }
- else
- {
+ } else {
painter.drawEllipse(r);
QRectF q(0, 0, 16, 16);
q.moveCenter(r.center());
diff --git a/components/qtmaterialbadge_p.h b/components/qtmaterialbadge_p.h
index 19757e7bb..16b6b8d21 100644
--- a/components/qtmaterialbadge_p.h
+++ b/components/qtmaterialbadge_p.h
@@ -1,10 +1,10 @@
#ifndef QTMATERIALBADGE_P_H
#define QTMATERIALBADGE_P_H
-#include
-#include
-#include
#include
+#include
+#include
+#include
class QtMaterialBadge;
@@ -20,15 +20,15 @@ class QtMaterialBadgePrivate
void init();
QtMaterialBadge *const q_ptr;
- QString text;
- QColor textColor;
- QColor backgroundColor;
- QSize size;
- QIcon icon;
- qreal x;
- qreal y;
- int padding;
- bool useThemeColors;
+ QString text;
+ QColor textColor;
+ QColor backgroundColor;
+ QSize size;
+ QIcon icon;
+ qreal x;
+ qreal y;
+ int padding;
+ bool useThemeColors;
};
-#endif // QTMATERIALBADGE_P_H
+#endif // QTMATERIALBADGE_P_H
diff --git a/components/qtmaterialcheckbox.cpp b/components/qtmaterialcheckbox.cpp
index b693a90d9..aed12ef97 100644
--- a/components/qtmaterialcheckbox.cpp
+++ b/components/qtmaterialcheckbox.cpp
@@ -1,32 +1,31 @@
#include "qtmaterialcheckbox.h"
+#include "materiallib/qtmaterialcheckable_internal.h"
#include "qtmaterialcheckbox_p.h"
#include
#include
#include
-#include "lib/qtmaterialcheckable_internal.h"
/*!
- * \class QtMaterialCheckBoxPrivate
- * \internal
+ * @class QtMaterialCheckBoxPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialCheckBoxPrivate::QtMaterialCheckBoxPrivate(QtMaterialCheckBox *q)
: QtMaterialCheckablePrivate(q)
+ , q_ptr(q)
{
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialCheckBoxPrivate::~QtMaterialCheckBoxPrivate()
-{
-}
+QtMaterialCheckBoxPrivate::~QtMaterialCheckBoxPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialCheckBoxPrivate::init()
{
@@ -71,7 +70,7 @@ void QtMaterialCheckBoxPrivate::init()
}
/*!
- * \class QtMaterialCheckBox
+ * @class QtMaterialCheckBox
*/
QtMaterialCheckBox::QtMaterialCheckBox(QWidget *parent)
@@ -80,6 +79,4 @@ QtMaterialCheckBox::QtMaterialCheckBox(QWidget *parent)
d_func()->init();
}
-QtMaterialCheckBox::~QtMaterialCheckBox()
-{
-}
+QtMaterialCheckBox::~QtMaterialCheckBox() {}
diff --git a/components/qtmaterialcheckbox_p.h b/components/qtmaterialcheckbox_p.h
index daa62d796..40781c6e1 100644
--- a/components/qtmaterialcheckbox_p.h
+++ b/components/qtmaterialcheckbox_p.h
@@ -1,7 +1,7 @@
#ifndef QTMATERIALCHECKBOX_P_H
#define QTMATERIALCHECKBOX_P_H
-#include "lib/qtmaterialcheckable_p.h"
+#include "materiallib/qtmaterialcheckable_p.h"
class QtMaterialCheckBox;
@@ -14,7 +14,9 @@ class QtMaterialCheckBoxPrivate : public QtMaterialCheckablePrivate
QtMaterialCheckBoxPrivate(QtMaterialCheckBox *q);
~QtMaterialCheckBoxPrivate();
+ QtMaterialCheckBox *const q_ptr;
+
void init();
};
-#endif // QTMATERIALCHECKBOX_P_H
+#endif // QTMATERIALCHECKBOX_P_H
diff --git a/components/qtmaterialcircularprogress.cpp b/components/qtmaterialcircularprogress.cpp
index f38ef0167..5ea7ffa61 100644
--- a/components/qtmaterialcircularprogress.cpp
+++ b/components/qtmaterialcircularprogress.cpp
@@ -1,15 +1,15 @@
#include "qtmaterialcircularprogress.h"
+#include "lib/qtmaterialstyle.h"
+#include "qtmaterialcircularprogress_internal.h"
#include "qtmaterialcircularprogress_p.h"
-#include
-#include
#include
#include
-#include "qtmaterialcircularprogress_internal.h"
-#include "lib/qtmaterialstyle.h"
+#include
+#include
/*!
- * \class QtMaterialCircularProgressPrivate
- * \internal
+ * @class QtMaterialCircularProgressPrivate
+ * @internal
*/
QtMaterialCircularProgressPrivate::QtMaterialCircularProgressPrivate(QtMaterialCircularProgress *q)
@@ -17,22 +17,19 @@ QtMaterialCircularProgressPrivate::QtMaterialCircularProgressPrivate(QtMaterialC
{
}
-QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate()
-{
-}
+QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate() {}
void QtMaterialCircularProgressPrivate::init()
{
Q_Q(QtMaterialCircularProgress);
- delegate = new QtMaterialCircularProgressDelegate(q);
- progressType = Material::IndeterminateProgress;
- penWidth = 6.25;
- size = 64;
+ delegate = new QtMaterialCircularProgressDelegate(q);
+ progressType = Material::IndeterminateProgress;
+ penWidth = 6.25;
+ size = 64;
useThemeColors = true;
- q->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
- QSizePolicy::MinimumExpanding));
+ q->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
QParallelAnimationGroup *group = new QParallelAnimationGroup(q);
group->setLoopCount(-1);
@@ -78,19 +75,17 @@ void QtMaterialCircularProgressPrivate::init()
}
/*!
- * \class QtMaterialCircularProgress
+ * @class QtMaterialCircularProgress
*/
QtMaterialCircularProgress::QtMaterialCircularProgress(QWidget *parent)
- : QProgressBar(parent),
- d_ptr(new QtMaterialCircularProgressPrivate(this))
+ : QProgressBar(parent)
+ , d_ptr(new QtMaterialCircularProgressPrivate(this))
{
d_func()->init();
}
-QtMaterialCircularProgress::~QtMaterialCircularProgress()
-{
-}
+QtMaterialCircularProgress::~QtMaterialCircularProgress() {}
void QtMaterialCircularProgress::setProgressType(Material::ProgressType type)
{
@@ -180,18 +175,18 @@ QColor QtMaterialCircularProgress::color() const
}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialCircularProgress::sizeHint() const
{
Q_D(const QtMaterialCircularProgress);
- const qreal s = d->size+d->penWidth+8;
+ const qreal s = d->size + d->penWidth + 8;
return QSize(s, s);
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
{
@@ -202,21 +197,19 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- if (!isEnabled())
- {
+ if (!isEnabled()) {
QPen pen;
pen.setCapStyle(Qt::RoundCap);
pen.setWidthF(d->penWidth);
pen.setColor(QtMaterialStyle::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));
+ painter.drawLine(rect().center() - QPointF(20, 20), rect().center() + QPointF(20, 20));
+ painter.drawLine(rect().center() + QPointF(20, -20), rect().center() - QPointF(20, -20));
return;
}
- if (Material::IndeterminateProgress == d->progressType)
- {
- painter.translate(width()/2, height()/2);
+ if (Material::IndeterminateProgress == d->progressType) {
+ painter.translate(width() / 2.0, height() / 2.0);
painter.rotate(d->delegate->angle());
}
@@ -225,26 +218,23 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
pen.setWidthF(d->penWidth);
pen.setColor(color());
- if (Material::IndeterminateProgress == d->progressType)
- {
+ if (Material::IndeterminateProgress == d->progressType) {
QVector pattern;
- pattern << d->delegate->dashLength()*d->size/50 << 30*d->size/50;
+ pattern << d->delegate->dashLength() * d->size / 50 << 30.0 * d->size / 50;
- pen.setDashOffset(d->delegate->dashOffset()*d->size/50);
+ pen.setDashOffset(d->delegate->dashOffset() * d->size / 50);
pen.setDashPattern(pattern);
painter.setPen(pen);
- painter.drawEllipse(QPoint(0, 0), d->size/2, d->size/2);
- }
- else
- {
+ painter.drawEllipse(QPoint(0, 0), d->size / 2, d->size / 2);
+ } else {
painter.setPen(pen);
- const qreal x = (width()-d->size)/2;
- const qreal y = (height()-d->size)/2;
+ const qreal x = (width() - d->size) / 2.0;
+ const qreal y = (height() - d->size) / 2.0;
- const qreal a = 360*(value()-minimum())/(maximum()-minimum());
+ const qreal a = 360.0 * (value() - minimum()) / (maximum() - minimum());
QPainterPath path;
path.arcMoveTo(x, y, d->size, d->size, 0);
diff --git a/components/qtmaterialcircularprogress_internal.cpp b/components/qtmaterialcircularprogress_internal.cpp
index b11a25f1d..c40c1c4bb 100644
--- a/components/qtmaterialcircularprogress_internal.cpp
+++ b/components/qtmaterialcircularprogress_internal.cpp
@@ -1,20 +1,18 @@
#include "qtmaterialcircularprogress_internal.h"
/*!
- * \class QtMaterialCircularProgressDelegate
- * \internal
+ * @class QtMaterialCircularProgressDelegate
+ * @internal
*/
QtMaterialCircularProgressDelegate::QtMaterialCircularProgressDelegate(QtMaterialCircularProgress *parent)
- : QObject(parent),
- m_progress(parent),
- m_dashOffset(0),
- m_dashLength(89),
- m_angle(0)
+ : QObject(parent)
+ , m_progress(parent)
+ , m_dashOffset(0)
+ , m_dashLength(89)
+ , m_angle(0)
{
Q_ASSERT(parent);
}
-QtMaterialCircularProgressDelegate::~QtMaterialCircularProgressDelegate()
-{
-}
+QtMaterialCircularProgressDelegate::~QtMaterialCircularProgressDelegate() {}
diff --git a/components/qtmaterialcircularprogress_internal.h b/components/qtmaterialcircularprogress_internal.h
index a05bd6371..8178aa200 100644
--- a/components/qtmaterialcircularprogress_internal.h
+++ b/components/qtmaterialcircularprogress_internal.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALCIRCULARPROGRESS_INTERNAL_H
#define QTMATERIALCIRCULARPROGRESS_INTERNAL_H
-#include
#include "qtmaterialcircularprogress.h"
+#include
class QtMaterialCircularProgressDelegate : public QObject
{
@@ -29,9 +29,9 @@ class QtMaterialCircularProgressDelegate : public QObject
Q_DISABLE_COPY(QtMaterialCircularProgressDelegate)
QtMaterialCircularProgress *const m_progress;
- qreal m_dashOffset;
- qreal m_dashLength;
- int m_angle;
+ qreal m_dashOffset;
+ qreal m_dashLength;
+ int m_angle;
};
inline void QtMaterialCircularProgressDelegate::setDashOffset(qreal offset)
@@ -67,4 +67,4 @@ inline int QtMaterialCircularProgressDelegate::angle() const
return m_angle;
}
-#endif // QTMATERIALCIRCULARPROGRESS_INTERNAL_H
+#endif // QTMATERIALCIRCULARPROGRESS_INTERNAL_H
diff --git a/components/qtmaterialcircularprogress_p.h b/components/qtmaterialcircularprogress_p.h
index 451bc9c4b..70492eef5 100644
--- a/components/qtmaterialcircularprogress_p.h
+++ b/components/qtmaterialcircularprogress_p.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALCIRCULARPROGRESS_P_H
#define QTMATERIALCIRCULARPROGRESS_P_H
-#include
#include "lib/qtmaterialtheme.h"
+#include
class QtMaterialCircularProgress;
class QtMaterialCircularProgressDelegate;
@@ -18,13 +18,13 @@ class QtMaterialCircularProgressPrivate
void init();
- QtMaterialCircularProgress *const q_ptr;
+ QtMaterialCircularProgress *const q_ptr;
QtMaterialCircularProgressDelegate *delegate;
- Material::ProgressType progressType;
- QColor color;
- qreal penWidth;
- int size;
- bool useThemeColors;
+ Material::ProgressType progressType;
+ QColor color;
+ qreal penWidth;
+ int size;
+ bool useThemeColors;
};
-#endif // QTMATERIALCIRCULARPROGRESS_P_H
+#endif // QTMATERIALCIRCULARPROGRESS_P_H
diff --git a/components/qtmaterialdialog.cpp b/components/qtmaterialdialog.cpp
index 82afc898f..7243abf60 100644
--- a/components/qtmaterialdialog.cpp
+++ b/components/qtmaterialdialog.cpp
@@ -1,18 +1,18 @@
#include "qtmaterialdialog.h"
+#include "lib/qtmaterialstatetransition.h"
+#include "qtmaterialdialog_internal.h"
#include "qtmaterialdialog_p.h"
-#include
-#include
-#include
+#include
+#include
#include
+#include
#include
-#include
-#include
-#include "qtmaterialdialog_internal.h"
-#include "lib/qtmaterialstatetransition.h"
+#include
+#include
/*!
- * \class QtMaterialDialogPrivate
- * \internal
+ * @class QtMaterialDialogPrivate
+ * @internal
*/
QtMaterialDialogPrivate::QtMaterialDialogPrivate(QtMaterialDialog *q)
@@ -20,19 +20,20 @@ QtMaterialDialogPrivate::QtMaterialDialogPrivate(QtMaterialDialog *q)
{
}
-QtMaterialDialogPrivate::~QtMaterialDialogPrivate()
-{
-}
+QtMaterialDialogPrivate::~QtMaterialDialogPrivate() {}
+// main
void QtMaterialDialogPrivate::init()
{
+ // get public class
Q_Q(QtMaterialDialog);
dialogWindow = new QtMaterialDialogWindow(q);
- proxyStack = new QStackedLayout;
+ proxyStack = new QStackedLayout;
stateMachine = new QStateMachine(q);
- proxy = new QtMaterialDialogProxy(dialogWindow, proxyStack, q);
+ proxy = new QtMaterialDialogProxy(dialogWindow, proxyStack, q);
+ // qvbox
QVBoxLayout *layout = new QVBoxLayout;
q->setLayout(layout);
@@ -40,6 +41,7 @@ void QtMaterialDialogPrivate::init()
widget->setLayout(proxyStack);
widget->setMinimumWidth(400);
+ // shadoweffect
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
effect->setColor(QColor(0, 0, 0, 200));
effect->setBlurRadius(64);
@@ -94,29 +96,25 @@ void QtMaterialDialogPrivate::init()
animation->setEasingCurve(QEasingCurve::OutCirc);
stateMachine->addDefaultAnimation(animation);
- QObject::connect(visibleState, SIGNAL(propertiesAssigned()),
- proxy, SLOT(makeOpaque()));
- QObject::connect(hiddenState, SIGNAL(propertiesAssigned()),
- proxy, SLOT(makeTransparent()));
+ QObject::connect(visibleState, SIGNAL(propertiesAssigned()), proxy, SLOT(makeOpaque()));
+ QObject::connect(hiddenState, SIGNAL(propertiesAssigned()), proxy, SLOT(makeTransparent()));
stateMachine->start();
QCoreApplication::processEvents();
}
/*!
- * \class QtMaterialDialog
+ * @class QtMaterialDialog
*/
QtMaterialDialog::QtMaterialDialog(QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- d_ptr(new QtMaterialDialogPrivate(this))
+ : QtMaterialOverlayWidget(parent)
+ , d_ptr(new QtMaterialDialogPrivate(this))
{
d_func()->init();
}
-QtMaterialDialog::~QtMaterialDialog()
-{
-}
+QtMaterialDialog::~QtMaterialDialog() {}
QLayout *QtMaterialDialog::windowLayout() const
{
@@ -149,6 +147,7 @@ void QtMaterialDialog::hideDialog()
d->proxyStack->setCurrentIndex(1);
}
+// just paint shadow
void QtMaterialDialog::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
@@ -162,6 +161,6 @@ void QtMaterialDialog::paintEvent(QPaintEvent *event)
brush.setColor(Qt::black);
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
- painter.setOpacity(d->proxy->opacity()/2.4);
+ painter.setOpacity(d->proxy->opacity() / 2.4);
painter.drawRect(rect());
}
diff --git a/components/qtmaterialdialog_internal.cpp b/components/qtmaterialdialog_internal.cpp
index 6cac9b8c9..00733c8fb 100644
--- a/components/qtmaterialdialog_internal.cpp
+++ b/components/qtmaterialdialog_internal.cpp
@@ -1,32 +1,29 @@
#include "qtmaterialdialog_internal.h"
+#include "qtmaterialdialog.h"
+#include
#include
#include
-#include
#include
-#include "qtmaterialdialog.h"
/*!
- * \class QtMaterialDialogProxy
- * \internal
+ * @class QtMaterialDialogProxy
+ * @internal
*/
-QtMaterialDialogProxy::QtMaterialDialogProxy(
- QtMaterialDialogWindow *source,
- QStackedLayout *layout,
- QtMaterialDialog *dialog,
- QWidget *parent)
- : QWidget(parent),
- m_source(source),
- m_layout(layout),
- m_dialog(dialog),
- m_opacity(0),
- m_mode(Transparent)
+QtMaterialDialogProxy::QtMaterialDialogProxy(QtMaterialDialogWindow *source,
+ QStackedLayout *layout,
+ QtMaterialDialog *dialog,
+ QWidget *parent)
+ : QWidget(parent)
+ , m_source(source)
+ , m_layout(layout)
+ , m_dialog(dialog)
+ , m_opacity(0)
+ , m_mode(Transparent)
{
}
-QtMaterialDialogProxy::~QtMaterialDialogProxy()
-{
-}
+QtMaterialDialogProxy::~QtMaterialDialogProxy() {}
void QtMaterialDialogProxy::setOpacity(qreal opacity)
{
@@ -36,7 +33,6 @@ void QtMaterialDialogProxy::setOpacity(qreal opacity)
m_dialog->update();
}
-
void QtMaterialDialogProxy::makeOpaque()
{
m_dialog->setAttribute(Qt::WA_TransparentForMouseEvents, false);
@@ -84,21 +80,17 @@ void QtMaterialDialogProxy::paintEvent(QPaintEvent *event)
}
/*!
- * \class QtMaterialDialogWindow
- * \internal
+ * @class QtMaterialDialogWindow
+ * @internal
*/
-QtMaterialDialogWindow::QtMaterialDialogWindow(
- QtMaterialDialog *dialog,
- QWidget *parent)
- : QWidget(parent),
- m_dialog(dialog)
+QtMaterialDialogWindow::QtMaterialDialogWindow(QtMaterialDialog *dialog, QWidget *parent)
+ : QWidget(parent)
+ , m_dialog(dialog)
{
}
-QtMaterialDialogWindow::~QtMaterialDialogWindow()
-{
-}
+QtMaterialDialogWindow::~QtMaterialDialogWindow() {}
void QtMaterialDialogWindow::setOffset(int offset)
{
diff --git a/components/qtmaterialdialog_internal.h b/components/qtmaterialdialog_internal.h
index 52f5a0557..c3e38c19e 100644
--- a/components/qtmaterialdialog_internal.h
+++ b/components/qtmaterialdialog_internal.h
@@ -20,10 +20,7 @@ class QtMaterialDialogProxy : public QWidget
};
public:
- QtMaterialDialogProxy(QtMaterialDialogWindow *source,
- QStackedLayout *layout,
- QtMaterialDialog *dialog,
- QWidget *parent = 0);
+ QtMaterialDialogProxy(QtMaterialDialogWindow *source, QStackedLayout *layout, QtMaterialDialog *dialog, QWidget *parent = 0);
~QtMaterialDialogProxy();
void setOpacity(qreal opacity);
@@ -43,10 +40,10 @@ protected slots:
Q_DISABLE_COPY(QtMaterialDialogProxy)
QtMaterialDialogWindow *const m_source;
- QStackedLayout *const m_layout;
- QtMaterialDialog *const m_dialog;
- qreal m_opacity;
- TransparencyMode m_mode;
+ QStackedLayout *const m_layout;
+ QtMaterialDialog *const m_dialog;
+ qreal m_opacity;
+ TransparencyMode m_mode;
};
inline qreal QtMaterialDialogProxy::opacity() const
@@ -76,4 +73,4 @@ class QtMaterialDialogWindow : public QWidget
QtMaterialDialog *const m_dialog;
};
-#endif // QTMATERIALDIALOG_INTERNAL_H
+#endif // QTMATERIALDIALOG_INTERNAL_H
diff --git a/components/qtmaterialdialog_p.h b/components/qtmaterialdialog_p.h
index b10088ee1..238edb813 100644
--- a/components/qtmaterialdialog_p.h
+++ b/components/qtmaterialdialog_p.h
@@ -20,11 +20,11 @@ class QtMaterialDialogPrivate
void init();
- QtMaterialDialog *const q_ptr;
+ QtMaterialDialog *const q_ptr;
QtMaterialDialogWindow *dialogWindow;
- QStackedLayout *proxyStack;
- QStateMachine *stateMachine;
- QtMaterialDialogProxy *proxy;
+ QStackedLayout *proxyStack;
+ QStateMachine *stateMachine;
+ QtMaterialDialogProxy *proxy;
};
-#endif // QTMATERIALDIALOG_P_H
+#endif // QTMATERIALDIALOG_P_H
diff --git a/components/qtmaterialdrawer.cpp b/components/qtmaterialdrawer.cpp
index 1bddd4729..93f23bdeb 100644
--- a/components/qtmaterialdrawer.cpp
+++ b/components/qtmaterialdrawer.cpp
@@ -1,22 +1,22 @@
#include "qtmaterialdrawer.h"
+#include "qtmaterialdrawer_internal.h"
#include "qtmaterialdrawer_p.h"
-#include
-#include
#include
+#include
+#include
#include
+#include
#include
#include
-#include
#include
-#include "qtmaterialdrawer_internal.h"
/*!
- * \class QtMaterialDrawerPrivate
- * \internal
+ * @class QtMaterialDrawerPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q)
: q_ptr(q)
@@ -24,33 +24,31 @@ QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q)
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialDrawerPrivate::~QtMaterialDrawerPrivate()
-{
-}
+QtMaterialDrawerPrivate::~QtMaterialDrawerPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialDrawerPrivate::init()
{
Q_Q(QtMaterialDrawer);
- widget = new QtMaterialDrawerWidget;
+ widget = new QtMaterialDrawerWidget;
stateMachine = new QtMaterialDrawerStateMachine(widget, q);
- window = new QWidget;
- width = 250;
+ window = new QWidget;
+ width = 250;
clickToClose = false;
- autoRaise = true;
- closed = true;
- overlay = false;
+ autoRaise = true;
+ closed = true;
+ overlay = false;
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(window);
widget->setLayout(layout);
- widget->setFixedWidth(width+16);
+ widget->setFixedWidth(width + 16);
widget->setParent(q);
@@ -59,19 +57,17 @@ void QtMaterialDrawerPrivate::init()
}
/*!
- * \class QtMaterialDrawer
+ * @class QtMaterialDrawer
*/
QtMaterialDrawer::QtMaterialDrawer(QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- d_ptr(new QtMaterialDrawerPrivate(this))
+ : QtMaterialOverlayWidget(parent)
+ , d_ptr(new QtMaterialDrawerPrivate(this))
{
d_func()->init();
}
-QtMaterialDrawer::~QtMaterialDrawer()
-{
-}
+QtMaterialDrawer::~QtMaterialDrawer() {}
void QtMaterialDrawer::setDrawerWidth(int width)
{
@@ -79,7 +75,7 @@ void QtMaterialDrawer::setDrawerWidth(int width)
d->width = width;
d->stateMachine->updatePropertyAssignments();
- d->widget->setFixedWidth(width+16);
+ d->widget->setFixedWidth(width + 16);
}
int QtMaterialDrawer::drawerWidth() const
@@ -162,9 +158,10 @@ void QtMaterialDrawer::openDrawer()
void QtMaterialDrawer::closeDrawer()
{
Q_D(QtMaterialDrawer);
-
+ // emit signal to close
emit d->stateMachine->signalClose();
+ // reset the attribute
if (d->overlay) {
setAttribute(Qt::WA_TransparentForMouseEvents);
setAttribute(Qt::WA_NoSystemBackground);
@@ -175,46 +172,47 @@ bool QtMaterialDrawer::event(QEvent *event)
{
Q_D(QtMaterialDrawer);
- switch (event->type())
- {
- case QEvent::Move:
- case QEvent::Resize:
- if (!d->overlay) {
- setMask(QRegion(d->widget->rect()));
- }
- break;
- default:
- break;
+ switch (event->type()) {
+ case QEvent::Move:
+ case QEvent::Resize:
+ if (!d->overlay) {
+ setMask(QRegion(d->widget->rect()));
+ }
+ break;
+ default:
+ break;
}
return QtMaterialOverlayWidget::event(event);
}
+// size
bool QtMaterialDrawer::eventFilter(QObject *obj, QEvent *event)
{
Q_D(QtMaterialDrawer);
- switch (event->type())
- {
- case QEvent::MouseButtonPress: {
- QMouseEvent *mouseEvent;
- if ((mouseEvent = static_cast(event))) {
- const bool canClose = d->clickToClose || d->overlay;
- if (!d->widget->geometry().contains(mouseEvent->pos()) && canClose) {
- closeDrawer();
+ switch (event->type()) {
+ case QEvent::MouseButtonPress: {
+ QMouseEvent *mouseEvent;
+ if ((mouseEvent = static_cast(event))) {
+ // check canClose
+ const bool canClose = d->clickToClose || d->overlay;
+ // auto close location
+ if (!d->widget->geometry().contains(mouseEvent->pos()) && canClose) {
+ closeDrawer();
+ }
}
+ break;
}
- break;
- }
- case QEvent::Move:
- case QEvent::Resize: {
- QLayout *lw = d->widget->layout();
- if (lw && 16 != lw->contentsMargins().right()) {
- lw->setContentsMargins(0, 0, 16, 0);
+ case QEvent::Move:
+ case QEvent::Resize: {
+ QLayout *lw = d->widget->layout();
+ if (lw && 16 != lw->contentsMargins().right()) {
+ lw->setContentsMargins(0, 0, 16, 0);
+ }
+ break;
}
- break;
- }
- default:
- break;
+ default:
+ break;
}
return QtMaterialOverlayWidget::eventFilter(obj, event);
}
@@ -228,6 +226,7 @@ void QtMaterialDrawer::paintEvent(QPaintEvent *event)
if (!d->overlay || d->stateMachine->isInClosedState()) {
return;
}
+ // shadow
QPainter painter(this);
painter.setOpacity(d->stateMachine->opacity());
painter.fillRect(rect(), Qt::SolidPattern);
diff --git a/components/qtmaterialdrawer_internal.cpp b/components/qtmaterialdrawer_internal.cpp
index 7f327005d..15782de1f 100644
--- a/components/qtmaterialdrawer_internal.cpp
+++ b/components/qtmaterialdrawer_internal.cpp
@@ -1,25 +1,25 @@
#include "qtmaterialdrawer_internal.h"
-#include
+#include "qtmaterialdrawer.h"
#include
-#include
-#include
#include
-#include "qtmaterialdrawer.h"
+#include
+#include
+#include
/*!
- * \class QtMaterialDrawerStateMachine
- * \internal
+ * @class QtMaterialDrawerStateMachine
+ * @internal
*/
QtMaterialDrawerStateMachine::QtMaterialDrawerStateMachine(QtMaterialDrawerWidget *drawer, QtMaterialDrawer *parent)
- : QStateMachine(parent),
- m_drawer(drawer),
- m_main(parent),
- m_openingState(new QState),
- m_openedState(new QState),
- m_closingState(new QState),
- m_closedState(new QState),
- m_opacity(0)
+ : QStateMachine(parent)
+ , m_drawer(drawer)
+ , m_main(parent)
+ , m_openingState(new QState)
+ , m_openedState(new QState)
+ , m_closingState(new QState)
+ , m_closedState(new QState)
+ , m_opacity(0)
{
addState(m_openingState);
addState(m_openedState);
@@ -85,9 +85,7 @@ QtMaterialDrawerStateMachine::QtMaterialDrawerStateMachine(QtMaterialDrawerWidge
updatePropertyAssignments();
}
-QtMaterialDrawerStateMachine::~QtMaterialDrawerStateMachine()
-{
-}
+QtMaterialDrawerStateMachine::~QtMaterialDrawerStateMachine() {}
void QtMaterialDrawerStateMachine::setOpacity(qreal opacity)
{
@@ -102,7 +100,7 @@ bool QtMaterialDrawerStateMachine::isInClosedState() const
void QtMaterialDrawerStateMachine::updatePropertyAssignments()
{
- const qreal closedOffset = -(m_drawer->width()+32);
+ const qreal closedOffset = -(m_drawer->width() + 32);
m_closingState->assignProperty(m_drawer, "offset", closedOffset);
m_closedState->assignProperty(m_drawer, "offset", closedOffset);
@@ -115,19 +113,17 @@ void QtMaterialDrawerStateMachine::updatePropertyAssignments()
}
/*!
- * \class QtMaterialDrawerWidget
- * \internal
+ * @class QtMaterialDrawerWidget
+ * @internal
*/
QtMaterialDrawerWidget::QtMaterialDrawerWidget(QWidget *parent)
- : QtMaterialOverlayWidget(parent),
- m_offset(0)
+ : QtMaterialOverlayWidget(parent)
+ , m_offset(0)
{
}
-QtMaterialDrawerWidget::~QtMaterialDrawerWidget()
-{
-}
+QtMaterialDrawerWidget::~QtMaterialDrawerWidget() {}
void QtMaterialDrawerWidget::setOffset(int offset)
{
@@ -154,13 +150,13 @@ void QtMaterialDrawerWidget::paintEvent(QPaintEvent *event)
painter.drawRect(rect().adjusted(0, 0, -16, 0));
- QLinearGradient gradient(QPointF(width()-16, 0), QPointF(width(), 0));
+ QLinearGradient gradient(QPointF(width() - 16, 0), QPointF(width(), 0));
gradient.setColorAt(0, QColor(0, 0, 0, 80));
gradient.setColorAt(0.5, QColor(0, 0, 0, 20));
gradient.setColorAt(1, QColor(0, 0, 0, 0));
painter.setBrush(QBrush(gradient));
- painter.drawRect(width()-16, 0, 16, height());
+ painter.drawRect(width() - 16, 0, 16, height());
}
QRect QtMaterialDrawerWidget::overlayGeometry() const
diff --git a/components/qtmaterialdrawer_internal.h b/components/qtmaterialdrawer_internal.h
index 76d219db2..2fb13b2be 100644
--- a/components/qtmaterialdrawer_internal.h
+++ b/components/qtmaterialdrawer_internal.h
@@ -1,8 +1,8 @@
#ifndef DRAWER_INTERNAL_H
#define DRAWER_INTERNAL_H
-#include
#include "lib/qtmaterialoverlaywidget.h"
+#include
class QtMaterialDrawer;
class QtMaterialDrawerWidget;
@@ -14,8 +14,7 @@ class QtMaterialDrawerStateMachine : public QStateMachine
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
public:
- explicit QtMaterialDrawerStateMachine(QtMaterialDrawerWidget *drawer,
- QtMaterialDrawer *parent);
+ explicit QtMaterialDrawerStateMachine(QtMaterialDrawerWidget *drawer, QtMaterialDrawer *parent);
~QtMaterialDrawerStateMachine();
void setOpacity(qreal opacity);
@@ -33,12 +32,12 @@ class QtMaterialDrawerStateMachine : public QStateMachine
Q_DISABLE_COPY(QtMaterialDrawerStateMachine)
QtMaterialDrawerWidget *const m_drawer;
- QtMaterialDrawer *const m_main;
- QState *const m_openingState;
- QState *const m_openedState;
- QState *const m_closingState;
- QState *const m_closedState;
- qreal m_opacity;
+ QtMaterialDrawer *const m_main;
+ QState *const m_openingState;
+ QState *const m_openedState;
+ QState *const m_closingState;
+ QState *const m_closedState;
+ qreal m_opacity;
};
inline qreal QtMaterialDrawerStateMachine::opacity() const
@@ -65,7 +64,7 @@ class QtMaterialDrawerWidget : public QtMaterialOverlayWidget
QRect overlayGeometry() const Q_DECL_OVERRIDE;
private:
- int m_offset;
+ int m_offset;
};
inline int QtMaterialDrawerWidget::offset() const
@@ -73,4 +72,4 @@ inline int QtMaterialDrawerWidget::offset() const
return m_offset;
}
-#endif // DRAWER_INTERNAL_H
+#endif // DRAWER_INTERNAL_H
diff --git a/components/qtmaterialdrawer_p.h b/components/qtmaterialdrawer_p.h
index cdd064d12..f9b772401 100644
--- a/components/qtmaterialdrawer_p.h
+++ b/components/qtmaterialdrawer_p.h
@@ -19,15 +19,15 @@ class QtMaterialDrawerPrivate
void init();
void setClosed(bool value = true);
- QtMaterialDrawer *const q_ptr;
- QtMaterialDrawerWidget *widget;
+ QtMaterialDrawer *const q_ptr;
+ QtMaterialDrawerWidget *widget;
QtMaterialDrawerStateMachine *stateMachine;
- QWidget *window;
- int width;
- bool clickToClose;
- bool autoRaise;
- bool closed;
- bool overlay;
+ QWidget *window;
+ int width;
+ bool clickToClose;
+ bool autoRaise;
+ bool closed;
+ bool overlay;
};
-#endif // DRAWER_P_H
+#endif // DRAWER_P_H
diff --git a/components/qtmaterialfab.cpp b/components/qtmaterialfab.cpp
index 3c3de8a1f..140122f7f 100644
--- a/components/qtmaterialfab.cpp
+++ b/components/qtmaterialfab.cpp
@@ -1,42 +1,41 @@
#include "qtmaterialfab.h"
+#include "lib/qtmaterialrippleoverlay.h"
#include "qtmaterialfab_p.h"
-#include
-#include
#include
#include
-#include "lib/qtmaterialrippleoverlay.h"
+#include
+#include
/*!
- * \class QtMaterialFloatingActionButtonPrivate
- * \internal
+ * @class QtMaterialFloatingActionButtonPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialFloatingActionButtonPrivate::QtMaterialFloatingActionButtonPrivate(QtMaterialFloatingActionButton *q)
: QtMaterialRaisedButtonPrivate(q)
+ , q_ptr(q)
{
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialFloatingActionButtonPrivate::~QtMaterialFloatingActionButtonPrivate()
-{
-}
+QtMaterialFloatingActionButtonPrivate::~QtMaterialFloatingActionButtonPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFloatingActionButtonPrivate::init()
{
Q_Q(QtMaterialFloatingActionButton);
corner = Qt::BottomRightCorner;
- mini = false;
- offsX = 34;
- offsY = 36;
+ mini = false;
+ offsX = 34;
+ offsY = 36;
q->setRole(Material::Primary);
q->setFixedSize(DefaultDiameter, DefaultDiameter);
@@ -52,7 +51,7 @@ void QtMaterialFloatingActionButtonPrivate::init()
}
/*!
- * \internal
+ * @internal
*/
QRect QtMaterialFloatingActionButtonPrivate::fabGeometry() const
{
@@ -65,23 +64,22 @@ QRect QtMaterialFloatingActionButtonPrivate::fabGeometry() const
const int s = mini ? MiniDiameter : DefaultDiameter;
- switch (corner)
- {
- case Qt::TopLeftCorner:
- return QRect(offsX, offsY, s, s);
- case Qt::TopRightCorner:
- return QRect(parent->width()-(offsX+s), offsY, s, s);
- case Qt::BottomLeftCorner:
- return QRect(offsX, parent->height()-(offsY+s), s, s);
- case Qt::BottomRightCorner:
- default:
- break;
+ switch (corner) {
+ case Qt::TopLeftCorner:
+ return QRect(offsX, offsY, s, s);
+ case Qt::TopRightCorner:
+ return QRect(parent->width() - (offsX + s), offsY, s, s);
+ case Qt::BottomLeftCorner:
+ return QRect(offsX, parent->height() - (offsY + s), s, s);
+ case Qt::BottomRightCorner:
+ default:
+ break;
}
- return QRect(parent->width()-(offsX+s), parent->height()-(offsY+s), s, s);
+ return QRect(parent->width() - (offsX + s), parent->height() - (offsY + s), s, s);
}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFloatingActionButtonPrivate::setupProperties()
{
@@ -101,7 +99,7 @@ void QtMaterialFloatingActionButtonPrivate::setupProperties()
}
/*!
- * \class QtMaterialFloatingActionButton
+ * @class QtMaterialFloatingActionButton
*/
QtMaterialFloatingActionButton::QtMaterialFloatingActionButton(const QIcon &icon, QWidget *parent)
@@ -112,20 +110,17 @@ QtMaterialFloatingActionButton::QtMaterialFloatingActionButton(const QIcon &icon
setIcon(icon);
}
-QtMaterialFloatingActionButton::~QtMaterialFloatingActionButton()
-{
-}
+QtMaterialFloatingActionButton::~QtMaterialFloatingActionButton() {}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialFloatingActionButton::sizeHint() const
{
Q_D(const QtMaterialFloatingActionButton);
if (d->mini) {
- return QSize(QtMaterialFloatingActionButtonPrivate::MiniDiameter,
- QtMaterialFloatingActionButtonPrivate::MiniDiameter);
+ return QSize(QtMaterialFloatingActionButtonPrivate::MiniDiameter, QtMaterialFloatingActionButtonPrivate::MiniDiameter);
} else {
return QSize(QtMaterialFloatingActionButtonPrivate::DefaultDiameter,
QtMaterialFloatingActionButtonPrivate::DefaultDiameter);
@@ -228,7 +223,7 @@ int QtMaterialFloatingActionButton::yOffset() const
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialFloatingActionButton::event(QEvent *event)
{
@@ -237,34 +232,30 @@ bool QtMaterialFloatingActionButton::event(QEvent *event)
if (!parent()) {
return QtMaterialRaisedButton::event(event);
}
- switch (event->type())
- {
- case QEvent::ParentChange:
- {
- parent()->installEventFilter(this);
- setGeometry(d->fabGeometry());
- break;
- }
- case QEvent::ParentAboutToChange:
- {
- parent()->removeEventFilter(this);
- break;
- }
- default:
- break;
+ switch (event->type()) {
+ case QEvent::ParentChange: {
+ parent()->installEventFilter(this);
+ setGeometry(d->fabGeometry());
+ break;
+ }
+ case QEvent::ParentAboutToChange: {
+ parent()->removeEventFilter(this);
+ break;
+ }
+ default:
+ break;
}
return QtMaterialRaisedButton::event(event);
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialFloatingActionButton::eventFilter(QObject *obj, QEvent *event)
{
const QEvent::Type type = event->type();
- if (QEvent::Move == type || QEvent::Resize == type)
- {
+ if (QEvent::Move == type || QEvent::Resize == type) {
Q_D(QtMaterialFloatingActionButton);
setGeometry(d->fabGeometry());
}
@@ -273,7 +264,7 @@ bool QtMaterialFloatingActionButton::eventFilter(QObject *obj, QEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialFloatingActionButton::paintEvent(QPaintEvent *event)
{
@@ -306,8 +297,7 @@ void QtMaterialFloatingActionButton::paintEvent(QPaintEvent *event)
QPixmap pixmap = icon().pixmap(QSize(d->iconSize(), d->iconSize()));
QPainter icon(&pixmap);
icon.setCompositionMode(QPainter::CompositionMode_SourceIn);
- icon.fillRect(pixmap.rect(), isEnabled() ? foregroundColor()
- : disabledForegroundColor());
+ icon.fillRect(pixmap.rect(), isEnabled() ? foregroundColor() : disabledForegroundColor());
painter.drawPixmap(iconGeometry, pixmap);
}
diff --git a/components/qtmaterialfab_p.h b/components/qtmaterialfab_p.h
index fae2d3ae8..e1671fe27 100644
--- a/components/qtmaterialfab_p.h
+++ b/components/qtmaterialfab_p.h
@@ -11,20 +11,16 @@ class QtMaterialFloatingActionButtonPrivate : public QtMaterialRaisedButtonPriva
Q_DECLARE_PUBLIC(QtMaterialFloatingActionButton)
public:
- enum {
- DefaultDiameter = 56,
- MiniDiameter = 40
- };
+ enum { DefaultDiameter = 56, MiniDiameter = 40 };
- enum {
- DefaultIconSize = 24,
- MiniIconSize = 18
- };
+ enum { DefaultIconSize = 24, MiniIconSize = 18 };
QtMaterialFloatingActionButtonPrivate(QtMaterialFloatingActionButton *q);
~QtMaterialFloatingActionButtonPrivate();
void init();
+
+ QtMaterialFloatingActionButton *const q_ptr;
QRect fabGeometry() const;
void setupProperties();
@@ -32,9 +28,9 @@ class QtMaterialFloatingActionButtonPrivate : public QtMaterialRaisedButtonPriva
inline int iconSize() const;
Qt::Corner corner;
- bool mini;
- int offsX;
- int offsY;
+ bool mini;
+ int offsX;
+ int offsY;
};
inline int QtMaterialFloatingActionButtonPrivate::diameter() const
@@ -47,4 +43,4 @@ inline int QtMaterialFloatingActionButtonPrivate::iconSize() const
return mini ? MiniIconSize : DefaultIconSize;
}
-#endif // QTMATERIALFAB_P_H
+#endif // QTMATERIALFAB_P_H
diff --git a/components/qtmaterialflatbutton.cpp b/components/qtmaterialflatbutton.cpp
index b9d84d7e2..e5a3687e4 100644
--- a/components/qtmaterialflatbutton.cpp
+++ b/components/qtmaterialflatbutton.cpp
@@ -1,23 +1,23 @@
#include "qtmaterialflatbutton.h"
-#include "qtmaterialflatbutton_p.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include "lib/qtmaterialrippleoverlay.h"
#include "lib/qtmaterialripple.h"
+#include "lib/qtmaterialrippleoverlay.h"
#include "lib/qtmaterialstyle.h"
#include "qtmaterialflatbutton_internal.h"
+#include "qtmaterialflatbutton_p.h"
+#include
+#include
+#include
+#include
+#include
+#include
/*!
- * \class QtMaterialFlatButtonPrivate
- * \internal
+ * @class QtMaterialFlatButtonPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialFlatButtonPrivate::QtMaterialFlatButtonPrivate(QtMaterialFlatButton *q)
: q_ptr(q)
@@ -25,34 +25,32 @@ QtMaterialFlatButtonPrivate::QtMaterialFlatButtonPrivate(QtMaterialFlatButton *q
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialFlatButtonPrivate::~QtMaterialFlatButtonPrivate()
-{
-}
+QtMaterialFlatButtonPrivate::~QtMaterialFlatButtonPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFlatButtonPrivate::init()
{
Q_Q(QtMaterialFlatButton);
- rippleOverlay = new QtMaterialRippleOverlay(q);
- stateMachine = new QtMaterialFlatButtonStateMachine(q);
- role = Material::Default;
- rippleStyle = Material::PositionedRipple;
- iconPlacement = Material::LeftIcon;
- overlayStyle = Material::GrayOverlay;
- bgMode = Qt::TransparentMode;
- textAlignment = Qt::AlignHCenter;
- fixedRippleRadius = 64;
- cornerRadius = 3;
- baseOpacity = 0.13;
- fontSize = 10; // 10.5;
- useThemeColors = true;
+ rippleOverlay = new QtMaterialRippleOverlay(q);
+ stateMachine = new QtMaterialFlatButtonStateMachine(q);
+ role = Material::Default;
+ rippleStyle = Material::PositionedRipple;
+ iconPlacement = Material::LeftIcon;
+ overlayStyle = Material::GrayOverlay;
+ bgMode = Qt::TransparentMode;
+ textAlignment = Qt::AlignHCenter;
+ fixedRippleRadius = 64;
+ cornerRadius = 3;
+ baseOpacity = 0.13;
+ fontSize = 10; // 10.5;
+ useThemeColors = true;
useFixedRippleRadius = false;
- haloVisible = true;
+ haloVisible = true;
q->setStyle(&QtMaterialStyle::instance());
q->setAttribute(Qt::WA_Hover);
@@ -72,12 +70,12 @@ void QtMaterialFlatButtonPrivate::init()
}
/*!
- * \class QtMaterialFlatButton
+ * @class QtMaterialFlatButton
*/
QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, Material::ButtonPreset preset)
- : QPushButton(parent),
- d_ptr(new QtMaterialFlatButtonPrivate(this))
+ : QPushButton(parent)
+ , d_ptr(new QtMaterialFlatButtonPrivate(this))
{
d_func()->init();
@@ -85,17 +83,20 @@ QtMaterialFlatButton::QtMaterialFlatButton(QWidget *parent, Material::ButtonPres
}
QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, QWidget *parent, Material::ButtonPreset preset)
- : QPushButton(text, parent),
- d_ptr(new QtMaterialFlatButtonPrivate(this))
+ : QPushButton(text, parent)
+ , d_ptr(new QtMaterialFlatButtonPrivate(this))
{
d_func()->init();
applyPreset(preset);
}
-QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, Material::Role role, QWidget *parent, Material::ButtonPreset preset)
- : QPushButton(text, parent),
- d_ptr(new QtMaterialFlatButtonPrivate(this))
+QtMaterialFlatButton::QtMaterialFlatButton(const QString &text,
+ Material::Role role,
+ QWidget *parent,
+ Material::ButtonPreset preset)
+ : QPushButton(text, parent)
+ , d_ptr(new QtMaterialFlatButtonPrivate(this))
{
d_func()->init();
@@ -103,24 +104,21 @@ QtMaterialFlatButton::QtMaterialFlatButton(const QString &text, Material::Role r
setRole(role);
}
-QtMaterialFlatButton::~QtMaterialFlatButton()
-{
-}
+QtMaterialFlatButton::~QtMaterialFlatButton() {}
void QtMaterialFlatButton::applyPreset(Material::ButtonPreset preset)
{
- switch (preset)
- {
- case Material::FlatPreset:
- setOverlayStyle(Material::NoOverlay);
- break;
- case Material::CheckablePreset:
- setOverlayStyle(Material::NoOverlay);
- setCheckable(true);
- setHaloVisible(false);
- break;
- default:
- break;
+ switch (preset) {
+ case Material::FlatPreset:
+ setOverlayStyle(Material::NoOverlay);
+ break;
+ case Material::CheckablePreset:
+ setOverlayStyle(Material::NoOverlay);
+ setCheckable(true);
+ setHaloVisible(false);
+ break;
+ default:
+ break;
}
}
@@ -172,20 +170,18 @@ QColor QtMaterialFlatButton::foregroundColor() const
{
Q_D(const QtMaterialFlatButton);
- if (d->useThemeColors || !d->foregroundColor.isValid())
- {
+ if (d->useThemeColors || !d->foregroundColor.isValid()) {
if (Qt::OpaqueMode == d->bgMode) {
return QtMaterialStyle::instance().themeColor("canvas");
}
- switch (d->role)
- {
- case Material::Primary:
- return QtMaterialStyle::instance().themeColor("primary1");
- case Material::Secondary:
- return QtMaterialStyle::instance().themeColor("accent1");
- case Material::Default:
- default:
- return QtMaterialStyle::instance().themeColor("text");
+ switch (d->role) {
+ case Material::Primary:
+ return QtMaterialStyle::instance().themeColor("primary1");
+ case Material::Secondary:
+ return QtMaterialStyle::instance().themeColor("accent1");
+ case Material::Default:
+ default:
+ return QtMaterialStyle::instance().themeColor("text");
}
}
return d->foregroundColor;
@@ -205,17 +201,15 @@ QColor QtMaterialFlatButton::backgroundColor() const
{
Q_D(const QtMaterialFlatButton);
- if (d->useThemeColors || !d->backgroundColor.isValid())
- {
- switch (d->role)
- {
- case Material::Primary:
- return QtMaterialStyle::instance().themeColor("primary1");
- case Material::Secondary:
- return QtMaterialStyle::instance().themeColor("accent1");
- case Material::Default:
- default:
- return QtMaterialStyle::instance().themeColor("text");
+ if (d->useThemeColors || !d->backgroundColor.isValid()) {
+ switch (d->role) {
+ case Material::Primary:
+ return QtMaterialStyle::instance().themeColor("primary1");
+ case Material::Secondary:
+ return QtMaterialStyle::instance().themeColor("accent1");
+ case Material::Default:
+ default:
+ return QtMaterialStyle::instance().themeColor("text");
}
}
return d->backgroundColor;
@@ -456,7 +450,7 @@ Qt::Alignment QtMaterialFlatButton::textAlignment() const
}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialFlatButton::sizeHint() const
{
@@ -473,9 +467,9 @@ QSize QtMaterialFlatButton::sizeHint() const
return QSize(w, 20 + h);
}
-QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidget *parent, Material::ButtonPreset preset)
- : QPushButton(parent),
- d_ptr(&d)
+QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d, QWidget *parent, Material::ButtonPreset preset)
+ : QPushButton(parent)
+ , d_ptr(&d)
{
d_func()->init();
@@ -483,7 +477,7 @@ QtMaterialFlatButton::QtMaterialFlatButton(QtMaterialFlatButtonPrivate &d,QWidge
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialFlatButton::checkStateSet()
{
@@ -495,14 +489,13 @@ void QtMaterialFlatButton::checkStateSet()
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event)
{
Q_D(QtMaterialFlatButton);
- if (Material::NoRipple != d->rippleStyle)
- {
+ if (Material::NoRipple != d->rippleStyle) {
QPoint pos;
qreal radiusEndValue;
@@ -515,7 +508,7 @@ void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event)
if (d->useFixedRippleRadius) {
radiusEndValue = d->fixedRippleRadius;
} else {
- radiusEndValue = static_cast(width())/2;
+ radiusEndValue = static_cast(width()) / 2;
}
QtMaterialRipple *ripple = new QtMaterialRipple(pos);
@@ -533,7 +526,7 @@ void QtMaterialFlatButton::mousePressEvent(QMouseEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialFlatButton::mouseReleaseEvent(QMouseEvent *event)
{
@@ -552,7 +545,7 @@ void QtMaterialFlatButton::resizeEvent(QResizeEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialFlatButton::paintEvent(QPaintEvent *event)
{
@@ -565,8 +558,7 @@ void QtMaterialFlatButton::paintEvent(QPaintEvent *event)
const qreal cr = d->cornerRadius;
- if (cr > 0)
- {
+ if (cr > 0) {
QPainterPath path;
path.addRoundedRect(rect(), cr, cr);
@@ -584,7 +576,7 @@ void QtMaterialFlatButton::paintEvent(QPaintEvent *event)
}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFlatButton::paintBackground(QPainter *painter)
{
@@ -629,16 +621,16 @@ void QtMaterialFlatButton::paintBackground(QPainter *painter)
if (isCheckable() && checkedProgress > 0) {
const qreal q = Qt::TransparentMode == d->bgMode ? 0.45 : 0.7;
brush.setColor(foregroundColor());
- painter->setOpacity(q*checkedProgress);
+ painter->setOpacity(q * checkedProgress);
painter->setBrush(brush);
QRect r(rect());
- r.setHeight(static_cast(r.height())*checkedProgress);
+ r.setHeight(static_cast(r.height()) * checkedProgress);
painter->drawRect(r);
}
}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFlatButton::paintHalo(QPainter *painter)
{
@@ -649,8 +641,8 @@ void QtMaterialFlatButton::paintHalo(QPainter *painter)
}
const qreal opacity = d->stateMachine->haloOpacity();
- const qreal s = d->stateMachine->haloScaleFactor()*d->stateMachine->haloSize();
- const qreal radius = static_cast(width())*s;
+ const qreal s = d->stateMachine->haloScaleFactor() * d->stateMachine->haloSize();
+ const qreal radius = static_cast(width()) * s;
if (isEnabled() && opacity > 0) {
QBrush brush;
@@ -664,10 +656,10 @@ void QtMaterialFlatButton::paintHalo(QPainter *painter)
}
}
-#define COLOR_INTERPOLATE(CH) (1-progress)*source.CH() + progress*dest.CH()
+#define COLOR_INTERPOLATE(CH) (1 - progress) * source.CH() + progress *dest.CH()
/*!
- * \internal
+ * @internal
*/
void QtMaterialFlatButton::paintForeground(QPainter *painter)
{
@@ -678,22 +670,19 @@ void QtMaterialFlatButton::paintForeground(QPainter *painter)
const qreal progress = d->stateMachine->checkedOverlayProgress();
if (isCheckable() && progress > 0) {
QColor source = foregroundColor();
- QColor dest = Qt::TransparentMode == d->bgMode ? Qt::white
- : backgroundColor();
+ QColor dest = Qt::TransparentMode == d->bgMode ? Qt::white : backgroundColor();
if (qFuzzyCompare(1, progress)) {
painter->setPen(dest);
} else {
- painter->setPen(QColor(COLOR_INTERPOLATE(red),
- COLOR_INTERPOLATE(green),
- COLOR_INTERPOLATE(blue),
- COLOR_INTERPOLATE(alpha)));
+ painter->setPen(
+ QColor(COLOR_INTERPOLATE(red), COLOR_INTERPOLATE(green), COLOR_INTERPOLATE(blue), COLOR_INTERPOLATE(alpha)));
}
}
} else {
painter->setPen(disabledForegroundColor());
}
- if (icon().isNull()) {
+ if (icon().isNull()) {
if (Qt::AlignLeft == d->textAlignment) {
painter->drawText(rect().adjusted(12, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, text());
} else {
@@ -703,13 +692,13 @@ void QtMaterialFlatButton::paintForeground(QPainter *painter)
}
QSize textSize(fontMetrics().size(Qt::TextSingleLine, text()));
- QSize base(size()-textSize);
+ QSize base(size() - textSize);
const int iw = iconSize().width() + IconPadding;
- QPoint pos(Qt::AlignLeft == d->textAlignment ? 12 : (base.width()-iw)/2, 0);
+ QPoint pos(Qt::AlignLeft == d->textAlignment ? 12 : (base.width() - iw) / 2, 0);
- QRect textGeometry(pos + QPoint(0, base.height()/2), textSize);
- QRect iconGeometry(pos + QPoint(0, (height()-iconSize().height())/2), iconSize());
+ QRect textGeometry(pos + QPoint(0, base.height() / 2), textSize);
+ QRect iconGeometry(pos + QPoint(0, (height() - iconSize().height()) / 2), iconSize());
if (Material::LeftIcon == d->iconPlacement) {
textGeometry.translate(iw, 0);
@@ -727,7 +716,7 @@ void QtMaterialFlatButton::paintForeground(QPainter *painter)
}
/*!
- * \internal
+ * @internal
*/
void QtMaterialFlatButton::updateClipPath()
{
diff --git a/components/qtmaterialflatbutton_internal.cpp b/components/qtmaterialflatbutton_internal.cpp
index 0709a45f5..4b90f09b3 100644
--- a/components/qtmaterialflatbutton_internal.cpp
+++ b/components/qtmaterialflatbutton_internal.cpp
@@ -1,36 +1,36 @@
#include "qtmaterialflatbutton_internal.h"
+#include "lib/qtmaterialstatetransition.h"
+#include "qtmaterialflatbutton.h"
#include
-#include
#include
+#include
#include
-#include "qtmaterialflatbutton.h"
-#include "lib/qtmaterialstatetransition.h"
/*!
- * \class QtMaterialFlatButtonStateMachine
- * \internal
+ * @class QtMaterialFlatButtonStateMachine
+ * @internal
*/
QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFlatButton *parent)
- : QStateMachine(parent),
- m_button(parent),
- m_topLevelState(new QState(QState::ParallelStates)),
- m_configState(new QState(m_topLevelState)),
- m_checkableState(new QState(m_topLevelState)),
- m_checkedState(new QState(m_checkableState)),
- m_uncheckedState(new QState(m_checkableState)),
- m_neutralState(new QState(m_configState)),
- m_neutralFocusedState(new QState(m_configState)),
- m_hoveredState(new QState(m_configState)),
- m_hoveredFocusedState(new QState(m_configState)),
- m_pressedState(new QState(m_configState)),
- m_haloAnimation(new QSequentialAnimationGroup(this)),
- m_overlayOpacity(0),
- m_checkedOverlayProgress(parent->isChecked() ? 1 : 0),
- m_haloOpacity(0),
- m_haloSize(0.8),
- m_haloScaleFactor(1),
- m_wasChecked(false)
+ : QStateMachine(parent)
+ , m_button(parent)
+ , m_topLevelState(new QState(QState::ParallelStates))
+ , m_configState(new QState(m_topLevelState))
+ , m_checkableState(new QState(m_topLevelState))
+ , m_checkedState(new QState(m_checkableState))
+ , m_uncheckedState(new QState(m_checkableState))
+ , m_neutralState(new QState(m_configState))
+ , m_neutralFocusedState(new QState(m_configState))
+ , m_hoveredState(new QState(m_configState))
+ , m_hoveredFocusedState(new QState(m_configState))
+ , m_pressedState(new QState(m_configState))
+ , m_haloAnimation(new QSequentialAnimationGroup(this))
+ , m_overlayOpacity(0)
+ , m_checkedOverlayProgress(parent->isChecked() ? 1 : 0)
+ , m_haloOpacity(0)
+ , m_haloSize(0.8)
+ , m_haloScaleFactor(1)
+ , m_wasChecked(false)
{
Q_ASSERT(parent);
@@ -40,8 +40,7 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla
addState(m_topLevelState);
setInitialState(m_topLevelState);
- m_checkableState->setInitialState(parent->isChecked() ? m_checkedState
- : m_uncheckedState);
+ m_checkableState->setInitialState(parent->isChecked() ? m_checkedState : m_uncheckedState);
QtMaterialStateTransition *transition;
QPropertyAnimation *animation;
@@ -105,9 +104,7 @@ QtMaterialFlatButtonStateMachine::QtMaterialFlatButtonStateMachine(QtMaterialFla
m_haloAnimation->setLoopCount(-1);
}
-QtMaterialFlatButtonStateMachine::~QtMaterialFlatButtonStateMachine()
-{
-}
+QtMaterialFlatButtonStateMachine::~QtMaterialFlatButtonStateMachine() {}
void QtMaterialFlatButtonStateMachine::setOverlayOpacity(qreal opacity)
{
@@ -186,8 +183,7 @@ void QtMaterialFlatButtonStateMachine::updateCheckedStatus()
}
}
-bool QtMaterialFlatButtonStateMachine::eventFilter(QObject *watched,
- QEvent *event)
+bool QtMaterialFlatButtonStateMachine::eventFilter(QObject *watched, QEvent *event)
{
if (QEvent::FocusIn == event->type()) {
QFocusEvent *focusEvent = static_cast(event);
@@ -199,17 +195,12 @@ bool QtMaterialFlatButtonStateMachine::eventFilter(QObject *watched,
return QStateMachine::eventFilter(watched, event);
}
-void QtMaterialFlatButtonStateMachine::addTransition(QObject *object,
- QEvent::Type eventType,
- QState *fromState,
- QState *toState)
+void QtMaterialFlatButtonStateMachine::addTransition(QObject *object, QEvent::Type eventType, QState *fromState, QState *toState)
{
addTransition(new QEventTransition(object, eventType), fromState, toState);
}
-void QtMaterialFlatButtonStateMachine::addTransition(QAbstractTransition *transition,
- QState *fromState,
- QState *toState)
+void QtMaterialFlatButtonStateMachine::addTransition(QAbstractTransition *transition, QState *fromState, QState *toState)
{
transition->setTargetState(toState);
diff --git a/components/qtmaterialflatbutton_internal.h b/components/qtmaterialflatbutton_internal.h
index ff93972b9..9c5130305 100644
--- a/components/qtmaterialflatbutton_internal.h
+++ b/components/qtmaterialflatbutton_internal.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALFLATBUTTON_INTERNAL_H
#define QTMATERIALFLATBUTTON_INTERNAL_H
-#include
#include
+#include
class QtMaterialFlatButton;
class QSequentialAnimationGroup;
@@ -55,24 +55,23 @@ class QtMaterialFlatButtonStateMachine : public QStateMachine
void addTransition(QAbstractTransition *transition, QState *fromState, QState *toState);
QtMaterialFlatButton *const m_button;
- QState *const m_topLevelState;
- QState *const m_configState;
- QState *const m_checkableState;
- QState *const m_checkedState;
- QState *const m_uncheckedState;
- QState *const m_neutralState;
- QState *const m_neutralFocusedState;
- QState *const m_hoveredState;
- QState *const m_hoveredFocusedState;
- QState *const m_pressedState;
- QSequentialAnimationGroup
- *const m_haloAnimation;
- qreal m_overlayOpacity;
- qreal m_checkedOverlayProgress;
- qreal m_haloOpacity;
- qreal m_haloSize;
- qreal m_haloScaleFactor;
- bool m_wasChecked;
+ QState *const m_topLevelState;
+ QState *const m_configState;
+ QState *const m_checkableState;
+ QState *const m_checkedState;
+ QState *const m_uncheckedState;
+ QState *const m_neutralState;
+ QState *const m_neutralFocusedState;
+ QState *const m_hoveredState;
+ QState *const m_hoveredFocusedState;
+ QState *const m_pressedState;
+ QSequentialAnimationGroup *const m_haloAnimation;
+ qreal m_overlayOpacity;
+ qreal m_checkedOverlayProgress;
+ qreal m_haloOpacity;
+ qreal m_haloSize;
+ qreal m_haloScaleFactor;
+ bool m_wasChecked;
};
inline qreal QtMaterialFlatButtonStateMachine::overlayOpacity() const
@@ -100,4 +99,4 @@ inline qreal QtMaterialFlatButtonStateMachine::haloScaleFactor() const
return m_haloScaleFactor;
}
-#endif // QTMATERIALFLATBUTTON_INTERNAL_H
+#endif // QTMATERIALFLATBUTTON_INTERNAL_H
diff --git a/components/qtmaterialflatbutton_p.h b/components/qtmaterialflatbutton_p.h
index 1ab3d226f..5d6a339a8 100644
--- a/components/qtmaterialflatbutton_p.h
+++ b/components/qtmaterialflatbutton_p.h
@@ -1,9 +1,9 @@
#ifndef QTMATERIALFLATBUTTON_P_H
#define QTMATERIALFLATBUTTON_P_H
-#include
-#include
#include "lib/qtmaterialtheme.h"
+#include
+#include
class QtMaterialFlatButton;
class QtMaterialRippleOverlay;
@@ -20,27 +20,27 @@ class QtMaterialFlatButtonPrivate
void init();
- QtMaterialFlatButton *const q_ptr;
- QtMaterialRippleOverlay *rippleOverlay;
+ QtMaterialFlatButton *const q_ptr;
+ QtMaterialRippleOverlay *rippleOverlay;
QtMaterialFlatButtonStateMachine *stateMachine;
- Material::Role role;
- Material::RippleStyle rippleStyle;
- Material::ButtonIconPlacement iconPlacement;
- Material::OverlayStyle overlayStyle;
- Qt::BGMode bgMode;
- Qt::Alignment textAlignment;
- QColor backgroundColor;
- QColor foregroundColor;
- QColor overlayColor;
- QColor disabledColor;
- QColor disabledBackgroundColor;
- qreal fixedRippleRadius;
- qreal cornerRadius;
- qreal baseOpacity;
- qreal fontSize;
- bool useThemeColors;
- bool useFixedRippleRadius;
- bool haloVisible;
+ Material::Role role;
+ Material::RippleStyle rippleStyle;
+ Material::ButtonIconPlacement iconPlacement;
+ Material::OverlayStyle overlayStyle;
+ Qt::BGMode bgMode;
+ Qt::Alignment textAlignment;
+ QColor backgroundColor;
+ QColor foregroundColor;
+ QColor overlayColor;
+ QColor disabledColor;
+ QColor disabledBackgroundColor;
+ qreal fixedRippleRadius;
+ qreal cornerRadius;
+ qreal baseOpacity;
+ qreal fontSize;
+ bool useThemeColors;
+ bool useFixedRippleRadius;
+ bool haloVisible;
};
-#endif // QTMATERIALFLATBUTTON_P_H
+#endif // QTMATERIALFLATBUTTON_P_H
diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp
index 525d6b206..ffac96d35 100644
--- a/components/qtmaterialiconbutton.cpp
+++ b/components/qtmaterialiconbutton.cpp
@@ -1,13 +1,13 @@
#include "qtmaterialiconbutton.h"
+#include "lib/qtmaterialrippleoverlay.h"
+#include "lib/qtmaterialstyle.h"
#include "qtmaterialiconbutton_p.h"
-#include
#include
-#include "lib/qtmaterialstyle.h"
-#include "lib/qtmaterialrippleoverlay.h"
+#include
/*!
- * \class QtMaterialIconButtonPrivate
- * \internal
+ * @class QtMaterialIconButtonPrivate
+ * @internal
*/
QtMaterialIconButtonPrivate::QtMaterialIconButtonPrivate(QtMaterialIconButton *q)
@@ -15,15 +15,13 @@ QtMaterialIconButtonPrivate::QtMaterialIconButtonPrivate(QtMaterialIconButton *q
{
}
-QtMaterialIconButtonPrivate::~QtMaterialIconButtonPrivate()
-{
-}
+QtMaterialIconButtonPrivate::~QtMaterialIconButtonPrivate() {}
void QtMaterialIconButtonPrivate::init()
{
Q_Q(QtMaterialIconButton);
- rippleOverlay = new QtMaterialRippleOverlay(q->parentWidget());
+ rippleOverlay = new QtMaterialRippleOverlay(q->parentWidget());
useThemeColors = true;
rippleOverlay->installEventFilter(q);
@@ -40,30 +38,28 @@ void QtMaterialIconButtonPrivate::updateRipple()
Q_Q(QtMaterialIconButton);
QRect r(q->rect());
- r.setSize(QSize(q->width()*2, q->height()*2));
+ r.setSize(QSize(q->width() * 2, q->height() * 2));
r.moveCenter(q->geometry().center());
rippleOverlay->setGeometry(r);
}
/*!
- * \class QtMaterialIconButton
+ * @class QtMaterialIconButton
*/
QtMaterialIconButton::QtMaterialIconButton(const QIcon &icon, QWidget *parent)
- : QAbstractButton(parent),
- d_ptr(new QtMaterialIconButtonPrivate(this))
+ : QAbstractButton(parent)
+ , d_ptr(new QtMaterialIconButtonPrivate(this))
{
d_func()->init();
setIcon(icon);
}
-QtMaterialIconButton::~QtMaterialIconButton()
-{
-}
+QtMaterialIconButton::~QtMaterialIconButton() {}
/*!
- * \reimp
+ * @reimp
*/
QSize QtMaterialIconButton::sizeHint() const
{
@@ -130,45 +126,43 @@ QColor QtMaterialIconButton::disabledColor() const
}
QtMaterialIconButton::QtMaterialIconButton(QtMaterialIconButtonPrivate &d, QWidget *parent)
- : QAbstractButton(parent),
- d_ptr(&d)
+ : QAbstractButton(parent)
+ , d_ptr(&d)
{
d_func()->init();
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialIconButton::event(QEvent *event)
{
Q_D(QtMaterialIconButton);
- switch (event->type())
- {
- case QEvent::Move:
- case QEvent::Resize:
- d->updateRipple();
- break;
- case QEvent::ParentChange: {
- QWidget *widget;
- if ((widget = parentWidget())) {
- d->rippleOverlay->setParent(widget);
+ switch (event->type()) {
+ case QEvent::Move:
+ case QEvent::Resize:
+ d->updateRipple();
+ break;
+ case QEvent::ParentChange: {
+ QWidget *widget;
+ if ((widget = parentWidget())) {
+ d->rippleOverlay->setParent(widget);
+ }
+ break;
}
- break;
- }
- default:
- break;
+ default:
+ break;
}
return QAbstractButton::event(event);
}
/*!
- * \reimp
+ * @reimp
*/
bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event)
{
- if (QEvent::Resize == event->type())
- {
+ if (QEvent::Resize == event->type()) {
Q_D(QtMaterialIconButton);
d->updateRipple();
@@ -177,22 +171,20 @@ bool QtMaterialIconButton::eventFilter(QObject *obj, QEvent *event)
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialIconButton::mousePressEvent(QMouseEvent *event)
{
Q_D(QtMaterialIconButton);
- d->rippleOverlay->addRipple(QPoint(d->rippleOverlay->width(),
- d->rippleOverlay->height())/2,
- iconSize().width());
+ d->rippleOverlay->addRipple(QPoint(d->rippleOverlay->width(), d->rippleOverlay->height()) / 2, iconSize().width());
emit clicked();
QAbstractButton::mousePressEvent(event);
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialIconButton::paintEvent(QPaintEvent *event)
{
@@ -208,5 +200,5 @@ void QtMaterialIconButton::paintEvent(QPaintEvent *event)
QRect r(rect());
const qreal w = pixmap.width();
const qreal h = pixmap.height();
- painter.drawPixmap(QRect((r.width()-w)/2, (r.height()-h)/2, w, h), pixmap);
+ painter.drawPixmap(QRect((r.width() - w) / 2, (r.height() - h) / 2, w, h), pixmap);
}
diff --git a/components/qtmaterialiconbutton_p.h b/components/qtmaterialiconbutton_p.h
index a532abca6..4e1e34c88 100644
--- a/components/qtmaterialiconbutton_p.h
+++ b/components/qtmaterialiconbutton_p.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALICONBUTTON_P_H
#define QTMATERIALICONBUTTON_P_H
+#include
#include
-
class QtMaterialIconButton;
class QtMaterialRippleOverlay;
class QColor;
@@ -19,11 +19,11 @@ class QtMaterialIconButtonPrivate
void init();
void updateRipple();
- QtMaterialIconButton *const q_ptr;
+ QtMaterialIconButton *const q_ptr;
QtMaterialRippleOverlay *rippleOverlay;
- QColor color;
- QColor disabledColor;
- bool useThemeColors;
+ QColor color;
+ QColor disabledColor;
+ bool useThemeColors;
};
-#endif // QTMATERIALICONBUTTON_P_H
+#endif // QTMATERIALICONBUTTON_P_H
diff --git a/components/qtmateriallist_p.h b/components/qtmateriallist_p.h
index c92b2d641..5844730b9 100644
--- a/components/qtmateriallist_p.h
+++ b/components/qtmateriallist_p.h
@@ -1,4 +1,4 @@
#ifndef QTMATERIALLIST_P_H
#define QTMATERIALLIST_P_H
-#endif // QTMATERIALLIST_P_H
+#endif // QTMATERIALLIST_P_H
diff --git a/components/qtmaterialmenu.cpp b/components/qtmaterialmenu.cpp
index 5808a99e0..407ccf019 100644
--- a/components/qtmaterialmenu.cpp
+++ b/components/qtmaterialmenu.cpp
@@ -1,5 +1,4 @@
#include "qtmaterialmenu.h"
-#include "qtmaterialmenu_p.h"
QtMaterialMenu::QtMaterialMenu(QWidget *parent)
: QWidget(parent)
diff --git a/components/qtmaterialmenu_internal.cpp b/components/qtmaterialmenu_internal.cpp
deleted file mode 100644
index e69de29bb..000000000
diff --git a/components/qtmaterialmenu_internal.h b/components/qtmaterialmenu_internal.h
deleted file mode 100644
index fb792356d..000000000
--- a/components/qtmaterialmenu_internal.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef QTMATERIALMENU_INTERNAL_H
-#define QTMATERIALMENU_INTERNAL_H
-
-#endif // QTMATERIALMENU_INTERNAL_H
diff --git a/components/qtmaterialmenu_p.h b/components/qtmaterialmenu_p.h
deleted file mode 100644
index 1328bdca1..000000000
--- a/components/qtmaterialmenu_p.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef QTMATERIALMENU_P_H
-#define QTMATERIALMENU_P_H
-
-#endif // QTMATERIALMENU_P_H
diff --git a/components/qtmaterialpaper_p.h b/components/qtmaterialpaper_p.h
index 65972a653..be77dbfa6 100644
--- a/components/qtmaterialpaper_p.h
+++ b/components/qtmaterialpaper_p.h
@@ -1,4 +1,4 @@
#ifndef QTMATERIALPAPER_P_H
#define QTMATERIALPAPER_P_H
-#endif // QTMATERIALPAPER_P_H
+#endif // QTMATERIALPAPER_P_H
diff --git a/components/qtmaterialprogress.cpp b/components/qtmaterialprogress.cpp
index 03b15b2f0..b2c477077 100644
--- a/components/qtmaterialprogress.cpp
+++ b/components/qtmaterialprogress.cpp
@@ -1,14 +1,14 @@
#include "qtmaterialprogress.h"
+#include "lib/qtmaterialstyle.h"
+#include "qtmaterialprogress_internal.h"
#include "qtmaterialprogress_p.h"
-#include
#include
#include
-#include "qtmaterialprogress_internal.h"
-#include "lib/qtmaterialstyle.h"
+#include
/*!
- * \class QtMaterialProgressPrivate
- * \internal
+ * @class QtMaterialProgressPrivate
+ * @internal
*/
QtMaterialProgressPrivate::QtMaterialProgressPrivate(QtMaterialProgress *q)
@@ -16,16 +16,14 @@ QtMaterialProgressPrivate::QtMaterialProgressPrivate(QtMaterialProgress *q)
{
}
-QtMaterialProgressPrivate::~QtMaterialProgressPrivate()
-{
-}
+QtMaterialProgressPrivate::~QtMaterialProgressPrivate() {}
void QtMaterialProgressPrivate::init()
{
Q_Q(QtMaterialProgress);
- delegate = new QtMaterialProgressDelegate(q);
- progressType = Material::IndeterminateProgress;
+ delegate = new QtMaterialProgressDelegate(q);
+ progressType = Material::IndeterminateProgress;
useThemeColors = true;
QPropertyAnimation *animation;
@@ -43,19 +41,17 @@ void QtMaterialProgressPrivate::init()
}
/*!
- * \class QtMaterialProgress
+ * @class QtMaterialProgress
*/
QtMaterialProgress::QtMaterialProgress(QWidget *parent)
- : QProgressBar(parent),
- d_ptr(new QtMaterialProgressPrivate(this))
+ : QProgressBar(parent)
+ , d_ptr(new QtMaterialProgressPrivate(this))
{
d_func()->init();
}
-QtMaterialProgress::~QtMaterialProgress()
-{
-}
+QtMaterialProgress::~QtMaterialProgress() {}
void QtMaterialProgress::setProgressType(Material::ProgressType type)
{
@@ -134,7 +130,7 @@ QColor QtMaterialProgress::backgroundColor() const
}
/*!
- * \reimp
+ * @reimp
*/
void QtMaterialProgress::paintEvent(QPaintEvent *event)
{
@@ -147,26 +143,24 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event)
QBrush brush;
brush.setStyle(Qt::SolidPattern);
- brush.setColor(isEnabled() ? backgroundColor()
- : QtMaterialStyle::instance().themeColor("disabled"));
+ brush.setColor(isEnabled() ? backgroundColor() : QtMaterialStyle::instance().themeColor("disabled"));
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
QPainterPath path;
- path.addRoundedRect(0, height()/2-3, width(), 6, 3, 3);
+ path.addRoundedRect(0, height() / 2.0 - 3, width(), 6, 3, 3);
painter.setClipPath(path);
painter.drawRect(0, 0, width(), height());
- if (isEnabled())
- {
+ if (isEnabled()) {
brush.setColor(progressColor());
painter.setBrush(brush);
if (Material::IndeterminateProgress == d->progressType) {
- painter.drawRect(d->delegate->offset()*width()*2-width(), 0, width(), height());
+ painter.drawRect(d->delegate->offset() * width() * 2 - width(), 0, width(), height());
} else {
- qreal p = static_cast(width())*(value()-minimum())/(maximum()-minimum());
+ qreal p = static_cast(width()) * (value() - minimum()) / (maximum() - minimum());
painter.drawRect(0, 0, p, height());
}
}
diff --git a/components/qtmaterialprogress_internal.cpp b/components/qtmaterialprogress_internal.cpp
index 0544baeba..db22e2862 100644
--- a/components/qtmaterialprogress_internal.cpp
+++ b/components/qtmaterialprogress_internal.cpp
@@ -1,8 +1,8 @@
#include "qtmaterialprogress_internal.h"
/*!
- * \class QtMaterialProgressDelegate
- * \internal
+ * @class QtMaterialProgressDelegate
+ * @internal
*/
QtMaterialProgressDelegate::QtMaterialProgressDelegate(QtMaterialProgress *parent)
diff --git a/components/qtmaterialprogress_internal.h b/components/qtmaterialprogress_internal.h
index 811e3d6de..31401eeea 100644
--- a/components/qtmaterialprogress_internal.h
+++ b/components/qtmaterialprogress_internal.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALPROGRESS_INTERNAL_H
#define QTMATERIALPROGRESS_INTERNAL_H
-#include
#include "qtmaterialprogress.h"
+#include
class QtMaterialProgressDelegate : public QObject
{
@@ -21,7 +21,7 @@ class QtMaterialProgressDelegate : public QObject
Q_DISABLE_COPY(QtMaterialProgressDelegate)
QtMaterialProgress *const m_progress;
- qreal m_offset;
+ qreal m_offset;
};
inline void QtMaterialProgressDelegate::setOffset(qreal offset)
@@ -35,4 +35,4 @@ inline qreal QtMaterialProgressDelegate::offset() const
return m_offset;
}
-#endif // QTMATERIALPROGRESS_INTERNAL_H
+#endif // QTMATERIALPROGRESS_INTERNAL_H
diff --git a/components/qtmaterialprogress_p.h b/components/qtmaterialprogress_p.h
index b55fb021c..33192c42a 100644
--- a/components/qtmaterialprogress_p.h
+++ b/components/qtmaterialprogress_p.h
@@ -1,9 +1,9 @@
#ifndef QTMATERIALPROGRESS_P_H
#define QTMATERIALPROGRESS_P_H
-#include
-#include
#include "lib/qtmaterialtheme.h"
+#include
+#include
class QtMaterialProgress;
class QtMaterialProgressDelegate;
@@ -19,12 +19,12 @@ class QtMaterialProgressPrivate
void init();
- QtMaterialProgress *const q_ptr;
+ QtMaterialProgress *const q_ptr;
QtMaterialProgressDelegate *delegate;
- Material::ProgressType progressType;
- QColor progressColor;
- QColor backgroundColor;
- bool useThemeColors;
+ Material::ProgressType progressType;
+ QColor progressColor;
+ QColor backgroundColor;
+ bool useThemeColors;
};
-#endif // QTMATERIALPROGRESS_P_H
+#endif // QTMATERIALPROGRESS_P_H
diff --git a/components/qtmaterialradiobutton.cpp b/components/qtmaterialradiobutton.cpp
index 86427c787..d3ba492d4 100644
--- a/components/qtmaterialradiobutton.cpp
+++ b/components/qtmaterialradiobutton.cpp
@@ -1,27 +1,29 @@
#include "qtmaterialradiobutton.h"
+#include "materiallib/qtmaterialcheckable_internal.h"
#include "qtmaterialradiobutton_p.h"
-#include
-#include
-#include
#include
-#include "lib/qtmaterialcheckable_internal.h"
+#include
+#include
+#include
/*!
* \class QtMaterialRadioButtonPrivate
- * \internal
+ * @parma state private class
+ * @internal
+ *
*/
QtMaterialRadioButtonPrivate::QtMaterialRadioButtonPrivate(QtMaterialRadioButton *q)
: QtMaterialCheckablePrivate(q)
+ , q_ptr(q)
{
}
-QtMaterialRadioButtonPrivate::~QtMaterialRadioButtonPrivate()
-{
-}
+QtMaterialRadioButtonPrivate::~QtMaterialRadioButtonPrivate() {}
void QtMaterialRadioButtonPrivate::init()
{
+ // get the public button
Q_Q(QtMaterialRadioButton);
q->setAutoExclusive(true);
@@ -84,9 +86,7 @@ QtMaterialRadioButton::QtMaterialRadioButton(QWidget *parent)
d_func()->init();
}
-QtMaterialRadioButton::~QtMaterialRadioButton()
-{
-}
+QtMaterialRadioButton::~QtMaterialRadioButton() {}
void QtMaterialRadioButton::setupProperties()
{
diff --git a/components/qtmaterialradiobutton_p.h b/components/qtmaterialradiobutton_p.h
index 6bb954aa1..dd117ec3a 100644
--- a/components/qtmaterialradiobutton_p.h
+++ b/components/qtmaterialradiobutton_p.h
@@ -1,7 +1,7 @@
#ifndef QTMATERIALRADIOBUTTON_P_H
#define QTMATERIALRADIOBUTTON_P_H
-#include "lib/qtmaterialcheckable_p.h"
+#include "materiallib/qtmaterialcheckable_p.h"
class QtMaterialRadioButton;
@@ -13,8 +13,8 @@ class QtMaterialRadioButtonPrivate : public QtMaterialCheckablePrivate
public:
QtMaterialRadioButtonPrivate(QtMaterialRadioButton *q);
~QtMaterialRadioButtonPrivate();
-
+ QtMaterialRadioButton *const q_ptr;
void init();
};
-#endif // QTMATERIALRADIOBUTTON_P_H
+#endif // QTMATERIALRADIOBUTTON_P_H
diff --git a/components/qtmaterialraisedbutton.cpp b/components/qtmaterialraisedbutton.cpp
index 1607c7072..23d1495dd 100644
--- a/components/qtmaterialraisedbutton.cpp
+++ b/components/qtmaterialraisedbutton.cpp
@@ -1,41 +1,40 @@
#include "qtmaterialraisedbutton.h"
#include "qtmaterialraisedbutton_p.h"
+#include
+#include
#include
#include
-#include
-#include
/*!
- * \class QtMaterialRaisedButtonPrivate
- * \internal
+ * @class QtMaterialRaisedButtonPrivate
+ * @internal
*/
/*!
- * \internal
+ * @internal
*/
QtMaterialRaisedButtonPrivate::QtMaterialRaisedButtonPrivate(QtMaterialRaisedButton *q)
: QtMaterialFlatButtonPrivate(q)
+ , q_ptr(q)
{
}
/*!
- * \internal
+ * @internal
*/
-QtMaterialRaisedButtonPrivate::~QtMaterialRaisedButtonPrivate()
-{
-}
+QtMaterialRaisedButtonPrivate::~QtMaterialRaisedButtonPrivate() {}
/*!
- * \internal
+ * @internal
*/
void QtMaterialRaisedButtonPrivate::init()
{
Q_Q(QtMaterialRaisedButton);
shadowStateMachine = new QStateMachine(q);
- normalState = new QState;
- pressedState = new QState;
- effect = new QGraphicsDropShadowEffect;
+ normalState = new QState;
+ pressedState = new QState;
+ effect = new QGraphicsDropShadowEffect;
effect->setBlurRadius(7);
effect->setOffset(QPointF(0, 2));
@@ -84,7 +83,7 @@ void QtMaterialRaisedButtonPrivate::init()
}
/*!
- * \class QtMaterialRaisedButton
+ * @class QtMaterialRaisedButton
*/
QtMaterialRaisedButton::QtMaterialRaisedButton(QWidget *parent)
@@ -101,9 +100,7 @@ QtMaterialRaisedButton::QtMaterialRaisedButton(const QString &text, QWidget *par
setText(text);
}
-QtMaterialRaisedButton::~QtMaterialRaisedButton()
-{
-}
+QtMaterialRaisedButton::~QtMaterialRaisedButton() {}
QtMaterialRaisedButton::QtMaterialRaisedButton(QtMaterialRaisedButtonPrivate &d, QWidget *parent)
: QtMaterialFlatButton(d, parent)
diff --git a/components/qtmaterialraisedbutton_p.h b/components/qtmaterialraisedbutton_p.h
index 12df43c82..319e83aed 100644
--- a/components/qtmaterialraisedbutton_p.h
+++ b/components/qtmaterialraisedbutton_p.h
@@ -18,11 +18,12 @@ class QtMaterialRaisedButtonPrivate : public QtMaterialFlatButtonPrivate
~QtMaterialRaisedButtonPrivate();
void init();
-
- QStateMachine *shadowStateMachine;
- QState *normalState;
- QState *pressedState;
+
+ QtMaterialRaisedButton *const q_ptr;
+ QStateMachine *shadowStateMachine;
+ QState *normalState;
+ QState *pressedState;
QGraphicsDropShadowEffect *effect;
};
-#endif // QTMATERIALRAISEDBUTTON_P_H
+#endif // QTMATERIALRAISEDBUTTON_P_H
diff --git a/components/qtmaterialscrollbar_internal.h b/components/qtmaterialscrollbar_internal.h
index 7b1cc92ac..020ded795 100644
--- a/components/qtmaterialscrollbar_internal.h
+++ b/components/qtmaterialscrollbar_internal.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALSCROLLBAR_INTERNAL_H
#define QTMATERIALSCROLLBAR_INTERNAL_H
-#include
#include "qtmaterialscrollbar.h"
+#include
class QtMaterialScrollBarStateMachine : public QStateMachine
{
@@ -21,9 +21,9 @@ class QtMaterialScrollBarStateMachine : public QStateMachine
Q_DISABLE_COPY(QtMaterialScrollBarStateMachine)
QtMaterialScrollBar *const m_scrollBar;
- QState *const m_focusState;
- QState *const m_blurState;
- qreal m_opacity;
+ QState *const m_focusState;
+ QState *const m_blurState;
+ qreal m_opacity;
};
inline void QtMaterialScrollBarStateMachine::setOpacity(qreal opacity)
@@ -37,4 +37,4 @@ inline qreal QtMaterialScrollBarStateMachine::opacity() const
return m_opacity;
}
-#endif // QTMATERIALSCROLLBAR_INTERNAL_H
+#endif // QTMATERIALSCROLLBAR_INTERNAL_H
diff --git a/components/qtmaterialscrollbar_p.h b/components/qtmaterialscrollbar_p.h
index 1d22cc06b..3eeaf0930 100644
--- a/components/qtmaterialscrollbar_p.h
+++ b/components/qtmaterialscrollbar_p.h
@@ -1,8 +1,8 @@
#ifndef QTMATERIALSCROLLBAR_P_H
#define QTMATERIALSCROLLBAR_P_H
-#include
#include
+#include
class QtMaterialScrollBar;
class QtMaterialScrollBarStateMachine;
@@ -18,13 +18,13 @@ class QtMaterialScrollBarPrivate
void init();
- QtMaterialScrollBar *const q_ptr;
+ QtMaterialScrollBar *const q_ptr;
QtMaterialScrollBarStateMachine *stateMachine;
- QColor backgroundColor;
- QColor sliderColor;
- QColor canvasColor;
- bool hideOnMouseOut;
- bool useThemeColors;
+ QColor backgroundColor;
+ QColor sliderColor;
+ QColor canvasColor;
+ bool hideOnMouseOut;
+ bool useThemeColors;
};
-#endif // QTMATERIALSCROLLBAR_P_H
+#endif // QTMATERIALSCROLLBAR_P_H
diff --git a/components/qtmaterialslider.cpp b/components/qtmaterialslider.cpp
index a0d17dc12..8b1b1aaa8 100644
--- a/components/qtmaterialslider.cpp
+++ b/components/qtmaterialslider.cpp
@@ -1,10 +1,10 @@
#include "qtmaterialslider.h"
+#include "lib/qtmaterialstatetransitionevent.h"
+#include "lib/qtmaterialstyle.h"
+#include "qtmaterialslider_internal.h"
#include "qtmaterialslider_p.h"
-#include
#include
-#include "qtmaterialslider_internal.h"
-#include "lib/qtmaterialstyle.h"
-#include "lib/qtmaterialstatetransitionevent.h"
+#include
/*!
* \class QtMaterialSliderPrivate
@@ -16,33 +16,30 @@ QtMaterialSliderPrivate::QtMaterialSliderPrivate(QtMaterialSlider *q)
{
}
-QtMaterialSliderPrivate::~QtMaterialSliderPrivate()
-{
-}
+QtMaterialSliderPrivate::~QtMaterialSliderPrivate() {}
void QtMaterialSliderPrivate::init()
{
Q_Q(QtMaterialSlider);
- thumb = new QtMaterialSliderThumb(q);
- track = new QtMaterialSliderTrack(thumb, q);
- stateMachine = new QtMaterialSliderStateMachine(q, thumb, track);
- stepTo = 0;
- oldValue = q->value();
- trackWidth = 2;
- hoverTrack = false;
- hoverThumb = false;
- hover = false;
- step = false;
- pageStepMode = true;
+ thumb = new QtMaterialSliderThumb(q);
+ track = new QtMaterialSliderTrack(thumb, q);
+ stateMachine = new QtMaterialSliderStateMachine(q, thumb, track);
+ stepTo = 0;
+ oldValue = q->value();
+ trackWidth = 2;
+ hoverTrack = false;
+ hoverThumb = false;
+ hover = false;
+ step = false;
+ pageStepMode = true;
useThemeColors = true;
q->setMouseTracking(true);
q->setFocusPolicy(Qt::StrongFocus);
q->setPageStep(1);
- QSizePolicy sp(QSizePolicy::Expanding,
- QSizePolicy::Fixed);
+ QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);
if (q->orientation() == Qt::Vertical) {
sp.transpose();
@@ -59,24 +56,25 @@ QRectF QtMaterialSliderPrivate::trackBoundingRect() const
{
Q_Q(const QtMaterialSlider);
- qreal hw = static_cast(trackWidth)/2;
+ qreal hw = static_cast(trackWidth) / 2;
- return Qt::Horizontal == q->orientation()
- ? QRectF(QT_MATERIAL_SLIDER_MARGIN, q->height()/2 - hw,
- q->width() - QT_MATERIAL_SLIDER_MARGIN*2, hw*2)
- : QRectF(q->width()/2 - hw, QT_MATERIAL_SLIDER_MARGIN, hw*2,
- q->height() - QT_MATERIAL_SLIDER_MARGIN*2);
+ return Qt::Horizontal == q->orientation() ?
+ QRectF(QT_MATERIAL_SLIDER_MARGIN, q->height() / 2.0 - hw, q->width() - QT_MATERIAL_SLIDER_MARGIN * 2, hw * 2) :
+ QRectF(q->width() / 2.0 - hw, QT_MATERIAL_SLIDER_MARGIN, hw * 2, q->height() - QT_MATERIAL_SLIDER_MARGIN * 2);
}
QRectF QtMaterialSliderPrivate::thumbBoundingRect() const
{
Q_Q(const QtMaterialSlider);
- return Qt::Horizontal == q->orientation()
- ? QRectF(thumb->offset(), q->height()/2 - QT_MATERIAL_SLIDER_MARGIN,
- QT_MATERIAL_SLIDER_MARGIN*2, QT_MATERIAL_SLIDER_MARGIN*2)
- : QRectF(q->width()/2 - QT_MATERIAL_SLIDER_MARGIN, thumb->offset(),
- QT_MATERIAL_SLIDER_MARGIN*2, QT_MATERIAL_SLIDER_MARGIN*2);
+ return Qt::Horizontal == q->orientation() ? QRectF(thumb->offset(),
+ q->height() / 2.0 - QT_MATERIAL_SLIDER_MARGIN,
+ QT_MATERIAL_SLIDER_MARGIN * 2,
+ QT_MATERIAL_SLIDER_MARGIN * 2) :
+ QRectF(q->width() / 2.0 - QT_MATERIAL_SLIDER_MARGIN,
+ thumb->offset(),
+ QT_MATERIAL_SLIDER_MARGIN * 2,
+ QT_MATERIAL_SLIDER_MARGIN * 2);
}
int QtMaterialSliderPrivate::valueFromPosition(const QPoint &pos) const
@@ -85,16 +83,11 @@ int QtMaterialSliderPrivate::valueFromPosition(const QPoint &pos) const
const int position = Qt::Horizontal == q->orientation() ? pos.x() : pos.y();
- const int span = Qt::Horizontal == q->orientation()
- ? q->width() - QT_MATERIAL_SLIDER_MARGIN*2
- : q->height() - QT_MATERIAL_SLIDER_MARGIN*2;
+ const int span = Qt::Horizontal == q->orientation() ? q->width() - QT_MATERIAL_SLIDER_MARGIN * 2 :
+ q->height() - QT_MATERIAL_SLIDER_MARGIN * 2;
return QtMaterialStyle::sliderValueFromPosition(
- q->minimum(),
- q->maximum(),
- position - QT_MATERIAL_SLIDER_MARGIN,
- span,
- q->invertedAppearance());
+ q->minimum(), q->maximum(), position - QT_MATERIAL_SLIDER_MARGIN, span, q->invertedAppearance());
}
void QtMaterialSliderPrivate::setHovered(bool status)
@@ -123,15 +116,13 @@ void QtMaterialSliderPrivate::setHovered(bool status)
*/
QtMaterialSlider::QtMaterialSlider(QWidget *parent)
- : QAbstractSlider(parent),
- d_ptr(new QtMaterialSliderPrivate(this))
+ : QAbstractSlider(parent)
+ , d_ptr(new QtMaterialSliderPrivate(this))
{
d_func()->init();
}
-QtMaterialSlider::~QtMaterialSlider()
-{
-}
+QtMaterialSlider::~QtMaterialSlider() {}
void QtMaterialSlider::setUseThemeColors(bool value)
{
@@ -237,9 +228,7 @@ bool QtMaterialSlider::pageStepMode() const
*/
QSize QtMaterialSlider::minimumSizeHint() const
{
- return Qt::Horizontal == orientation()
- ? QSize(130, 34)
- : QSize(34, 130);
+ return Qt::Horizontal == orientation() ? QSize(130, 34) : QSize(34, 130);
}
void QtMaterialSlider::setInvertedAppearance(bool value)
@@ -256,16 +245,13 @@ void QtMaterialSlider::sliderChange(SliderChange change)
{
Q_D(QtMaterialSlider);
- if (SliderOrientationChange == change)
- {
+ if (SliderOrientationChange == change) {
QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);
if (orientation() == Qt::Vertical) {
sp.transpose();
}
setSizePolicy(sp);
- }
- else if (SliderValueChange == change)
- {
+ } else if (SliderValueChange == change) {
if (minimum() == value()) {
triggerAction(SliderToMinimum);
d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(SliderChangedToMinimum));
@@ -290,12 +276,9 @@ void QtMaterialSlider::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QtMaterialSlider);
- if (isSliderDown())
- {
+ if (isSliderDown()) {
setSliderPosition(d->valueFromPosition(event->pos()));
- }
- else
- {
+ } else {
QRectF track(d->trackBoundingRect().adjusted(-2, -2, 2, 2));
if (track.contains(event->pos()) != d->hoverTrack) {
@@ -344,9 +327,7 @@ void QtMaterialSlider::mousePressEvent(QMouseEvent *event)
d->step = true;
d->stepTo = d->valueFromPosition(pos);
- SliderAction action = d->stepTo > sliderPosition()
- ? SliderPageStepAdd
- : SliderPageStepSub;
+ SliderAction action = d->stepTo > sliderPosition() ? SliderPageStepAdd : SliderPageStepSub;
triggerAction(action);
setRepeatAction(action, 400, 8);
@@ -398,9 +379,7 @@ void QtMaterialSlider::updateThumbOffset()
minimum(),
maximum(),
sliderPosition(),
- Qt::Horizontal == orientation()
- ? width() - QT_MATERIAL_SLIDER_MARGIN*2
- : height() - QT_MATERIAL_SLIDER_MARGIN*2,
+ Qt::Horizontal == orientation() ? width() - QT_MATERIAL_SLIDER_MARGIN * 2 : height() - QT_MATERIAL_SLIDER_MARGIN * 2,
invertedAppearance());
d->thumb->setOffset(offset);
diff --git a/components/qtmaterialslider_internal.cpp b/components/qtmaterialslider_internal.cpp
index fd2d50bf8..de21627e9 100644
--- a/components/qtmaterialslider_internal.cpp
+++ b/components/qtmaterialslider_internal.cpp
@@ -1,37 +1,36 @@
#include "qtmaterialslider_internal.h"
-#include
+#include "lib/qtmaterialstatetransition.h"
+#include "lib/qtmaterialstyle.h"
+#include "qtmaterialslider.h"
#include
-#include
#include
-#include
#include
-#include "qtmaterialslider.h"
-#include "lib/qtmaterialstyle.h"
-#include "lib/qtmaterialstatetransition.h"
+#include
+#include
+#include
/*!
* \class QtMaterialSliderStateMachine
* \internal
*/
-QtMaterialSliderStateMachine::QtMaterialSliderStateMachine(
- QtMaterialSlider *slider,
- QtMaterialSliderThumb *thumb,
- QtMaterialSliderTrack *track)
- : QStateMachine(slider),
- m_slider(slider),
- m_thumb(thumb),
- m_track(track),
- m_topState(new QState(QState::ParallelStates)),
- m_fstState(new QState(m_topState)),
- m_sndState(new QState(m_topState)),
- m_inactiveState(new QState(m_fstState)),
- m_focusState(new QState(m_fstState)),
- m_slidingState(new QState(m_fstState)),
- m_pulseOutState(new QState(m_focusState)),
- m_pulseInState(new QState(m_focusState)),
- m_minState(new QState(m_sndState)),
- m_normalState(new QState(m_sndState))
+QtMaterialSliderStateMachine::QtMaterialSliderStateMachine(QtMaterialSlider *slider,
+ QtMaterialSliderThumb *thumb,
+ QtMaterialSliderTrack *track)
+ : QStateMachine(slider)
+ , m_slider(slider)
+ , m_thumb(thumb)
+ , m_track(track)
+ , m_topState(new QState(QState::ParallelStates))
+ , m_fstState(new QState(m_topState))
+ , m_sndState(new QState(m_topState))
+ , m_inactiveState(new QState(m_fstState))
+ , m_focusState(new QState(m_fstState))
+ , m_slidingState(new QState(m_fstState))
+ , m_pulseOutState(new QState(m_focusState))
+ , m_pulseInState(new QState(m_focusState))
+ , m_minState(new QState(m_sndState))
+ , m_normalState(new QState(m_sndState))
{
addState(m_topState);
setInitialState(m_topState);
@@ -197,9 +196,7 @@ QtMaterialSliderStateMachine::QtMaterialSliderStateMachine(
setupProperties();
}
-QtMaterialSliderStateMachine::~QtMaterialSliderStateMachine()
-{
-}
+QtMaterialSliderStateMachine::~QtMaterialSliderStateMachine() {}
void QtMaterialSliderStateMachine::setupProperties()
{
@@ -234,21 +231,19 @@ void QtMaterialSliderStateMachine::setupProperties()
*/
QtMaterialSliderThumb::QtMaterialSliderThumb(QtMaterialSlider *slider)
- : QtMaterialOverlayWidget(slider->parentWidget()),
- m_slider(slider),
- m_diameter(11),
- m_borderWidth(2),
- m_haloSize(0),
- m_offset(0)
+ : QtMaterialOverlayWidget(slider->parentWidget())
+ , m_slider(slider)
+ , m_diameter(11)
+ , m_borderWidth(2)
+ , m_haloSize(0)
+ , m_offset(0)
{
slider->installEventFilter(this);
setAttribute(Qt::WA_TransparentForMouseEvents, true);
}
-QtMaterialSliderThumb::~QtMaterialSliderThumb()
-{
-}
+QtMaterialSliderThumb::~QtMaterialSliderThumb() {}
bool QtMaterialSliderThumb::eventFilter(QObject *obj, QEvent *event)
{
@@ -274,12 +269,11 @@ void QtMaterialSliderThumb::paintEvent(QPaintEvent *event)
painter.setBrush(brush);
painter.setPen(Qt::NoPen);
- QPointF disp = Qt::Horizontal == m_slider->orientation()
- ? QPointF(QT_MATERIAL_SLIDER_MARGIN + m_offset, m_slider->height()/2)
- : QPointF(m_slider->width()/2, QT_MATERIAL_SLIDER_MARGIN + m_offset);
+ QPointF disp = Qt::Horizontal == m_slider->orientation() ?
+ QPointF(QT_MATERIAL_SLIDER_MARGIN + m_offset, m_slider->height() / 2.0) :
+ QPointF(m_slider->width() / 2.0, QT_MATERIAL_SLIDER_MARGIN + m_offset);
- QRectF halo((m_slider->pos() - QPointF(m_haloSize, m_haloSize)/2) + disp,
- QSizeF(m_haloSize, m_haloSize));
+ QRectF halo((m_slider->pos() - QPointF(m_haloSize, m_haloSize) / 2) + disp, QSizeF(m_haloSize, m_haloSize));
painter.setOpacity(0.15);
painter.drawEllipse(halo);
@@ -288,12 +282,8 @@ void QtMaterialSliderThumb::paintEvent(QPaintEvent *event)
const bool isMin = m_slider->value() == m_slider->minimum();
- brush.setColor(m_slider->isEnabled()
- ? m_fillColor
- : m_slider->disabledColor());
- painter.setBrush(!m_slider->isEnabled() && isMin
- ? Qt::NoBrush
- : brush);
+ brush.setColor(m_slider->isEnabled() ? m_fillColor : m_slider->disabledColor());
+ painter.setBrush(!m_slider->isEnabled() && isMin ? Qt::NoBrush : brush);
if (m_slider->isEnabled() || isMin) {
QPen pen;
@@ -304,11 +294,16 @@ void QtMaterialSliderThumb::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen);
}
- QRectF geometry = Qt::Horizontal == m_slider->orientation()
- ? QRectF(m_offset, m_slider->height()/2 - QT_MATERIAL_SLIDER_MARGIN,
- QT_MATERIAL_SLIDER_MARGIN*2, QT_MATERIAL_SLIDER_MARGIN*2).translated(m_slider->pos())
- : QRectF(m_slider->width()/2 - QT_MATERIAL_SLIDER_MARGIN, m_offset,
- QT_MATERIAL_SLIDER_MARGIN*2, QT_MATERIAL_SLIDER_MARGIN*2).translated(m_slider->pos());
+ QRectF geometry = Qt::Horizontal == m_slider->orientation() ? QRectF(m_offset,
+ m_slider->height() / 2.0 - QT_MATERIAL_SLIDER_MARGIN,
+ QT_MATERIAL_SLIDER_MARGIN * 2,
+ QT_MATERIAL_SLIDER_MARGIN * 2)
+ .translated(m_slider->pos()) :
+ QRectF(m_slider->width() / 2.0 - QT_MATERIAL_SLIDER_MARGIN,
+ m_offset,
+ QT_MATERIAL_SLIDER_MARGIN * 2,
+ QT_MATERIAL_SLIDER_MARGIN * 2)
+ .translated(m_slider->pos());
qreal s = m_slider->isEnabled() ? m_diameter : 7;
@@ -326,10 +321,10 @@ void QtMaterialSliderThumb::paintEvent(QPaintEvent *event)
*/
QtMaterialSliderTrack::QtMaterialSliderTrack(QtMaterialSliderThumb *thumb, QtMaterialSlider *slider)
- : QtMaterialOverlayWidget(slider->parentWidget()),
- m_slider(slider),
- m_thumb(thumb),
- m_trackWidth(2)
+ : QtMaterialOverlayWidget(slider->parentWidget())
+ , m_slider(slider)
+ , m_thumb(thumb)
+ , m_trackWidth(2)
{
slider->installEventFilter(this);
@@ -338,9 +333,7 @@ QtMaterialSliderTrack::QtMaterialSliderTrack(QtMaterialSliderThumb *thumb, QtMat
connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(update()));
}
-QtMaterialSliderTrack::~QtMaterialSliderTrack()
-{
-}
+QtMaterialSliderTrack::~QtMaterialSliderTrack() {}
bool QtMaterialSliderTrack::eventFilter(QObject *obj, QEvent *event)
{
@@ -360,28 +353,24 @@ void QtMaterialSliderTrack::paintEvent(QPaintEvent *event)
QBrush fg;
fg.setStyle(Qt::SolidPattern);
- fg.setColor(m_slider->isEnabled() ? m_slider->thumbColor()
- : m_slider->disabledColor());
+ fg.setColor(m_slider->isEnabled() ? m_slider->thumbColor() : m_slider->disabledColor());
QBrush bg;
bg.setStyle(Qt::SolidPattern);
- bg.setColor(m_slider->isEnabled() ? m_fillColor
- : m_slider->disabledColor());
+ bg.setColor(m_slider->isEnabled() ? m_fillColor : m_slider->disabledColor());
qreal offset = m_thumb->offset();
if (Qt::Horizontal == m_slider->orientation()) {
painter.translate(m_slider->x() + QT_MATERIAL_SLIDER_MARGIN,
- m_slider->y() + m_slider->height()/2
- - static_cast(m_trackWidth)/2);
+ m_slider->y() + m_slider->height() / 2.0 - static_cast(m_trackWidth) / 2.0);
} else {
- painter.translate(m_slider->x() + m_slider->width()/2
- - static_cast(m_trackWidth)/2,
+ painter.translate(m_slider->x() + m_slider->width() / 2.0 - static_cast(m_trackWidth) / 2.0,
m_slider->y() + QT_MATERIAL_SLIDER_MARGIN);
}
- QRectF geometry = Qt::Horizontal == m_slider->orientation()
- ? QRectF(0, 0, m_slider->width() - QT_MATERIAL_SLIDER_MARGIN*2, m_trackWidth)
- : QRectF(0, 0, m_trackWidth, m_slider->height() - QT_MATERIAL_SLIDER_MARGIN*2);
+ QRectF geometry = Qt::Horizontal == m_slider->orientation() ?
+ QRectF(0, 0, m_slider->width() - QT_MATERIAL_SLIDER_MARGIN * 2, m_trackWidth) :
+ QRectF(0, 0, m_trackWidth, m_slider->height() - QT_MATERIAL_SLIDER_MARGIN * 2);
QRectF bgRect;
QRectF fgRect;
diff --git a/components/qtmaterialslider_p.h b/components/qtmaterialslider_p.h
index ff6b7ca2b..baaf745f3 100644
--- a/components/qtmaterialslider_p.h
+++ b/components/qtmaterialslider_p.h
@@ -1,9 +1,9 @@
#ifndef QTMATERIALSLIDER_P_H
#define QTMATERIALSLIDER_P_H
-#include