From f57f2d9e45b177232b76bde07ff96ef3e43fe5b1 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 15 May 2017 12:52:44 +0200 Subject: Say hello to the Fusion style [ChangeLog][Controls] Introduced a Fusion style that offers a platform agnostic desktop-oriented look'n'feel. Change-Id: Id1c1baf10f4b3a79e89bcc72f6d170ed0b2cc8b0 Reviewed-by: Mitch Curtis --- .gitignore | 1 + .../images/qtquickcontrols2-fusion-palettes.png | Bin 0 -> 12467 bytes .../doc/images/qtquickcontrols2-fusion-violet.png | Bin 0 -> 3763 bytes .../doc/images/qtquickcontrols2-fusion.png | Bin 0 -> 12316 bytes .../controls/doc/src/qtquickcontrols2-fusion.qdoc | 93 +++++++++++ .../controls/doc/src/qtquickcontrols2-index.qdoc | 20 ++- .../controls/doc/src/qtquickcontrols2-styles.qdoc | 27 ++- src/imports/controls/fusion/ApplicationWindow.qml | 55 +++++++ src/imports/controls/fusion/BusyIndicator.qml | 69 ++++++++ src/imports/controls/fusion/Button.qml | 77 +++++++++ src/imports/controls/fusion/ButtonPanel.qml | 77 +++++++++ src/imports/controls/fusion/CheckBox.qml | 75 +++++++++ src/imports/controls/fusion/CheckDelegate.qml | 88 ++++++++++ src/imports/controls/fusion/CheckIndicator.qml | 92 +++++++++++ src/imports/controls/fusion/ComboBox.qml | 176 ++++++++++++++++++++ src/imports/controls/fusion/DelayButton.qml | 137 +++++++++++++++ src/imports/controls/fusion/Dial.qml | 72 ++++++++ src/imports/controls/fusion/Dialog.qml | 95 +++++++++++ src/imports/controls/fusion/DialogButtonBox.qml | 77 +++++++++ src/imports/controls/fusion/Drawer.qml | 82 +++++++++ src/imports/controls/fusion/Frame.qml | 59 +++++++ src/imports/controls/fusion/GroupBox.qml | 80 +++++++++ src/imports/controls/fusion/ItemDelegate.qml | 78 +++++++++ src/imports/controls/fusion/Label.qml | 49 ++++++ src/imports/controls/fusion/Menu.qml | 83 ++++++++++ src/imports/controls/fusion/MenuItem.qml | 90 ++++++++++ src/imports/controls/fusion/MenuSeparator.qml | 59 +++++++ src/imports/controls/fusion/Page.qml | 62 +++++++ src/imports/controls/fusion/PageIndicator.qml | 74 +++++++++ src/imports/controls/fusion/Pane.qml | 58 +++++++ src/imports/controls/fusion/Popup.qml | 62 +++++++ src/imports/controls/fusion/ProgressBar.qml | 118 +++++++++++++ src/imports/controls/fusion/RadioButton.qml | 75 +++++++++ src/imports/controls/fusion/RadioDelegate.qml | 88 ++++++++++ src/imports/controls/fusion/RadioIndicator.qml | 78 +++++++++ src/imports/controls/fusion/RangeSlider.qml | 82 +++++++++ src/imports/controls/fusion/RoundButton.qml | 102 ++++++++++++ src/imports/controls/fusion/ScrollBar.qml | 79 +++++++++ src/imports/controls/fusion/ScrollIndicator.qml | 80 +++++++++ src/imports/controls/fusion/ScrollView.qml | 68 ++++++++ src/imports/controls/fusion/Slider.qml | 68 ++++++++ src/imports/controls/fusion/SliderGroove.qml | 94 +++++++++++ src/imports/controls/fusion/SliderHandle.qml | 86 ++++++++++ src/imports/controls/fusion/SpinBox.qml | 183 +++++++++++++++++++++ src/imports/controls/fusion/SwipeDelegate.qml | 80 +++++++++ src/imports/controls/fusion/Switch.qml | 75 +++++++++ src/imports/controls/fusion/SwitchDelegate.qml | 87 ++++++++++ src/imports/controls/fusion/SwitchIndicator.qml | 137 +++++++++++++++ src/imports/controls/fusion/TabBar.qml | 80 +++++++++ src/imports/controls/fusion/TabButton.qml | 110 +++++++++++++ src/imports/controls/fusion/TextArea.qml | 76 +++++++++ src/imports/controls/fusion/TextField.qml | 103 ++++++++++++ src/imports/controls/fusion/ToolBar.qml | 85 ++++++++++ src/imports/controls/fusion/ToolButton.qml | 77 +++++++++ src/imports/controls/fusion/ToolSeparator.qml | 66 ++++++++ src/imports/controls/fusion/ToolTip.qml | 80 +++++++++ src/imports/controls/fusion/Tumbler.qml | 74 +++++++++ src/imports/controls/fusion/fusion.pri | 65 ++++++++ src/imports/controls/fusion/fusion.pro | 25 +++ src/imports/controls/fusion/images/arrow.png | Bin 0 -> 195 bytes src/imports/controls/fusion/images/arrow.svg | 75 +++++++++ src/imports/controls/fusion/images/arrow@2x.png | Bin 0 -> 219 bytes src/imports/controls/fusion/images/arrow@3x.png | Bin 0 -> 245 bytes src/imports/controls/fusion/images/arrow@4x.png | Bin 0 -> 290 bytes src/imports/controls/fusion/images/checkmark.png | Bin 0 -> 255 bytes src/imports/controls/fusion/images/checkmark.svg | 72 ++++++++ .../controls/fusion/images/checkmark@2x.png | Bin 0 -> 390 bytes .../controls/fusion/images/checkmark@3x.png | Bin 0 -> 494 bytes .../controls/fusion/images/checkmark@4x.png | Bin 0 -> 556 bytes .../controls/fusion/images/progressmask.png | Bin 0 -> 383 bytes .../controls/fusion/images/progressmask.svg | 74 +++++++++ .../controls/fusion/images/progressmask@2x.png | Bin 0 -> 660 bytes .../controls/fusion/images/progressmask@3x.png | Bin 0 -> 866 bytes .../controls/fusion/images/progressmask@4x.png | Bin 0 -> 1103 bytes src/imports/controls/fusion/qmldir | 4 + .../controls/fusion/qquickfusionbusyindicator.cpp | 90 ++++++++++ .../controls/fusion/qquickfusionbusyindicator_p.h | 75 +++++++++ src/imports/controls/fusion/qquickfusiondial.cpp | 152 +++++++++++++++++ src/imports/controls/fusion/qquickfusiondial_p.h | 80 +++++++++ src/imports/controls/fusion/qquickfusionknob.cpp | 99 +++++++++++ src/imports/controls/fusion/qquickfusionknob_p.h | 75 +++++++++ src/imports/controls/fusion/qquickfusionstyle.cpp | 172 +++++++++++++++++++ src/imports/controls/fusion/qquickfusionstyle_p.h | 87 ++++++++++ src/imports/controls/fusion/qquickfusiontheme.cpp | 51 ++++++ src/imports/controls/fusion/qquickfusiontheme_p.h | 67 ++++++++ .../fusion/qtquickcontrols2fusionstyle.qrc | 16 ++ .../fusion/qtquickcontrols2fusionstyleplugin.cpp | 121 ++++++++++++++ src/imports/imports.pro | 1 + src/quickcontrols2/configure.json | 9 +- tests/auto/controls/controls.pro | 1 + tests/auto/controls/fusion/dependencies.qml | 6 + tests/auto/controls/fusion/fusion.pro | 15 ++ tests/auto/controls/fusion/tst_fusion.cpp | 47 ++++++ tests/auto/sanity/tst_sanity.cpp | 1 + tests/benchmarks/objectcount/tst_objectcount.cpp | 1 + 95 files changed, 5867 insertions(+), 12 deletions(-) create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-fusion-palettes.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-fusion-violet.png create mode 100644 src/imports/controls/doc/images/qtquickcontrols2-fusion.png create mode 100644 src/imports/controls/doc/src/qtquickcontrols2-fusion.qdoc create mode 100644 src/imports/controls/fusion/ApplicationWindow.qml create mode 100644 src/imports/controls/fusion/BusyIndicator.qml create mode 100644 src/imports/controls/fusion/Button.qml create mode 100644 src/imports/controls/fusion/ButtonPanel.qml create mode 100644 src/imports/controls/fusion/CheckBox.qml create mode 100644 src/imports/controls/fusion/CheckDelegate.qml create mode 100644 src/imports/controls/fusion/CheckIndicator.qml create mode 100644 src/imports/controls/fusion/ComboBox.qml create mode 100644 src/imports/controls/fusion/DelayButton.qml create mode 100644 src/imports/controls/fusion/Dial.qml create mode 100644 src/imports/controls/fusion/Dialog.qml create mode 100644 src/imports/controls/fusion/DialogButtonBox.qml create mode 100644 src/imports/controls/fusion/Drawer.qml create mode 100644 src/imports/controls/fusion/Frame.qml create mode 100644 src/imports/controls/fusion/GroupBox.qml create mode 100644 src/imports/controls/fusion/ItemDelegate.qml create mode 100644 src/imports/controls/fusion/Label.qml create mode 100644 src/imports/controls/fusion/Menu.qml create mode 100644 src/imports/controls/fusion/MenuItem.qml create mode 100644 src/imports/controls/fusion/MenuSeparator.qml create mode 100644 src/imports/controls/fusion/Page.qml create mode 100644 src/imports/controls/fusion/PageIndicator.qml create mode 100644 src/imports/controls/fusion/Pane.qml create mode 100644 src/imports/controls/fusion/Popup.qml create mode 100644 src/imports/controls/fusion/ProgressBar.qml create mode 100644 src/imports/controls/fusion/RadioButton.qml create mode 100644 src/imports/controls/fusion/RadioDelegate.qml create mode 100644 src/imports/controls/fusion/RadioIndicator.qml create mode 100644 src/imports/controls/fusion/RangeSlider.qml create mode 100644 src/imports/controls/fusion/RoundButton.qml create mode 100644 src/imports/controls/fusion/ScrollBar.qml create mode 100644 src/imports/controls/fusion/ScrollIndicator.qml create mode 100644 src/imports/controls/fusion/ScrollView.qml create mode 100644 src/imports/controls/fusion/Slider.qml create mode 100644 src/imports/controls/fusion/SliderGroove.qml create mode 100644 src/imports/controls/fusion/SliderHandle.qml create mode 100644 src/imports/controls/fusion/SpinBox.qml create mode 100644 src/imports/controls/fusion/SwipeDelegate.qml create mode 100644 src/imports/controls/fusion/Switch.qml create mode 100644 src/imports/controls/fusion/SwitchDelegate.qml create mode 100644 src/imports/controls/fusion/SwitchIndicator.qml create mode 100644 src/imports/controls/fusion/TabBar.qml create mode 100644 src/imports/controls/fusion/TabButton.qml create mode 100644 src/imports/controls/fusion/TextArea.qml create mode 100644 src/imports/controls/fusion/TextField.qml create mode 100644 src/imports/controls/fusion/ToolBar.qml create mode 100644 src/imports/controls/fusion/ToolButton.qml create mode 100644 src/imports/controls/fusion/ToolSeparator.qml create mode 100644 src/imports/controls/fusion/ToolTip.qml create mode 100644 src/imports/controls/fusion/Tumbler.qml create mode 100644 src/imports/controls/fusion/fusion.pri create mode 100644 src/imports/controls/fusion/fusion.pro create mode 100644 src/imports/controls/fusion/images/arrow.png create mode 100644 src/imports/controls/fusion/images/arrow.svg create mode 100644 src/imports/controls/fusion/images/arrow@2x.png create mode 100644 src/imports/controls/fusion/images/arrow@3x.png create mode 100644 src/imports/controls/fusion/images/arrow@4x.png create mode 100644 src/imports/controls/fusion/images/checkmark.png create mode 100644 src/imports/controls/fusion/images/checkmark.svg create mode 100644 src/imports/controls/fusion/images/checkmark@2x.png create mode 100644 src/imports/controls/fusion/images/checkmark@3x.png create mode 100644 src/imports/controls/fusion/images/checkmark@4x.png create mode 100644 src/imports/controls/fusion/images/progressmask.png create mode 100644 src/imports/controls/fusion/images/progressmask.svg create mode 100644 src/imports/controls/fusion/images/progressmask@2x.png create mode 100644 src/imports/controls/fusion/images/progressmask@3x.png create mode 100644 src/imports/controls/fusion/images/progressmask@4x.png create mode 100644 src/imports/controls/fusion/qmldir create mode 100644 src/imports/controls/fusion/qquickfusionbusyindicator.cpp create mode 100644 src/imports/controls/fusion/qquickfusionbusyindicator_p.h create mode 100644 src/imports/controls/fusion/qquickfusiondial.cpp create mode 100644 src/imports/controls/fusion/qquickfusiondial_p.h create mode 100644 src/imports/controls/fusion/qquickfusionknob.cpp create mode 100644 src/imports/controls/fusion/qquickfusionknob_p.h create mode 100644 src/imports/controls/fusion/qquickfusionstyle.cpp create mode 100644 src/imports/controls/fusion/qquickfusionstyle_p.h create mode 100644 src/imports/controls/fusion/qquickfusiontheme.cpp create mode 100644 src/imports/controls/fusion/qquickfusiontheme_p.h create mode 100644 src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc create mode 100644 src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp create mode 100644 tests/auto/controls/fusion/dependencies.qml create mode 100644 tests/auto/controls/fusion/fusion.pro create mode 100644 tests/auto/controls/fusion/tst_fusion.cpp diff --git a/.gitignore b/.gitignore index 1de963b0..775a39da 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ /tests/auto/applicationwindow/tst_applicationwindow /tests/auto/calendar/tst_calendar /tests/auto/controls/default/tst_default +/tests/auto/controls/fusion/tst_fusion /tests/auto/controls/material/tst_material /tests/auto/controls/universal/tst_universal /tests/auto/cursor/tst_cursor diff --git a/src/imports/controls/doc/images/qtquickcontrols2-fusion-palettes.png b/src/imports/controls/doc/images/qtquickcontrols2-fusion-palettes.png new file mode 100644 index 00000000..d649e137 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-fusion-palettes.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-fusion-violet.png b/src/imports/controls/doc/images/qtquickcontrols2-fusion-violet.png new file mode 100644 index 00000000..4186a78f Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-fusion-violet.png differ diff --git a/src/imports/controls/doc/images/qtquickcontrols2-fusion.png b/src/imports/controls/doc/images/qtquickcontrols2-fusion.png new file mode 100644 index 00000000..037069b5 Binary files /dev/null and b/src/imports/controls/doc/images/qtquickcontrols2-fusion.png differ diff --git a/src/imports/controls/doc/src/qtquickcontrols2-fusion.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-fusion.qdoc new file mode 100644 index 00000000..d5d6657a --- /dev/null +++ b/src/imports/controls/doc/src/qtquickcontrols2-fusion.qdoc @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtquickcontrols2-fusion.html + \title Fusion Style + + The Fusion style is a desktop-oriented style. + + The Fusion style is a platform-agnostic style that offers a desktop-oriented + look'n'feel. It implements the same design language as the \l {Fusion Style Widget Gallery} + {Fusion style for Qt Widgets}. + + \image qtquickcontrols2-fusion.png + + To run an application with the Fusion style, see + \l {Using Styles in Qt Quick Controls 2}. + + \note The Fusion style is not a native desktop style. The style runs on any + platform, and looks similar everywhere. Minor differences may occur due to + differences in the standard system palettes, available fonts, and font + rendering engines. + + \section2 Customization + + The Fusion style uses the standard system \l {Control::palette}{palettes} + to provide colors that match the desktop environment. + + \image qtquickcontrols2-fusion-palettes.png + + Custom palettes can be specified for any \l {Control::palette}{control}, + \l {Popup::palette}{popup}, or \l {ApplicationWindow::palette}{application window}. + Explicit palette attributes are automatically propagated from parent to children, + overriding any system defaults for that attribute. In the following example, + the window and all three switches appear with a violet highlight color: + + \table + \row + \li + \qml + import QtQuick 2.7 + import QtQuick.Controls 2.3 + + ApplicationWindow { + visible: true + + palette.highlight: "violet" + + Column { + anchors.centerIn: parent + + Switch { text: qsTr("First"); checked: true } + Switch { text: qsTr("Second"); checked: true } + Switch { text: qsTr("Third") } + } + } + \endqml + \li + \image qtquickcontrols2-fusion-violet.png + \endtable + + \b {See also} \l {Default Style}, \l {Material Style}, \l {Universal Style} + + \section1 Related Information + + \list + \li \l{Styling Qt Quick Controls 2} + \endlist +*/ diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 703c5d33..81318cde 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -46,21 +46,31 @@ Default - + Material - + + + Default Style + Material Style + + + + + Fusion + + + Universal - Default - Material - Universal + Fusion Style + Universal Style \endraw diff --git a/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc index 42d8bc62..472b02c9 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-styles.qdoc @@ -34,7 +34,7 @@ \raw HTML - - + + + + + + +
+ @@ -44,11 +44,6 @@ - - - -
@@ -61,6 +56,25 @@ based on the Google Material Design Guidelines, but requires more system resources than the Default style.
+ + + + + + + +
+ The Fusion style is + a platform-agnostic style that offers a desktop-oriented look'n'feel + for Qt Quick Controls 2. + The Universal style offers an appealing design based on the Microsoft Universal Design Guidelines, @@ -136,6 +150,7 @@ \section1 Related Information \list \li \l {Default Style} + \li \l {Fusion Style} \li \l {Material Style} \li \l {Universal Style} \li \l {Using File Selectors with Qt Quick Controls 2} diff --git a/src/imports/controls/fusion/ApplicationWindow.qml b/src/imports/controls/fusion/ApplicationWindow.qml new file mode 100644 index 00000000..8ba73b1d --- /dev/null +++ b/src/imports/controls/fusion/ApplicationWindow.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Window 2.2 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ApplicationWindow { + id: window + + color: palette.window + + overlay.modal: Rectangle { + color: Fusion.topShadow + } + + overlay.modeless: Rectangle { + color: Fusion.topShadow + } +} diff --git a/src/imports/controls/fusion/BusyIndicator.qml b/src/imports/controls/fusion/BusyIndicator.qml new file mode 100644 index 00000000..89c08ca8 --- /dev/null +++ b/src/imports/controls/fusion/BusyIndicator.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.BusyIndicator { + id: control + + implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding + implicitHeight: contentItem.implicitHeight + topPadding + bottomPadding + + padding: 6 + + contentItem: BusyIndicatorImpl { + implicitWidth: 28 + implicitHeight: 28 + color: control.palette.text + + opacity: control.running ? 1 : 0 + visible: control.running || opacityAnimator.running + Behavior on opacity { OpacityAnimator { id: opacityAnimator; duration: 250 } } + + RotationAnimator on rotation { + running: control.running || opacityAnimator.running + from: 0 + to: 360 + duration: 1000 + loops: Animation.Infinite + } + } +} diff --git a/src/imports/controls/fusion/Button.qml b/src/imports/controls/fusion/Button.qml new file mode 100644 index 00000000..e402d64e --- /dev/null +++ b/src/imports/controls/fusion/Button.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Button { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 4 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + + icon: control.icon + text: control.text + font: control.font + color: control.palette.buttonText + } + + background: ButtonPanel { + implicitWidth: 80 + implicitHeight: 24 + + control: control + visible: !control.flat || control.down || control.checked || control.highlighted || control.visualFocus || control.hovered + } +} diff --git a/src/imports/controls/fusion/ButtonPanel.qml b/src/imports/controls/fusion/ButtonPanel.qml new file mode 100644 index 00000000..c590756e --- /dev/null +++ b/src/imports/controls/fusion/ButtonPanel.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: panel + + property Item control + property bool highlighted: control.highlighted + + visible: !control.flat || control.down || control.checked + + color: Fusion.buttonColor(control.palette, panel.highlighted, control.down || control.checked, control.hovered) + gradient: control.down || control.checked ? null : buttonGradient + + Gradient { + id: buttonGradient + GradientStop { + position: 0 + color: Fusion.gradientStart(Fusion.buttonColor(control.palette, panel.highlighted, control.down, control.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(control.palette, panel.highlighted, control.down, control.hovered)) + } + } + + radius: 2 + border.color: Fusion.buttonOutline(control.palette, panel.highlighted || control.visualFocus, control.enabled) + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + border.color: Fusion.innerContrastLine + color: "transparent" + radius: 2 + } +} diff --git a/src/imports/controls/fusion/CheckBox.qml b/src/imports/controls/fusion/CheckBox.qml new file mode 100644 index 00000000..235e2efa --- /dev/null +++ b/src/imports/controls/fusion/CheckBox.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.CheckBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + indicator: CheckIndicator { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + control: control + } + + contentItem: Text { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + + text: control.text + font: control.font + color: control.palette.windowText + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/imports/controls/fusion/CheckDelegate.qml b/src/imports/controls/fusion/CheckDelegate.qml new file mode 100644 index 00000000..8841d5bf --- /dev/null +++ b/src/imports/controls/fusion/CheckDelegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.CheckDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + leftPadding: control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: !control.mirrored ? control.indicator.width + control.spacing : 0 + + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + indicator: CheckIndicator { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: control.down ? Fusion.buttonColor(control.palette, false, true, true) + : control.highlighted ? Fusion.highlight(control.palette) : control.palette.base + } +} diff --git a/src/imports/controls/fusion/CheckIndicator.qml b/src/imports/controls/fusion/CheckIndicator.qml new file mode 100644 index 00000000..54175205 --- /dev/null +++ b/src/imports/controls/fusion/CheckIndicator.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: indicator + + property Item control + readonly property color pressedColor: Fusion.mergedColors(control.palette.base, control.palette.windowText, 85) + readonly property color checkMarkColor: Qt.darker(control.palette.text, 1.2) + + implicitWidth: 14 + implicitHeight: 14 + + color: control.down ? indicator.pressedColor : control.palette.base + border.color: control.visualFocus ? Fusion.highlightedOutline(control.palette) + : Qt.lighter(Fusion.outline(control.palette), 1.1) + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: 1 + color: Fusion.topShadow + visible: control.enabled && !control.down + } + + ColorImage { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + color: Color.transparent(indicator.checkMarkColor, 210 / 255) + source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/checkmark.png" + visible: control.checkState === Qt.Checked || (control.checked && control.checkState === undefined) + } + + Rectangle { + x: 3; y: 3 + width: parent.width - 6 + height: parent.width - 6 + + visible: control.checkState === Qt.PartiallyChecked + + gradient: Gradient { + GradientStop { + position: 0 + color: Color.transparent(indicator.checkMarkColor, 80 / 255) + } + GradientStop { + position: 1 + color: Color.transparent(indicator.checkMarkColor, 140 / 255) + } + } + border.color: Color.transparent(indicator.checkMarkColor, 180 / 255) + } +} diff --git a/src/imports/controls/fusion/ComboBox.qml b/src/imports/controls/fusion/ComboBox.qml new file mode 100644 index 00000000..6e02cbc3 --- /dev/null +++ b/src/imports/controls/fusion/ComboBox.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ComboBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + leftPadding: padding + (!control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) + rightPadding: padding + (control.mirrored || !indicator || !indicator.visible ? 0 : indicator.width + spacing) + + delegate: MenuItem { + width: parent.width + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData + highlighted: control.highlightedIndex === index + hoverEnabled: control.hoverEnabled + } + + indicator: ColorImage { + x: control.mirrored ? control.padding : control.width - width - control.padding + y: control.topPadding + (control.availableHeight - height) / 2 + color: control.editable ? control.palette.text : control.palette.buttonText + source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/arrow.png" + width: 20 + fillMode: Image.Pad + } + + contentItem: T.TextField { + topPadding: 4 + leftPadding: 4 - control.padding + rightPadding: 4 - control.padding + bottomPadding: 4 + + text: control.editable ? control.editText : control.displayText + + enabled: control.editable + autoScroll: control.editable + readOnly: control.popup.visible + inputMethodHints: control.inputMethodHints + validator: control.validator + + font: control.font + color: control.editable ? control.palette.text : control.palette.buttonText + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + + background: PaddedRectangle { + clip: true + radius: 2 + padding: 1 + leftPadding: control.mirrored ? -2 : padding + rightPadding: !control.mirrored ? -2 : padding + color: control.palette.base + visible: control.editable && !control.flat + + Rectangle { + x: parent.width - width + y: 1 + width: 1 + height: parent.height - 2 + color: Fusion.buttonOutline(control.palette, control.activeFocus, control.enabled) + } + + Rectangle { + x: 1 + y: 1 + width: parent.width - 3 + height: 1 + color: Fusion.topShadow + } + } + + Rectangle { + x: 1 - control.leftPadding + y: 1 + width: control.width - 2 + height: control.height - 2 + color: "transparent" + border.color: Color.transparent(Fusion.highlightedOutline(control.palette), 40 / 255) + visible: control.activeFocus + radius: 1.7 + } + } + + background: ButtonPanel { + implicitWidth: 120 + implicitHeight: 24 + + control: control + visible: !control.flat || control.down + // ### TODO: fix control.contentItem.activeFocus + highlighted: control.visualFocus || control.contentItem.activeFocus + } + + popup: T.Popup { + id: popup + width: control.width + implicitHeight: contentItem.implicitHeight + 2 + topMargin: 6 + bottomMargin: 6 + palette: control.palette + padding: 1 + + contentItem: ListView { + clip: true + implicitHeight: contentHeight + model: control.popup.visible ? control.delegateModel : null + currentIndex: control.highlightedIndex + highlightRangeMode: ListView.ApplyRange + highlightMoveDuration: 0 + + T.ScrollBar.vertical: ScrollBar { } + } + + background: Rectangle { + color: popup.palette.window + border.color: Fusion.outline(control.palette) + + Rectangle { + z: -1 + x: 1; y: 1 + width: parent.width + height: parent.height + color: control.palette.shadow + opacity: 0.2 + } + } + } +} diff --git a/src/imports/controls/fusion/DelayButton.qml b/src/imports/controls/fusion/DelayButton.qml new file mode 100644 index 00000000..db9257e8 --- /dev/null +++ b/src/imports/controls/fusion/DelayButton.qml @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.DelayButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + + transition: Transition { + NumberAnimation { + duration: control.delay * (control.pressed ? 1.0 - control.progress : 0.3 * control.progress) + } + } + + contentItem: Item { + implicitWidth: label.implicitWidth + implicitHeight: label.implicitHeight + + Item { + x: -control.leftPadding + (control.mirrored ? 0 : control.progress * control.width) + width: control.width + height: parent.height + + clip: control.progress > 0 + visible: control.mirrored ? control.progress > 0 : control.progress < 1 + + Text { + id: label + x: -parent.x + width: control.availableWidth + height: parent.height + + text: control.text + font: control.font + color: control.mirrored ? control.palette.brightText : control.palette.buttonText + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + + Item { + x: -control.leftPadding + width: (control.mirrored ? 1.0 - control.progress : control.progress) * control.width + height: parent.height + + clip: control.progress > 0 + visible: control.mirrored ? control.progress < 1 : control.progress > 0 + + Text { + x: -parent.x + width: control.availableWidth + height: parent.height + + text: control.text + font: control.font + color: control.mirrored ? control.palette.buttonText : control.palette.brightText + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + } + } + + background: ButtonPanel { + implicitWidth: 80 + implicitHeight: 24 + + control: control + highlighted: false + scale: control.mirrored ? -1 : 1 + + Rectangle { + width: control.progress * parent.width + height: parent.height + + radius: 2 + border.color: Qt.darker(Fusion.highlight(control.palette), 1.4) + gradient: Gradient { + GradientStop { + position: 0 + color: Qt.lighter(Fusion.highlight(control.palette), 1.2) + } + GradientStop { + position: 1 + color: Fusion.highlight(control.palette) + } + } + } + } +} diff --git a/src/imports/controls/fusion/Dial.qml b/src/imports/controls/fusion/Dial.qml new file mode 100644 index 00000000..ec83cccf --- /dev/null +++ b/src/imports/controls/fusion/Dial.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Dial { + id: control + + implicitWidth: 100 + implicitHeight: 100 + + background: DialImpl { + palette: control.palette + highlight: control.visualFocus + } + + handle: KnobImpl { + x: background.x + background.width / 2 - handle.width / 2 + y: background.y + background.height / 2 - handle.height / 2 + width: control.width / 7 + height: control.height / 7 + palette: control.palette + transform: [ + Translate { + y: -Math.min(background.width, background.height) * 0.42 + handle.height + }, + Rotation { + angle: control.angle + origin.x: handle.width / 2 + origin.y: handle.height / 2 + } + ] + } +} diff --git a/src/imports/controls/fusion/Dialog.qml b/src/imports/controls/fusion/Dialog.qml new file mode 100644 index 00000000..a0c9ef18 --- /dev/null +++ b/src/imports/controls/fusion/Dialog.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Dialog { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + header && header.visible ? header.implicitWidth : 0, + footer && footer.visible ? footer.implicitWidth : 0, + contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0) + + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: 6 + + background: Rectangle { + color: control.palette.window + border.color: control.palette.mid + radius: 2 + + Rectangle { + z: -1 + x: 1; y: 1 + width: parent.width + height: parent.height + color: control.palette.shadow + opacity: 0.2 + radius: 2 + } + } + + header: Label { + text: control.title + visible: control.title + elide: Label.ElideRight + font.bold: true + padding: 6 + background: Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 1 + color: control.palette.window + radius: 2 + } + } + + footer: DialogButtonBox { + visible: count > 0 + } +} diff --git a/src/imports/controls/fusion/DialogButtonBox.qml b/src/imports/controls/fusion/DialogButtonBox.qml new file mode 100644 index 00000000..b4a6afd8 --- /dev/null +++ b/src/imports/controls/fusion/DialogButtonBox.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.DialogButtonBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + + spacing: 6 + padding: 6 + alignment: Qt.AlignRight + + delegate: Button { } + + contentItem: ListView { + implicitWidth: contentWidth + implicitHeight: 24 + + model: control.contentModel + spacing: control.spacing + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + } + + background: Rectangle { + implicitHeight: 32 + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + color: control.palette.window + radius: 2 + } +} diff --git a/src/imports/controls/fusion/Drawer.qml b/src/imports/controls/fusion/Drawer.qml new file mode 100644 index 00000000..4115ec06 --- /dev/null +++ b/src/imports/controls/fusion/Drawer.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Drawer { + id: control + + parent: T.ApplicationWindow.overlay + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + topPadding: control.edge === Qt.BottomEdge + leftPadding: control.edge === Qt.RightEdge + rightPadding: control.edge === Qt.LeftEdge + bottomPadding: control.edge === Qt.TopEdge + + enter: Transition { SmoothedAnimation { velocity: 5 } } + exit: Transition { SmoothedAnimation { velocity: 5 } } + + background: Rectangle { + color: control.palette.window + readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge + Rectangle { + width: parent.horizontal ? 1 : parent.width + height: parent.horizontal ? parent.height : 1 + color: control.palette.mid + x: control.edge === Qt.LeftEdge ? parent.width - 1 : 0 + y: control.edge === Qt.TopEdge ? parent.height - 1 : 0 + } + Rectangle { + width: parent.horizontal ? 1 : parent.width + height: parent.horizontal ? parent.height : 1 + color: control.palette.shadow + opacity: 0.2 + x: control.edge === Qt.LeftEdge ? parent.width : 0 + y: control.edge === Qt.TopEdge ? parent.height : 0 + } + } +} diff --git a/src/imports/controls/fusion/Frame.qml b/src/imports/controls/fusion/Frame.qml new file mode 100644 index 00000000..b5837baa --- /dev/null +++ b/src/imports/controls/fusion/Frame.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +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: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: 9 + + background: Rectangle { + color: "transparent" + border.color: Qt.lighter(Fusion.outline(control.palette), 1.08) + } +} diff --git a/src/imports/controls/fusion/GroupBox.qml b/src/imports/controls/fusion/GroupBox.qml new file mode 100644 index 00000000..93dc751d --- /dev/null +++ b/src/imports/controls/fusion/GroupBox.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.GroupBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + label ? label.implicitWidth + leftPadding + rightPadding : 0, + contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + spacing: 6 + padding: 9 + topPadding: padding + (label && label.implicitWidth > 0 ? label.implicitHeight + spacing : 0) + + label: Text { + x: control.leftPadding + width: control.availableWidth + + text: control.title + font: control.font + color: control.palette.windowText + elide: Text.ElideRight + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + background: Rectangle { + y: control.topPadding - control.padding + width: parent.width + height: parent.height - control.topPadding + control.padding + + radius: 2 + color: Color.transparent("black", 3 / 255) + border.color: Qt.lighter(Fusion.outline(control.palette), 1.08) + } +} diff --git a/src/imports/controls/fusion/ItemDelegate.qml b/src/imports/controls/fusion/ItemDelegate.qml new file mode 100644 index 00000000..9a0c0784 --- /dev/null +++ b/src/imports/controls/fusion/ItemDelegate.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ItemDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: control.down ? Fusion.buttonColor(control.palette, false, true, true) + : control.highlighted ? Fusion.highlight(control.palette) : control.palette.base + } +} diff --git a/src/imports/controls/fusion/Label.qml b/src/imports/controls/fusion/Label.qml new file mode 100644 index 00000000..a4295d1c --- /dev/null +++ b/src/imports/controls/fusion/Label.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Label { + id: control + + color: control.palette.windowText + linkColor: control.palette.link +} diff --git a/src/imports/controls/fusion/Menu.qml b/src/imports/controls/fusion/Menu.qml new file mode 100644 index 00000000..9343afea --- /dev/null +++ b/src/imports/controls/fusion/Menu.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Menu { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding + + margins: 0 + padding: 1 + + contentItem: ListView { + implicitHeight: contentHeight + model: control.contentModel + // TODO: improve this? + interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false + clip: true + keyNavigationWraps: false + currentIndex: -1 + + ScrollIndicator.vertical: ScrollIndicator {} + } + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 20 + + color: control.palette.base + border.color: Fusion.outline(control.palette) + + Rectangle { + z: -1 + x: 1; y: 1 + width: parent.width + height: parent.height + color: control.palette.shadow + opacity: 0.2 + } + } +} diff --git a/src/imports/controls/fusion/MenuItem.qml b/src/imports/controls/fusion/MenuItem.qml new file mode 100644 index 00000000..6cdc8992 --- /dev/null +++ b/src/imports/controls/fusion/MenuItem.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.MenuItem { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + leftPadding: !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.mirrored ? control.indicator.width + control.spacing : 0 + + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.down || control.hovered || control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + indicator: CheckIndicator { + x: control.mirrored ? control.width - width - control.rightPadding : control.leftPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + visible: control.checkable + } + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 20 + + color: Fusion.highlight(control.palette) + visible: control.down || control.hovered || control.highlighted + } +} diff --git a/src/imports/controls/fusion/MenuSeparator.qml b/src/imports/controls/fusion/MenuSeparator.qml new file mode 100644 index 00000000..d15a1015 --- /dev/null +++ b/src/imports/controls/fusion/MenuSeparator.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.MenuSeparator { + 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: 5 + topPadding: 1 + bottomPadding: 1 + + contentItem: Rectangle { + implicitWidth: 188 + implicitHeight: 1 + color: Qt.lighter(Fusion.darkShade, 1.06) + } +} diff --git a/src/imports/controls/fusion/Page.qml b/src/imports/controls/fusion/Page.qml new file mode 100644 index 00000000..501e91cb --- /dev/null +++ b/src/imports/controls/fusion/Page.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Page { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(contentWidth, + header && header.visible ? header.implicitWidth : 0, + footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentHeight + topPadding + bottomPadding + + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0)) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + background: Rectangle { + color: palette.window + } +} diff --git a/src/imports/controls/fusion/PageIndicator.qml b/src/imports/controls/fusion/PageIndicator.qml new file mode 100644 index 00000000..812bb172 --- /dev/null +++ b/src/imports/controls/fusion/PageIndicator.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +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: 4 + spacing: 4 + + delegate: Rectangle { + implicitWidth: 6 + implicitHeight: 6 + + radius: width / 2 + color: control.palette.shadow + + opacity: index === currentIndex ? 0.95 : pressed ? 0.75 : 0.45 + Behavior on opacity { OpacityAnimator { duration: 100 } } + } + + contentItem: Row { + spacing: control.spacing + + Repeater { + model: control.count + delegate: control.delegate + } + } +} diff --git a/src/imports/controls/fusion/Pane.qml b/src/imports/controls/fusion/Pane.qml new file mode 100644 index 00000000..683386b8 --- /dev/null +++ b/src/imports/controls/fusion/Pane.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Pane { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: 9 + + background: Rectangle { + color: palette.window + } +} diff --git a/src/imports/controls/fusion/Popup.qml b/src/imports/controls/fusion/Popup.qml new file mode 100644 index 00000000..64c9fe49 --- /dev/null +++ b/src/imports/controls/fusion/Popup.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Popup { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + padding: 6 + + background: Rectangle { + color: control.palette.window + border.color: control.palette.mid + radius: 2 + } +} diff --git a/src/imports/controls/fusion/ProgressBar.qml b/src/imports/controls/fusion/ProgressBar.qml new file mode 100644 index 00000000..55fab03e --- /dev/null +++ b/src/imports/controls/fusion/ProgressBar.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ProgressBar { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem ? contentItem.implicitHeight + topPadding + bottomPadding : 0) + + contentItem: Item { + implicitWidth: 120 + implicitHeight: 24 + scale: control.mirrored ? -1 : 1 + + Rectangle { + height: parent.height + width: (control.indeterminate ? 1.0 : control.position) * parent.width + + radius: 2 + border.color: Qt.darker(Fusion.highlight(control.palette), 1.4) + gradient: Gradient { + GradientStop { + position: 0 + color: Qt.lighter(Fusion.highlight(control.palette), 1.2) + } + GradientStop { + position: 1 + color: Fusion.highlight(control.palette) + } + } + } + + Item { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + visible: control.indeterminate + clip: true + + ColorImage { + id: mask + width: Math.ceil(parent.width / implicitWidth + 1) * implicitWidth + height: parent.height + + mirror: control.mirrored + fillMode: Image.TileHorizontally + source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/progressmask.png" + color: Color.transparent(Qt.lighter(Fusion.highlight(control.palette), 1.2), 160 / 255) + + visible: control.indeterminate + NumberAnimation on x { + running: control.indeterminate && control.visible + from: -mask.implicitWidth + to: 0 + loops: Animation.Infinite + duration: 750 + } + } + } + } + + background: Rectangle { + implicitWidth: 120 + implicitHeight: 24 + + radius: 2 + color: control.palette.base + border.color: Fusion.outline(control.palette) + + Rectangle { + x: 1; y: 1; height: 1 + width: parent.width - 2 + color: Fusion.topShadow + } + } +} diff --git a/src/imports/controls/fusion/RadioButton.qml b/src/imports/controls/fusion/RadioButton.qml new file mode 100644 index 00000000..cf4040f3 --- /dev/null +++ b/src/imports/controls/fusion/RadioButton.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.RadioButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + indicator: RadioIndicator { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + control: control + } + + contentItem: Text { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + + text: control.text + font: control.font + color: control.palette.windowText + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/imports/controls/fusion/RadioDelegate.qml b/src/imports/controls/fusion/RadioDelegate.qml new file mode 100644 index 00000000..8d66d22e --- /dev/null +++ b/src/imports/controls/fusion/RadioDelegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.RadioDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + leftPadding: control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: !control.mirrored ? control.indicator.width + control.spacing : 0 + + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + indicator: RadioIndicator { + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding + y: control.topPadding + (control.availableHeight - height) / 2 + + control: control + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: control.down ? Fusion.buttonColor(control.palette, false, true, true) + : control.highlighted ? Fusion.highlight(control.palette) : control.palette.base + } +} diff --git a/src/imports/controls/fusion/RadioIndicator.qml b/src/imports/controls/fusion/RadioIndicator.qml new file mode 100644 index 00000000..a3c9ecd0 --- /dev/null +++ b/src/imports/controls/fusion/RadioIndicator.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: indicator + + property Item control + readonly property color pressedColor: Fusion.mergedColors(control.palette.base, control.palette.windowText, 85) + readonly property color checkMarkColor: Qt.darker(control.palette.text, 1.2) + + implicitWidth: 14 + implicitHeight: 14 + + radius: width / 2 + color: control.down ? indicator.pressedColor : control.palette.base + border.color: control.visualFocus ? Fusion.highlightedOutline(control.palette) + : Qt.darker(control.palette.window, 1.5) + + Rectangle { + y: 1 + width: parent.width + height: parent.height - 1 + radius: width / 2 + color: "transparent" + border.color: Fusion.topShadow + visible: control.enabled && !control.down + } + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 2.32 + height: parent.height / 2.32 + radius: width / 2 + color: Color.transparent(indicator.checkMarkColor, 180 / 255) + border.color: Color.transparent(indicator.checkMarkColor, 200 / 255) + visible: control.checked + } +} diff --git a/src/imports/controls/fusion/RangeSlider.qml b/src/imports/controls/fusion/RangeSlider.qml new file mode 100644 index 00000000..ea9975e8 --- /dev/null +++ b/src/imports/controls/fusion/RangeSlider.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.RangeSlider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + Math.max(first.handle ? first.handle.implicitWidth : 0, + second.handle ? second.handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(first.handle ? first.handle.implicitHeight : 0, + second.handle ? second.handle.implicitHeight : 0) + topPadding + bottomPadding) + + first.handle: SliderHandle { + x: control.leftPadding + Math.round(control.horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + Math.round(control.horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) + + palette: control.palette + pressed: control.first.pressed + hovered: control.first.hovered + vertical: control.vertical + visualFocus: activeFocus + } + + second.handle: SliderHandle { + x: control.leftPadding + Math.round(control.horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + Math.round(control.horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height)) + + palette: control.palette + pressed: control.second.pressed + hovered: control.second.hovered + vertical: control.vertical + visualFocus: activeFocus + } + + background: SliderGroove { + control: control + offset: control.first.position + progress: control.second.position + visualProgress: control.second.visualPosition + } +} diff --git a/src/imports/controls/fusion/RoundButton.qml b/src/imports/controls/fusion/RoundButton.qml new file mode 100644 index 00000000..c17fd72c --- /dev/null +++ b/src/imports/controls/fusion/RoundButton.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.RoundButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + + icon: control.icon + text: control.text + font: control.font + color: control.palette.buttonText + } + + background: Rectangle { + implicitWidth: 32 + implicitHeight: 32 + visible: !control.flat || control.down || control.checked + + color: Fusion.buttonColor(control.palette, control.highlighted, control.down || control.checked, control.hovered) + gradient: control.down || control.checked ? null : buttonGradient + + Gradient { + id: buttonGradient + GradientStop { + position: 0 + color: Fusion.gradientStart(Fusion.buttonColor(control.palette, control.highlighted, control.down, control.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(control.palette, control.highlighted, control.down, control.hovered)) + } + } + + radius: control.radius + border.color: Fusion.buttonOutline(control.palette, control.highlighted || control.visualFocus, control.enabled) + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + border.color: Fusion.innerContrastLine + color: "transparent" + radius: control.radius + } + } +} diff --git a/src/imports/controls/fusion/ScrollBar.qml b/src/imports/controls/fusion/ScrollBar.qml new file mode 100644 index 00000000..071f362d --- /dev/null +++ b/src/imports/controls/fusion/ScrollBar.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ScrollBar { + 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: 2 + visible: control.policy !== T.ScrollBar.AlwaysOff + + contentItem: Rectangle { + id: handle + + implicitWidth: control.interactive ? 6 : 2 + implicitHeight: control.interactive ? 6 : 2 + + radius: width / 2 + color: control.pressed ? control.palette.dark : control.palette.mid + opacity: 0.0 + + states: State { + name: "active" + when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0) + PropertyChanges { target: handle; opacity: 0.75 } + } + + transitions: Transition { + from: "active" + SequentialAnimation { + PauseAnimation { duration: 450 } + NumberAnimation { target: handle; duration: 200; property: "opacity"; to: 0.0 } + } + } + } +} diff --git a/src/imports/controls/fusion/ScrollIndicator.qml b/src/imports/controls/fusion/ScrollIndicator.qml new file mode 100644 index 00000000..a23687ab --- /dev/null +++ b/src/imports/controls/fusion/ScrollIndicator.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ScrollIndicator { + 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: 2 + + contentItem: Rectangle { + id: indicator + + implicitWidth: 2 + implicitHeight: 2 + + color: control.palette.mid + visible: control.size < 1.0 + opacity: 0.0 + + 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 } + } + } + ] + } +} diff --git a/src/imports/controls/fusion/ScrollView.qml b/src/imports/controls/fusion/ScrollView.qml new file mode 100644 index 00000000..d38e4537 --- /dev/null +++ b/src/imports/controls/fusion/ScrollView.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ScrollView { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : -1) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : -1) + + ScrollBar.vertical: ScrollBar { + parent: control + x: control.mirrored ? 0 : control.width - width + y: control.topPadding + height: control.availableHeight + active: control.ScrollBar.horizontal.active + } + + ScrollBar.horizontal: ScrollBar { + parent: control + x: control.leftPadding + y: control.height - height + width: control.availableWidth + active: control.ScrollBar.vertical.active + } +} diff --git a/src/imports/controls/fusion/Slider.qml b/src/imports/controls/fusion/Slider.qml new file mode 100644 index 00000000..37a3ef14 --- /dev/null +++ b/src/imports/controls/fusion/Slider.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Slider { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + (handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) + + handle: SliderHandle { + x: control.leftPadding + Math.round(control.horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) + y: control.topPadding + Math.round(control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) + + palette: control.palette + pressed: control.pressed + hovered: control.hovered + vertical: control.vertical + visualFocus: control.visualFocus + } + + background: SliderGroove { + control: control + progress: control.position + visualProgress: control.visualPosition + } +} diff --git a/src/imports/controls/fusion/SliderGroove.qml b/src/imports/controls/fusion/SliderGroove.qml new file mode 100644 index 00000000..c243ccc3 --- /dev/null +++ b/src/imports/controls/fusion/SliderGroove.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: groove + + property Item control + property real offset + property real progress + property real visualProgress + + x: control.horizontal ? 0 : (control.availableWidth - width) / 2 + y: control.horizontal ? (control.availableHeight - height) / 2 : 0 + + implicitWidth: control.horizontal ? 160 : 5 + implicitHeight: control.horizontal ? 5 : 160 + width: control.horizontal ? control.availableWidth : implicitWidth + height: control.horizontal ? implicitHeight : control.availableHeight + + radius: 2 + border.color: Fusion.outline(control.palette) + scale: control.horizontal && control.mirrored ? -1 : 1 + + gradient: Gradient { + GradientStop { + position: 0 + color: Qt.darker(Fusion.grooveColor(control.palette), 1.1) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.grooveColor(control.palette), 1.1) + } + } + + Rectangle { + x: control.horizontal ? groove.offset * parent.width : 0 + y: control.horizontal ? 0 : groove.visualProgress * parent.height + width: control.horizontal ? groove.progress * parent.width - groove.offset * parent.width : 5 + height: control.horizontal ? 5 : groove.progress * parent.height - groove.offset * parent.height + + radius: 2 + border.color: Qt.darker(Fusion.highlightedOutline(control.palette), 1.1) + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.highlight(control.palette) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.highlight(control.palette), 1.2) + } + } + } +} diff --git a/src/imports/controls/fusion/SliderHandle.qml b/src/imports/controls/fusion/SliderHandle.qml new file mode 100644 index 00000000..71aff706 --- /dev/null +++ b/src/imports/controls/fusion/SliderHandle.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: handle + + property var palette + property bool pressed + property bool hovered + property bool vertical + property bool visualFocus + + implicitWidth: 13 + implicitHeight: 13 + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.gradientStart(Fusion.buttonColor(handle.palette, handle.visualFocus, handle.pressed, handle.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(handle.palette, handle.visualFocus, handle.pressed, handle.hovered)) + } + } + rotation: handle.vertical ? -90 : 0 + border.width: 1 + border.color: "transparent" + radius: 2 + + Rectangle { + width: parent.width + height: parent.height + border.color: handle.visualFocus ? Fusion.highlightedOutline(handle.palette) : Fusion.outline(handle.palette) + color: "transparent" + radius: 2 + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + border.color: Fusion.innerContrastLine + color: "transparent" + radius: 2 + } + } +} diff --git a/src/imports/controls/fusion/SpinBox.qml b/src/imports/controls/fusion/SpinBox.qml new file mode 100644 index 00000000..ce11d244 --- /dev/null +++ b/src/imports/controls/fusion/SpinBox.qml @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.SpinBox { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + 2 * padding + + Math.max(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)) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 4 + leftPadding: padding + (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0)) + rightPadding: padding + (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0)) + + validator: IntValidator { + locale: control.locale.name + bottom: Math.min(control.from, control.to) + top: Math.max(control.from, control.to) + } + + contentItem: TextInput { + z: 2 + text: control.textFromValue(control.value, control.locale) + + font: control.font + color: control.palette.text + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + + readOnly: !control.editable + validator: control.validator + inputMethodHints: control.inputMethodHints + } + + up.indicator: PaddedRectangle { + x: control.mirrored ? 1 : parent.width - width - 1 + y: 1 + height: parent.height / 2 - 1 + implicitWidth: 16 + implicitHeight: 10 + + radius: 1.7 + clip: true + topPadding: -2 + leftPadding: -2 + color: control.up.pressed ? Fusion.buttonColor(control.palette, false, true, true) : "transparent" + + ColorImage { + scale: -1 + width: parent.width + height: parent.height + opacity: enabled ? 1.0 : 0.5 + color: control.palette.buttonText + source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/arrow.png" + fillMode: Image.Pad + } + } + + down.indicator: PaddedRectangle { + x: control.mirrored ? 1 : parent.width - width - 1 + y: parent.height - height - 1 + height: parent.height / 2 - 1 + implicitWidth: 16 + implicitHeight: 10 + + radius: 1.7 + clip: true + topPadding: -2 + leftPadding: -2 + color: control.down.pressed ? Fusion.buttonColor(control.palette, false, true, true) : "transparent" + + ColorImage { + width: parent.width + height: parent.height + opacity: enabled ? 1.0 : 0.5 + color: control.palette.buttonText + source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/arrow.png" + fillMode: Image.Pad + } + } + + background: Rectangle { + implicitWidth: 120 + implicitHeight: 24 + + radius: 2 + color: control.palette.base + border.color: control.activeFocus ? Fusion.highlightedOutline(control.palette) : Fusion.outline(control.palette) + + Rectangle { + x: 2 + y: 1 + width: parent.width - 4 + height: 1 + color: Fusion.topShadow + } + + Rectangle { + x: control.mirrored ? 1 : parent.width - width - 1 + y: 1 + width: Math.max(up.indicator ? up.indicator.width : 0, + down.indicator ? down.indicator.width : 0) + 1 + height: parent.height - 2 + + radius: 2 + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.gradientStart(Fusion.buttonColor(control.palette, control.visualFocus, false, control.up.hovered || control.down.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(control.palette, control.visualFocus, false, control.up.hovered || control.down.hovered)) + } + } + + Rectangle { + x: control.mirrored ? parent.width - 1 : 0 + height: parent.height + width: 1 + color: Fusion.outline(control.palette) + } + } + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + color: "transparent" + border.color: Color.transparent(Fusion.highlightedOutline(control.palette), 40 / 255) + visible: control.activeFocus + radius: 1.7 + } + } +} diff --git a/src/imports/controls/fusion/SwipeDelegate.qml b/src/imports/controls/fusion/SwipeDelegate.qml new file mode 100644 index 00000000..f279963b --- /dev/null +++ b/src/imports/controls/fusion/SwipeDelegate.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.SwipeDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + swipe.transition: Transition { SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic } } + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: control.down ? Fusion.buttonColor(control.palette, false, true, true) + : control.highlighted ? Fusion.highlight(control.palette) : control.palette.base + } +} diff --git a/src/imports/controls/fusion/Switch.qml b/src/imports/controls/fusion/Switch.qml new file mode 100644 index 00000000..3bb7607d --- /dev/null +++ b/src/imports/controls/fusion/Switch.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Switch { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + indicator: SwitchIndicator { + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + control: control + } + + contentItem: Text { + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + + text: control.text + font: control.font + color: control.palette.text + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } +} diff --git a/src/imports/controls/fusion/SwitchDelegate.qml b/src/imports/controls/fusion/SwitchDelegate.qml new file mode 100644 index 00000000..fde4b38f --- /dev/null +++ b/src/imports/controls/fusion/SwitchDelegate.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.SwitchDelegate { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + Math.max(contentItem.implicitHeight, + indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + indicator: SwitchIndicator { + x: text ? (control.mirrored ? control.leftPadding : control.width - width - control.rightPadding) : control.leftPadding + (control.availableWidth - width) / 2 + y: control.topPadding + (control.availableHeight - height) / 2 + control: control + } + + contentItem: IconLabel { + leftPadding: control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: !control.mirrored ? control.indicator.width + control.spacing : 0 + + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft + + icon: control.icon + text: control.text + font: control.font + color: control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: control.down ? Fusion.buttonColor(control.palette, false, true, true) + : control.highlighted ? Fusion.highlight(control.palette) : control.palette.base + } +} diff --git a/src/imports/controls/fusion/SwitchIndicator.qml b/src/imports/controls/fusion/SwitchIndicator.qml new file mode 100644 index 00000000..a674afe4 --- /dev/null +++ b/src/imports/controls/fusion/SwitchIndicator.qml @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +Rectangle { + id: indicator + + property Item control + readonly property color pressedColor: Fusion.mergedColors(control.palette.base, control.palette.windowText, 85) + readonly property color checkMarkColor: Qt.darker(control.palette.text, 1.2) + + implicitWidth: 40 + implicitHeight: 16 + + radius: 2 + border.color: Fusion.outline(control.palette) + + gradient: Gradient { + GradientStop { + position: 0 + color: Qt.darker(Fusion.grooveColor(control.palette), 1.1) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.grooveColor(control.palette), 1.1) + } + } + + Rectangle { + x: control.mirrored ? handle.x : 0 + width: control.mirrored ? parent.width - handle.x : handle.x + handle.width + height: parent.height + + opacity: control.checked ? 1 : 0 + Behavior on opacity { + enabled: !control.down + NumberAnimation { duration: 80 } + } + + radius: 2 + border.color: Qt.darker(Fusion.highlightedOutline(control.palette), 1.1) + border.width: control.enabled ? 1 : 0 + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.highlight(control.palette) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.highlight(control.palette), 1.2) + } + } + } + + Rectangle { + id: handle + x: Math.max(0, Math.min(parent.width - width, control.visualPosition * parent.width - (width / 2))) + y: (parent.height - height) / 2 + width: 20 + height: 16 + radius: 2 + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.gradientStart(Fusion.buttonColor(control.palette, control.visualFocus, control.pressed, control.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(control.palette, control.visualFocus, control.pressed, control.hovered)) + } + } + border.width: 1 + border.color: "transparent" + + Rectangle { + width: parent.width + height: parent.height + border.color: control.visualFocus ? Fusion.highlightedOutline(control.palette) : Fusion.outline(control.palette) + color: "transparent" + radius: 2 + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + border.color: Fusion.innerContrastLine + color: "transparent" + radius: 2 + } + } + + Behavior on x { + enabled: !control.down + SmoothedAnimation { velocity: 200 } + } + } +} diff --git a/src/imports/controls/fusion/TabBar.qml b/src/imports/controls/fusion/TabBar.qml new file mode 100644 index 00000000..d28c55e4 --- /dev/null +++ b/src/imports/controls/fusion/TabBar.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.TabBar { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentHeight + topPadding + bottomPadding) + + spacing: -1 + + contentItem: ListView { + model: control.contentModel + currentIndex: control.currentIndex + + spacing: control.spacing + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + flickableDirection: Flickable.AutoFlickIfNeeded + snapMode: ListView.SnapToItem + + highlightMoveDuration: 0 + highlightRangeMode: ListView.ApplyRange + preferredHighlightBegin: 40 + preferredHighlightEnd: width - 40 + } + + background: Item { + implicitHeight: 21 + + Rectangle { + width: parent.width + height: 1 + y: control.position === T.TabBar.Header ? parent.height - 1 : 0 + color: Fusion.outline(control.palette) + } + } +} diff --git a/src/imports/controls/fusion/TabButton.qml b/src/imports/controls/fusion/TabButton.qml new file mode 100644 index 00000000..fab406dc --- /dev/null +++ b/src/imports/controls/fusion/TabButton.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.TabButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 2 + leftPadding: 4 + rightPadding: 4 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + z: checked + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + + icon: control.icon + text: control.text + font: control.font + color: control.palette.buttonText + } + + background: Rectangle { + y: control.checked || control.TabBar.position !== T.TabBar.Header ? 0 : 2 + implicitHeight: 21 + height: control.height - (control.checked ? 0 : 2) + + border.color: Qt.lighter(Fusion.outline(control.palette), 1.1) + gradient: control.checked ? selectedGradient : normalGradient + + Gradient { + id: selectedGradient + GradientStop { + position: 0 + color: Qt.lighter(Fusion.tabFrameColor(control.palette), 1.04) + } + GradientStop { + position: 1 + color: Fusion.tabFrameColor(control.palette) + } + } + + Gradient { + id: normalGradient + GradientStop { + position: 0 + color: Qt.darker(Fusion.tabFrameColor(control.palette), 1.08) + } + GradientStop { + position: 0.85 + color: Qt.darker(Fusion.tabFrameColor(control.palette), 1.08) + } + GradientStop { + position: 1 + color: Qt.darker(Fusion.tabFrameColor(control.palette), 1.16) + } + } + } +} diff --git a/src/imports/controls/fusion/TextArea.qml b/src/imports/controls/fusion/TextArea.qml new file mode 100644 index 00000000..bf1de555 --- /dev/null +++ b/src/imports/controls/fusion/TextArea.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +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 + leftPadding: padding + 4 + + color: control.palette.text + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + + PlaceholderText { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + opacity: 0.5 + text: control.placeholderText + font: control.font + color: control.palette.text + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + } +} diff --git a/src/imports/controls/fusion/TextField.qml b/src/imports/controls/fusion/TextField.qml new file mode 100644 index 00000000..49e38c1e --- /dev/null +++ b/src/imports/controls/fusion/TextField.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.TextField { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + placeholderText ? placeholder.implicitWidth + leftPadding + rightPadding : 0) + || contentWidth + leftPadding + rightPadding + implicitHeight: Math.max(contentHeight + topPadding + bottomPadding, + background ? background.implicitHeight : 0, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 4 + + color: control.palette.text + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + verticalAlignment: TextInput.AlignVCenter + + PlaceholderText { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + opacity: 0.5 + text: control.placeholderText + font: control.font + color: control.palette.text + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + } + + background: Rectangle { + implicitWidth: 120 + implicitHeight: 24 + + radius: 2 + color: control.palette.base + border.color: control.activeFocus ? Fusion.highlightedOutline(control.palette) : Fusion.outline(control.palette) + + Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 2 + color: "transparent" + border.color: Color.transparent(Fusion.highlightedOutline(control.palette), 40 / 255) + visible: control.activeFocus + radius: 1.7 + } + + Rectangle { + x: 2 + y: 1 + width: parent.width - 4 + height: 1 + color: Fusion.topShadow + } + } +} diff --git a/src/imports/controls/fusion/ToolBar.qml b/src/imports/controls/fusion/ToolBar.qml new file mode 100644 index 00000000..0181a509 --- /dev/null +++ b/src/imports/controls/fusion/ToolBar.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ToolBar { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding) + + contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) + contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) + + leftPadding: 6 + rightPadding: 6 + topPadding: control.position === T.ToolBar.Footer ? 1 : 0 + bottomPadding: control.position === T.ToolBar.Header ? 1 : 0 + + background: Rectangle { + implicitHeight: 26 + + gradient: Gradient { + GradientStop { + position: 0 + color: Qt.lighter(control.palette.window, 1.04) + } + GradientStop { + position: 1 + color: control.palette.window + } + } + + Rectangle { + width: parent.width + height: 1 + color: control.position === T.ToolBar.Header ? Fusion.lightShade : Fusion.darkShade + } + + Rectangle { + y: parent.height - height + width: parent.width + height: 1 + color: control.position === T.ToolBar.Header ? Fusion.darkShade : Fusion.lightShade + } + } +} diff --git a/src/imports/controls/fusion/ToolButton.qml b/src/imports/controls/fusion/ToolButton.qml new file mode 100644 index 00000000..aa7516b0 --- /dev/null +++ b/src/imports/controls/fusion/ToolButton.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ToolButton { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + baselineOffset: contentItem.y + contentItem.baselineOffset + + padding: 6 + spacing: 6 + + icon.width: 16 + icon.height: 16 + + contentItem: IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + + icon: control.icon + text: control.text + font: control.font + color: control.palette.buttonText + } + + background: ButtonPanel { + implicitWidth: 20 + implicitHeight: 20 + + control: control + visible: control.down || control.checked || control.highlighted || control.visualFocus || control.hovered + } +} diff --git a/src/imports/controls/fusion/ToolSeparator.qml b/src/imports/controls/fusion/ToolSeparator.qml new file mode 100644 index 00000000..70509f3f --- /dev/null +++ b/src/imports/controls/fusion/ToolSeparator.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ToolSeparator { + 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: vertical ? 6 : 2 + topPadding: vertical ? 2 : 6 + bottomPadding: vertical ? 2 : 6 + + contentItem: Rectangle { + implicitWidth: vertical ? 2 : 8 + implicitHeight: vertical ? 8 : 2 + color: Qt.darker(control.palette.window, 1.1) + + Rectangle { + x: 1 + width: 1 + height: parent.height + color: Qt.lighter(control.palette.window, 1.1) + } + } +} diff --git a/src/imports/controls/fusion/ToolTip.qml b/src/imports/controls/fusion/ToolTip.qml new file mode 100644 index 00000000..8e9be597 --- /dev/null +++ b/src/imports/controls/fusion/ToolTip.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.ToolTip { + id: control + + x: parent ? (parent.width - implicitWidth) / 2 : 0 + y: -implicitHeight - 3 + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + contentItem.implicitHeight + topPadding + bottomPadding) + + margins: 6 + padding: 6 + + closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnReleaseOutsideParent + + contentItem: Text { + text: control.text + font: control.font + color: control.palette.toolTipText + // TODO: wrapMode: Label.Wrap + } + + background: Rectangle { + color: control.palette.toolTipBase + border.color: control.palette.toolTipText + + Rectangle { + z: -1 + x: 1; y: 1 + width: parent.width + height: parent.height + color: control.palette.shadow + opacity: 0.5 + } + } +} diff --git a/src/imports/controls/fusion/Tumbler.qml b/src/imports/controls/fusion/Tumbler.qml new file mode 100644 index 00000000..77a0c93c --- /dev/null +++ b/src/imports/controls/fusion/Tumbler.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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.9 +import QtQuick.Templates 2.3 as T +import QtQuick.Controls 2.3 +import QtQuick.Controls.impl 2.3 +import QtQuick.Controls.Fusion 2.3 +import QtQuick.Controls.Fusion.impl 2.3 + +T.Tumbler { + id: control + implicitWidth: 60 + implicitHeight: 200 + + delegate: Text { + id: label + text: modelData + color: control.palette.windowText + font: control.font + opacity: (1.0 - Math.abs(Tumbler.displacement) / (visibleItemCount / 2)) * (control.enabled ? 1 : 0.6) + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + contentItem: TumblerView { + id: tumblerView + model: control.model + delegate: control.delegate + path: Path { + startX: tumblerView.width / 2 + startY: -tumblerView.delegateHeight / 2 + PathLine { + x: tumblerView.width / 2 + y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2 + } + } + + property real delegateHeight: control.availableHeight / control.visibleItemCount + } +} diff --git a/src/imports/controls/fusion/fusion.pri b/src/imports/controls/fusion/fusion.pri new file mode 100644 index 00000000..9902e971 --- /dev/null +++ b/src/imports/controls/fusion/fusion.pri @@ -0,0 +1,65 @@ +HEADERS += \ + $$PWD/qquickfusionbusyindicator_p.h \ + $$PWD/qquickfusiondial_p.h \ + $$PWD/qquickfusionknob_p.h \ + $$PWD/qquickfusionstyle_p.h \ + $$PWD/qquickfusiontheme_p.h + +SOURCES += \ + $$PWD/qquickfusionbusyindicator.cpp \ + $$PWD/qquickfusiondial.cpp \ + $$PWD/qquickfusionknob.cpp \ + $$PWD/qquickfusionstyle.cpp \ + $$PWD/qquickfusiontheme.cpp + +QML_FILES += \ + $$PWD/ApplicationWindow.qml \ + $$PWD/BusyIndicator.qml \ + $$PWD/Button.qml \ + $$PWD/ButtonPanel.qml \ + $$PWD/CheckBox.qml \ + $$PWD/CheckDelegate.qml \ + $$PWD/CheckIndicator.qml \ + $$PWD/ComboBox.qml \ + $$PWD/DelayButton.qml \ + $$PWD/Dial.qml \ + $$PWD/Dialog.qml \ + $$PWD/DialogButtonBox.qml \ + $$PWD/Drawer.qml \ + $$PWD/Frame.qml \ + $$PWD/GroupBox.qml \ + $$PWD/ItemDelegate.qml \ + $$PWD/Label.qml \ + $$PWD/Menu.qml \ + $$PWD/MenuItem.qml \ + $$PWD/MenuSeparator.qml \ + $$PWD/Page.qml \ + $$PWD/PageIndicator.qml \ + $$PWD/Pane.qml \ + $$PWD/Popup.qml \ + $$PWD/ProgressBar.qml \ + $$PWD/RadioButton.qml \ + $$PWD/RadioDelegate.qml \ + $$PWD/RadioIndicator.qml \ + $$PWD/RangeSlider.qml \ + $$PWD/RoundButton.qml \ + $$PWD/ScrollBar.qml \ + $$PWD/ScrollIndicator.qml \ + $$PWD/ScrollView.qml \ + $$PWD/Slider.qml \ + $$PWD/SliderGroove.qml \ + $$PWD/SliderHandle.qml \ + $$PWD/SpinBox.qml \ + $$PWD/SwipeDelegate.qml \ + $$PWD/SwitchDelegate.qml \ + $$PWD/SwitchIndicator.qml \ + $$PWD/Switch.qml \ + $$PWD/TabBar.qml \ + $$PWD/TabButton.qml \ + $$PWD/TextArea.qml \ + $$PWD/TextField.qml \ + $$PWD/ToolBar.qml \ + $$PWD/ToolButton.qml \ + $$PWD/ToolSeparator.qml \ + $$PWD/ToolTip.qml \ + $$PWD/Tumbler.qml diff --git a/src/imports/controls/fusion/fusion.pro b/src/imports/controls/fusion/fusion.pro new file mode 100644 index 00000000..c2b649cf --- /dev/null +++ b/src/imports/controls/fusion/fusion.pro @@ -0,0 +1,25 @@ +TARGET = qtquickcontrols2fusionstyleplugin +TARGETPATH = QtQuick/Controls.2/Fusion +IMPORT_VERSION = 2.3 + +QT += qml quick +QT_PRIVATE += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private + +DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII + +include(fusion.pri) + +OTHER_FILES += \ + qmldir \ + $$QML_FILES + +SOURCES += \ + $$PWD/qtquickcontrols2fusionstyleplugin.cpp + +RESOURCES += \ + $$PWD/qtquickcontrols2fusionstyle.qrc + +CONFIG += no_cxx_module +load(qml_plugin) + +requires(qtConfig(quickcontrols2-fusion)) diff --git a/src/imports/controls/fusion/images/arrow.png b/src/imports/controls/fusion/images/arrow.png new file mode 100644 index 00000000..ad8cdc95 Binary files /dev/null and b/src/imports/controls/fusion/images/arrow.png differ diff --git a/src/imports/controls/fusion/images/arrow.svg b/src/imports/controls/fusion/images/arrow.svg new file mode 100644 index 00000000..44383924 --- /dev/null +++ b/src/imports/controls/fusion/images/arrow.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/imports/controls/fusion/images/arrow@2x.png b/src/imports/controls/fusion/images/arrow@2x.png new file mode 100644 index 00000000..4f94c58f Binary files /dev/null and b/src/imports/controls/fusion/images/arrow@2x.png differ diff --git a/src/imports/controls/fusion/images/arrow@3x.png b/src/imports/controls/fusion/images/arrow@3x.png new file mode 100644 index 00000000..68928ea9 Binary files /dev/null and b/src/imports/controls/fusion/images/arrow@3x.png differ diff --git a/src/imports/controls/fusion/images/arrow@4x.png b/src/imports/controls/fusion/images/arrow@4x.png new file mode 100644 index 00000000..edde50f3 Binary files /dev/null and b/src/imports/controls/fusion/images/arrow@4x.png differ diff --git a/src/imports/controls/fusion/images/checkmark.png b/src/imports/controls/fusion/images/checkmark.png new file mode 100644 index 00000000..9cb04883 Binary files /dev/null and b/src/imports/controls/fusion/images/checkmark.png differ diff --git a/src/imports/controls/fusion/images/checkmark.svg b/src/imports/controls/fusion/images/checkmark.svg new file mode 100644 index 00000000..f1afdc4f --- /dev/null +++ b/src/imports/controls/fusion/images/checkmark.svg @@ -0,0 +1,72 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/imports/controls/fusion/images/checkmark@2x.png b/src/imports/controls/fusion/images/checkmark@2x.png new file mode 100644 index 00000000..ae9a7749 Binary files /dev/null and b/src/imports/controls/fusion/images/checkmark@2x.png differ diff --git a/src/imports/controls/fusion/images/checkmark@3x.png b/src/imports/controls/fusion/images/checkmark@3x.png new file mode 100644 index 00000000..4a67e88a Binary files /dev/null and b/src/imports/controls/fusion/images/checkmark@3x.png differ diff --git a/src/imports/controls/fusion/images/checkmark@4x.png b/src/imports/controls/fusion/images/checkmark@4x.png new file mode 100644 index 00000000..0890d2ba Binary files /dev/null and b/src/imports/controls/fusion/images/checkmark@4x.png differ diff --git a/src/imports/controls/fusion/images/progressmask.png b/src/imports/controls/fusion/images/progressmask.png new file mode 100644 index 00000000..683f9e2f Binary files /dev/null and b/src/imports/controls/fusion/images/progressmask.png differ diff --git a/src/imports/controls/fusion/images/progressmask.svg b/src/imports/controls/fusion/images/progressmask.svg new file mode 100644 index 00000000..a0dfc426 --- /dev/null +++ b/src/imports/controls/fusion/images/progressmask.svg @@ -0,0 +1,74 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/imports/controls/fusion/images/progressmask@2x.png b/src/imports/controls/fusion/images/progressmask@2x.png new file mode 100644 index 00000000..e101f5de Binary files /dev/null and b/src/imports/controls/fusion/images/progressmask@2x.png differ diff --git a/src/imports/controls/fusion/images/progressmask@3x.png b/src/imports/controls/fusion/images/progressmask@3x.png new file mode 100644 index 00000000..784f01c0 Binary files /dev/null and b/src/imports/controls/fusion/images/progressmask@3x.png differ diff --git a/src/imports/controls/fusion/images/progressmask@4x.png b/src/imports/controls/fusion/images/progressmask@4x.png new file mode 100644 index 00000000..8af0b2c2 Binary files /dev/null and b/src/imports/controls/fusion/images/progressmask@4x.png differ diff --git a/src/imports/controls/fusion/qmldir b/src/imports/controls/fusion/qmldir new file mode 100644 index 00000000..c37b9f9f --- /dev/null +++ b/src/imports/controls/fusion/qmldir @@ -0,0 +1,4 @@ +module QtQuick.Controls.Fusion +plugin qtquickcontrols2fusionstyleplugin +classname QtQuickControls2FusionStylePlugin +depends QtQuick.Controls 2.3 diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp new file mode 100644 index 00000000..7254b7b7 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusionbusyindicator_p.h" + +#include + +QT_BEGIN_NAMESPACE + +QQuickFusionBusyIndicator::QQuickFusionBusyIndicator(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor QQuickFusionBusyIndicator::color() const +{ + return m_color; +} + +void QQuickFusionBusyIndicator::setColor(const QColor &color) +{ + if (color == m_color) + return; + + m_color = color; + update(); +} + +void QQuickFusionBusyIndicator::paint(QPainter *painter) +{ + const qreal w = width(); + const qreal h = height(); + if (w <= 0 || h <= 0 || !isVisible()) + return; + + const qreal sz = qMin(w, h); + const qreal dx = (w - sz) / 2; + const qreal dy = (h - sz) / 2; + const int hpw = qRound(qMax(1.0, sz / 14)) & -1; + const int pw = 2 * hpw; + const QRectF bounds(dx + hpw, dy + hpw, sz - pw - 1, sz - pw - 1); + + QConicalGradient gradient; + gradient.setCenter(QPointF(dx + sz / 2, dy + sz / 2)); + gradient.setColorAt(0, m_color); + gradient.setColorAt(0.1, m_color); + gradient.setColorAt(1, Qt::transparent); + + painter->translate(0.5, 0.5); + painter->setRenderHint(QPainter::Antialiasing, true); + painter->setPen(QPen(gradient, pw, Qt::SolidLine)); + painter->drawArc(bounds, 0, 360 * 16); + painter->setPen(QPen(m_color, pw, Qt::SolidLine, Qt::RoundCap)); + painter->drawArc(bounds, 0, 20 * 16); +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator_p.h b/src/imports/controls/fusion/qquickfusionbusyindicator_p.h new file mode 100644 index 00000000..c8af3311 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionbusyindicator_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 QQUICKFUSIONBUSYINDICATOR_P_H +#define QQUICKFUSIONBUSYINDICATOR_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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionBusyIndicator : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor FINAL) + +public: + explicit QQuickFusionBusyIndicator(QQuickItem *parent = nullptr); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter) override; + +private: + QColor m_color; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONBUSYINDICATOR_P_H diff --git a/src/imports/controls/fusion/qquickfusiondial.cpp b/src/imports/controls/fusion/qquickfusiondial.cpp new file mode 100644 index 00000000..014078e6 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusiondial.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusiondial_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QQuickFusionDial::QQuickFusionDial(QQuickItem *parent) + : QQuickPaintedItem(parent), + m_highlight(false) +{ +} + +bool QQuickFusionDial::highlight() const +{ + return m_highlight; +} + +void QQuickFusionDial::setHighlight(bool highlight) +{ + if (m_highlight == highlight) + return; + + m_highlight = highlight; + update(); +} + +QPalette QQuickFusionDial::palette() const +{ + return m_palette; +} + +void QQuickFusionDial::setPalette(const QPalette &palette) +{ + if (palette == m_palette) + return; + + m_palette = palette; + update(); +} + +// based on QStyleHelper::drawDial() +void QQuickFusionDial::paint(QPainter *painter) +{ + const int width = QQuickItem::width(); + const int height = QQuickItem::height(); + if (width <= 0 || height <= 0 || !isVisible()) + return; + + QColor buttonColor = m_palette.button().color(); + const bool enabled = isEnabled(); + qreal r = qMin(width, height) / 2; + r -= r/50; + const qreal penSize = r/20.0; + + painter->setRenderHint(QPainter::Antialiasing); + + const qreal d_ = r / 6; + const qreal dx = d_ + (width - 2 * r) / 2 + 1; + const qreal dy = d_ + (height - 2 * r) / 2 + 1; + + QRectF br = QRectF(dx + 0.5, dy + 0.5, + int(r * 2 - 2 * d_ - 2), + int(r * 2 - 2 * d_ - 2)); + buttonColor.setHsv(buttonColor .hue(), + qMin(140, buttonColor .saturation()), + qMax(180, buttonColor.value())); + + if (enabled) { + // Drop shadow + qreal shadowSize = qMax(1.0, penSize/2.0); + QRectF shadowRect= br.adjusted(-2*shadowSize, -2*shadowSize, + 2*shadowSize, 2*shadowSize); + QRadialGradient shadowGradient(shadowRect.center().x(), + shadowRect.center().y(), shadowRect.width()/2.0, + shadowRect.center().x(), shadowRect.center().y()); + shadowGradient.setColorAt(qreal(0.91), QColor(0, 0, 0, 40)); + shadowGradient.setColorAt(qreal(1.0), Qt::transparent); + painter->setBrush(shadowGradient); + painter->setPen(Qt::NoPen); + painter->translate(shadowSize, shadowSize); + painter->drawEllipse(shadowRect); + painter->translate(-shadowSize, -shadowSize); + + // Main gradient + QRadialGradient gradient(br.center().x() - br.width()/3, dy, + br.width()*1.3, br.center().x(), + br.center().y() - br.height()/2); + gradient.setColorAt(0, buttonColor.lighter(110)); + gradient.setColorAt(qreal(0.5), buttonColor); + gradient.setColorAt(qreal(0.501), buttonColor.darker(102)); + gradient.setColorAt(1, buttonColor.darker(115)); + painter->setBrush(gradient); + } else { + painter->setBrush(Qt::NoBrush); + } + + painter->setPen(QPen(buttonColor.darker(280))); + painter->drawEllipse(br); + painter->setBrush(Qt::NoBrush); + painter->setPen(buttonColor.lighter(110)); + painter->drawEllipse(br.adjusted(1, 1, -1, -1)); + + if (m_highlight) { + QColor highlight = m_palette.highlight().color(); + highlight.setHsv(highlight.hue(), + qMin(160, highlight.saturation()), + qMax(230, highlight.value())); + highlight.setAlpha(127); + painter->setPen(QPen(highlight, 2.0)); + painter->setBrush(Qt::NoBrush); + painter->drawEllipse(br.adjusted(-1, -1, 1, 1)); + } +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusiondial_p.h b/src/imports/controls/fusion/qquickfusiondial_p.h new file mode 100644 index 00000000..d3216521 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusiondial_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 QQUICKFUSIONDIAL_P_H +#define QQUICKFUSIONDIAL_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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionDial : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool highlight READ highlight WRITE setHighlight FINAL) + Q_PROPERTY(QPalette palette READ palette WRITE setPalette FINAL) + +public: + explicit QQuickFusionDial(QQuickItem *parent = nullptr); + + bool highlight() const; + void setHighlight(bool highlight); + + QPalette palette() const; + void setPalette(const QPalette &palette); + + void paint(QPainter *painter) override; + +private: + bool m_highlight; + QPalette m_palette; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONDIAL_P_H diff --git a/src/imports/controls/fusion/qquickfusionknob.cpp b/src/imports/controls/fusion/qquickfusionknob.cpp new file mode 100644 index 00000000..9f1824a6 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionknob.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusionknob_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QQuickFusionKnob::QQuickFusionKnob(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QPalette QQuickFusionKnob::palette() const +{ + return m_palette; +} + +void QQuickFusionKnob::setPalette(const QPalette &palette) +{ + if (palette == m_palette) + return; + + m_palette = palette; + update(); +} + +// extracted from QStyleHelper::drawDial() +void QQuickFusionKnob::paint(QPainter *painter) +{ + const qreal w = width(); + const qreal h = height(); + if (w <= 0 || h <= 0) + return; + + QColor color = m_palette.color(QPalette::Button); + color.setHsv(color.hue(), + qMin(140, color .saturation()), + qMax(180, color.value())); + color = color.lighter(104); + color.setAlphaF(qreal(0.8)); + + const qreal sz = qMin(w, h); + QRectF rect(0, 0, sz, sz); + rect.moveCenter(QPointF(w / 2.0, h / 2.0)); + const QPointF center = rect.center(); + + QRadialGradient gradient(center.x() + rect.width() / 2, + center.y() + rect.width(), + rect.width() * 2, + center.x(), center.y()); + gradient.setColorAt(1, color.darker(140)); + gradient.setColorAt(qreal(0.4), color.darker(120)); + gradient.setColorAt(0, color.darker(110)); + + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(gradient); + painter->setPen(QColor(255, 255, 255, 150)); + painter->drawEllipse(rect); + painter->setPen(QColor(0, 0, 0, 80)); + painter->drawEllipse(rect.adjusted(1, 1, -1, -1)); +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusionknob_p.h b/src/imports/controls/fusion/qquickfusionknob_p.h new file mode 100644 index 00000000..062aaf21 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionknob_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 QQUICKFUSIONKNOB_P_H +#define QQUICKFUSIONKNOB_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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionKnob : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QPalette palette READ palette WRITE setPalette FINAL) + +public: + explicit QQuickFusionKnob(QQuickItem *parent = nullptr); + + QPalette palette() const; + void setPalette(const QPalette &palette); + + void paint(QPainter *painter) override; + +private: + QPalette m_palette; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONKNOB_P_H diff --git a/src/imports/controls/fusion/qquickfusionstyle.cpp b/src/imports/controls/fusion/qquickfusionstyle.cpp new file mode 100644 index 00000000..a66665fc --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionstyle.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusionstyle_p.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +// On mac we want a standard blue color used when the system palette is used +static bool isMacSystemPalette(const QPalette &palette) +{ + Q_UNUSED(palette); +#if defined(Q_OS_MACOS) + const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette(); + if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) == + palette.color(QPalette::Normal, QPalette::Highlight) && + themePalette->color(QPalette::Normal, QPalette::HighlightedText) == + palette.color(QPalette::Normal, QPalette::HighlightedText)) + return true; +#endif + return false; +} + +QQuickFusionStyle::QQuickFusionStyle(QObject *parent) + : QObject(parent) +{ +} + +QColor QQuickFusionStyle::lightShade() +{ + return QColor(255, 255, 255, 90); +} + +QColor QQuickFusionStyle::darkShade() +{ + return QColor(0, 0, 0, 60); +} + +QColor QQuickFusionStyle::topShadow() +{ + return QColor(0, 0, 0, 18); +} + +QColor QQuickFusionStyle::innerContrastLine() +{ + return QColor(255, 255, 255, 30); +} + +QColor QQuickFusionStyle::highlight(const QPalette &palette) +{ + if (isMacSystemPalette(palette)) + return QColor(60, 140, 230); + return palette.color(QPalette::Highlight); +} + +QColor QQuickFusionStyle::highlightedText(const QPalette &palette) +{ + if (isMacSystemPalette(palette)) + return Qt::white; + return palette.color(QPalette::HighlightedText); +} + +QColor QQuickFusionStyle::outline(const QPalette &palette) +{ + if (palette.window().style() == Qt::TexturePattern) + return QColor(0, 0, 0, 160); + return palette.background().color().darker(140); +} + +QColor QQuickFusionStyle::highlightedOutline(const QPalette &palette) +{ + QColor highlightedOutline = highlight(palette).darker(125); + if (highlightedOutline.value() > 160) + highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160); + return highlightedOutline; +} + +QColor QQuickFusionStyle::tabFrameColor(const QPalette &palette) +{ + if (palette.window().style() == Qt::TexturePattern) + return QColor(255, 255, 255, 8); + return buttonColor(palette).lighter(104); +} + +QColor QQuickFusionStyle::buttonColor(const QPalette &palette, bool highlighted, bool down, bool hovered) +{ + QColor buttonColor = palette.button().color(); + int val = qGray(buttonColor.rgb()); + buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6)); + buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value()); + if (highlighted) + buttonColor = mergedColors(buttonColor, highlightedOutline(palette).lighter(130), 90); + if (!hovered) + buttonColor = buttonColor.darker(104); + if (down) + buttonColor = buttonColor.darker(110); + return buttonColor; +} + +QColor QQuickFusionStyle::buttonOutline(const QPalette &palette, bool highlighted, bool enabled) +{ + QColor darkOutline = enabled && highlighted ? highlightedOutline(palette) : outline(palette); + return !enabled ? darkOutline.lighter(115) : darkOutline; +} + +QColor QQuickFusionStyle::gradientStart(const QColor &baseColor) +{ + return baseColor.lighter(124); +} + +QColor QQuickFusionStyle::gradientStop(const QColor &baseColor) +{ + return baseColor.lighter(102); +} + +QColor QQuickFusionStyle::mergedColors(const QColor &colorA, const QColor &colorB, int factor) +{ + const int maxFactor = 100; + QColor tmp = colorA; + tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor); + tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor); + tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor); + return tmp; +} + +QColor QQuickFusionStyle::grooveColor(const QPalette &palette) +{ + QColor color = buttonColor(palette); + color.setHsv(color.hue(), + qMin(255, color.saturation()), + qMin(255, color.value() * 0.9)); + return color; +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusionstyle_p.h b/src/imports/controls/fusion/qquickfusionstyle_p.h new file mode 100644 index 00000000..e0a99cc6 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusionstyle_p.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 QQUICKFUSIONSTYLE_P_H +#define QQUICKFUSIONSTYLE_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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionStyle : public QObject +{ + Q_OBJECT + Q_PROPERTY(QColor lightShade READ lightShade CONSTANT) + Q_PROPERTY(QColor darkShade READ darkShade CONSTANT) + Q_PROPERTY(QColor topShadow READ topShadow CONSTANT) + Q_PROPERTY(QColor innerContrastLine READ innerContrastLine CONSTANT) + +public: + explicit QQuickFusionStyle(QObject *parent = nullptr); + + static QColor lightShade(); + static QColor darkShade(); + static QColor topShadow(); + static QColor innerContrastLine(); + + Q_INVOKABLE static QColor highlight(const QPalette &palette); + Q_INVOKABLE static QColor highlightedText(const QPalette &palette); + Q_INVOKABLE static QColor outline(const QPalette &palette); + Q_INVOKABLE static QColor highlightedOutline(const QPalette &palette); + Q_INVOKABLE static QColor tabFrameColor(const QPalette &palette); + Q_INVOKABLE static QColor buttonColor(const QPalette &palette, bool highlighted = false, bool down = false, bool hovered = false); + Q_INVOKABLE static QColor buttonOutline(const QPalette &palette, bool highlighted = false, bool enabled = true); + Q_INVOKABLE static QColor gradientStart(const QColor &baseColor); + Q_INVOKABLE static QColor gradientStop(const QColor &baseColor); + Q_INVOKABLE static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50); + Q_INVOKABLE static QColor grooveColor(const QPalette &palette); +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONSTYLE_P_H diff --git a/src/imports/controls/fusion/qquickfusiontheme.cpp b/src/imports/controls/fusion/qquickfusiontheme.cpp new file mode 100644 index 00000000..54536101 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusiontheme.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusiontheme_p.h" + +QT_BEGIN_NAMESPACE + +QQuickFusionTheme::QQuickFusionTheme(QPlatformTheme *theme) + : QQuickProxyTheme(theme) +{ +} + +const QPalette *QQuickFusionTheme::palette(Palette type) const +{ + return QQuickProxyTheme::palette(type); +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusiontheme_p.h b/src/imports/controls/fusion/qquickfusiontheme_p.h new file mode 100644 index 00000000..c5949848 --- /dev/null +++ b/src/imports/controls/fusion/qquickfusiontheme_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 QQUICKFUSIONTHEME_P_H +#define QQUICKFUSIONTHEME_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 QQuickFusionTheme : public QQuickProxyTheme +{ +public: + explicit QQuickFusionTheme(QPlatformTheme *theme = nullptr); + + const QPalette *palette(Palette type = SystemPalette) const override; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONTHEME_P_H diff --git a/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc b/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc new file mode 100644 index 00000000..74c8e671 --- /dev/null +++ b/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc @@ -0,0 +1,16 @@ + + + images/arrow.png + images/arrow@2x.png + images/arrow@3x.png + images/arrow@4x.png + images/checkmark.png + images/checkmark@2x.png + images/checkmark@3x.png + images/checkmark@4x.png + images/progressmask.png + images/progressmask@2x.png + images/progressmask@3x.png + images/progressmask@4x.png + + diff --git a/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp new file mode 100644 index 00000000..1fcacc5e --- /dev/null +++ b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 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 "qquickfusionbusyindicator_p.h" +#include "qquickfusiondial_p.h" +#include "qquickfusionknob_p.h" +#include "qquickfusionstyle_p.h" +#include "qquickfusiontheme_p.h" + +static inline void initResources() +{ + Q_INIT_RESOURCE(qtquickcontrols2fusionstyle); +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Controls_2_Fusion); +#endif +} + +QT_BEGIN_NAMESPACE + +static QObject *styleSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + return new QQuickFusionStyle; +} + +class QtQuickControls2FusionStylePlugin: public QQuickStylePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QtQuickControls2FusionStylePlugin(QObject *parent = nullptr); + + void registerTypes(const char *uri) override; + void initializeEngine(QQmlEngine *engine, const char *uri) override; + + QString name() const override; + QQuickProxyTheme *createTheme() const override; +}; + +QtQuickControls2FusionStylePlugin::QtQuickControls2FusionStylePlugin(QObject *parent) : QQuickStylePlugin(parent) +{ + initResources(); +} + +void QtQuickControls2FusionStylePlugin::registerTypes(const char *uri) +{ + qmlRegisterModule(uri, 2, QT_VERSION_MINOR - 7); // Qt 5.10->2.3, 5.11->2.4... +} + +void QtQuickControls2FusionStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri) +{ + QQuickStylePlugin::initializeEngine(engine, uri); + + QByteArray import = QByteArray(uri) + ".impl"; + qmlRegisterModule(import, 2, QT_VERSION_MINOR - 7); // Qt 5.10->2.3, 5.11->2.4... + + qmlRegisterSingletonType(import, 2, 3, "Fusion", styleSingleton); + + qmlRegisterType(import, 2, 3, "BusyIndicatorImpl"); + qmlRegisterType(import, 2, 3, "DialImpl"); + qmlRegisterType(import, 2, 3, "KnobImpl"); + + qmlRegisterType(typeUrl(QStringLiteral("ButtonPanel.qml")), import, 2, 3, "ButtonPanel"); + qmlRegisterType(typeUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 3, "CheckIndicator"); + qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 3, "RadioIndicator"); + qmlRegisterType(typeUrl(QStringLiteral("SliderGroove.qml")), import, 2, 3, "SliderGroove"); + qmlRegisterType(typeUrl(QStringLiteral("SliderHandle.qml")), import, 2, 3, "SliderHandle"); + qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 3, "SwitchIndicator"); +} + +QString QtQuickControls2FusionStylePlugin::name() const +{ + return QStringLiteral("fusion"); +} + +QQuickProxyTheme *QtQuickControls2FusionStylePlugin::createTheme() const +{ + return new QQuickFusionTheme; +} + +QT_END_NAMESPACE + +#include "qtquickcontrols2fusionstyleplugin.moc" diff --git a/src/imports/imports.pro b/src/imports/imports.pro index e1da66c9..dfba46ac 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -6,5 +6,6 @@ SUBDIRS += \ templates SUBDIRS += \ + controls/fusion/fusion.pro \ controls/material/material.pro \ controls/universal/universal.pro diff --git a/src/quickcontrols2/configure.json b/src/quickcontrols2/configure.json index 113d321a..121f3f49 100644 --- a/src/quickcontrols2/configure.json +++ b/src/quickcontrols2/configure.json @@ -3,6 +3,7 @@ "commandline": { "options": { + "style-fusion": { "type": "boolean", "name": "quickcontrols2-fusion" }, "style-material": { "type": "boolean", "name": "quickcontrols2-material" }, "style-universal": { "type": "boolean", "name": "quickcontrols2-universal" } } @@ -13,6 +14,12 @@ "label": "Default", "output": [ "privateFeature" ] }, + "quickcontrols2-fusion": { + "label": "Fusion", + "purpose": "Provides a platform agnostic Fusion style for the Qt Quick Controls 2", + "condition": "features.quickcontrols2-default", + "output": [ "privateFeature" ] + }, "quickcontrols2-material": { "label": "Material", "purpose": "Provides a Qt Quick Controls 2 style based on the Material Design guidelines", @@ -34,7 +41,7 @@ { "message": "Styles", "type": "featureList", - "args": "quickcontrols2-default quickcontrols2-material quickcontrols2-universal" + "args": "quickcontrols2-default quickcontrols2-fusion quickcontrols2-material quickcontrols2-universal" } ] } diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro index 8f2f8e69..c61dff0e 100644 --- a/tests/auto/controls/controls.pro +++ b/tests/auto/controls/controls.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ default \ + fusion \ material \ universal diff --git a/tests/auto/controls/fusion/dependencies.qml b/tests/auto/controls/fusion/dependencies.qml new file mode 100644 index 00000000..30c32fa5 --- /dev/null +++ b/tests/auto/controls/fusion/dependencies.qml @@ -0,0 +1,6 @@ +import QtTest 1.0 +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Controls.Fusion 2.3 + +TestCase { } diff --git a/tests/auto/controls/fusion/fusion.pro b/tests/auto/controls/fusion/fusion.pro new file mode 100644 index 00000000..f3374f34 --- /dev/null +++ b/tests/auto/controls/fusion/fusion.pro @@ -0,0 +1,15 @@ +TEMPLATE = app +TARGET = tst_fusion +CONFIG += qmltestcase +QT += quickcontrols2 + +DEFINES += TST_CONTROLS_DATA=\\\"$$QQC2_SOURCE_TREE/tests/auto/controls/data\\\" + +SOURCES += \ + $$PWD/tst_fusion.cpp + +OTHER_FILES += \ + $$PWD/../data/*.qml + +TESTDATA += \ + $$PWD/../data/tst_* diff --git a/tests/auto/controls/fusion/tst_fusion.cpp b/tests/auto/controls/fusion/tst_fusion.cpp new file mode 100644 index 00000000..84f9c231 --- /dev/null +++ b/tests/auto/controls/fusion/tst_fusion.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite 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 + +int main(int argc, char *argv[]) +{ + QTEST_ADD_GPU_BLACKLIST_SUPPORT + QTEST_SET_MAIN_SOURCE_PATH + qputenv("QML_NO_TOUCH_COMPRESSION", "1"); + QQuickStyle::setStyle("Fusion"); + return quick_test_main(argc, argv, "tst_controls::Fusion", TST_CONTROLS_DATA); +} diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp index 2988c96c..25e118e3 100644 --- a/tests/auto/sanity/tst_sanity.cpp +++ b/tests/auto/sanity/tst_sanity.cpp @@ -314,6 +314,7 @@ void tst_Sanity::attachedObjects_data() QTest::addColumn("url"); addTestRows(&engine, "calendar", "Qt/labs/calendar"); addTestRows(&engine, "controls", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRows(&engine, "controls/fusion", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); addTestRows(&engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); addTestRows(&engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); } diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index d12f3293..551d2009 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -124,6 +124,7 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt static void initTestRows(QQmlEngine *engine) { addTestRows(engine, "controls", "QtQuick/Controls.2", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); + addTestRows(engine, "controls/fusion", "QtQuick/Controls.2/Fusion", QStringList() << "ButtonPanel" << "CheckIndicator" << "RadioIndicator" << "SliderGroove" << "SliderHandle" << "SwitchIndicator"); addTestRows(engine, "controls/material", "QtQuick/Controls.2/Material", QStringList() << "Ripple" << "SliderHandle" << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator" << "BoxShadow" << "ElevationEffect" << "CursorDelegate"); addTestRows(engine, "controls/universal", "QtQuick/Controls.2/Universal", QStringList() << "CheckIndicator" << "RadioIndicator" << "SwitchIndicator"); } -- cgit v1.2.3