From 5246dd2de211ffb81313a5c29ae7894545a28c43 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 27 Mar 2020 11:17:35 +0100 Subject: Register C++ types declaratively Adapt to the new way of registering C++ types. The types need to be seen at compile time so that code can be generated that invokes them. This patch: - Adds QML_* macros where applicable. - Adapts the build system files to the new way of registering modules. - Splits up the QtQuick.Controls[.*].impl files into their own plugins, as we can only register one QML module per .pro file. - Removes C++ type registration calls in every plugin. - Moves private types from src/quickcontrols2/quickcontrols2.pro to src/quickcontrols2/impl/quickcontrols2-impl.pro. Some of these types need to be exposed to QML, but quickcontrols2.pro is already in use to declare the QtQuick.Controls import (and also provides the public C++ QQuickStyle API), and the new QML_IMPORT_NAME/VERSION syntax only allows one module per project. As some of the types that need to be exposed to QML are also referenced by some C++ code (e.g. tests, etc.), we just move all of the private types to the new library. Follow-up patches will register the QML types declaratively. Task-number: QTBUG-82922 Change-Id: Iaf9ee106237d61701d57a8896f3822304c8151a6 Reviewed-by: Ulf Hermann --- src/imports/controls/fusion/.prev_CMakeLists.txt | 6 +- src/imports/controls/fusion/ButtonPanel.qml | 77 ------------ src/imports/controls/fusion/CMakeLists.txt | 6 +- src/imports/controls/fusion/CheckIndicator.qml | 92 -------------- src/imports/controls/fusion/ComboBox.qml | 2 +- src/imports/controls/fusion/MenuItem.qml | 2 +- src/imports/controls/fusion/ProgressBar.qml | 2 +- src/imports/controls/fusion/RadioIndicator.qml | 78 ------------ src/imports/controls/fusion/SliderGroove.qml | 94 -------------- src/imports/controls/fusion/SliderHandle.qml | 86 ------------- src/imports/controls/fusion/SpinBox.qml | 4 +- src/imports/controls/fusion/SwitchIndicator.qml | 137 -------------------- src/imports/controls/fusion/fusion.pri | 12 -- src/imports/controls/fusion/impl/ButtonPanel.qml | 77 ++++++++++++ .../controls/fusion/impl/CheckIndicator.qml | 92 ++++++++++++++ .../controls/fusion/impl/RadioIndicator.qml | 78 ++++++++++++ src/imports/controls/fusion/impl/SliderGroove.qml | 94 ++++++++++++++ src/imports/controls/fusion/impl/SliderHandle.qml | 86 +++++++++++++ .../controls/fusion/impl/SwitchIndicator.qml | 137 ++++++++++++++++++++ src/imports/controls/fusion/impl/fusion-impl.pro | 39 ++++++ src/imports/controls/fusion/impl/qmldir | 3 + .../fusion/impl/qquickfusionbusyindicator.cpp | 111 ++++++++++++++++ .../fusion/impl/qquickfusionbusyindicator_p.h | 84 +++++++++++++ .../controls/fusion/impl/qquickfusiondial.cpp | 139 +++++++++++++++++++++ .../controls/fusion/impl/qquickfusiondial_p.h | 76 +++++++++++ .../controls/fusion/impl/qquickfusionknob.cpp | 88 +++++++++++++ .../controls/fusion/impl/qquickfusionknob_p.h | 69 ++++++++++ .../impl/qtquickcontrols2fusionstyleimplplugin.cpp | 57 +++++++++ .../controls/fusion/qquickfusionbusyindicator.cpp | 111 ---------------- .../controls/fusion/qquickfusionbusyindicator_p.h | 82 ------------ src/imports/controls/fusion/qquickfusiondial.cpp | 139 --------------------- src/imports/controls/fusion/qquickfusiondial_p.h | 74 ----------- src/imports/controls/fusion/qquickfusionknob.cpp | 88 ------------- src/imports/controls/fusion/qquickfusionknob_p.h | 67 ---------- src/imports/controls/fusion/qquickfusionstyle_p.h | 4 + .../fusion/qtquickcontrols2fusionstyle.qrc | 2 +- .../fusion/qtquickcontrols2fusionstyleplugin.cpp | 21 +--- 37 files changed, 1247 insertions(+), 1169 deletions(-) delete mode 100644 src/imports/controls/fusion/ButtonPanel.qml delete mode 100644 src/imports/controls/fusion/CheckIndicator.qml delete mode 100644 src/imports/controls/fusion/RadioIndicator.qml delete mode 100644 src/imports/controls/fusion/SliderGroove.qml delete mode 100644 src/imports/controls/fusion/SliderHandle.qml delete mode 100644 src/imports/controls/fusion/SwitchIndicator.qml create mode 100644 src/imports/controls/fusion/impl/ButtonPanel.qml create mode 100644 src/imports/controls/fusion/impl/CheckIndicator.qml create mode 100644 src/imports/controls/fusion/impl/RadioIndicator.qml create mode 100644 src/imports/controls/fusion/impl/SliderGroove.qml create mode 100644 src/imports/controls/fusion/impl/SliderHandle.qml create mode 100644 src/imports/controls/fusion/impl/SwitchIndicator.qml create mode 100644 src/imports/controls/fusion/impl/fusion-impl.pro create mode 100644 src/imports/controls/fusion/impl/qmldir create mode 100644 src/imports/controls/fusion/impl/qquickfusionbusyindicator.cpp create mode 100644 src/imports/controls/fusion/impl/qquickfusionbusyindicator_p.h create mode 100644 src/imports/controls/fusion/impl/qquickfusiondial.cpp create mode 100644 src/imports/controls/fusion/impl/qquickfusiondial_p.h create mode 100644 src/imports/controls/fusion/impl/qquickfusionknob.cpp create mode 100644 src/imports/controls/fusion/impl/qquickfusionknob_p.h create mode 100644 src/imports/controls/fusion/impl/qtquickcontrols2fusionstyleimplplugin.cpp delete mode 100644 src/imports/controls/fusion/qquickfusionbusyindicator.cpp delete mode 100644 src/imports/controls/fusion/qquickfusionbusyindicator_p.h delete mode 100644 src/imports/controls/fusion/qquickfusiondial.cpp delete mode 100644 src/imports/controls/fusion/qquickfusiondial_p.h delete mode 100644 src/imports/controls/fusion/qquickfusionknob.cpp delete mode 100644 src/imports/controls/fusion/qquickfusionknob_p.h (limited to 'src/imports/controls/fusion') diff --git a/src/imports/controls/fusion/.prev_CMakeLists.txt b/src/imports/controls/fusion/.prev_CMakeLists.txt index 2fb5b2a1..4c59e4f6 100644 --- a/src/imports/controls/fusion/.prev_CMakeLists.txt +++ b/src/imports/controls/fusion/.prev_CMakeLists.txt @@ -5,7 +5,7 @@ ##################################################################### add_qml_module(qtquickcontrols2fusionstyleplugin - TARGET_PATH "QtQuick/Controls.2/Fusion" + TARGET_PATH "QtQuick/Controls/Fusion" URI "QtQuick.Controls.Fusion" VERSION "2.${CMAKE_PROJECT_VERSION_MINOR}" CLASSNAME QtQuickControls2FusionStylePlugin @@ -54,7 +54,7 @@ set(qtquickcontrols2fusionstyle_resource_files add_qt_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusionstyle" PREFIX - "/qt-project.org/imports/QtQuick/Controls.2/Fusion" + "/qt-project.org/imports/QtQuick/Controls/Fusion" FILES ${qtquickcontrols2fusionstyle_resource_files} ) @@ -64,7 +64,7 @@ add_qt_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusionstyle" # IMPORT_NAME = "QtQuick.Controls.Fusion" # IMPORT_VERSION = "2.$$QT_MINOR_VERSION" # OTHER_FILES = "qmldir" "$$QML_FILES" -# TARGETPATH = "QtQuick/Controls.2/Fusion" +# TARGETPATH = "QtQuick/Controls/Fusion" # _REQUIREMENTS = "qtConfig(quickcontrols2-fusion)" set(qml_files diff --git a/src/imports/controls/fusion/ButtonPanel.qml b/src/imports/controls/fusion/ButtonPanel.qml deleted file mode 100644 index 125aa2f3..00000000 --- a/src/imports/controls/fusion/ButtonPanel.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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(panel.control.palette, panel.highlighted, panel.control.down, panel.control.hovered)) - } - GradientStop { - position: 1 - color: Fusion.gradientStop(Fusion.buttonColor(panel.control.palette, panel.highlighted, panel.control.down, panel.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/CMakeLists.txt b/src/imports/controls/fusion/CMakeLists.txt index 59b06842..5eb28d21 100644 --- a/src/imports/controls/fusion/CMakeLists.txt +++ b/src/imports/controls/fusion/CMakeLists.txt @@ -5,7 +5,7 @@ ##################################################################### qt_add_qml_module(qtquickcontrols2fusionstyleplugin - TARGET_PATH "QtQuick/Controls.2/Fusion" + TARGET_PATH "QtQuick/Controls/Fusion" URI "QtQuick.Controls.Fusion" VERSION "2.${CMAKE_PROJECT_VERSION_MINOR}" CLASSNAME QtQuickControls2FusionStylePlugin @@ -54,7 +54,7 @@ set(qtquickcontrols2fusionstyle_resource_files qt_add_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusionstyle" PREFIX - "/qt-project.org/imports/QtQuick/Controls.2/Fusion" + "/qt-project.org/imports/QtQuick/Controls/Fusion" FILES ${qtquickcontrols2fusionstyle_resource_files} ) @@ -64,7 +64,7 @@ qt_add_resource(qtquickcontrols2fusionstyleplugin "qtquickcontrols2fusionstyle" # IMPORT_NAME = "QtQuick.Controls.Fusion" # IMPORT_VERSION = "2.$$QT_MINOR_VERSION" # OTHER_FILES = "qmldir" "$$QML_FILES" -# TARGETPATH = "QtQuick/Controls.2/Fusion" +# TARGETPATH = "QtQuick/Controls/Fusion" # _REQUIREMENTS = "qtConfig(quickcontrols2-fusion)" set(qml_files diff --git a/src/imports/controls/fusion/CheckIndicator.qml b/src/imports/controls/fusion/CheckIndicator.qml deleted file mode 100644 index 7dcfee30..00000000 --- a/src/imports/controls/fusion/CheckIndicator.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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: indicator.control.enabled && !indicator.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: indicator.control.checkState === Qt.Checked || (indicator.control.checked && indicator.control.checkState === undefined) - } - - Rectangle { - x: 3; y: 3 - width: parent.width - 6 - height: parent.width - 6 - - visible: indicator.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 index d0e4b564..64e9603f 100644 --- a/src/imports/controls/fusion/ComboBox.qml +++ b/src/imports/controls/fusion/ComboBox.qml @@ -66,7 +66,7 @@ T.ComboBox { 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" + source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/arrow.png" width: 20 fillMode: Image.Pad } diff --git a/src/imports/controls/fusion/MenuItem.qml b/src/imports/controls/fusion/MenuItem.qml index a428fbc8..ebd727e0 100644 --- a/src/imports/controls/fusion/MenuItem.qml +++ b/src/imports/controls/fusion/MenuItem.qml @@ -81,7 +81,7 @@ T.MenuItem { visible: control.subMenu rotation: control.mirrored ? 90 : -90 color: control.down || control.hovered || control.highlighted ? Fusion.highlightedText(control.palette) : control.palette.text - source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/arrow.png" + source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/arrow.png" fillMode: Image.Pad } diff --git a/src/imports/controls/fusion/ProgressBar.qml b/src/imports/controls/fusion/ProgressBar.qml index 5deade58..a522563a 100644 --- a/src/imports/controls/fusion/ProgressBar.qml +++ b/src/imports/controls/fusion/ProgressBar.qml @@ -85,7 +85,7 @@ T.ProgressBar { mirror: control.mirrored fillMode: Image.TileHorizontally - source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Fusion/images/progressmask.png" + source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/progressmask.png" color: Color.transparent(Qt.lighter(Fusion.highlight(control.palette), 1.2), 160 / 255) visible: control.indeterminate diff --git a/src/imports/controls/fusion/RadioIndicator.qml b/src/imports/controls/fusion/RadioIndicator.qml deleted file mode 100644 index c73cd49f..00000000 --- a/src/imports/controls/fusion/RadioIndicator.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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: indicator.control.enabled && !indicator.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: indicator.control.checked - } -} diff --git a/src/imports/controls/fusion/SliderGroove.qml b/src/imports/controls/fusion/SliderGroove.qml deleted file mode 100644 index 381a02b5..00000000 --- a/src/imports/controls/fusion/SliderGroove.qml +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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(groove.control.palette), 1.1) - } - GradientStop { - position: 1 - color: Qt.lighter(Fusion.grooveColor(groove.control.palette), 1.1) - } - } - - Rectangle { - x: groove.control.horizontal ? groove.offset * parent.width : 0 - y: groove.control.horizontal ? 0 : groove.visualProgress * parent.height - width: groove.control.horizontal ? groove.progress * parent.width - groove.offset * parent.width : 5 - height: groove.control.horizontal ? 5 : groove.progress * parent.height - groove.offset * parent.height - - radius: 2 - border.color: Qt.darker(Fusion.highlightedOutline(groove.control.palette), 1.1) - - gradient: Gradient { - GradientStop { - position: 0 - color: Fusion.highlight(groove.control.palette) - } - GradientStop { - position: 1 - color: Qt.lighter(Fusion.highlight(groove.control.palette), 1.2) - } - } - } -} diff --git a/src/imports/controls/fusion/SliderHandle.qml b/src/imports/controls/fusion/SliderHandle.qml deleted file mode 100644 index c53af57e..00000000 --- a/src/imports/controls/fusion/SliderHandle.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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 index 41754f63..44387e3c 100644 --- a/src/imports/controls/fusion/SpinBox.qml +++ b/src/imports/controls/fusion/SpinBox.qml @@ -98,7 +98,7 @@ T.SpinBox { 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" + source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/arrow.png" fillMode: Image.Pad } } @@ -121,7 +121,7 @@ T.SpinBox { 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" + source: "qrc:/qt-project.org/imports/QtQuick/Controls/Fusion/images/arrow.png" fillMode: Image.Pad } } diff --git a/src/imports/controls/fusion/SwitchIndicator.qml b/src/imports/controls/fusion/SwitchIndicator.qml deleted file mode 100644 index ae7c89a0..00000000 --- a/src/imports/controls/fusion/SwitchIndicator.qml +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** 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.12 -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 -import QtQuick.Controls.Fusion 2.12 -import QtQuick.Controls.Fusion.impl 2.12 - -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(indicator.control.palette), 1.1) - } - GradientStop { - position: 1 - color: Qt.lighter(Fusion.grooveColor(indicator.control.palette), 1.1) - } - } - - Rectangle { - x: indicator.control.mirrored ? handle.x : 0 - width: indicator.control.mirrored ? parent.width - handle.x : handle.x + handle.width - height: parent.height - - opacity: indicator.control.checked ? 1 : 0 - Behavior on opacity { - enabled: !indicator.control.down - NumberAnimation { duration: 80 } - } - - radius: 2 - border.color: Qt.darker(Fusion.highlightedOutline(indicator.control.palette), 1.1) - border.width: indicator.control.enabled ? 1 : 0 - - gradient: Gradient { - GradientStop { - position: 0 - color: Fusion.highlight(indicator.control.palette) - } - GradientStop { - position: 1 - color: Qt.lighter(Fusion.highlight(indicator.control.palette), 1.2) - } - } - } - - Rectangle { - id: handle - x: Math.max(0, Math.min(parent.width - width, indicator.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(indicator.control.palette, indicator.control.visualFocus, indicator.control.pressed, indicator.control.hovered)) - } - GradientStop { - position: 1 - color: Fusion.gradientStop(Fusion.buttonColor(indicator.control.palette, indicator.control.visualFocus, indicator.control.pressed, indicator.control.hovered)) - } - } - border.width: 1 - border.color: "transparent" - - Rectangle { - width: parent.width - height: parent.height - border.color: indicator.control.visualFocus ? Fusion.highlightedOutline(indicator.control.palette) : Fusion.outline(indicator.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: !indicator.control.down - SmoothedAnimation { velocity: 200 } - } - } -} diff --git a/src/imports/controls/fusion/fusion.pri b/src/imports/controls/fusion/fusion.pri index bdc413fd..5bc3fbce 100644 --- a/src/imports/controls/fusion/fusion.pri +++ b/src/imports/controls/fusion/fusion.pri @@ -1,14 +1,8 @@ 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 @@ -16,10 +10,8 @@ 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 \ @@ -43,19 +35,15 @@ QML_FILES += \ $$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/Slider.qml \ - $$PWD/SliderGroove.qml \ - $$PWD/SliderHandle.qml \ $$PWD/SpinBox.qml \ $$PWD/SplitView.qml \ $$PWD/SwipeDelegate.qml \ $$PWD/SwitchDelegate.qml \ - $$PWD/SwitchIndicator.qml \ $$PWD/Switch.qml \ $$PWD/TabBar.qml \ $$PWD/TabButton.qml \ diff --git a/src/imports/controls/fusion/impl/ButtonPanel.qml b/src/imports/controls/fusion/impl/ButtonPanel.qml new file mode 100644 index 00000000..125aa2f3 --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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(panel.control.palette, panel.highlighted, panel.control.down, panel.control.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(panel.control.palette, panel.highlighted, panel.control.down, panel.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/impl/CheckIndicator.qml b/src/imports/controls/fusion/impl/CheckIndicator.qml new file mode 100644 index 00000000..f8c127c4 --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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: indicator.control.enabled && !indicator.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/Fusion/images/checkmark.png" + visible: indicator.control.checkState === Qt.Checked || (indicator.control.checked && indicator.control.checkState === undefined) + } + + Rectangle { + x: 3; y: 3 + width: parent.width - 6 + height: parent.width - 6 + + visible: indicator.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/impl/RadioIndicator.qml b/src/imports/controls/fusion/impl/RadioIndicator.qml new file mode 100644 index 00000000..c73cd49f --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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: indicator.control.enabled && !indicator.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: indicator.control.checked + } +} diff --git a/src/imports/controls/fusion/impl/SliderGroove.qml b/src/imports/controls/fusion/impl/SliderGroove.qml new file mode 100644 index 00000000..381a02b5 --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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(groove.control.palette), 1.1) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.grooveColor(groove.control.palette), 1.1) + } + } + + Rectangle { + x: groove.control.horizontal ? groove.offset * parent.width : 0 + y: groove.control.horizontal ? 0 : groove.visualProgress * parent.height + width: groove.control.horizontal ? groove.progress * parent.width - groove.offset * parent.width : 5 + height: groove.control.horizontal ? 5 : groove.progress * parent.height - groove.offset * parent.height + + radius: 2 + border.color: Qt.darker(Fusion.highlightedOutline(groove.control.palette), 1.1) + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.highlight(groove.control.palette) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.highlight(groove.control.palette), 1.2) + } + } + } +} diff --git a/src/imports/controls/fusion/impl/SliderHandle.qml b/src/imports/controls/fusion/impl/SliderHandle.qml new file mode 100644 index 00000000..c53af57e --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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/impl/SwitchIndicator.qml b/src/imports/controls/fusion/impl/SwitchIndicator.qml new file mode 100644 index 00000000..ae7c89a0 --- /dev/null +++ b/src/imports/controls/fusion/impl/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.12 +import QtQuick.Controls 2.12 +import QtQuick.Controls.impl 2.12 +import QtQuick.Controls.Fusion 2.12 +import QtQuick.Controls.Fusion.impl 2.12 + +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(indicator.control.palette), 1.1) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.grooveColor(indicator.control.palette), 1.1) + } + } + + Rectangle { + x: indicator.control.mirrored ? handle.x : 0 + width: indicator.control.mirrored ? parent.width - handle.x : handle.x + handle.width + height: parent.height + + opacity: indicator.control.checked ? 1 : 0 + Behavior on opacity { + enabled: !indicator.control.down + NumberAnimation { duration: 80 } + } + + radius: 2 + border.color: Qt.darker(Fusion.highlightedOutline(indicator.control.palette), 1.1) + border.width: indicator.control.enabled ? 1 : 0 + + gradient: Gradient { + GradientStop { + position: 0 + color: Fusion.highlight(indicator.control.palette) + } + GradientStop { + position: 1 + color: Qt.lighter(Fusion.highlight(indicator.control.palette), 1.2) + } + } + } + + Rectangle { + id: handle + x: Math.max(0, Math.min(parent.width - width, indicator.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(indicator.control.palette, indicator.control.visualFocus, indicator.control.pressed, indicator.control.hovered)) + } + GradientStop { + position: 1 + color: Fusion.gradientStop(Fusion.buttonColor(indicator.control.palette, indicator.control.visualFocus, indicator.control.pressed, indicator.control.hovered)) + } + } + border.width: 1 + border.color: "transparent" + + Rectangle { + width: parent.width + height: parent.height + border.color: indicator.control.visualFocus ? Fusion.highlightedOutline(indicator.control.palette) : Fusion.outline(indicator.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: !indicator.control.down + SmoothedAnimation { velocity: 200 } + } + } +} diff --git a/src/imports/controls/fusion/impl/fusion-impl.pro b/src/imports/controls/fusion/impl/fusion-impl.pro new file mode 100644 index 00000000..e3333e18 --- /dev/null +++ b/src/imports/controls/fusion/impl/fusion-impl.pro @@ -0,0 +1,39 @@ +TARGET = qtquickcontrols2fusionstyleimplplugin +TARGETPATH = QtQuick/Controls.2/Fusion/impl + +QML_IMPORT_NAME = QtQuick.Controls.Fusion.impl +QML_IMPORT_VERSION = 2.$$QT_MINOR_VERSION + +QT += qml quick +QT_PRIVATE += core-private gui qml-private quick-private quicktemplates2-private quickcontrols2impl-private +QT_FOR_CONFIG = quickcontrols2-private + +DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII + +QML_FILES += \ + $$PWD/ButtonPanel.qml \ + $$PWD/CheckIndicator.qml \ + $$PWD/RadioIndicator.qml \ + $$PWD/SliderGroove.qml \ + $$PWD/SliderHandle.qml \ + $$PWD/SwitchIndicator.qml + +OTHER_FILES += \ + qmldir \ + $$QML_FILES + +HEADERS += \ + $$PWD/qquickfusionbusyindicator_p.h \ + $$PWD/qquickfusiondial_p.h \ + $$PWD/qquickfusionknob_p.h + +SOURCES += \ + $$PWD/qquickfusionbusyindicator.cpp \ + $$PWD/qquickfusiondial.cpp \ + $$PWD/qquickfusionknob.cpp \ + $$PWD/qtquickcontrols2fusionstyleimplplugin.cpp + +CONFIG += qmltypes install_qmltypes no_cxx_module install_qml_files builtin_resources qtquickcompiler +load(qml_plugin) + +requires(qtConfig(quickcontrols2-fusion)) diff --git a/src/imports/controls/fusion/impl/qmldir b/src/imports/controls/fusion/impl/qmldir new file mode 100644 index 00000000..16ed7fd8 --- /dev/null +++ b/src/imports/controls/fusion/impl/qmldir @@ -0,0 +1,3 @@ +module QtQuick.Controls.Fusion.impl +plugin qtquickcontrols2fusionstyleimplplugin +classname QtQuickControls2FusionStyleImpPlugin diff --git a/src/imports/controls/fusion/impl/qquickfusionbusyindicator.cpp b/src/imports/controls/fusion/impl/qquickfusionbusyindicator.cpp new file mode 100644 index 00000000..a9b75d27 --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusionbusyindicator.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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(); +} + +bool QQuickFusionBusyIndicator::isRunning() const +{ + return isVisible(); +} + +void QQuickFusionBusyIndicator::setRunning(bool running) +{ + if (running) { + setVisible(true); + update(); + } +} + +void QQuickFusionBusyIndicator::paint(QPainter *painter) +{ + const qreal w = width(); + const qreal h = height(); + if (w <= 0 || h <= 0 || !isRunning()) + return; + + const qreal sz = qMin(w, h); + const qreal dx = (w - sz) / 2; + const qreal dy = (h - sz) / 2; + const int hpw = qRound(qMax(qreal(1), 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); +} + +void QQuickFusionBusyIndicator::itemChange(ItemChange change, const ItemChangeData &data) +{ + QQuickPaintedItem::itemChange(change, data); + + if (change == ItemOpacityHasChanged && qFuzzyIsNull(data.realValue)) + setVisible(false); +} + +QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/impl/qquickfusionbusyindicator_p.h b/src/imports/controls/fusion/impl/qquickfusionbusyindicator_p.h new file mode 100644 index 00000000..5aeea6c4 --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusionbusyindicator_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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) + Q_PROPERTY(bool running READ isRunning WRITE setRunning) + QML_NAMED_ELEMENT(BusyIndicatorImpl) + QML_ADDED_IN_VERSION(2, 3) + +public: + explicit QQuickFusionBusyIndicator(QQuickItem *parent = nullptr); + + QColor color() const; + void setColor(const QColor &color); + + bool isRunning() const; + void setRunning(bool running); + + void paint(QPainter *painter) override; + +protected: + void itemChange(ItemChange change, const ItemChangeData &data) override; + +private: + QColor m_color; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONBUSYINDICATOR_P_H diff --git a/src/imports/controls/fusion/impl/qquickfusiondial.cpp b/src/imports/controls/fusion/impl/qquickfusiondial.cpp new file mode 100644 index 00000000..eb6f21ad --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusiondial.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 +#include +#include + +QT_BEGIN_NAMESPACE + +QQuickFusionDial::QQuickFusionDial(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +bool QQuickFusionDial::highlight() const +{ + return m_highlight; +} + +void QQuickFusionDial::setHighlight(bool highlight) +{ + if (m_highlight == highlight) + return; + + m_highlight = highlight; + 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 = QQuickItemPrivate::get(this)->palette()->button(); + const bool enabled = isEnabled(); + qreal r = qMin(width, height) / 2.0; + 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 = QQuickItemPrivate::get(this)->palette()->highlight(); + 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/impl/qquickfusiondial_p.h b/src/imports/controls/fusion/impl/qquickfusiondial_p.h new file mode 100644 index 00000000..c320527a --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusiondial_p.h @@ -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$ +** +****************************************************************************/ + +#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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionDial : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool highlight READ highlight WRITE setHighlight FINAL) + QML_NAMED_ELEMENT(DialImpl) + QML_ADDED_IN_VERSION(2, 3) + +public: + explicit QQuickFusionDial(QQuickItem *parent = nullptr); + + bool highlight() const; + void setHighlight(bool highlight); + + void paint(QPainter *painter) override; + +private: + bool m_highlight = false; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONDIAL_P_H diff --git a/src/imports/controls/fusion/impl/qquickfusionknob.cpp b/src/imports/controls/fusion/impl/qquickfusionknob.cpp new file mode 100644 index 00000000..a641d190 --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusionknob.cpp @@ -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$ +** +****************************************************************************/ + +#include "qquickfusionknob_p.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQuickFusionKnob::QQuickFusionKnob(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ + connect(this, &QQuickItem::paletteChanged, this, [this](){ 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 = QQuickItemPrivate::get(this)->palette()->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/impl/qquickfusionknob_p.h b/src/imports/controls/fusion/impl/qquickfusionknob_p.h new file mode 100644 index 00000000..b9b9c377 --- /dev/null +++ b/src/imports/controls/fusion/impl/qquickfusionknob_p.h @@ -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$ +** +****************************************************************************/ + +#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 + +QT_BEGIN_NAMESPACE + +class QQuickFusionKnob : public QQuickPaintedItem +{ + Q_OBJECT + QML_NAMED_ELEMENT(KnobImpl) + QML_ADDED_IN_VERSION(2, 3) + +public: + explicit QQuickFusionKnob(QQuickItem *parent = nullptr); + + void paint(QPainter *painter) override; +}; + +QT_END_NAMESPACE + +#endif // QQUICKFUSIONKNOB_P_H diff --git a/src/imports/controls/fusion/impl/qtquickcontrols2fusionstyleimplplugin.cpp b/src/imports/controls/fusion/impl/qtquickcontrols2fusionstyleimplplugin.cpp new file mode 100644 index 00000000..56cfc151 --- /dev/null +++ b/src/imports/controls/fusion/impl/qtquickcontrols2fusionstyleimplplugin.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2020 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 + +QT_BEGIN_NAMESPACE + +class QtQuickControls2FusionStyleImplPlugin : public QQmlEngineExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) + +public: + QtQuickControls2FusionStyleImplPlugin(QObject *parent = nullptr); +}; + +QtQuickControls2FusionStyleImplPlugin::QtQuickControls2FusionStyleImplPlugin(QObject *parent) + : QQmlEngineExtensionPlugin(parent) +{ +} + +QT_END_NAMESPACE + +#include "qtquickcontrols2fusionstyleimplplugin.moc" diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp b/src/imports/controls/fusion/qquickfusionbusyindicator.cpp deleted file mode 100644 index a9b75d27..00000000 --- a/src/imports/controls/fusion/qquickfusionbusyindicator.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** 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(); -} - -bool QQuickFusionBusyIndicator::isRunning() const -{ - return isVisible(); -} - -void QQuickFusionBusyIndicator::setRunning(bool running) -{ - if (running) { - setVisible(true); - update(); - } -} - -void QQuickFusionBusyIndicator::paint(QPainter *painter) -{ - const qreal w = width(); - const qreal h = height(); - if (w <= 0 || h <= 0 || !isRunning()) - return; - - const qreal sz = qMin(w, h); - const qreal dx = (w - sz) / 2; - const qreal dy = (h - sz) / 2; - const int hpw = qRound(qMax(qreal(1), 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); -} - -void QQuickFusionBusyIndicator::itemChange(ItemChange change, const ItemChangeData &data) -{ - QQuickPaintedItem::itemChange(change, data); - - if (change == ItemOpacityHasChanged && qFuzzyIsNull(data.realValue)) - setVisible(false); -} - -QT_END_NAMESPACE diff --git a/src/imports/controls/fusion/qquickfusionbusyindicator_p.h b/src/imports/controls/fusion/qquickfusionbusyindicator_p.h deleted file mode 100644 index 77487ec8..00000000 --- a/src/imports/controls/fusion/qquickfusionbusyindicator_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** 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) - Q_PROPERTY(bool running READ isRunning WRITE setRunning) - -public: - explicit QQuickFusionBusyIndicator(QQuickItem *parent = nullptr); - - QColor color() const; - void setColor(const QColor &color); - - bool isRunning() const; - void setRunning(bool running); - - void paint(QPainter *painter) override; - -protected: - void itemChange(ItemChange change, const ItemChangeData &data) 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 deleted file mode 100644 index eb6f21ad..00000000 --- a/src/imports/controls/fusion/qquickfusiondial.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -QT_BEGIN_NAMESPACE - -QQuickFusionDial::QQuickFusionDial(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -bool QQuickFusionDial::highlight() const -{ - return m_highlight; -} - -void QQuickFusionDial::setHighlight(bool highlight) -{ - if (m_highlight == highlight) - return; - - m_highlight = highlight; - 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 = QQuickItemPrivate::get(this)->palette()->button(); - const bool enabled = isEnabled(); - qreal r = qMin(width, height) / 2.0; - 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 = QQuickItemPrivate::get(this)->palette()->highlight(); - 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 deleted file mode 100644 index 07c80cdb..00000000 --- a/src/imports/controls/fusion/qquickfusiondial_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** 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 - -QT_BEGIN_NAMESPACE - -class QQuickFusionDial : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(bool highlight READ highlight WRITE setHighlight FINAL) - -public: - explicit QQuickFusionDial(QQuickItem *parent = nullptr); - - bool highlight() const; - void setHighlight(bool highlight); - - void paint(QPainter *painter) override; - -private: - bool m_highlight = false; -}; - -QT_END_NAMESPACE - -#endif // QQUICKFUSIONDIAL_P_H diff --git a/src/imports/controls/fusion/qquickfusionknob.cpp b/src/imports/controls/fusion/qquickfusionknob.cpp deleted file mode 100644 index a641d190..00000000 --- a/src/imports/controls/fusion/qquickfusionknob.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 -#include -#include - -QT_BEGIN_NAMESPACE - -QQuickFusionKnob::QQuickFusionKnob(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ - connect(this, &QQuickItem::paletteChanged, this, [this](){ 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 = QQuickItemPrivate::get(this)->palette()->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 deleted file mode 100644 index 85e5f53e..00000000 --- a/src/imports/controls/fusion/qquickfusionknob_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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 - -QT_BEGIN_NAMESPACE - -class QQuickFusionKnob : public QQuickPaintedItem -{ - Q_OBJECT - -public: - explicit QQuickFusionKnob(QQuickItem *parent = nullptr); - - void paint(QPainter *painter) override; -}; - -QT_END_NAMESPACE - -#endif // QQUICKFUSIONKNOB_P_H diff --git a/src/imports/controls/fusion/qquickfusionstyle_p.h b/src/imports/controls/fusion/qquickfusionstyle_p.h index 0e7526ee..4655fd3d 100644 --- a/src/imports/controls/fusion/qquickfusionstyle_p.h +++ b/src/imports/controls/fusion/qquickfusionstyle_p.h @@ -50,6 +50,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -62,6 +63,9 @@ class QQuickFusionStyle : public QObject Q_PROPERTY(QColor darkShade READ darkShade CONSTANT) Q_PROPERTY(QColor topShadow READ topShadow CONSTANT) Q_PROPERTY(QColor innerContrastLine READ innerContrastLine CONSTANT) + QML_NAMED_ELEMENT(Fusion) + QML_SINGLETON + QML_ADDED_IN_VERSION(2, 3) public: explicit QQuickFusionStyle(QObject *parent = nullptr); diff --git a/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc b/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc index 74c8e671..0a9e195a 100644 --- a/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc +++ b/src/imports/controls/fusion/qtquickcontrols2fusionstyle.qrc @@ -1,5 +1,5 @@ - + images/arrow.png images/arrow@2x.png images/arrow@3x.png diff --git a/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp index 985945cf..1f9b4a1b 100644 --- a/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp +++ b/src/imports/controls/fusion/qtquickcontrols2fusionstyleplugin.cpp @@ -37,22 +37,12 @@ #include #include -#include "qquickfusionbusyindicator_p.h" -#include "qquickfusiondial_p.h" -#include "qquickfusionknob_p.h" #include "qquickfusionstyle_p.h" #include "qquickfusiontheme_p.h" QT_BEGIN_NAMESPACE -static QObject *styleSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) -{ - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new QQuickFusionStyle; -} - -class QtQuickControls2FusionStylePlugin: public QQuickStylePlugin +class QtQuickControls2FusionStylePlugin : public QQuickStylePlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) @@ -72,18 +62,9 @@ QtQuickControls2FusionStylePlugin::QtQuickControls2FusionStylePlugin(QObject *pa void QtQuickControls2FusionStylePlugin::registerTypes(const char *uri) { - qmlRegisterModule(uri, 2, 3); // Qt 5.10->2.3 - qmlRegisterModule(uri, 2, 15); // Qt 5.12->2.12, 5.13->2.13... - QByteArray import = QByteArray(uri) + ".impl"; qmlRegisterModule(import, 2, 15); // Qt 5.12->2.12, 5.13->2.13... - qmlRegisterSingletonType(import, 2, 3, "Fusion", styleSingleton); - - qmlRegisterType(import, 2, 3, "BusyIndicatorImpl"); - qmlRegisterType(import, 2, 3, "DialImpl"); - qmlRegisterType(import, 2, 3, "KnobImpl"); - qmlRegisterType(resolvedUrl(QStringLiteral("ButtonPanel.qml")), import, 2, 3, "ButtonPanel"); qmlRegisterType(resolvedUrl(QStringLiteral("CheckIndicator.qml")), import, 2, 3, "CheckIndicator"); qmlRegisterType(resolvedUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 3, "RadioIndicator"); -- cgit v1.2.3