From fe483bcaa4c5259777c7b1ea83772e041bea8738 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 30 Oct 2015 16:04:09 +0100 Subject: Add Material style Change-Id: I93662a53b42858a5b65154c5ede334182e738dde Reviewed-by: J-P Nurmi --- .../controls/material/ApplicationWindow.qml | 46 ++ src/imports/controls/material/BusyIndicator.qml | 71 ++ src/imports/controls/material/Button.qml | 99 +++ src/imports/controls/material/CheckBox.qml | 194 ++++++ src/imports/controls/material/Dial.qml | 78 +++ src/imports/controls/material/Drawer.qml | 58 ++ src/imports/controls/material/Frame.qml | 66 ++ src/imports/controls/material/GroupBox.qml | 83 +++ src/imports/controls/material/Label.qml | 46 ++ src/imports/controls/material/PageIndicator.qml | 75 ++ src/imports/controls/material/ProgressBar.qml | 102 +++ src/imports/controls/material/RadioButton.qml | 102 +++ src/imports/controls/material/RangeSlider.qml | 98 +++ src/imports/controls/material/Ripple.qml | 51 ++ src/imports/controls/material/ScrollBar.qml | 83 +++ src/imports/controls/material/ScrollIndicator.qml | 85 +++ src/imports/controls/material/Slider.qml | 86 +++ src/imports/controls/material/SliderHandle.qml | 66 ++ src/imports/controls/material/SpinBox.qml | 143 ++++ src/imports/controls/material/StackView.qml | 66 ++ src/imports/controls/material/SwipeView.qml | 64 ++ src/imports/controls/material/Switch.qml | 124 ++++ src/imports/controls/material/TabBar.qml | 76 ++ src/imports/controls/material/TabButton.qml | 75 ++ src/imports/controls/material/TextArea.qml | 93 +++ src/imports/controls/material/TextField.qml | 93 +++ src/imports/controls/material/ToolBar.qml | 52 ++ src/imports/controls/material/ToolButton.qml | 77 +++ src/imports/controls/material/Tumbler.qml | 82 +++ src/imports/controls/material/images/check.png | Bin 0 -> 670 bytes src/imports/controls/material/material.pri | 39 ++ src/imports/controls/material/material.pro | 18 + src/imports/controls/material/qmldir | 4 + .../material/qquickmaterialprogressring.cpp | 283 ++++++++ .../material/qquickmaterialprogressring_p.h | 94 +++ .../controls/material/qquickmaterialstyle.cpp | 765 +++++++++++++++++++++ .../controls/material/qquickmaterialstyle_p.h | 214 ++++++ .../material/qtquickmaterialstyleplugin.cpp | 64 ++ src/imports/controls/material/resources.qrc | 5 + src/imports/imports.pro | 1 + 40 files changed, 3921 insertions(+) create mode 100644 src/imports/controls/material/ApplicationWindow.qml create mode 100644 src/imports/controls/material/BusyIndicator.qml create mode 100644 src/imports/controls/material/Button.qml create mode 100644 src/imports/controls/material/CheckBox.qml create mode 100644 src/imports/controls/material/Dial.qml create mode 100644 src/imports/controls/material/Drawer.qml create mode 100644 src/imports/controls/material/Frame.qml create mode 100644 src/imports/controls/material/GroupBox.qml create mode 100644 src/imports/controls/material/Label.qml create mode 100644 src/imports/controls/material/PageIndicator.qml create mode 100644 src/imports/controls/material/ProgressBar.qml create mode 100644 src/imports/controls/material/RadioButton.qml create mode 100644 src/imports/controls/material/RangeSlider.qml create mode 100644 src/imports/controls/material/Ripple.qml create mode 100644 src/imports/controls/material/ScrollBar.qml create mode 100644 src/imports/controls/material/ScrollIndicator.qml create mode 100644 src/imports/controls/material/Slider.qml create mode 100644 src/imports/controls/material/SliderHandle.qml create mode 100644 src/imports/controls/material/SpinBox.qml create mode 100644 src/imports/controls/material/StackView.qml create mode 100644 src/imports/controls/material/SwipeView.qml create mode 100644 src/imports/controls/material/Switch.qml create mode 100644 src/imports/controls/material/TabBar.qml create mode 100644 src/imports/controls/material/TabButton.qml create mode 100644 src/imports/controls/material/TextArea.qml create mode 100644 src/imports/controls/material/TextField.qml create mode 100644 src/imports/controls/material/ToolBar.qml create mode 100644 src/imports/controls/material/ToolButton.qml create mode 100644 src/imports/controls/material/Tumbler.qml create mode 100644 src/imports/controls/material/images/check.png create mode 100644 src/imports/controls/material/material.pri create mode 100644 src/imports/controls/material/material.pro create mode 100644 src/imports/controls/material/qmldir create mode 100644 src/imports/controls/material/qquickmaterialprogressring.cpp create mode 100644 src/imports/controls/material/qquickmaterialprogressring_p.h create mode 100644 src/imports/controls/material/qquickmaterialstyle.cpp create mode 100644 src/imports/controls/material/qquickmaterialstyle_p.h create mode 100644 src/imports/controls/material/qtquickmaterialstyleplugin.cpp create mode 100644 src/imports/controls/material/resources.qrc (limited to 'src') diff --git a/src/imports/controls/material/ApplicationWindow.qml b/src/imports/controls/material/ApplicationWindow.qml new file mode 100644 index 00000000..bf8b62bc --- /dev/null +++ b/src/imports/controls/material/ApplicationWindow.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ApplicationWindow { + id: window + + color: Material.backgroundColor +} diff --git a/src/imports/controls/material/BusyIndicator.qml b/src/imports/controls/material/BusyIndicator.qml new file mode 100644 index 00000000..6d5e4e8d --- /dev/null +++ b/src/imports/controls/material/BusyIndicator.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.BusyIndicator { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding + + padding: 6 + + //! [contentItem] + contentItem: ProgressRing { + id: ring + x: control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + implicitWidth: 48 + implicitHeight: 48 + width: size + height: size + opacity: control.running ? 1 : 0 + color: control.Material.accentColor + + readonly property real size: Math.min(control.availableWidth, control.availableHeight) + + Behavior on opacity { OpacityAnimator { duration: 250 } } + + RingAnimator { + target: ring + running: control.visible && control.running + } + } + //! [contentItem] +} diff --git a/src/imports/controls/material/Button.qml b/src/imports/controls/material/Button.qml new file mode 100644 index 00000000..2ffcd056 --- /dev/null +++ b/src/imports/controls/material/Button.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 +import QtGraphicalEffects 1.0 + +T.Button { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + label ? label.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + label ? label.implicitHeight + topPadding + bottomPadding : 0) + + padding: 6 + leftPadding: 8 + rightPadding: 8 + + //! [label] + label: Text { + x: control.leftPadding + y: control.topPadding + width: control.availableWidth + height: control.availableHeight + + text: control.text + color: control.Material.primaryTextColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + //! [label] + + //! [background] + background: Rectangle { + implicitWidth: 36 + implicitHeight: 36 + + radius: 2 + color: !control.enabled ? control.Material.raisedButtonDisabledColor : + (control.pressed ? control.Material.raisedButtonPressColor : + (control.activeFocus ? control.Material.raisedButtonHoverColor : control.Material.raisedButtonColor)) + + Behavior on color { + ColorAnimation { + duration: 400 + } + } + + layer.enabled: control.enabled + layer.effect: DropShadow { + verticalOffset: 1 + color: control.Material.dropShadowColor + samples: control.pressed ? 15 : 9 + spread: 0.5 + + // TODO: Doesn't work because of QTBUG-49072 + Behavior on radius { + NumberAnimation { duration: 1000 } + } + } + } + //! [background] +} diff --git a/src/imports/controls/material/CheckBox.qml b/src/imports/controls/material/CheckBox.qml new file mode 100644 index 00000000..efba23d4 --- /dev/null +++ b/src/imports/controls/material/CheckBox.qml @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.CheckBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 6 + spacing: 6 + + //! [indicator] + indicator: Rectangle { + id: indicatorItem + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + implicitWidth: 20 + implicitHeight: 20 + border.color: control.Material.secondaryTextColor + radius: 2 + + Component.onCompleted: { + color = control.checked || control.pressed ? control.Material.accentColor : "transparent"; + border.width = control.checked || control.pressed ? 0 : 2; + } + + Ripple { + width: parent.width + height: width + control: control + colored: control.checked + opacity: control.pressed ? 1 : 0 + } + + // TODO: This needs to be transparent + Image { + id: checkImage + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + source: "qrc:/images/check.png" + fillMode: Image.PreserveAspectFit + + Component.onCompleted: { + width = control.checked || control.pressed ? 16 : 0; + height = control.checked || control.pressed ? 16 : 0; + } + } + + Connections { + target: control + onCheckedChanged: { + pressScaleAnimation.start(); + if (control.checked) + checkedAnimation.start(); + else + uncheckedAnimation.start(); + } + } + + SequentialAnimation { + id: pressScaleAnimation + + NumberAnimation { + target: indicatorItem + property: "scale" + // Go down 2 pixels in size. + to: 1 - 2 / indicatorItem.width + duration: 120 + } + NumberAnimation { + target: indicatorItem + property: "scale" + to: 1 + duration: 120 + } + } + + SequentialAnimation { + id: checkedAnimation + + PropertyAction { + target: indicatorItem.border + property: "color" + value: control.Material.accentColor + } + NumberAnimation { + target: indicatorItem.border + property: "width" + from: 2 + to: indicatorItem.width / 2 + easing.type: Easing.OutCubic + duration: 100 + } + NumberAnimation { + target: checkImage + properties: "width, height" + from: 0 + to: 16 + duration: 100 + } + } + + SequentialAnimation { + id: uncheckedAnimation + + PropertyAction { + target: indicatorItem.border + property: "color" + value: control.Material.secondaryTextColor + } + NumberAnimation { + target: checkImage + properties: "width, height" + from: 16 + to: 0 + duration: 100 + } + NumberAnimation { + target: indicatorItem.border + property: "width" + from: indicatorItem.width / 2 + to: 2 + easing.type: Easing.OutCubic + duration: 100 + } + PropertyAction { + target: indicatorItem + property: "color" + value: "transparent" + } + } + } + //! [indicator] + + //! [label] + label: Text { + x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing) + y: control.topPadding + width: control.availableWidth - indicator.width - control.spacing + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] +} diff --git a/src/imports/controls/material/Dial.qml b/src/imports/controls/material/Dial.qml new file mode 100644 index 00000000..d3f6bb65 --- /dev/null +++ b/src/imports/controls/material/Dial.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Dial { + id: control + + implicitWidth: 100 + implicitHeight: 100 + + //! [background] + background: Rectangle { + color: "transparent" + radius: width / 2 + + border.color: control.enabled ? control.Material.accentColor : control.Material.hintTextColor + } + //! [background] + + //! [handle] + handle: Rectangle { + id: handleItem + + x: background.width / 2 - handle.width / 2 + y: background.height / 2 - handle.height / 2 + transform: [ + Translate { + y: -background.height * 0.35 + }, + Rotation { + angle: control.angle + origin.x: handle.width / 2 + origin.y: handle.height / 2 + } + ] + implicitWidth: 14 + implicitHeight: 14 + radius: width / 2 + color: control.enabled ? control.Material.accentColor : control.Material.hintTextColor + } + //! [handle] +} diff --git a/src/imports/controls/material/Drawer.qml b/src/imports/controls/material/Drawer.qml new file mode 100644 index 00000000..baaa4453 --- /dev/null +++ b/src/imports/controls/material/Drawer.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Drawer { + id: control + + width: parent ? parent.width : 0 // TODO: Window.width + height: parent ? parent.height : 0 // TODO: Window.height + + //! [background] + background: Rectangle { + color: control.Material.drawerBackgroundColor + opacity: position * 0.75 + } + //! [background] + + // TODO: make this a proper transition + animation: SmoothedAnimation { + velocity: 5 + } +} diff --git a/src/imports/controls/material/Frame.qml b/src/imports/controls/material/Frame.qml new file mode 100644 index 00000000..3b4c8bd5 --- /dev/null +++ b/src/imports/controls/material/Frame.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Frame { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0 + contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0 + + padding: 6 + + //! [contentItem] + contentItem: Item { } + //! [contentItem] + + //! [frame] + frame: Rectangle { + width: parent.width + height: parent.height + + radius: 3 + color: "transparent" + border.color: control.Material.frameColor + } + //! [frame] +} diff --git a/src/imports/controls/material/GroupBox.qml b/src/imports/controls/material/GroupBox.qml new file mode 100644 index 00000000..de47ff14 --- /dev/null +++ b/src/imports/controls/material/GroupBox.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.GroupBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0 + contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0 + + spacing: 6 + padding: 6 + topPadding: 6 + (label && title ? label.implicitHeight + spacing : 0) + + //! [contentItem] + contentItem: Item {} + //! [contentItem] + + //! [label] + label: Text { + x: control.leftPadding + width: control.availableWidth + + text: control.title + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] + + //! [frame] + frame: Rectangle { + y: control.topPadding - control.padding + width: parent.width + height: parent.height - control.topPadding + control.padding + + radius: 3 + color: "transparent" + border.color: control.Material.frameColor + } + //! [frame] +} diff --git a/src/imports/controls/material/Label.qml b/src/imports/controls/material/Label.qml new file mode 100644 index 00000000..3d8952f2 --- /dev/null +++ b/src/imports/controls/material/Label.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Label { + id: control + + color: Material.primaryTextColor + linkColor: Material.accentColor +} diff --git a/src/imports/controls/material/PageIndicator.qml b/src/imports/controls/material/PageIndicator.qml new file mode 100644 index 00000000..1d646f97 --- /dev/null +++ b/src/imports/controls/material/PageIndicator.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.PageIndicator { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + + padding: 6 + spacing: 6 + + //! [delegate] + delegate: Rectangle { + implicitWidth: 8 + implicitHeight: 8 + + radius: width / 2 + color: control.Material.primaryTextColor + + opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45 + Behavior on opacity { OpacityAnimator { duration: 100 } } + } + //! [delegate] + + //! [contentItem] + contentItem: Row { + spacing: control.spacing + + Repeater { + model: control.count + delegate: control.delegate + } + } + //! [contentItem] +} diff --git a/src/imports/controls/material/ProgressBar.qml b/src/imports/controls/material/ProgressBar.qml new file mode 100644 index 00000000..34e1aaea --- /dev/null +++ b/src/imports/controls/material/ProgressBar.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ProgressBar { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + indicator ? indicator.implicitWidth : 0) + leftPadding + rightPadding + implicitHeight: Math.max(background ? background.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding + + padding: 6 + + //! [indicator] + indicator: Item { + x: control.leftPadding + y: control.topPadding + width: control.availableWidth + height: control.availableHeight + + scale: control.mirrored ? -1 : 1 + + Repeater { + model: indeterminate ? 2 : 1 + + Rectangle { + property real offset: indeterminate ? 0 : control.position + + x: (indeterminate ? offset * parent.width : 0) + y: (parent.height - height) / 2 + width: offset * (parent.width - x) + height: 6 + + color: control.Material.accentColor + + SequentialAnimation on offset { + loops: Animation.Infinite + running: indeterminate && visible + PauseAnimation { duration: index ? 520 : 0 } + NumberAnimation { + easing.type: Easing.OutCubic + duration: 1240 + from: 0 + to: 1 + } + PauseAnimation { duration: index ? 0 : 520 } + } + } + } + } + //! [indicator] + + //! [background] + background: Rectangle { + implicitWidth: 200 + implicitHeight: 6 + x: control.leftPadding + y: control.topPadding + (control.availableHeight - height) / 2 + width: control.availableWidth + height: 6 + + color: Qt.rgba(control.Material.accentColor.r, control.Material.accentColor.g, control.Material.accentColor.b, 0.25) + } + //! [background] +} diff --git a/src/imports/controls/material/RadioButton.qml b/src/imports/controls/material/RadioButton.qml new file mode 100644 index 00000000..4e07e0e4 --- /dev/null +++ b/src/imports/controls/material/RadioButton.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.RadioButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 6 + spacing: 6 + + //! [indicator] + indicator: Rectangle { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + implicitWidth: 20 + implicitHeight: 20 + radius: width / 2 + border.width: 2 + border.color: control.checked || control.pressed ? control.Material.accentColor : control.Material.secondaryTextColor + color: "transparent" + + Ripple { + width: parent.width + height: width + control: control + colored: control.checked + opacity: control.pressed ? 1 : 0 + } + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 10 + height: 10 + radius: width / 2 + color: parent.border.color + visible: control.checked || control.pressed + } + } + //! [indicator] + + //! [label] + label: Text { + x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing) + y: control.topPadding + width: control.availableWidth - indicator.width - control.spacing + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] +} diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml new file mode 100644 index 00000000..bf8c16ef --- /dev/null +++ b/src/imports/controls/material/RangeSlider.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.RangeSlider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(track ? track.implicitWidth : 0, + first.handle ? first.handle.implicitWidth : 0, + second.handle ? second.handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(track ? track.implicitHeight : 0, + first.handle ? first.handle.implicitHeight : 0, + second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 6 + + //! [firstHandle] + first.handle: SliderHandle { + x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) + value: first.value + handleHasFocus: activeFocus + handlePressed: first.pressed + } + //! [firstHandle] + + //! [secondHandle] + second.handle: SliderHandle { + x: control.leftPadding + (horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) + value: second.value + handleHasFocus: activeFocus + handlePressed: second.pressed + } + //! [secondHandle] + + //! [track] + track: Rectangle { + x: control.leftPadding + (horizontal ? 0 : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : 0) + implicitWidth: horizontal ? 200 : 1 + implicitHeight: horizontal ? 1 : 200 + width: horizontal ? control.availableWidth : implicitWidth + height: horizontal ? implicitHeight : control.availableHeight + color: control.Material.primaryTextColor + scale: horizontal && control.mirrored ? -1 : 1 + + readonly property bool horizontal: control.orientation === Qt.Horizontal + + Rectangle { + x: parent.horizontal ? control.first.position * parent.width : -1 + y: parent.horizontal ? -1 : control.second.visualPosition * parent.height + 3 + width: parent.horizontal ? control.second.position * parent.width - control.first.position * parent.width - 3 : 3 + height: parent.horizontal ? 3 : control.second.position * parent.height - control.first.position * parent.height - 3 + + color: control.Material.accentColor + } + } + //! [track] +} diff --git a/src/imports/controls/material/Ripple.qml b/src/imports/controls/material/Ripple.qml new file mode 100644 index 00000000..a8fd27e8 --- /dev/null +++ b/src/imports/controls/material/Ripple.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.controls.material 1.0 + +Rectangle { + property Item control + property bool colored: false + + radius: width / 2 + scale: 2.5 + color: colored ? control.Material.checkBoxCheckedRippleColor : control.Material.checkBoxUncheckedRippleColor + + Behavior on opacity { + NumberAnimation {} + } +} diff --git a/src/imports/controls/material/ScrollBar.qml b/src/imports/controls/material/ScrollBar.qml new file mode 100644 index 00000000..539b9243 --- /dev/null +++ b/src/imports/controls/material/ScrollBar.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ScrollBar { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + handle.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + handle.implicitHeight + topPadding + bottomPadding) + + padding: 2 + + //! [handle] + handle: Rectangle { + id: handle + + implicitWidth: 4 + implicitHeight: 4 + + color: control.pressed ? control.Material.scrollBarPressedColor : control.Material.scrollBarColor + visible: control.size < 1.0 + opacity: 0.0 + + readonly property bool horizontal: control.orientation === Qt.Horizontal + x: control.leftPadding + (horizontal ? control.position * control.width : 0) + y: control.topPadding + (horizontal ? 0 : control.position * control.height) + width: horizontal ? control.size * control.availableWidth : implicitWidth + height: horizontal ? implicitHeight : control.size * control.availableHeight + + states: State { + name: "active" + when: control.active + PropertyChanges { target: handle; opacity: 0.75 } + } + + transitions: Transition { + from: "active" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 } + } + } + } + //! [handle] +} diff --git a/src/imports/controls/material/ScrollIndicator.qml b/src/imports/controls/material/ScrollIndicator.qml new file mode 100644 index 00000000..f92b366f --- /dev/null +++ b/src/imports/controls/material/ScrollIndicator.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ScrollIndicator { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + indicator.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + indicator.implicitHeight + topPadding + bottomPadding) + + padding: 2 + + //! [indicator] + indicator: Rectangle { + id: indicator + + implicitWidth: 4 + implicitHeight: 4 + + color: control.Material.scrollBarColor + visible: control.size < 1.0 + opacity: 0.0 + + readonly property bool horizontal: control.orientation === Qt.Horizontal + x: control.leftPadding + (horizontal ? control.position * control.width : 0) + y: control.topPadding + (horizontal ? 0 : control.position * control.height) + width: horizontal ? control.size * control.availableWidth : implicitWidth + height: horizontal ? implicitHeight : control.size * control.availableHeight + + states: State { + name: "active" + when: control.active + PropertyChanges { target: indicator; opacity: 0.75 } + } + + transitions: [ + Transition { + from: "active" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { target: indicator; duration: 200; property: "opacity"; to: 0.0 } + } + } + ] + } + //! [indicator] +} diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml new file mode 100644 index 00000000..139c9151 --- /dev/null +++ b/src/imports/controls/material/Slider.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Slider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(track ? track.implicitWidth : 0, + handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(track ? track.implicitHeight : 0, + handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 6 + + //! [handle] + handle: SliderHandle { + x: control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) + value: control.value + handleHasFocus: control.activeFocus + handlePressed: control.pressed + } + //! [handle] + + //! [track] + track: Rectangle { + x: control.leftPadding + (horizontal ? 0 : (control.availableWidth - width) / 2) + y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : 0) + implicitWidth: horizontal ? 200 : 1 + implicitHeight: horizontal ? 1 : 200 + width: horizontal ? control.availableWidth : implicitWidth + height: horizontal ? 1 : control.position * implicitHeight - 4 + color: control.Material.primaryTextColor + scale: horizontal && control.mirrored ? -1 : 1 + + readonly property bool horizontal: control.orientation === Qt.Horizontal + + Rectangle { + x: 0 + y: parent.horizontal ? -1 : control.visualPosition * parent.height + 3 + width: parent.horizontal ? control.position * parent.width : 3 + height: parent.horizontal ? 3 : control.availableHeight + + color: control.Material.accentColor + } + } + //! [track] +} diff --git a/src/imports/controls/material/SliderHandle.qml b/src/imports/controls/material/SliderHandle.qml new file mode 100644 index 00000000..dc1a836d --- /dev/null +++ b/src/imports/controls/material/SliderHandle.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.controls.material 1.0 + +Item { + id: root + implicitWidth: initialSize + implicitHeight: initialSize + + property real value: 0 + property bool handleHasFocus: false + property bool handlePressed: false + readonly property int initialSize: 13 + readonly property bool horizontal: control.orientation === Qt.Horizontal + readonly property var control: parent + + Rectangle { + id: handleRect + width: parent.width + height: parent.height + radius: width / 2 + color: root.control.Material.accentColor + scale: root.handlePressed || root.handleHasFocus ? 1.5 : 1 + + Behavior on scale { + NumberAnimation { + duration: 250 + } + } + } +} diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml new file mode 100644 index 00000000..3020efae --- /dev/null +++ b/src/imports/controls/material/SpinBox.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtGraphicalEffects 1.0 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.SpinBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + 2 * padding + + (up.indicator ? up.indicator.implicitWidth : 0) + + (down.indicator ? down.indicator.implicitWidth : 0)) + implicitHeight: Math.max(contentItem.implicitHeight + topPadding + bottomPadding, + background ? background.implicitHeight : 0, + up.indicator ? up.indicator.implicitHeight : 0, + down.indicator ? down.indicator.implicitHeight : 0) + + padding: 6 + leftPadding: 6 + (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0)) + rightPadding: 6 + (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0)) + + //! [validator] + validator: IntValidator { + locale: control.locale.name + bottom: Math.min(control.from, control.to) + top: Math.max(control.from, control.to) + } + //! [validator] + + //! [contentItem] + contentItem: TextInput { + text: control.textFromValue(control.value, control.locale) + + font: control.font + color: control.Material.primaryTextColor + selectionColor: control.Material.textSelectionColor + selectedTextColor: control.Material.primaryTextColor + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + + validator: control.validator + inputMethodHints: Qt.ImhFormattedNumbersOnly + } + //! [contentItem] + + //! [up.indicator] + up.indicator: Rectangle { + x: control.mirrored ? 0 : parent.width - width + implicitWidth: 26 + height: parent.height + radius: 3 + color: Qt.tint(Qt.tint(control.Material.raisedButtonColor, + control.activeFocus ? control.Material.raisedButtonHoverColor : "transparent"), + control.up.pressed ? control.Material.raisedButtonPressColor: "transparent") + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: Math.min(parent.width / 3, parent.width / 3) + height: 2 + color: control.Material.primaryTextColor + } + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 2 + height: Math.min(parent.width / 3, parent.width / 3) + color: control.Material.primaryTextColor + } + } + //! [up.indicator] + + //! [down.indicator] + down.indicator: Rectangle { + x: control.mirrored ? parent.width - width : 0 + implicitWidth: 26 + height: parent.height + radius: 3 + color: Qt.tint(Qt.tint(control.Material.raisedButtonColor, + control.activeFocus ? control.Material.raisedButtonHoverColor : "transparent"), + control.down.pressed ? control.Material.raisedButtonPressColor : "transparent") + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 3 + height: 2 + color: control.Material.primaryTextColor + } + } + //! [down.indicator] + + //! [background] + background: Item { + implicitWidth: 100 + implicitHeight: 26 + + Rectangle { + x: parent.width / 2 - width / 2 + y: parent.y + parent.height - height + width: Math.max(26, control.contentItem.implicitWidth) + height: control.activeFocus ? 2 : 1 + color: control.activeFocus ? control.Material.accentColor : control.Material.hintTextColor + } + } + //! [background] +} diff --git a/src/imports/controls/material/StackView.qml b/src/imports/controls/material/StackView.qml new file mode 100644 index 00000000..5fdcf969 --- /dev/null +++ b/src/imports/controls/material/StackView.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.4 +import Qt.labs.templates 1.0 as T + +T.StackView { + id: root + + //! [popEnter] + popEnter: Transition { + NumberAnimation { property: "x"; from: -root.width; to: 0; duration: 400; easing.type: Easing.OutCubic } + } + //! [popEnter] + + //! [popExit] + popExit: Transition { + NumberAnimation { property: "x"; from: 0; to: root.width; duration: 400; easing.type: Easing.OutCubic } + } + //! [popExit] + + //! [pushEnter] + pushEnter: Transition { + NumberAnimation { property: "x"; from: root.width; to: 0; duration: 400; easing.type: Easing.OutCubic } + } + //! [pushEnter] + + //! [pushExit] + pushExit: Transition { + NumberAnimation { property: "x"; from: 0; to: -root.width; duration: 400; easing.type: Easing.OutCubic } + } + //! [pushExit] +} diff --git a/src/imports/controls/material/SwipeView.qml b/src/imports/controls/material/SwipeView.qml new file mode 100644 index 00000000..00655bcb --- /dev/null +++ b/src/imports/controls/material/SwipeView.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T + +T.SwipeView { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + + //! [contentItem] + contentItem: ListView { + model: control.contentModel + currentIndex: control.currentIndex + + spacing: control.spacing + orientation: Qt.Horizontal + snapMode: ListView.SnapOneItem + boundsBehavior: Flickable.StopAtBounds + + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: 0 + preferredHighlightEnd: 0 + highlightMoveDuration: 250 + } + //! [contentItem] +} diff --git a/src/imports/controls/material/Switch.qml b/src/imports/controls/material/Switch.qml new file mode 100644 index 00000000..75aeb566 --- /dev/null +++ b/src/imports/controls/material/Switch.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.controls.material 1.0 +import Qt.labs.templates 1.0 as T +import QtGraphicalEffects 1.0 + +T.Switch { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (label ? label.implicitWidth : 0) + + (indicator ? indicator.implicitWidth : 0) + + (label && indicator ? spacing : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(label ? label.implicitHeight : 0, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + + padding: 6 + spacing: 6 + + //! [indicator] + indicator: Item { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + implicitWidth: 40 + implicitHeight: 20 + + Ripple { + x: handle.x + handle.width / 2 - width / 2 + y: handle.y + handle.height / 2 - height / 2 + width: handle.width - 4 + height: width + control: control + colored: control.checked + opacity: control.pressed ? 1 : 0 + } + + Rectangle { + width: parent.width + height: 16 + radius: height / 2 + y: parent.height / 2 - height / 2 + color: control.enabled ? (control.checked ? control.Material.switchCheckedTrackColor : control.Material.switchUncheckedTrackColor) + : control.Material.switchDisabledTrackColor + } + + Rectangle { + id: handle + x: Math.max(0, Math.min(parent.width - width, control.visualPosition * parent.width - (width / 2))) + y: (parent.height - height) / 2 + width: 24 + height: 24 + radius: width / 2 + color: control.enabled ? (control.checked ? control.Material.switchCheckedHandleColor : control.Material.switchUncheckedHandleColor) + : control.Material.switchDisabledHandleColor + layer.enabled: true + layer.effect: DropShadow { + verticalOffset: 1 + color: control.Material.dropShadowColor + spread: 0.3 + } + + Behavior on x { + enabled: !control.pressed + SmoothedAnimation { + duration: 300 + } + } + } + } + //! [indicator] + + //! [label] + label: Text { + x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing) + y: control.topPadding + width: control.availableWidth - indicator.width - control.spacing + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + //! [label] +} diff --git a/src/imports/controls/material/TabBar.qml b/src/imports/controls/material/TabBar.qml new file mode 100644 index 00000000..4aaef818 --- /dev/null +++ b/src/imports/controls/material/TabBar.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.TabBar { + id: control + + implicitWidth: Math.max(26, contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(26, contentItem.implicitHeight + topPadding + bottomPadding) + + spacing: 1 + + //! [contentItem] + contentItem: ListView { + implicitWidth: contentWidth + implicitHeight: contentHeight + + model: control.contentModel + currentIndex: control.currentIndex + + spacing: control.spacing + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + + highlightMoveDuration: 250 + highlightResizeDuration: 0 + highlightFollowsCurrentItem: true + highlight: Item { + z: 2 + Rectangle { + height: 2 + width: parent.width + y: parent.height - height + color: control.Material.accentColor + } + } + } + //! [contentItem] +} diff --git a/src/imports/controls/material/TabButton.qml b/src/imports/controls/material/TabButton.qml new file mode 100644 index 00000000..62bf4bb7 --- /dev/null +++ b/src/imports/controls/material/TabButton.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.TabButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + label ? label.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + label ? label.implicitHeight + topPadding + bottomPadding : 0) + + padding: 6 + + font.pointSize: 10 + + //! [label] + label: Text { + x: control.leftPadding + y: control.topPadding + width: control.availableWidth + height: control.availableHeight + + text: control.text + font: control.font + elide: Text.ElideRight + color: !control.enabled ? control.Material.hintTextColor : control.pressed || control.checked ? control.Material.accentColor : control.Material.primaryTextColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + //! [label] + + //! [background] + background: Item { + height: parent.height - 1 + implicitHeight: 26 + } + //! [background] +} diff --git a/src/imports/controls/material/TextArea.qml b/src/imports/controls/material/TextArea.qml new file mode 100644 index 00000000..4f5c7491 --- /dev/null +++ b/src/imports/controls/material/TextArea.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.TextArea { + id: control + + implicitWidth: Math.max(contentWidth + leftPadding + rightPadding, + background ? background.implicitWidth : 0, + placeholder.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(contentHeight + topPadding + bottomPadding, + background ? background.implicitHeight : 0, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 6 + + color: enabled ? Material.primaryTextColor : Material.hintTextColor +// selectionColor: Theme.selectionColor +// selectedTextColor: Theme.selectedTextColor + cursorDelegate: Rectangle { + color: control.Material.accentColor + width: 2 + + Timer { + running: true + repeat: true + interval: 500 + onTriggered: parent.visible = !parent.visible + } + } + + //! [placeholder] + Text { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + text: control.placeholderText + font: control.font + color: control.Material.hintTextColor + horizontalAlignment: control.horizontalAlignment + verticalAlignment: control.verticalAlignment + elide: Text.ElideRight + visible: !control.length && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + } + //! [placeholder] + + //! [background] + background: Rectangle { + y: control.y + control.height - height + implicitWidth: 120 + height: control.activeFocus ? 2 : 1 + color: control.activeFocus ? control.Material.accentColor : control.Material.hintTextColor + } + //! [background] +} diff --git a/src/imports/controls/material/TextField.qml b/src/imports/controls/material/TextField.qml new file mode 100644 index 00000000..d5c944a9 --- /dev/null +++ b/src/imports/controls/material/TextField.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.TextField { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + placeholder.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 6 + + color: enabled ? Material.primaryTextColor : Material.hintTextColor +// selectionColor: Theme.selectionColor +// selectedTextColor: Theme.selectedTextColor + verticalAlignment: TextInput.AlignVCenter + cursorDelegate: Rectangle { + color: control.Material.accentColor + width: 2 + + Timer { + running: true + repeat: true + interval: 500 + onTriggered: parent.visible = !parent.visible + } + } + + //! [placeholder] + Text { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + text: control.placeholderText + font: control.font + color: control.Material.hintTextColor + horizontalAlignment: control.horizontalAlignment + verticalAlignment: control.verticalAlignment + elide: Text.ElideRight + visible: !control.displayText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + + } + //! [placeholder] + + //! [background] + background: Rectangle { + y: control.y + control.height - height + implicitWidth: 120 + height: control.activeFocus ? 2 : 1 + color: control.activeFocus ? control.Material.accentColor : control.Material.hintTextColor + } + //! [background] +} diff --git a/src/imports/controls/material/ToolBar.qml b/src/imports/controls/material/ToolBar.qml new file mode 100644 index 00000000..59a0e599 --- /dev/null +++ b/src/imports/controls/material/ToolBar.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T + +T.ToolBar { + id: control + + implicitWidth: contentWidth + leftPadding + rightPadding + implicitHeight: Math.max(26, contentHeight + topPadding + bottomPadding) + + contentWidth: contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0 + contentHeight: contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0 + + //! [contentItem] + contentItem: Item { } + //! [contentItem] +} diff --git a/src/imports/controls/material/ToolButton.qml b/src/imports/controls/material/ToolButton.qml new file mode 100644 index 00000000..5f422e32 --- /dev/null +++ b/src/imports/controls/material/ToolButton.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.ToolButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + label ? label.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + label ? label.implicitHeight + topPadding + bottomPadding : 0) + + padding: 6 + + //! [label] + label: Text { + x: control.leftPadding + y: control.topPadding + width: control.availableWidth + height: control.availableHeight + + text: control.text + font: control.font + color: control.enabled ? control.Material.primaryTextColor : control.Material.hintTextColor + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + //! [label] + + //! [background] + background: Rectangle { + implicitWidth: 26 + implicitHeight: 26 + + color: control.activeFocus || (control.checkable && control.checked) + ? control.Material.flatButtonFocusColor : control.Material.flatButtonPressColor + visible: control.pressed || control.activeFocus || (control.checkable && control.checked) + } + //! [background] +} diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml new file mode 100644 index 00000000..e5b930a8 --- /dev/null +++ b/src/imports/controls/material/Tumbler.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.controls 1.0 +import Qt.labs.templates 1.0 as T +import Qt.labs.controls.material 1.0 + +T.Tumbler { + id: control + implicitWidth: 60 + implicitHeight: 200 + + //! [delegate] + delegate: Text { + id: label + text: modelData + color: control.Material.primaryTextColor + font: control.font + opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + //! [delegate] + + //! [contentItem] + contentItem: PathView { + id: pathView + model: control.model + delegate: control.delegate + clip: true + pathItemCount: control.visibleItemCount + 1 + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + dragMargin: width / 2 + + path: Path { + startX: pathView.width / 2 + startY: -pathView.delegateHeight / 2 + PathLine { + x: pathView.width / 2 + y: pathView.pathItemCount * pathView.delegateHeight - pathView.delegateHeight / 2 + } + } + + property real delegateHeight: control.availableHeight / control.visibleItemCount + } + //! [contentItem] +} diff --git a/src/imports/controls/material/images/check.png b/src/imports/controls/material/images/check.png new file mode 100644 index 00000000..6bd4283e Binary files /dev/null and b/src/imports/controls/material/images/check.png differ diff --git a/src/imports/controls/material/material.pri b/src/imports/controls/material/material.pri new file mode 100644 index 00000000..c71256da --- /dev/null +++ b/src/imports/controls/material/material.pri @@ -0,0 +1,39 @@ +HEADERS += \ + $$PWD/qquickmaterialstyle_p.h \ + $$PWD/qquickmaterialprogressring_p.h + +SOURCES += \ + $$PWD/qtquickmaterialstyleplugin.cpp \ + $$PWD/qquickmaterialstyle.cpp \ + $$PWD/qquickmaterialprogressring.cpp + +QML_FILES += \ + $$PWD/ApplicationWindow.qml \ + $$PWD/BusyIndicator.qml \ + $$PWD/Button.qml \ + $$PWD/CheckBox.qml \ + $$PWD/Dial.qml \ + $$PWD/Drawer.qml \ + $$PWD/Frame.qml \ + $$PWD/GroupBox.qml \ + $$PWD/Label.qml \ + $$PWD/PageIndicator.qml \ + $$PWD/ProgressBar.qml \ + $$PWD/RadioButton.qml \ + $$PWD/RangeSlider.qml \ + $$PWD/Ripple.qml \ + $$PWD/ScrollBar.qml \ + $$PWD/ScrollIndicator.qml \ + $$PWD/Slider.qml \ + $$PWD/SliderHandle.qml \ + $$PWD/SpinBox.qml \ + $$PWD/StackView.qml \ + $$PWD/SwipeView.qml \ + $$PWD/Switch.qml \ + $$PWD/TabBar.qml \ + $$PWD/TabButton.qml \ + $$PWD/TextArea.qml \ + $$PWD/TextField.qml \ + $$PWD/ToolBar.qml \ + $$PWD/ToolButton.qml \ + $$PWD/Tumbler.qml diff --git a/src/imports/controls/material/material.pro b/src/imports/controls/material/material.pro new file mode 100644 index 00000000..4c456665 --- /dev/null +++ b/src/imports/controls/material/material.pro @@ -0,0 +1,18 @@ +TARGET = qtquickmaterialstyleplugin +TARGETPATH = Qt/labs/controls/material +IMPORT_VERSION = 1.0 + +QT += qml quick +QT_PRIVATE += core-private gui-private qml-private quick-private + +OTHER_FILES += \ + qmldir + +include(material.pri) +include(../shared/shared.pri) + +RESOURCES += \ + resources.qrc + +CONFIG += no_cxx_module +load(qml_plugin) diff --git a/src/imports/controls/material/qmldir b/src/imports/controls/material/qmldir new file mode 100644 index 00000000..1a2aafe2 --- /dev/null +++ b/src/imports/controls/material/qmldir @@ -0,0 +1,4 @@ +module Qt.labs.controls.material +plugin qtquickmaterialstyleplugin +classname QtQuickMaterialStylePlugin +depends Qt.labs.controls 1.0 diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp new file mode 100644 index 00000000..1ac327ca --- /dev/null +++ b/src/imports/controls/material/qquickmaterialprogressring.cpp @@ -0,0 +1,283 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickmaterialprogressring_p.h" + +#include + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/* + Relevant Android code: + + - core/res/res/anim/progress_indeterminate_rotation_material.xml contains + the rotation animation data. + - core/res/res/anim/progress_indeterminate_material.xml contains the trim + animation data. + - core/res/res/interpolator/trim_start_interpolator.xml and + core/res/res/interpolator/trim_end_interpolator.xml contain the start + and end trim path interpolators. + - addCommand() in core/java/android/util/PathParser.java has a list of the + different path commands available. +*/ + +class QQuickMaterialRingAnimatorJob : public QQuickAnimatorJob +{ +public: + QQuickMaterialRingAnimatorJob(); + ~QQuickMaterialRingAnimatorJob(); + + void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE; + void updateCurrentTime(int time) Q_DECL_OVERRIDE; + void writeBack() Q_DECL_OVERRIDE; + void nodeWasDestroyed() Q_DECL_OVERRIDE; + +private: + QSGNode *m_itemNode; + QQuickWindow *m_window; +}; + +class QQuickMaterialRingTexture : public QSGSimpleTextureNode +{ +public: + QQuickMaterialRingTexture(); + ~QQuickMaterialRingTexture(); + + QColor color() const; + void setColor(QColor color); + +private: + QColor m_color; +}; + +QQuickMaterialProgressRing::QQuickMaterialProgressRing(QQuickItem *parent) : + QQuickItem(parent) +{ + setFlag(QQuickItem::ItemHasContents); +} + +QQuickMaterialProgressRing::~QQuickMaterialProgressRing() +{ +} + +QSGNode *QQuickMaterialProgressRing::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) +{ + if (!oldNode) + oldNode = new QSGSimpleRectNode(boundingRect(), Qt::transparent); + + static_cast(oldNode)->setRect(boundingRect()); + + QQuickMaterialRingTexture *textureNode = static_cast(oldNode->firstChild()); + if (!textureNode) { + textureNode = new QQuickMaterialRingTexture; + textureNode->setOwnsTexture(true); + oldNode->appendChildNode(textureNode); + } + + // A texture seems to be required here, but we don't have one yet, as we haven't drawn anything, + // so just use a blank image. + QImage blankImage(width(), height(), QImage::Format_ARGB32_Premultiplied); + blankImage.fill(Qt::transparent); + QPainter painter(&blankImage); + painter.fillRect(0, 0, width(), height(), Qt::transparent); + painter.end(); + textureNode->setColor(m_color); + textureNode->setRect(boundingRect()); + textureNode->setTexture(window()->createTextureFromImage(blankImage)); + + return oldNode; +} + +QColor QQuickMaterialProgressRing::color() const +{ + return m_color; +} + +void QQuickMaterialProgressRing::setColor(QColor color) +{ + if (m_color != color) { + m_color = color; + update(); + emit colorChanged(); + } +} + +static const int spanAnimationDuration = 700; +static const int rotationAnimationDuration = spanAnimationDuration * 6; +static const int targetRotation = 720; +static const int oneDegree = 16; +static const qreal minSweepSpan = 10 * oneDegree; +static const qreal maxSweepSpan = 300 * oneDegree; + +QQuickMaterialRingAnimator::QQuickMaterialRingAnimator(QObject *parent) : + QQuickAnimator(parent) +{ + setDuration(rotationAnimationDuration); + setLoops(QQuickAnimator::Infinite); +} + +QString QQuickMaterialRingAnimator::propertyName() const +{ + return QString(); +} + +QQuickAnimatorJob *QQuickMaterialRingAnimator::createJob() const +{ + return new QQuickMaterialRingAnimatorJob; +} + +QQuickMaterialRingAnimatorJob::QQuickMaterialRingAnimatorJob() : + m_itemNode(Q_NULLPTR), + m_window(Q_NULLPTR) +{ +} + +QQuickMaterialRingAnimatorJob::~QQuickMaterialRingAnimatorJob() +{ +} + +void QQuickMaterialRingAnimatorJob::initialize(QQuickAnimatorController *controller) +{ + QQuickAnimatorJob::initialize(controller); + m_itemNode = QQuickItemPrivate::get(m_target)->itemNode(); + m_window = m_target->window(); +} + +void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time) +{ + QSGNode *childContainerNode = QQuickItemPrivate::get(m_target)->childContainerNode(); + QSGSimpleRectNode *rectNode = static_cast(childContainerNode->firstChild()); + if (!rectNode) + return; + + Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType); + + const qreal width = rectNode->rect().width(); + const qreal height = rectNode->rect().height(); + QImage image(width, height, QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::transparent); + + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing); + + QPen pen; + QQuickMaterialRingTexture *textureNode = static_cast(rectNode->firstChild()); + pen.setColor(textureNode->color()); + pen.setWidth(4); + painter.setPen(pen); + + const qreal percentageComplete = time / qreal(rotationAnimationDuration); + const qreal spanPercentageComplete = (time % spanAnimationDuration) / qreal(spanAnimationDuration); + const int iteration = time / spanAnimationDuration; + int startAngle = 0; + int endAngle = 0; + static int lastStartAngle = 0; + static int lastEndAngle = 0; + + if (iteration % 2 == 0) { + if (lastStartAngle > 360 * oneDegree) { + lastStartAngle -= 360 * oneDegree; + } + + // The start angle is only affected by the rotation animation for the "grow" phase. + startAngle = lastStartAngle; + // TODO: use the correct curve here. QEasingCurve's bezier API doesn't support SVG path data. + QEasingCurve angleCurve(QEasingCurve::OutQuad); + const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete); + endAngle = lastStartAngle + minSweepSpan + percentage * (maxSweepSpan - minSweepSpan); + lastEndAngle = endAngle; + } else { + // Both the start angle *and* the span are affected by the "shrink" phase. + // TODO: use the correct curve here. QEasingCurve's bezier API doesn't support SVG path data. + QEasingCurve angleCurve(QEasingCurve::InQuad); + const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete); + startAngle = lastEndAngle - maxSweepSpan + percentage * (maxSweepSpan - minSweepSpan); + endAngle = lastEndAngle; + lastStartAngle = startAngle; + } + + const int halfPen = pen.width() / 2; + const QRectF arcBounds = QRectF(rectNode->rect().adjusted(halfPen, halfPen, -halfPen, -halfPen)); + // The current angle of the rotation animation. + const qreal rotation = oneDegree * percentageComplete * -targetRotation; + startAngle -= rotation; + endAngle -= rotation; + const int angleSpan = endAngle - startAngle; + painter.drawArc(arcBounds, -startAngle, -angleSpan); + painter.end(); + + textureNode->setTexture(m_window->createTextureFromImage(image)); +} + +void QQuickMaterialRingAnimatorJob::writeBack() +{ +} + +void QQuickMaterialRingAnimatorJob::nodeWasDestroyed() +{ + m_itemNode = Q_NULLPTR; + m_window = Q_NULLPTR; +} + +QQuickMaterialRingTexture::QQuickMaterialRingTexture() +{ +} + +QQuickMaterialRingTexture::~QQuickMaterialRingTexture() +{ +} + +QColor QQuickMaterialRingTexture::color() const +{ + return m_color; +} + +void QQuickMaterialRingTexture::setColor(QColor color) +{ + m_color = color; +} + +Q_DECLARE_TYPEINFO(QQuickMaterialRingAnimatorJob, Q_COMPLEX_TYPE); +Q_DECLARE_TYPEINFO(QQuickMaterialRingTexture, Q_COMPLEX_TYPE); + +QT_END_NAMESPACE diff --git a/src/imports/controls/material/qquickmaterialprogressring_p.h b/src/imports/controls/material/qquickmaterialprogressring_p.h new file mode 100644 index 00000000..17845a66 --- /dev/null +++ b/src/imports/controls/material/qquickmaterialprogressring_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKMATERIALPROGRESSRING_P_H +#define QQUICKMATERIALPROGRESSRING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickMaterialProgressRing : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL) + +public: + explicit QQuickMaterialProgressRing(QQuickItem *parent = Q_NULLPTR); + ~QQuickMaterialProgressRing(); + + QColor color() const; + void setColor(QColor color); + +Q_SIGNALS: + void colorChanged(); + +protected: + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + +private: + QColor m_color; +}; + +class QQuickMaterialRingAnimator : public QQuickAnimator +{ +public: + QQuickMaterialRingAnimator(QObject *parent = Q_NULLPTR); + +protected: + QString propertyName() const Q_DECL_OVERRIDE; + QQuickAnimatorJob *createJob() const Q_DECL_OVERRIDE; +}; + +Q_DECLARE_TYPEINFO(QQuickMaterialProgressRing, Q_COMPLEX_TYPE); +Q_DECLARE_TYPEINFO(QQuickMaterialRingAnimator, Q_COMPLEX_TYPE); + +QT_END_NAMESPACE + +#endif // QQUICKMATERIALPROGRESSRING_P_H diff --git a/src/imports/controls/material/qquickmaterialstyle.cpp b/src/imports/controls/material/qquickmaterialstyle.cpp new file mode 100644 index 00000000..bae03cf1 --- /dev/null +++ b/src/imports/controls/material/qquickmaterialstyle.cpp @@ -0,0 +1,765 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickmaterialstyle_p.h" +#include "qquickstyle_p.h" + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \qmltype Material + \inherits QtObject + \instantiates QQuickMaterialStyleAttached + \inqmlmodule QtQuick.Controls.Material + \ingroup utilities + \brief A style interface. + + TODO +*/ + +/*! + \qmlattachedproperty color QtQuickControls2::Material::textColorPrimaray +*/ + +struct MaterialColor +{ + MaterialColor() : + color(QQuickMaterialStyle::Red), + shade(QQuickMaterialStyle::Shade500) + { + } + + MaterialColor(QQuickMaterialStyle::Color color, QQuickMaterialStyle::Shade shade) : + color(color), + shade(shade) + { + } + + QQuickMaterialStyle::Color color; + QQuickMaterialStyle::Shade shade; +}; + +inline bool operator==(const MaterialColor &lhs, const MaterialColor &rhs) +{ + return lhs.color == rhs.color && lhs.shade == rhs.shade; +} + +inline uint qHash(const MaterialColor &color, uint seed) +{ + return qHash(color.color, seed) ^ color.shade; +} + +class QQuickMaterialStylePrivate : public QObjectPrivate, public QQuickItemChangeListener +{ + Q_DECLARE_PUBLIC(QQuickMaterialStyle) + +public: + QQuickMaterialStylePrivate(); + + enum Method { Implicit, Explicit, Inherit }; + + QPointer parentStyle; + QSet childStyles; + QHash colors; + + bool explicitTheme; + bool explicitPrimary; + bool explicitAccent; + QQuickMaterialStyle::Theme theme; + QQuickMaterialStyle::Color primary; + QQuickMaterialStyle::Color accent; +}; + +static const QQuickMaterialStyle::Theme defaultTheme = QQuickMaterialStyle::Light; +static const QQuickMaterialStyle::Color defaultPrimary = QQuickMaterialStyle::BlueGrey; +static const QQuickMaterialStyle::Color defaultAccent = QQuickMaterialStyle::Teal; +static const QColor backgroundColorLight = "#FFFAFAFA"; +static const QColor backgroundColorDark = "#FF303030"; +static const QColor dialogColorLight = "#FFFFFFFF"; +static const QColor dialogColorDark = "#FF303030"; +static const QColor primaryTextColorLight = "#DD000000"; +static const QColor primaryTextColorDark = "#FFFFFFFF"; +static const QColor secondaryTextColorLight = "#89000000"; +static const QColor secondaryTextColorDark = "#B2FFFFFF"; +static const QColor hintTextColorLight = "#60000000"; +static const QColor hintTextColorDark = "#4CFFFFFF"; +static const QColor dividerTextColorLight = "#1E000000"; +static const QColor dividerTextColorDark = "#1EFFFFFF"; +static const QColor raisedButtonColorLight = "#FFD6D7D7"; +// TODO: find out actual value +static const QColor raisedButtonPressColorLight = "#FFCCCDCD"; +static const QColor raisedButtonDisabledColorLight = dividerTextColorLight; +static const QColor raisedButtonDisabledColorDark = dividerTextColorDark; +static const QColor flatButtonPressColorLight = "#66999999"; +static const QColor flatButtonPressColorDark = "#3FCCCCCC"; +static const QColor flatButtonFocusColorLight = "#33CCCCCC"; +static const QColor flatButtonFocusColorDark = "#26CCCCCC"; +static const QColor frameColorLight = hintTextColorLight; +static const QColor frameColorDark = hintTextColorDark; +static const QColor switchUncheckedTrackColorLight = "#42000000"; +static const QColor switchUncheckedTrackColorDark = "#4CFFFFFF"; +static const QColor switchDisabledTrackColorLight = "#1E000000"; +static const QColor switchDisabledTrackColorDark = "#19FFFFFF"; +// TODO: find out actual values +static const QColor checkBoxUncheckedRippleColorLight = "#10000000"; +static const QColor checkBoxUncheckedRippleColorDark = "#20FFFFFF"; + +QQuickMaterialStylePrivate::QQuickMaterialStylePrivate() : + explicitTheme(false), + explicitPrimary(false), + explicitAccent(false), + theme(defaultTheme), + primary(defaultPrimary), + accent(defaultAccent) +{ + if (colors.isEmpty()) { + typedef QQuickMaterialStyle Style; + colors[MaterialColor(Style::Red, Style::Shade50)] = "#FFEBEE"; + colors[MaterialColor(Style::Red, Style::Shade100)] = "#FFCDD2"; + colors[MaterialColor(Style::Red, Style::Shade200)] = "#EF9A9A"; + colors[MaterialColor(Style::Red, Style::Shade300)] = "#E57373"; + colors[MaterialColor(Style::Red, Style::Shade400)] = "#EF5350"; + colors[MaterialColor(Style::Red, Style::Shade500)] = "#F44336"; + colors[MaterialColor(Style::Red, Style::Shade600)] = "#E53935"; + colors[MaterialColor(Style::Red, Style::Shade700)] = "#D32F2F"; + colors[MaterialColor(Style::Red, Style::Shade800)] = "#C62828"; + colors[MaterialColor(Style::Red, Style::Shade900)] = "#B71C1C"; + colors[MaterialColor(Style::Red, Style::ShadeA100)] = "#FF8A80"; + colors[MaterialColor(Style::Red, Style::ShadeA200)] = "#FF5252"; + colors[MaterialColor(Style::Red, Style::ShadeA400)] = "#FF1744"; + colors[MaterialColor(Style::Red, Style::ShadeA700)] = "#D50000"; + colors[MaterialColor(Style::Pink, Style::Shade50)] = "#FCE4EC"; + colors[MaterialColor(Style::Pink, Style::Shade100)] = "#F8BBD0"; + colors[MaterialColor(Style::Pink, Style::Shade200)] = "#F48FB1"; + colors[MaterialColor(Style::Pink, Style::Shade300)] = "#F06292"; + colors[MaterialColor(Style::Pink, Style::Shade400)] = "#EC407A"; + colors[MaterialColor(Style::Pink, Style::Shade500)] = "#E91E63"; + colors[MaterialColor(Style::Pink, Style::Shade600)] = "#D81B60"; + colors[MaterialColor(Style::Pink, Style::Shade700)] = "#C2185B"; + colors[MaterialColor(Style::Pink, Style::Shade800)] = "#AD1457"; + colors[MaterialColor(Style::Pink, Style::Shade900)] = "#880E4F"; + colors[MaterialColor(Style::Pink, Style::ShadeA100)] = "#FF80AB"; + colors[MaterialColor(Style::Pink, Style::ShadeA200)] = "#FF4081"; + colors[MaterialColor(Style::Pink, Style::ShadeA400)] = "#F50057"; + colors[MaterialColor(Style::Pink, Style::ShadeA700)] = "#C51162"; + colors[MaterialColor(Style::Purple, Style::Shade50)] = "#F3E5F5"; + colors[MaterialColor(Style::Purple, Style::Shade100)] = "#E1BEE7"; + colors[MaterialColor(Style::Purple, Style::Shade200)] = "#CE93D8"; + colors[MaterialColor(Style::Purple, Style::Shade300)] = "#BA68C8"; + colors[MaterialColor(Style::Purple, Style::Shade400)] = "#AB47BC"; + colors[MaterialColor(Style::Purple, Style::Shade500)] = "#9C27B0"; + colors[MaterialColor(Style::Purple, Style::Shade600)] = "#8E24AA"; + colors[MaterialColor(Style::Purple, Style::Shade700)] = "#7B1FA2"; + colors[MaterialColor(Style::Purple, Style::Shade800)] = "#6A1B9A"; + colors[MaterialColor(Style::Purple, Style::Shade900)] = "#4A148C"; + colors[MaterialColor(Style::Purple, Style::ShadeA100)] = "#EA80FC"; + colors[MaterialColor(Style::Purple, Style::ShadeA200)] = "#E040FB"; + colors[MaterialColor(Style::Purple, Style::ShadeA400)] = "#D500F9"; + colors[MaterialColor(Style::Purple, Style::ShadeA700)] = "#AA00FF"; + colors[MaterialColor(Style::DeepPurple, Style::Shade50)] = "#EDE7F6"; + colors[MaterialColor(Style::DeepPurple, Style::Shade100)] = "#D1C4E9"; + colors[MaterialColor(Style::DeepPurple, Style::Shade200)] = "#B39DDB"; + colors[MaterialColor(Style::DeepPurple, Style::Shade300)] = "#9575CD"; + colors[MaterialColor(Style::DeepPurple, Style::Shade400)] = "#7E57C2"; + colors[MaterialColor(Style::DeepPurple, Style::Shade500)] = "#673AB7"; + colors[MaterialColor(Style::DeepPurple, Style::Shade600)] = "#5E35B1"; + colors[MaterialColor(Style::DeepPurple, Style::Shade700)] = "#512DA8"; + colors[MaterialColor(Style::DeepPurple, Style::Shade800)] = "#4527A0"; + colors[MaterialColor(Style::DeepPurple, Style::Shade900)] = "#311B92"; + colors[MaterialColor(Style::DeepPurple, Style::ShadeA100)] = "#B388FF"; + colors[MaterialColor(Style::DeepPurple, Style::ShadeA200)] = "#7C4DFF"; + colors[MaterialColor(Style::DeepPurple, Style::ShadeA400)] = "#651FFF"; + colors[MaterialColor(Style::DeepPurple, Style::ShadeA700)] = "#6200EA"; + colors[MaterialColor(Style::Indigo, Style::Shade50)] = "#E8EAF6"; + colors[MaterialColor(Style::Indigo, Style::Shade100)] = "#C5CAE9"; + colors[MaterialColor(Style::Indigo, Style::Shade200)] = "#9FA8DA"; + colors[MaterialColor(Style::Indigo, Style::Shade300)] = "#7986CB"; + colors[MaterialColor(Style::Indigo, Style::Shade400)] = "#5C6BC0"; + colors[MaterialColor(Style::Indigo, Style::Shade500)] = "#3F51B5"; + colors[MaterialColor(Style::Indigo, Style::Shade600)] = "#3949AB"; + colors[MaterialColor(Style::Indigo, Style::Shade700)] = "#303F9F"; + colors[MaterialColor(Style::Indigo, Style::Shade800)] = "#283593"; + colors[MaterialColor(Style::Indigo, Style::Shade900)] = "#1A237E"; + colors[MaterialColor(Style::Indigo, Style::ShadeA100)] = "#8C9EFF"; + colors[MaterialColor(Style::Indigo, Style::ShadeA200)] = "#536DFE"; + colors[MaterialColor(Style::Indigo, Style::ShadeA400)] = "#3D5AFE"; + colors[MaterialColor(Style::Indigo, Style::ShadeA700)] = "#304FFE"; + colors[MaterialColor(Style::Blue, Style::Shade50)] = "#E3F2FD"; + colors[MaterialColor(Style::Blue, Style::Shade100)] = "#BBDEFB"; + colors[MaterialColor(Style::Blue, Style::Shade200)] = "#90CAF9"; + colors[MaterialColor(Style::Blue, Style::Shade300)] = "#64B5F6"; + colors[MaterialColor(Style::Blue, Style::Shade400)] = "#42A5F5"; + colors[MaterialColor(Style::Blue, Style::Shade500)] = "#2196F3"; + colors[MaterialColor(Style::Blue, Style::Shade600)] = "#1E88E5"; + colors[MaterialColor(Style::Blue, Style::Shade700)] = "#1976D2"; + colors[MaterialColor(Style::Blue, Style::Shade800)] = "#1565C0"; + colors[MaterialColor(Style::Blue, Style::Shade900)] = "#0D47A1"; + colors[MaterialColor(Style::Blue, Style::ShadeA100)] = "#82B1FF"; + colors[MaterialColor(Style::Blue, Style::ShadeA200)] = "#448AFF"; + colors[MaterialColor(Style::Blue, Style::ShadeA400)] = "#2979FF"; + colors[MaterialColor(Style::Blue, Style::ShadeA700)] = "#2962FF"; + colors[MaterialColor(Style::LightBlue, Style::Shade50)] = "#E1F5FE"; + colors[MaterialColor(Style::LightBlue, Style::Shade100)] = "#B3E5FC"; + colors[MaterialColor(Style::LightBlue, Style::Shade200)] = "#81D4FA"; + colors[MaterialColor(Style::LightBlue, Style::Shade300)] = "#4FC3F7"; + colors[MaterialColor(Style::LightBlue, Style::Shade400)] = "#29B6F6"; + colors[MaterialColor(Style::LightBlue, Style::Shade500)] = "#03A9F4"; + colors[MaterialColor(Style::LightBlue, Style::Shade600)] = "#039BE5"; + colors[MaterialColor(Style::LightBlue, Style::Shade700)] = "#0288D1"; + colors[MaterialColor(Style::LightBlue, Style::Shade800)] = "#0277BD"; + colors[MaterialColor(Style::LightBlue, Style::Shade900)] = "#01579B"; + colors[MaterialColor(Style::LightBlue, Style::ShadeA100)] = "#80D8FF"; + colors[MaterialColor(Style::LightBlue, Style::ShadeA200)] = "#40C4FF"; + colors[MaterialColor(Style::LightBlue, Style::ShadeA400)] = "#00B0FF"; + colors[MaterialColor(Style::LightBlue, Style::ShadeA700)] = "#0091EA"; + colors[MaterialColor(Style::Cyan, Style::Shade50)] = "#E0F7FA"; + colors[MaterialColor(Style::Cyan, Style::Shade100)] = "#B2EBF2"; + colors[MaterialColor(Style::Cyan, Style::Shade200)] = "#80DEEA"; + colors[MaterialColor(Style::Cyan, Style::Shade300)] = "#4DD0E1"; + colors[MaterialColor(Style::Cyan, Style::Shade400)] = "#26C6DA"; + colors[MaterialColor(Style::Cyan, Style::Shade500)] = "#00BCD4"; + colors[MaterialColor(Style::Cyan, Style::Shade600)] = "#00ACC1"; + colors[MaterialColor(Style::Cyan, Style::Shade700)] = "#0097A7"; + colors[MaterialColor(Style::Cyan, Style::Shade800)] = "#00838F"; + colors[MaterialColor(Style::Cyan, Style::Shade900)] = "#006064"; + colors[MaterialColor(Style::Cyan, Style::ShadeA100)] = "#84FFFF"; + colors[MaterialColor(Style::Cyan, Style::ShadeA200)] = "#18FFFF"; + colors[MaterialColor(Style::Cyan, Style::ShadeA400)] = "#00E5FF"; + colors[MaterialColor(Style::Cyan, Style::ShadeA700)] = "#00B8D4"; + colors[MaterialColor(Style::Teal, Style::Shade50)] = "#E0F2F1"; + colors[MaterialColor(Style::Teal, Style::Shade100)] = "#B2DFDB"; + colors[MaterialColor(Style::Teal, Style::Shade200)] = "#80CBC4"; + colors[MaterialColor(Style::Teal, Style::Shade300)] = "#4DB6AC"; + colors[MaterialColor(Style::Teal, Style::Shade400)] = "#26A69A"; + colors[MaterialColor(Style::Teal, Style::Shade500)] = "#009688"; + colors[MaterialColor(Style::Teal, Style::Shade600)] = "#00897B"; + colors[MaterialColor(Style::Teal, Style::Shade700)] = "#00796B"; + colors[MaterialColor(Style::Teal, Style::Shade800)] = "#00695C"; + colors[MaterialColor(Style::Teal, Style::Shade900)] = "#004D40"; + colors[MaterialColor(Style::Teal, Style::ShadeA100)] = "#A7FFEB"; + colors[MaterialColor(Style::Teal, Style::ShadeA200)] = "#64FFDA"; + colors[MaterialColor(Style::Teal, Style::ShadeA400)] = "#1DE9B6"; + colors[MaterialColor(Style::Teal, Style::ShadeA700)] = "#00BFA5"; + colors[MaterialColor(Style::Green, Style::Shade50)] = "#E8F5E9"; + colors[MaterialColor(Style::Green, Style::Shade100)] = "#C8E6C9"; + colors[MaterialColor(Style::Green, Style::Shade200)] = "#A5D6A7"; + colors[MaterialColor(Style::Green, Style::Shade300)] = "#81C784"; + colors[MaterialColor(Style::Green, Style::Shade400)] = "#66BB6A"; + colors[MaterialColor(Style::Green, Style::Shade500)] = "#4CAF50"; + colors[MaterialColor(Style::Green, Style::Shade600)] = "#43A047"; + colors[MaterialColor(Style::Green, Style::Shade700)] = "#388E3C"; + colors[MaterialColor(Style::Green, Style::Shade800)] = "#2E7D32"; + colors[MaterialColor(Style::Green, Style::Shade900)] = "#1B5E20"; + colors[MaterialColor(Style::Green, Style::ShadeA100)] = "#B9F6CA"; + colors[MaterialColor(Style::Green, Style::ShadeA200)] = "#69F0AE"; + colors[MaterialColor(Style::Green, Style::ShadeA400)] = "#00E676"; + colors[MaterialColor(Style::Green, Style::ShadeA700)] = "#00C853"; + colors[MaterialColor(Style::LightGreen, Style::Shade50)] = "#F1F8E9"; + colors[MaterialColor(Style::LightGreen, Style::Shade100)] = "#DCEDC8"; + colors[MaterialColor(Style::LightGreen, Style::Shade200)] = "#C5E1A5"; + colors[MaterialColor(Style::LightGreen, Style::Shade300)] = "#AED581"; + colors[MaterialColor(Style::LightGreen, Style::Shade400)] = "#9CCC65"; + colors[MaterialColor(Style::LightGreen, Style::Shade500)] = "#8BC34A"; + colors[MaterialColor(Style::LightGreen, Style::Shade600)] = "#7CB342"; + colors[MaterialColor(Style::LightGreen, Style::Shade700)] = "#689F38"; + colors[MaterialColor(Style::LightGreen, Style::Shade800)] = "#558B2F"; + colors[MaterialColor(Style::LightGreen, Style::Shade900)] = "#33691E"; + colors[MaterialColor(Style::LightGreen, Style::ShadeA100)] = "#CCFF90"; + colors[MaterialColor(Style::LightGreen, Style::ShadeA200)] = "#B2FF59"; + colors[MaterialColor(Style::LightGreen, Style::ShadeA400)] = "#76FF03"; + colors[MaterialColor(Style::LightGreen, Style::ShadeA700)] = "#64DD17"; + colors[MaterialColor(Style::Lime, Style::Shade50)] = "#F9FBE7"; + colors[MaterialColor(Style::Lime, Style::Shade100)] = "#F0F4C3"; + colors[MaterialColor(Style::Lime, Style::Shade200)] = "#E6EE9C"; + colors[MaterialColor(Style::Lime, Style::Shade300)] = "#DCE775"; + colors[MaterialColor(Style::Lime, Style::Shade400)] = "#D4E157"; + colors[MaterialColor(Style::Lime, Style::Shade500)] = "#CDDC39"; + colors[MaterialColor(Style::Lime, Style::Shade600)] = "#C0CA33"; + colors[MaterialColor(Style::Lime, Style::Shade700)] = "#AFB42B"; + colors[MaterialColor(Style::Lime, Style::Shade800)] = "#9E9D24"; + colors[MaterialColor(Style::Lime, Style::Shade900)] = "#827717"; + colors[MaterialColor(Style::Lime, Style::ShadeA100)] = "#F4FF81"; + colors[MaterialColor(Style::Lime, Style::ShadeA200)] = "#EEFF41"; + colors[MaterialColor(Style::Lime, Style::ShadeA400)] = "#C6FF00"; + colors[MaterialColor(Style::Lime, Style::ShadeA700)] = "#AEEA00"; + colors[MaterialColor(Style::Yellow, Style::Shade50)] = "#FFFDE7"; + colors[MaterialColor(Style::Yellow, Style::Shade100)] = "#FFF9C4"; + colors[MaterialColor(Style::Yellow, Style::Shade200)] = "#FFF59D"; + colors[MaterialColor(Style::Yellow, Style::Shade300)] = "#FFF176"; + colors[MaterialColor(Style::Yellow, Style::Shade400)] = "#FFEE58"; + colors[MaterialColor(Style::Yellow, Style::Shade500)] = "#FFEB3B"; + colors[MaterialColor(Style::Yellow, Style::Shade600)] = "#FDD835"; + colors[MaterialColor(Style::Yellow, Style::Shade700)] = "#FBC02D"; + colors[MaterialColor(Style::Yellow, Style::Shade800)] = "#F9A825"; + colors[MaterialColor(Style::Yellow, Style::Shade900)] = "#F57F17"; + colors[MaterialColor(Style::Yellow, Style::ShadeA100)] = "#FFFF8D"; + colors[MaterialColor(Style::Yellow, Style::ShadeA200)] = "#FFFF00"; + colors[MaterialColor(Style::Yellow, Style::ShadeA400)] = "#FFEA00"; + colors[MaterialColor(Style::Yellow, Style::ShadeA700)] = "#FFD600"; + colors[MaterialColor(Style::Amber, Style::Shade50)] = "#FFF8E1"; + colors[MaterialColor(Style::Amber, Style::Shade100)] = "#FFECB3"; + colors[MaterialColor(Style::Amber, Style::Shade200)] = "#FFE082"; + colors[MaterialColor(Style::Amber, Style::Shade300)] = "#FFD54F"; + colors[MaterialColor(Style::Amber, Style::Shade400)] = "#FFCA28"; + colors[MaterialColor(Style::Amber, Style::Shade500)] = "#FFC107"; + colors[MaterialColor(Style::Amber, Style::Shade600)] = "#FFB300"; + colors[MaterialColor(Style::Amber, Style::Shade700)] = "#FFA000"; + colors[MaterialColor(Style::Amber, Style::Shade800)] = "#FF8F00"; + colors[MaterialColor(Style::Amber, Style::Shade900)] = "#FF6F00"; + colors[MaterialColor(Style::Amber, Style::ShadeA100)] = "#FFE57F"; + colors[MaterialColor(Style::Amber, Style::ShadeA200)] = "#FFD740"; + colors[MaterialColor(Style::Amber, Style::ShadeA400)] = "#FFC400"; + colors[MaterialColor(Style::Amber, Style::ShadeA700)] = "#FFAB00"; + colors[MaterialColor(Style::Orange, Style::Shade50)] = "#FFF3E0"; + colors[MaterialColor(Style::Orange, Style::Shade100)] = "#FFE0B2"; + colors[MaterialColor(Style::Orange, Style::Shade200)] = "#FFCC80"; + colors[MaterialColor(Style::Orange, Style::Shade300)] = "#FFB74D"; + colors[MaterialColor(Style::Orange, Style::Shade400)] = "#FFA726"; + colors[MaterialColor(Style::Orange, Style::Shade500)] = "#FF9800"; + colors[MaterialColor(Style::Orange, Style::Shade600)] = "#FB8C00"; + colors[MaterialColor(Style::Orange, Style::Shade700)] = "#F57C00"; + colors[MaterialColor(Style::Orange, Style::Shade800)] = "#EF6C00"; + colors[MaterialColor(Style::Orange, Style::Shade900)] = "#E65100"; + colors[MaterialColor(Style::Orange, Style::ShadeA100)] = "#FFD180"; + colors[MaterialColor(Style::Orange, Style::ShadeA200)] = "#FFAB40"; + colors[MaterialColor(Style::Orange, Style::ShadeA400)] = "#FF9100"; + colors[MaterialColor(Style::Orange, Style::ShadeA700)] = "#FF6D00"; + colors[MaterialColor(Style::DeepOrange, Style::Shade50)] = "#FBE9E7"; + colors[MaterialColor(Style::DeepOrange, Style::Shade100)] = "#FFCCBC"; + colors[MaterialColor(Style::DeepOrange, Style::Shade200)] = "#FFAB91"; + colors[MaterialColor(Style::DeepOrange, Style::Shade300)] = "#FF8A65"; + colors[MaterialColor(Style::DeepOrange, Style::Shade400)] = "#FF7043"; + colors[MaterialColor(Style::DeepOrange, Style::Shade500)] = "#FF5722"; + colors[MaterialColor(Style::DeepOrange, Style::Shade600)] = "#F4511E"; + colors[MaterialColor(Style::DeepOrange, Style::Shade700)] = "#E64A19"; + colors[MaterialColor(Style::DeepOrange, Style::Shade800)] = "#D84315"; + colors[MaterialColor(Style::DeepOrange, Style::Shade900)] = "#BF360C"; + colors[MaterialColor(Style::DeepOrange, Style::ShadeA100)] = "#FF9E80"; + colors[MaterialColor(Style::DeepOrange, Style::ShadeA200)] = "#FF6E40"; + colors[MaterialColor(Style::DeepOrange, Style::ShadeA400)] = "#FF3D00"; + colors[MaterialColor(Style::DeepOrange, Style::ShadeA700)] = "#DD2C00"; + colors[MaterialColor(Style::Brown, Style::Shade50)] = "#EFEBE9"; + colors[MaterialColor(Style::Brown, Style::Shade100)] = "#D7CCC8"; + colors[MaterialColor(Style::Brown, Style::Shade200)] = "#BCAAA4"; + colors[MaterialColor(Style::Brown, Style::Shade300)] = "#A1887F"; + colors[MaterialColor(Style::Brown, Style::Shade400)] = "#8D6E63"; + colors[MaterialColor(Style::Brown, Style::Shade500)] = "#795548"; + colors[MaterialColor(Style::Brown, Style::Shade600)] = "#6D4C41"; + colors[MaterialColor(Style::Brown, Style::Shade700)] = "#5D4037"; + colors[MaterialColor(Style::Brown, Style::Shade800)] = "#4E342E"; + colors[MaterialColor(Style::Brown, Style::Shade900)] = "#3E2723"; + colors[MaterialColor(Style::Grey, Style::Shade50)] = "#FAFAFA"; + colors[MaterialColor(Style::Grey, Style::Shade100)] = "#F5F5F5"; + colors[MaterialColor(Style::Grey, Style::Shade200)] = "#EEEEEE"; + colors[MaterialColor(Style::Grey, Style::Shade300)] = "#E0E0E0"; + colors[MaterialColor(Style::Grey, Style::Shade400)] = "#BDBDBD"; + colors[MaterialColor(Style::Grey, Style::Shade500)] = "#9E9E9E"; + colors[MaterialColor(Style::Grey, Style::Shade600)] = "#757575"; + colors[MaterialColor(Style::Grey, Style::Shade700)] = "#616161"; + colors[MaterialColor(Style::Grey, Style::Shade800)] = "#424242"; + colors[MaterialColor(Style::Grey, Style::Shade900)] = "#212121"; + colors[MaterialColor(Style::BlueGrey, Style::Shade50)] = "#ECEFF1"; + colors[MaterialColor(Style::BlueGrey, Style::Shade100)] = "#CFD8DC"; + colors[MaterialColor(Style::BlueGrey, Style::Shade200)] = "#B0BEC5"; + colors[MaterialColor(Style::BlueGrey, Style::Shade300)] = "#90A4AE"; + colors[MaterialColor(Style::BlueGrey, Style::Shade400)] = "#78909C"; + colors[MaterialColor(Style::BlueGrey, Style::Shade500)] = "#607D8B"; + colors[MaterialColor(Style::BlueGrey, Style::Shade600)] = "#546E7A"; + colors[MaterialColor(Style::BlueGrey, Style::Shade700)] = "#455A64"; + colors[MaterialColor(Style::BlueGrey, Style::Shade800)] = "#37474F"; + colors[MaterialColor(Style::BlueGrey, Style::Shade900)] = "#263238"; + } +} + +QQuickMaterialStyle::QQuickMaterialStyle(QObject *parent) : + QObject(*(new QQuickMaterialStylePrivate()), parent) +{ + Q_D(QQuickMaterialStyle); + QQuickItem *item = qobject_cast(parent); + if (item) + QQuickItemPrivate::get(item)->addItemChangeListener(d, QQuickItemPrivate::Parent); +} + +QQuickMaterialStyle::~QQuickMaterialStyle() +{ + Q_D(QQuickMaterialStyle); + QQuickItem *item = qobject_cast(parent()); + if (item) + QQuickItemPrivate::get(item)->removeItemChangeListener(d, QQuickItemPrivate::Parent); + + reparent(Q_NULLPTR); +} + +QQuickMaterialStyle *QQuickMaterialStyle::qmlAttachedProperties(QObject *object) +{ + QQuickMaterialStyle *style = new QQuickMaterialStyle(object); + QQuickMaterialStyle *parent = QQuickStyle::findParent(object); + if (parent) + style->reparent(parent); + + QList childStyles = QQuickStyle::findChildren(object); + foreach (QQuickMaterialStyle *child, childStyles) + child->reparent(style); + return style; +} + +QQuickMaterialStyle::Theme QQuickMaterialStyle::theme() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme; +} + +void QQuickMaterialStyle::setTheme(Theme theme) +{ + Q_D(QQuickMaterialStyle); + d->explicitTheme = true; + if (d->theme != theme) { + d->theme = theme; + foreach (QQuickMaterialStyle *child, d->childStyles) { + child->inheritTheme(theme); + } + emit themeChanged(); + emit paletteChanged(); + } +} + +void QQuickMaterialStyle::inheritTheme(Theme theme) +{ + Q_D(QQuickMaterialStyle); + if (!d->explicitTheme && d->theme != theme) { + d->theme = theme; + foreach (QQuickMaterialStyle *child, d->childStyles) { + child->inheritTheme(theme); + } + emit themeChanged(); + emit paletteChanged(); + } +} + +void QQuickMaterialStyle::resetTheme() +{ + Q_D(QQuickMaterialStyle); + if (d->explicitTheme) { + d->explicitTheme = false; + QQuickMaterialStyle *attachedParent = QQuickStyle::findParent(parent()); + inheritTheme(attachedParent ? attachedParent->theme() : defaultTheme); + } +} + +QQuickMaterialStyle::Color QQuickMaterialStyle::primary() const +{ + Q_D(const QQuickMaterialStyle); + return d->primary; +} + +void QQuickMaterialStyle::setPrimary(QQuickMaterialStyle::Color color) +{ + Q_D(QQuickMaterialStyle); + d->explicitPrimary = true; + if (d->primary != color) { + d->primary = color; + emit primaryChanged(); + emit paletteChanged(); + + foreach (QQuickMaterialStyle *child, d->childStyles) + child->inheritPrimary(color); + } +} + +void QQuickMaterialStyle::inheritPrimary(QQuickMaterialStyle::Color color) +{ + Q_D(QQuickMaterialStyle); + if (!d->explicitPrimary && d->primary != color) { + d->primary = color; + foreach (QQuickMaterialStyle *child, d->childStyles) + child->inheritPrimary(color); + emit primaryChanged(); + } +} + +void QQuickMaterialStyle::resetPrimary() +{ + Q_D(QQuickMaterialStyle); + if (d->explicitPrimary) { + d->explicitPrimary = false; + QQuickMaterialStyle *attachedParent = QQuickStyle::findParent(parent()); + inheritPrimary(attachedParent ? attachedParent->primary() : defaultPrimary); + } +} + +QQuickMaterialStyle::Color QQuickMaterialStyle::accent() const +{ + Q_D(const QQuickMaterialStyle); + return d->accent; +} + +void QQuickMaterialStyle::setAccent(QQuickMaterialStyle::Color color) +{ + Q_D(QQuickMaterialStyle); + d->explicitAccent = true; + if (d->accent != color) { + d->accent = color; + emit accentChanged(); + emit paletteChanged(); + + foreach (QQuickMaterialStyle *child, d->childStyles) + child->inheritAccent(color); + } +} + +void QQuickMaterialStyle::inheritAccent(QQuickMaterialStyle::Color color) +{ + Q_D(QQuickMaterialStyle); + if (!d->explicitAccent && d->accent != color) { + d->accent = color; + foreach (QQuickMaterialStyle *child, d->childStyles) + child->inheritAccent(color); + emit accentChanged(); + } +} + +void QQuickMaterialStyle::resetAccent() +{ + Q_D(QQuickMaterialStyle); + if (d->explicitAccent) { + d->explicitAccent = false; + QQuickMaterialStyle *attachedParent = QQuickStyle::findParent(parent()); + inheritAccent(attachedParent ? attachedParent->accent() : defaultAccent); + } +} + +QColor QQuickMaterialStyle::accentColor() const +{ + Q_D(const QQuickMaterialStyle); + return color(d->accent, Shade500); +} + +QColor QQuickMaterialStyle::backgroundColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? backgroundColorLight : backgroundColorDark; +} + +QColor QQuickMaterialStyle::primaryTextColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? primaryTextColorLight : primaryTextColorDark; +} + +QColor QQuickMaterialStyle::secondaryTextColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? secondaryTextColorLight : secondaryTextColorDark; +} + +QColor QQuickMaterialStyle::hintTextColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? hintTextColorLight : hintTextColorDark; +} + +QColor QQuickMaterialStyle::textSelectionColor() const +{ + QColor color = accentColor(); + color.setAlphaF(0.4); + return color; +} + +QColor QQuickMaterialStyle::dropShadowColor() const +{ + return QColor("#40000000"); +} + +QColor QQuickMaterialStyle::dividerColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? dividerTextColorLight : dividerTextColorDark; +} + +QColor QQuickMaterialStyle::raisedButtonColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? raisedButtonColorLight : accentColor(); +} + +QColor QQuickMaterialStyle::raisedButtonHoverColor() const +{ + Q_D(const QQuickMaterialStyle); + // The specs don't specify different colors here for the light theme. + return d->theme == Light ? raisedButtonColorLight : color(d->accent, Shade600); +} + +QColor QQuickMaterialStyle::raisedButtonPressColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? raisedButtonPressColorLight : color(d->accent, Shade700); +} + +QColor QQuickMaterialStyle::raisedButtonDisabledColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? raisedButtonDisabledColorLight : raisedButtonDisabledColorDark; +} + +QColor QQuickMaterialStyle::flatButtonPressColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? flatButtonPressColorLight : flatButtonPressColorDark; +} + +QColor QQuickMaterialStyle::flatButtonFocusColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? flatButtonFocusColorLight : flatButtonFocusColorDark; +} + +QColor QQuickMaterialStyle::frameColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? frameColorLight : frameColorDark; +} + +QColor QQuickMaterialStyle::checkBoxUncheckedRippleColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? checkBoxUncheckedRippleColorLight : checkBoxUncheckedRippleColorDark; +} + +QColor QQuickMaterialStyle::checkBoxCheckedRippleColor() const +{ + Q_D(const QQuickMaterialStyle); + QColor pressColor = color(d->accent, Shade500); + // TODO: find out actual value + pressColor.setAlpha(30); + return pressColor; +} + +QColor QQuickMaterialStyle::switchUncheckedTrackColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? switchUncheckedTrackColorLight : switchUncheckedTrackColorDark; +} + +QColor QQuickMaterialStyle::switchCheckedTrackColor() const +{ + Q_D(const QQuickMaterialStyle); + QColor trackColor = d->theme == Light ? accentColor() : color(d->accent, Shade200); + trackColor.setAlphaF(0.5); + return trackColor; +} + +QColor QQuickMaterialStyle::switchUncheckedHandleColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? color(Grey, Shade50) : color(Grey, Shade400); +} + +QColor QQuickMaterialStyle::switchCheckedHandleColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? accentColor() : color(d->accent, Shade200); +} + +QColor QQuickMaterialStyle::switchDisabledTrackColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? switchDisabledTrackColorLight : switchDisabledTrackColorDark; +} + +QColor QQuickMaterialStyle::switchDisabledHandleColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? color(Grey, Shade400) : color(Grey, Shade800); +} + +QColor QQuickMaterialStyle::scrollBarColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? "#40000000" : "#40FFFFFF"; +} + +QColor QQuickMaterialStyle::scrollBarPressedColor() const +{ + Q_D(const QQuickMaterialStyle); + return d->theme == Light ? "#80000000" : "#80FFFFFF"; +} + +QColor QQuickMaterialStyle::drawerBackgroundColor() const +{ + return dividerTextColorLight; +} + +QColor QQuickMaterialStyle::color(QQuickMaterialStyle::Color color, QQuickMaterialStyle::Shade shade) const +{ + Q_D(const QQuickMaterialStyle); + return d->colors.value(MaterialColor(color, shade)); +} + +void QQuickMaterialStyle::reparent(QQuickMaterialStyle *style) +{ + Q_D(QQuickMaterialStyle); + if (d->parentStyle != style) { + if (d->parentStyle) + d->parentStyle->d_func()->childStyles.remove(this); + d->parentStyle = style; + if (style) { + style->d_func()->childStyles.insert(this); + inheritPrimary(style->primary()); + inheritAccent(style->accent()); + inheritTheme(style->theme()); + } + } +} + +void QQuickMaterialStyle::itemParentChanged(QQuickItem *item, QQuickItem *parentItem) +{ + QQuickMaterialStyle *style = QQuickStyle::instance(item); + if (style) { + QQuickMaterialStyle *parent = QQuickStyle::findParent(parentItem); + if (parent) + style->reparent(parent); + } +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h new file mode 100644 index 00000000..c13dab77 --- /dev/null +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKMATERIALSTYLE_P_H +#define QQUICKMATERIALSTYLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQuickMaterialStylePrivate; + +class QQuickMaterialStyle : public QObject, public QQuickItemChangeListener +{ + Q_OBJECT + Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL) + Q_PROPERTY(Color primary READ primary WRITE setPrimary RESET resetPrimary NOTIFY primaryChanged FINAL) + Q_PROPERTY(Color accent READ accent WRITE setAccent RESET resetAccent NOTIFY accentChanged FINAL) + Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL) + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor textSelectionColor READ textSelectionColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor dropShadowColor READ dropShadowColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor dividerColor READ dividerColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor raisedButtonColor READ raisedButtonColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor raisedButtonHoverColor READ raisedButtonHoverColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor raisedButtonPressColor READ raisedButtonPressColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor raisedButtonDisabledColor READ raisedButtonDisabledColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor flatButtonPressColor READ flatButtonPressColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor flatButtonFocusColor READ flatButtonFocusColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor frameColor READ frameColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor checkBoxUncheckedRippleColor READ checkBoxUncheckedRippleColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor checkBoxCheckedRippleColor READ checkBoxCheckedRippleColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchUncheckedTrackColor READ switchUncheckedTrackColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchCheckedTrackColor READ switchCheckedTrackColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchUncheckedHandleColor READ switchUncheckedHandleColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchCheckedHandleColor READ switchCheckedHandleColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchDisabledTrackColor READ switchDisabledTrackColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor switchDisabledHandleColor READ switchDisabledHandleColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor scrollBarColor READ scrollBarColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor drawerBackgroundColor READ drawerBackgroundColor NOTIFY paletteChanged FINAL) + +public: + enum Theme { + Light, + Dark + }; + + enum Color { + Red, + Pink, + Purple, + DeepPurple, + Indigo, + Blue, + LightBlue, + Cyan, + Teal, + Green, + LightGreen, + Lime, + Yellow, + Amber, + Orange, + DeepOrange, + Brown, + Grey, + BlueGrey + }; + + enum Shade { + Shade50, + Shade100, + Shade200, + Shade300, + Shade400, + Shade500, + Shade600, + Shade700, + Shade800, + Shade900, + ShadeA100, + ShadeA200, + ShadeA400, + ShadeA700, + }; + + Q_ENUM(Theme) + Q_ENUM(Color) + Q_ENUM(Shade) + + explicit QQuickMaterialStyle(QObject *parent = Q_NULLPTR); + ~QQuickMaterialStyle(); + + static QQuickMaterialStyle *qmlAttachedProperties(QObject *object); + + Theme theme() const; + void setTheme(Theme theme); + void inheritTheme(Theme theme); + void resetTheme(); + + QColor primaryColorLight() const; + + Color primary() const; + void setPrimary(Color color); + void inheritPrimary(Color color); + void resetPrimary(); + + QColor primaryColorDark() const; + + Color accent() const; + void setAccent(Color color); + void inheritAccent(Color color); + void resetAccent(); + + QColor accentColor() const; + QColor backgroundColor() const; + QColor primaryTextColor() const; + QColor secondaryTextColor() const; + QColor hintTextColor() const; + QColor textSelectionColor() const; + QColor dropShadowColor() const; + QColor dividerColor() const; + QColor raisedButtonColor() const; + QColor raisedButtonHoverColor() const; + QColor raisedButtonPressColor() const; + QColor raisedButtonDisabledColor() const; + QColor flatButtonPressColor() const; + QColor flatButtonFocusColor() const; + QColor frameColor() const; + QColor checkBoxUncheckedRippleColor() const; + QColor checkBoxCheckedRippleColor() const; + QColor switchUncheckedTrackColor() const; + QColor switchCheckedTrackColor() const; + QColor switchUncheckedHandleColor() const; + QColor switchCheckedHandleColor() const; + QColor switchDisabledTrackColor() const; + QColor switchDisabledHandleColor() const; + QColor scrollBarColor() const; + QColor scrollBarPressedColor() const; + QColor drawerBackgroundColor() const; + + Q_INVOKABLE QColor color(Color color, Shade shade) const; + +Q_SIGNALS: + void themeChanged(); + void primaryChanged(); + void accentChanged(); + void paletteChanged(); + +protected: + void reparent(QQuickMaterialStyle *theme); + void itemParentChanged(QQuickItem *item, QQuickItem *parent) Q_DECL_OVERRIDE; + +private: + Q_DISABLE_COPY(QQuickMaterialStyle) + Q_DECLARE_PRIVATE(QQuickMaterialStyle) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQuickMaterialStyle, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQUICKMATERIALSTYLE_P_H diff --git a/src/imports/controls/material/qtquickmaterialstyleplugin.cpp b/src/imports/controls/material/qtquickmaterialstyleplugin.cpp new file mode 100644 index 00000000..5821ac08 --- /dev/null +++ b/src/imports/controls/material/qtquickmaterialstyleplugin.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "qquickmaterialstyle_p.h" +#include "qquickmaterialprogressring_p.h" + +QT_BEGIN_NAMESPACE + +class QtQuickMaterialStylePlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + +public: + void registerTypes(const char *uri); +}; + +void QtQuickMaterialStylePlugin::registerTypes(const char *uri) +{ + qmlRegisterUncreatableType(uri, 1, 0, "Material", "Material is an attached property"); + qmlRegisterType(uri, 1, 0, "ProgressRing"); + qmlRegisterType(uri, 1, 0, "RingAnimator"); +} + +QT_END_NAMESPACE + +#include "qtquickmaterialstyleplugin.moc" diff --git a/src/imports/controls/material/resources.qrc b/src/imports/controls/material/resources.qrc new file mode 100644 index 00000000..c2cb2c73 --- /dev/null +++ b/src/imports/controls/material/resources.qrc @@ -0,0 +1,5 @@ + + + images/check.png + + diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 7a5e5bf5..ad8f4645 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ controls \ + controls/material/material.pro \ calendar \ templates -- cgit v1.2.3