aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-10-31 14:30:39 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-11-02 09:12:14 +0000
commit0504150e4a0a3874a8e431af351277f7342dac95 (patch)
tree1fc32d24f40763affcec66b03bcf59e04c9ec70b /src/imports/controls
parent6f89cf6370daa443169d24ce45a925000b6e0248 (diff)
Default: merge CheckIndicator back to CheckBox & CheckDelegate
The internal CheckIndicator helper was introduced together with CheckDelegate in 1acb34a, because we naturally wanted to share the indicator instead of duplicating it. This change is controversial, because it leads to duplicate code, but keeping the indicator definitions inline is clearly faster. This is not seen as a huge problem for the Default style, because the indicator is not too complicated. Basically, this fixes a ~5% performance regression introduced by 1acb34a. Before: running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_checkbox.qml [...] Average: 72.8 frames; using samples; MedianAll=73; StdDev=1.48324, CoV=0.0203742 After: running: qmlbench/benchmarks/auto/creation/quick.controls2/delegates_checkbox.qml [...] Average: 77 frames; using samples; MedianAll=77; StdDev=1.41421, CoV=0.0183664 Change-Id: Ibee0e29e83a64ee4a6a772a90b1784a9c8c715bb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/controls')
-rw-r--r--src/imports/controls/CheckBox.qml29
-rw-r--r--src/imports/controls/CheckDelegate.qml30
-rw-r--r--src/imports/controls/CheckIndicator.qml70
-rw-r--r--src/imports/controls/controls.pri1
-rw-r--r--src/imports/controls/plugins.qmltypes9
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp1
6 files changed, 54 insertions, 86 deletions
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml
index 4348781d..ec539b19 100644
--- a/src/imports/controls/CheckBox.qml
+++ b/src/imports/controls/CheckBox.qml
@@ -52,10 +52,35 @@ T.CheckBox {
padding: 6
spacing: 6
- indicator: CheckIndicator {
+ // keep in sync with CheckDelegate.qml (shared CheckIndicator.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
+
+ 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
+
+ ColorImage {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ defaultColor: "#353637"
+ color: control.palette.text
+ source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/images/check.png"
+ visible: control.checkState === Qt.Checked
+ }
+
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 16
+ height: 3
+ color: control.palette.text
+ visible: control.checkState === Qt.PartiallyChecked
+ }
}
contentItem: CheckLabel {
diff --git a/src/imports/controls/CheckDelegate.qml b/src/imports/controls/CheckDelegate.qml
index 55dd05eb..36b9f2ba 100644
--- a/src/imports/controls/CheckDelegate.qml
+++ b/src/imports/controls/CheckDelegate.qml
@@ -71,11 +71,35 @@ T.CheckDelegate {
color: control.palette.text
}
- indicator: CheckIndicator {
- x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
+ // keep in sync with CheckBox.qml (shared CheckIndicator.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
+ 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
+
+ ColorImage {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ defaultColor: "#353637"
+ color: control.palette.text
+ source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/images/check.png"
+ visible: control.checkState === Qt.Checked
+ }
+
+ Rectangle {
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 16
+ height: 3
+ color: control.palette.text
+ visible: control.checkState === Qt.PartiallyChecked
+ }
}
background: Rectangle {
diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml
deleted file mode 100644
index 730878be..00000000
--- a/src/imports/controls/CheckIndicator.qml
+++ /dev/null
@@ -1,70 +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 {
- id: indicator
-
- property Item control
-
- implicitWidth: 28
- implicitHeight: 28
-
- 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
-
- ColorImage {
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- defaultColor: "#353637"
- color: control.palette.text
- source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/images/check.png"
- visible: control.checkState === Qt.Checked
- }
-
- Rectangle {
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- width: 16
- height: 3
- color: control.palette.text
- visible: control.checkState === Qt.PartiallyChecked
- }
-}
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index 56c7a8ee..0bdf0e52 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -22,7 +22,6 @@ QML_CONTROLS = \
$$PWD/ButtonGroup.qml \
$$PWD/CheckBox.qml \
$$PWD/CheckDelegate.qml \
- $$PWD/CheckIndicator.qml \
$$PWD/ComboBox.qml \
$$PWD/Container.qml \
$$PWD/Control.qml \
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index a4f59481..ff096286 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -255,15 +255,6 @@ Module {
defaultProperty: "data"
}
Component {
- prototype: "QQuickRectangle"
- name: "QtQuick.Controls.impl/CheckIndicator 2.0"
- exports: ["QtQuick.Controls.impl/CheckIndicator 2.0"]
- exportMetaObjectRevisions: [0]
- isComposite: true
- defaultProperty: "data"
- Property { name: "control"; type: "QQuickItem"; isPointer: true }
- }
- Component {
prototype: "QQuickComboBox"
name: "QtQuick.Controls/ComboBox 2.0"
exports: ["QtQuick.Controls/ComboBox 2.0"]
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 768f4ab8..29121a74 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("CheckIndicator.qml")), import, 2, 0, "CheckIndicator");
qmlRegisterType(typeUrl(QStringLiteral("RadioIndicator.qml")), import, 2, 0, "RadioIndicator");
qmlRegisterType(typeUrl(QStringLiteral("SwitchIndicator.qml")), import, 2, 0, "SwitchIndicator");