diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-04-01 15:37:07 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-08-26 11:45:55 +0200 |
commit | 9aafea810b8867fb31f9ec27a238628467e7ab56 (patch) | |
tree | 061b16374195312e6df496e15430f540b76057d9 /src/imports/controls/CheckBox.qml | |
parent | ef771a0fd70f05d7204fb8cbd8789aa1ed6eff4b (diff) |
Move Default style out into its own plugin
In upcoming patches, we start registering C++ types declaratively.
A condition of doing so requires that each .pro corresponds to one
QML module. This conflicts with the QtQuick.Controls import, which
currently does quite a lot:
- Registers (and selects) QML files for the style that was set
- Registers private C++ utility types (such as IconLabel) that are
useful for all styles under the QtQuick.Controls.impl import
- Registers private C++ types that are only useful for the Default
style (such as BusyIndicatorImpl).
The reason it does so much can probably be explained by the
intended usage of Qt Quick Controls 2; when you do
import QtQuick.Controls 2.0
you get access to the QML types (e.g. Button) that the style
you're using provides. So if you're using the Material style,
you'll get a Material style button. API-wise, the button is
identical to any other button, because the types in
QtQuick.Templates are what we advertise as the public API.
If we didn't have this functionality, users would need to
import specific style imports to use controls, and the
convenience of being able to simply start the application
with a different style by e.g. passing an application argument
would be lost.
To support declarative registration of types while also supporting
the existing use cases, we split out the Default-style-specific
stuff into a QtQuick.Controls.Default import.
Task-number: QTBUG-82922
Change-Id: Ib4f1620cae78d7acdc13d9ac0752a020bc22f3ea
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/imports/controls/CheckBox.qml')
-rw-r--r-- | src/imports/controls/CheckBox.qml | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml deleted file mode 100644 index b1f50ed1..00000000 --- a/src/imports/controls/CheckBox.qml +++ /dev/null @@ -1,93 +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.Templates 2.12 as T -import QtQuick.Controls 2.12 -import QtQuick.Controls.impl 2.12 - -T.CheckBox { - id: control - - implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - implicitContentWidth + leftPadding + rightPadding) - implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - implicitContentHeight + topPadding + bottomPadding, - implicitIndicatorHeight + topPadding + bottomPadding) - - padding: 6 - spacing: 6 - - // keep in sync with CheckDelegate.qml (shared CheckIndicator.qml was removed for performance reasons) - indicator: Rectangle { - implicitWidth: 28 - implicitHeight: 28 - - x: control.text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 - y: control.topPadding + (control.availableHeight - height) / 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 - - 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 { - leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 - rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 - - text: control.text - font: control.font - color: control.palette.windowText - } -} |