diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-10-31 14:55:34 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-11-02 09:12:18 +0000 |
commit | 1350b91aaf9a343d721ea085fd924812e518ccbd (patch) | |
tree | d2d5c0740001ae51b79469e23f2e0db2c8933765 /src | |
parent | 0504150e4a0a3874a8e431af351277f7342dac95 (diff) |
Default: merge RadioIndicator back to RadioButton & RadioDelegate
See the previous commit (CheckIndicator) for more details.
Before:
running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_radiobutton.qml
[...]
Average: 91.6 frames; using samples; MedianAll=91; StdDev=1.51658, CoV=0.0165565
After:
running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_radiobutton.qml
[...]
Average: 95.8 frames; using samples; MedianAll=96; StdDev=2.04939, CoV=0.0213924
Change-Id: Ic185241767d0b9422e86919356e3155e00803e56
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/RadioButton.qml | 22 | ||||
-rw-r--r-- | src/imports/controls/RadioDelegate.qml | 21 | ||||
-rw-r--r-- | src/imports/controls/RadioIndicator.qml | 61 | ||||
-rw-r--r-- | src/imports/controls/controls.pri | 1 | ||||
-rw-r--r-- | src/imports/controls/plugins.qmltypes | 9 | ||||
-rw-r--r-- | src/imports/controls/qtquickcontrols2plugin.cpp | 1 |
6 files changed, 39 insertions, 76 deletions
diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 2ea9dbfa..a9f63652 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -52,10 +52,28 @@ T.RadioButton { padding: 6 spacing: 6 - indicator: RadioIndicator { + // keep in sync with RadioDelegate.qml (shared RadioIndicator.qml was removed for performance reasons) + indicator: Rectangle { + implicitWidth: 28 + implicitHeight: 28 + x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 y: control.topPadding + (control.availableHeight - height) / 2 - control: control + + radius: width / 2 + color: control.down ? control.palette.light : control.palette.base + border.width: control.visualFocus ? 2 : 1 + border.color: control.visualFocus ? control.palette.highlight : control.palette.mid + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 20 + height: 20 + radius: width / 2 + color: control.palette.text + visible: control.checked + } } contentItem: CheckLabel { diff --git a/src/imports/controls/RadioDelegate.qml b/src/imports/controls/RadioDelegate.qml index bf14dbc1..8cfe6e5f 100644 --- a/src/imports/controls/RadioDelegate.qml +++ b/src/imports/controls/RadioDelegate.qml @@ -71,11 +71,28 @@ T.RadioDelegate { color: control.palette.text } - indicator: RadioIndicator { + // keep in sync with RadioButton.qml (shared RadioIndicator.qml was removed for performance reasons) + indicator: Rectangle { + implicitWidth: 28 + implicitHeight: 28 + x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding y: control.topPadding + (control.availableHeight - height) / 2 - control: control + radius: width / 2 + color: control.down ? control.palette.light : control.palette.base + border.width: control.visualFocus ? 2 : 1 + border.color: control.visualFocus ? control.palette.highlight : control.palette.mid + + Rectangle { + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: 20 + height: 20 + radius: width / 2 + color: control.palette.text + visible: control.checked + } } background: Rectangle { diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml deleted file mode 100644 index e0d32047..00000000 --- a/src/imports/controls/RadioIndicator.qml +++ /dev/null @@ -1,61 +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.10 -import QtQuick.Controls 2.3 -import QtQuick.Controls.impl 2.3 - -Rectangle { - implicitWidth: 28 - implicitHeight: 28 - - radius: width / 2 - color: control.down ? control.palette.light : control.palette.base - border.width: control.visualFocus ? 2 : 1 - border.color: control.visualFocus ? control.palette.highlight : control.palette.mid - - property Item control - - Rectangle { - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: 20 - height: 20 - radius: width / 2 - color: control.palette.text - visible: control.checked - } -} diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index 0bdf0e52..e31d455b 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -46,7 +46,6 @@ QML_CONTROLS = \ $$PWD/ProgressBar.qml \ $$PWD/RadioButton.qml \ $$PWD/RadioDelegate.qml \ - $$PWD/RadioIndicator.qml \ $$PWD/RangeSlider.qml \ $$PWD/RoundButton.qml \ $$PWD/ScrollBar.qml \ diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index ff096286..0dd0d720 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -447,15 +447,6 @@ Module { defaultProperty: "data" } Component { - prototype: "QQuickRectangle" - name: "QtQuick.Controls.impl/RadioIndicator 2.0" - exports: ["QtQuick.Controls.impl/RadioIndicator 2.0"] - exportMetaObjectRevisions: [0] - isComposite: true - defaultProperty: "data" - Property { name: "control"; type: "QQuickItem"; isPointer: true } - } - Component { prototype: "QQuickRangeSlider" name: "QtQuick.Controls/RangeSlider 2.0" exports: ["QtQuick.Controls/RangeSlider 2.0"] diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 29121a74..ea234939 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -194,7 +194,6 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur qmlRegisterType<QQuickTumblerView>(import, 2, 1, "TumblerView"); #endif qmlRegisterSingletonType<QQuickDefaultStyle>(import, 2, 1, "Default", styleSingleton); - qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 0, "RadioIndicator"); qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator"); qmlRegisterType<QQuickColorImage>(import, 2, 3, "ColorImage"); |