diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-25 19:28:36 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-09-25 19:49:47 +0000 |
commit | 46215a8bcc4423fe79be4e4830435a1e10db22e7 (patch) | |
tree | 319cad15d62597bea6f626ad1ade7774fb864e62 /src | |
parent | d703de8752e07cb12e8ce2e2a05d608f2b26425a (diff) |
Remove ToggleButton
We don't have a sensible design. It's better not to have it at
all than to have a confusing tiny bit tweaked clone of Switch.
Change-Id: Ib0eabd075590100e9e49846c7172909525b54a57
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/ToggleButton.qml | 106 | ||||
-rw-r--r-- | src/imports/controls/controls.pri | 1 | ||||
-rw-r--r-- | src/imports/controls/designer/ToggleButtonSpecifics.qml | 81 | ||||
-rw-r--r-- | src/imports/controls/designer/designer.pri | 1 | ||||
-rw-r--r-- | src/imports/controls/designer/qtquickcontrols2.metainfo | 15 | ||||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc | 26 | ||||
-rw-r--r-- | src/imports/controls/qtquickcontrols2plugin.cpp | 1 | ||||
-rw-r--r-- | src/imports/templates/qtquicktemplates2plugin.cpp | 2 | ||||
-rw-r--r-- | src/templates/qquicktogglebutton.cpp | 84 | ||||
-rw-r--r-- | src/templates/qquicktogglebutton_p.h | 67 | ||||
-rw-r--r-- | src/templates/templates.pri | 2 |
11 files changed, 1 insertions, 385 deletions
diff --git a/src/imports/controls/ToggleButton.qml b/src/imports/controls/ToggleButton.qml deleted file mode 100644 index e5dd2805..00000000 --- a/src/imports/controls/ToggleButton.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 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.6 -import QtQuick.Controls 2.0 -import QtQuick.Templates 2.0 as T - -T.ToggleButton { - id: control - - implicitWidth: Math.max(background ? background.implicitWidth : 0, - (label ? label.implicitWidth : 0) + - (indicator ? indicator.implicitWidth : 0) + - (label && indicator ? spacing : 0) + leftPadding + rightPadding) - implicitHeight: Math.max(background ? background.implicitHeight : 0, - Math.max(label ? label.implicitHeight : 0, - indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) - - padding: 6 - spacing: 6 - - //! [indicator] - indicator: Rectangle { - implicitWidth: 36 - implicitHeight: 20 - x: text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2 - y: control.topPadding + (control.availableHeight - height) / 2 - - radius: 3 - border.width: control.activeFocus ? 2 : 1 - border.color: control.activeFocus ? control.Theme.focusColor : control.Theme.frameColor - color: control.Theme.backgroundColor - - Rectangle { - width: 12 - height: 12 - - color: Qt.tint(control.checked && !control.enabled ? control.Theme.disabledColor : - control.checked && control.activeFocus ? control.Theme.focusColor : - control.checked ? control.Theme.accentColor : control.Theme.baseColor, - control.pressed ? control.Theme.pressColor : "transparent") - border.width: control.checked || control.pressed ? 0 : 1 - border.color: control.Theme.frameColor - - x: Math.max(4, Math.min(parent.width - width - 4, - control.visualPosition * parent.width - (width / 2))) - y: (parent.height - height) / 2 - - Behavior on x { - enabled: !control.pressed - SmoothedAnimation { velocity: 200 } - } - } - } - //! [indicator] - - //! [label] - label: Text { - x: control.mirrored ? control.leftPadding : (indicator.x + indicator.width + control.spacing) - y: control.topPadding - width: control.availableWidth - indicator.width - control.spacing - height: control.availableHeight - - text: control.text - font: control.font - color: control.enabled ? control.Theme.textColor : control.Theme.disabledColor - elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - //! [label] -} diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index ed62ee45..ee9c2e63 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -21,7 +21,6 @@ QML_FILES = \ TabButton.qml \ TextArea.qml \ TextField.qml \ - ToggleButton.qml \ ToolBar.qml \ ToolButton.qml \ Tumbler.qml diff --git a/src/imports/controls/designer/ToggleButtonSpecifics.qml b/src/imports/controls/designer/ToggleButtonSpecifics.qml deleted file mode 100644 index c23c9cb9..00000000 --- a/src/imports/controls/designer/ToggleButtonSpecifics.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 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.1 -import HelperWidgets 2.0 -import QtQuick.Layouts 1.0 - -Column { - width: parent.width - - Section { - width: parent.width - caption: qsTr("Toggle Button") - - SectionLayout { - Label { - text: qsTr("Text") - tooltip: qsTr("The text displayed on the toggle button.") - } - SecondColumnLayout { - LineEdit { - backendValue: backendValues.text - Layout.fillWidth: true - } - } - - Label { - text: qsTr("Checked") - tooltip: qsTr("The checked state of the toggle button.") - } - SecondColumnLayout { - CheckBox { - text: backendValues.checked.valueToString - backendValue: backendValues.checked - Layout.fillWidth: true - } - } - } - } - - ControlSection { - width: parent.width - } - - PaddingSection { - width: parent.width - } -} diff --git a/src/imports/controls/designer/designer.pri b/src/imports/controls/designer/designer.pri index 69202e83..8a14bc69 100644 --- a/src/imports/controls/designer/designer.pri +++ b/src/imports/controls/designer/designer.pri @@ -18,7 +18,6 @@ QML_FILES += \ $$PWD/SwitchSpecifics.qml \ $$PWD/TextAreaSpecifics.qml \ $$PWD/TextFieldSpecifics.qml \ - $$PWD/ToggleButtonSpecifics.qml \ $$PWD/ToolBarSpecifics.qml \ $$PWD/ToolButtonSpecifics.qml diff --git a/src/imports/controls/designer/qtquickcontrols2.metainfo b/src/imports/controls/designer/qtquickcontrols2.metainfo index d00b541f..40439833 100644 --- a/src/imports/controls/designer/qtquickcontrols2.metainfo +++ b/src/imports/controls/designer/qtquickcontrols2.metainfo @@ -196,21 +196,6 @@ MetaInfo { } Type { - name: "QtQuick.Controls.ToggleButton" - icon: "images/todo16.png" - - ItemLibraryEntry { - name: "Toggle Button" - category: "Qt Quick - Controls" - libraryIcon: "images/todo.png" - version: "2.0" - requiredImport: "QtQuick.Controls" - - Property { name: "text"; type: "binding"; value: "qsTr('Toggle Button')" } - } - } - - Type { name: "QtQuick.Controls.ToolButton" icon: "images/todo16.png" diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc index e554b202..7b4176f5 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc @@ -329,30 +329,6 @@ \snippet TextField.qml placeholder - \section1 Customizing ToggleButton - - ToggleButton consists of three visual items: \l {Control::background}{background}, - \l {AbstractButton::label}{label} and \l {Checkable::indicator}{indicator}. - - \section3 Background - - \image qtquickcontrols2-togglebutton-background.png - - ToggleButton has no background item by default. - - \section3 Label - - \image qtquickcontrols2-togglebutton-label.png - - \snippet ToggleButton.qml label - - \section3 Indicator - - \image qtquickcontrols2-togglebutton-indicator.png - - \snippet ToggleButton.qml indicator - - \section1 Customizing ToolBar ToolBar consists of two visual items: \l {Control::background}{background} and @@ -368,7 +344,7 @@ \image qtquickcontrols2-toolbar-frame.png - ToggleButton has no frame item by default. + ToolBar has no frame item by default. \section1 Customizing ToolButton diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 1d9467bc..d12f164b 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -91,7 +91,6 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/TabButton.qml"))), uri, 2, 0, "TabButton"); qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/TextArea.qml"))), uri, 2, 0, "TextArea"); qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/TextField.qml"))), uri, 2, 0, "TextField"); - qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/ToggleButton.qml"))), uri, 2, 0, "ToggleButton"); qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/ToolBar.qml"))), uri, 2, 0, "ToolBar"); qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/ToolButton.qml"))), uri, 2, 0, "ToolButton"); qmlRegisterType(selector.select(QUrl(base + QStringLiteral("/Tumbler.qml"))), uri, 2, 0, "Tumbler"); diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 6ce40e99..7d25d3db 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -60,7 +60,6 @@ #include <QtQuickTemplates/private/qquicktabbutton_p.h> #include <QtQuickTemplates/private/qquicktextarea_p.h> #include <QtQuickTemplates/private/qquicktextfield_p.h> -#include <QtQuickTemplates/private/qquicktogglebutton_p.h> #include <QtQuickTemplates/private/qquicktoolbar_p.h> #include <QtQuickTemplates/private/qquicktoolbutton_p.h> #include <QtQuickTemplates/private/qquicktumbler_p.h> @@ -103,7 +102,6 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType<QQuickTabButton>(uri, 2, 0, "TabButton"); qmlRegisterType<QQuickTextArea>(uri, 2, 0, "TextArea"); qmlRegisterType<QQuickTextField>(uri, 2, 0, "TextField"); - qmlRegisterType<QQuickToggleButton>(uri, 2, 0, "ToggleButton"); qmlRegisterType<QQuickToolBar>(uri, 2, 0, "ToolBar"); qmlRegisterType<QQuickToolButton>(uri, 2, 0, "ToolButton"); qmlRegisterType<QQuickTumblerAttached>(); diff --git a/src/templates/qquicktogglebutton.cpp b/src/templates/qquicktogglebutton.cpp deleted file mode 100644 index 96edbefd..00000000 --- a/src/templates/qquicktogglebutton.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 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 "qquicktogglebutton_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \qmltype ToggleButton - \inherits Checkable - \instantiates QQuickToggleButton - \inqmlmodule QtQuick.Controls - \ingroup buttons - \brief A toggle button control. - - ToggleButton is an option button that can be dragged or toggled on - (checked) or off (unchecked). ToggleButtons are typically used to - select between two states. - - \table - \row \li \image qtquickcontrols2-togglebutton-normal.png - \li A toggle button in its normal state. - \row \li \image qtquickcontrols2-togglebutton-checked.png - \li A toggle button that is checked. - \row \li \image qtquickcontrols2-togglebutton-focused.png - \li A toggle button that has active focus. - \row \li \image qtquickcontrols2-togglebutton-disabled.png - \li A toggle button that is disabled. - \endtable - - \code - ColumnLayout { - ToggleButton { - text: qsTr("Wi-Fi") - } - ToggleButton { - text: qsTr("Bluetooth") - } - } - \endcode - - \sa {Customizing ToggleButton} -*/ - -QQuickToggleButton::QQuickToggleButton(QQuickItem *parent) : - QQuickSwitch(parent) -{ - setAccessibleRole(0x0000002B); //QAccessible::Button -} - -QT_END_NAMESPACE diff --git a/src/templates/qquicktogglebutton_p.h b/src/templates/qquicktogglebutton_p.h deleted file mode 100644 index 8f80437e..00000000 --- a/src/templates/qquicktogglebutton_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Controls 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 QQUICKTOGGLEBUTTON_P_H -#define QQUICKTOGGLEBUTTON_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 <QtQuickTemplates/private/qquickswitch_p.h> - -QT_BEGIN_NAMESPACE - -class Q_QUICKTEMPLATES_EXPORT QQuickToggleButton : public QQuickSwitch -{ - Q_OBJECT - -public: - explicit QQuickToggleButton(QQuickItem *parent = Q_NULLPTR); -}; - -Q_DECLARE_TYPEINFO(QQuickToggleButton, Q_COMPLEX_TYPE); - -QT_END_NAMESPACE - -#endif // QQUICKTOGGLEBUTTON_P_H diff --git a/src/templates/templates.pri b/src/templates/templates.pri index 3c3cd3d9..572fa69c 100644 --- a/src/templates/templates.pri +++ b/src/templates/templates.pri @@ -38,7 +38,6 @@ HEADERS += \ $$PWD/qquicktextarea_p_p.h \ $$PWD/qquicktextfield_p.h \ $$PWD/qquicktextfield_p_p.h \ - $$PWD/qquicktogglebutton_p.h \ $$PWD/qquicktoolbar_p.h \ $$PWD/qquicktoolbutton_p.h \ $$PWD/qquicktumbler_p.h @@ -73,7 +72,6 @@ SOURCES += \ $$PWD/qquicktabbutton.cpp \ $$PWD/qquicktextarea.cpp \ $$PWD/qquicktextfield.cpp \ - $$PWD/qquicktogglebutton.cpp \ $$PWD/qquicktoolbar.cpp \ $$PWD/qquicktoolbutton.cpp \ $$PWD/qquicktumbler.cpp |