From 46215a8bcc4423fe79be4e4830435a1e10db22e7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 25 Sep 2015 19:28:36 +0200 Subject: 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 --- tests/auto/accessibility/data/togglebutton.qml | 13 -- tests/auto/accessibility/tst_accessibility.cpp | 1 - .../activeFocusOnTab/data/activeFocusOnTab.qml | 5 - .../auto/activeFocusOnTab/tst_activeFocusOnTab.cpp | 22 +- tests/auto/controls/data/tst_exclusivegroup.qml | 11 - tests/auto/controls/data/tst_togglebutton.qml | 259 --------------------- .../qtquickcontrols2-togglebutton-background.qml | 10 - .../qtquickcontrols2-togglebutton-checked.qml | 7 - .../qtquickcontrols2-togglebutton-disabled.qml | 7 - .../qtquickcontrols2-togglebutton-focused.qml | 7 - .../qtquickcontrols2-togglebutton-indicator.qml | 11 - .../qtquickcontrols2-togglebutton-label.qml | 11 - .../qtquickcontrols2-togglebutton-normal.qml | 6 - tests/benchmarks/objectcount/tst_objectcount.cpp | 4 - tests/manual/fonts/main.qml | 1 - 15 files changed, 2 insertions(+), 373 deletions(-) delete mode 100644 tests/auto/accessibility/data/togglebutton.qml delete mode 100644 tests/auto/controls/data/tst_togglebutton.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-background.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-checked.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-disabled.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-focused.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-indicator.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-label.qml delete mode 100644 tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-normal.qml (limited to 'tests') diff --git a/tests/auto/accessibility/data/togglebutton.qml b/tests/auto/accessibility/data/togglebutton.qml deleted file mode 100644 index 8f75c364..00000000 --- a/tests/auto/accessibility/data/togglebutton.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.0 - -Window { - visible: true - - ToggleButton { - id: togglebutton - objectName: "togglebutton" - text: "ToggleButton" - } -} diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 41a0ed4b..450fb88a 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -87,7 +87,6 @@ void tst_accessibility::a11y_data() QTest::newRow("TabButton") << "tabbutton" << 0x00000025 << "TabButton"; //QAccessible::PageTab QTest::newRow("TextArea") << "textarea" << 0x0000002A << "TextArea"; //QAccessible::Accessible.EditableText QTest::newRow("TextField") << "textfield" << 0x0000002A << "TextField"; //QAccessible::Accessible.EditableText - QTest::newRow("ToggleButton") << "togglebutton" << 0x0000002B << "ToggleButton"; //QAccessible::Button QTest::newRow("ToolBar") << "toolbar" << 0x00000016 << ""; //QAccessible::ToolBar QTest::newRow("ToolButton") << "toolbutton" << 0x0000002B << "ToolButton"; //QAccessible::Button diff --git a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml index 92a90127..dd2281dd 100644 --- a/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml +++ b/tests/auto/activeFocusOnTab/data/activeFocusOnTab.qml @@ -163,11 +163,6 @@ Item { objectName: "textfield" text: "abc" } - ToggleButton { - id: togglebutton - objectName: "togglebutton" - text: "togglebutton" - } ToolBar { width: parent.width id: toolbar diff --git a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp index 8ac756b9..b0fbf597 100644 --- a/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp +++ b/tests/auto/activeFocusOnTab/tst_activeFocusOnTab.cpp @@ -207,16 +207,7 @@ void tst_activeFocusOnTab::activeFocusOnTab() QVERIFY(item); QVERIFY(item->hasActiveFocus()); - // Tab: textfield->togglebutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->rootObject(), "togglebutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: togglebutton->toolbutton + // Tab: textfield->toolbutton key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); QGuiApplication::sendEvent(window, &key); QVERIFY(key.isAccepted()); @@ -243,16 +234,7 @@ void tst_activeFocusOnTab::activeFocusOnTab() QVERIFY(item); QVERIFY(item->hasActiveFocus()); - // BackTab: toolbutton->togglebutton - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->rootObject(), "togglebutton"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: togglebutton->textfield + // BackTab: toolbutton->textfield key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); QGuiApplication::sendEvent(window, &key); QVERIFY(key.isAccepted()); diff --git a/tests/auto/controls/data/tst_exclusivegroup.qml b/tests/auto/controls/data/tst_exclusivegroup.qml index 41794ab2..61076ec8 100644 --- a/tests/auto/controls/data/tst_exclusivegroup.qml +++ b/tests/auto/controls/data/tst_exclusivegroup.qml @@ -256,16 +256,6 @@ TestCase { } } - Component { - id: toggleButtons - Item { - property ExclusiveGroup group: ExclusiveGroup { id: group } - property ToggleButton control1: ToggleButton { ExclusiveGroup.group: group } - property ToggleButton control2: ToggleButton { ExclusiveGroup.group: group } - property ToggleButton control3: ToggleButton { ExclusiveGroup.group: group } - } - } - Component { id: childControls Item { @@ -285,7 +275,6 @@ TestCase { { tag: "CheckBox", component: checkBoxes }, { tag: "RadioButton", component: radioButtons }, { tag: "Switch", component: switches }, - { tag: "ToggleButton", component: toggleButtons }, { tag: "Children", component: childControls } ] } diff --git a/tests/auto/controls/data/tst_togglebutton.qml b/tests/auto/controls/data/tst_togglebutton.qml deleted file mode 100644 index 416be713..00000000 --- a/tests/auto/controls/data/tst_togglebutton.qml +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtTest 1.0 -import QtQuick.Controls 2.0 - -TestCase { - id: testCase - width: 200 - height: 200 - visible: true - when: windowShown - name: "ToggleButton" - - SignalSpy { - id: checkedSpy - signalName: "checkedChanged" - } - - SignalSpy { - id: pressedSpy - signalName: "pressedChanged" - } - - SignalSpy { - id: clickedSpy - signalName: "clicked" - } - - Component { - id: toggleButton - ToggleButton { } - } - - function init() { - verify(!checkedSpy.target) - verify(!pressedSpy.target) - verify(!clickedSpy.target) - compare(checkedSpy.count, 0) - compare(pressedSpy.count, 0) - compare(clickedSpy.count, 0) - } - - function cleanup() { - checkedSpy.target = null - pressedSpy.target = null - clickedSpy.target = null - checkedSpy.clear() - pressedSpy.clear() - clickedSpy.clear() - } - - function test_text() { - var control = toggleButton.createObject(testCase) - verify(control) - - compare(control.text, "") - control.text = "ToggleButton" - compare(control.text, "ToggleButton") - control.text = "" - compare(control.text, "") - - control.destroy() - } - - function test_checked() { - var control = toggleButton.createObject(testCase) - verify(control) - - checkedSpy.target = control - verify(checkedSpy.valid) - - compare(control.checked, false) - compare(checkedSpy.count, 0) - - control.checked = true - compare(control.checked, true) - compare(checkedSpy.count, 1) - - control.checked = false - compare(control.checked, false) - compare(checkedSpy.count, 2) - - control.destroy() - } - - function test_mouse() { - var control = toggleButton.createObject(testCase) - verify(control) - - checkedSpy.target = control - pressedSpy.target = control - clickedSpy.target = control - verify(checkedSpy.valid) - verify(pressedSpy.valid) - verify(clickedSpy.valid) - - // check - mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(pressedSpy.count, 1) - compare(control.pressed, true) - mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(clickedSpy.count, 1) - compare(checkedSpy.count, 1) - compare(pressedSpy.count, 2) - compare(control.checked, true) - compare(control.pressed, false) - - // uncheck - mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(pressedSpy.count, 3) - compare(control.pressed, true) - mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 2) - compare(pressedSpy.count, 4) - compare(control.checked, false) - compare(control.pressed, false) - - // release on the right - mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(pressedSpy.count, 5) - compare(control.pressed, true) - mouseMove(control, control.width * 2, control.height / 2, 0, Qt.LeftButton) - compare(control.pressed, true) - mouseRelease(control, control.width * 2, control.height / 2, Qt.LeftButton) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 3) - compare(pressedSpy.count, 6) - compare(control.checked, true) - compare(control.pressed, false) - - // release on the left - mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) - compare(pressedSpy.count, 7) - compare(control.pressed, true) - mouseMove(control, -control.width, control.height / 2, 0, Qt.LeftButton) - compare(control.pressed, true) - mouseRelease(control, -control.width, control.height / 2, Qt.LeftButton) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 4) - compare(pressedSpy.count, 8) - compare(control.checked, false) - compare(control.pressed, false) - - // right button - mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) - compare(pressedSpy.count, 8) - compare(control.pressed, false) - mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 4) - compare(pressedSpy.count, 8) - compare(control.checked, false) - compare(control.pressed, false) - - control.destroy() - } - - function test_keys() { - var control = toggleButton.createObject(testCase) - verify(control) - - checkedSpy.target = control - clickedSpy.target = control - verify(checkedSpy.valid) - verify(clickedSpy.valid) - - control.forceActiveFocus() - verify(control.activeFocus) - - // check - keyClick(Qt.Key_Space) - compare(clickedSpy.count, 1) - compare(checkedSpy.count, 1) - compare(control.checked, true) - - // uncheck - keyClick(Qt.Key_Space) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 2) - compare(control.checked, false) - - // no change - var keys = [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab] - for (var i = 0; i < keys.length; ++i) { - keyClick(keys[i]) - compare(clickedSpy.count, 2) - compare(checkedSpy.count, 2) - compare(control.checked, false) - } - - control.destroy() - } - - Component { - id: twoToggleButtones - Item { - property ToggleButton tb1: ToggleButton { id: tb1 } - property ToggleButton tb2: ToggleButton { id: tb2; checked: tb1.checked; enabled: false } - } - } - - function test_binding() { - var container = twoToggleButtones.createObject(testCase) - verify(container) - - compare(container.tb1.checked, false) - compare(container.tb2.checked, false) - - container.tb1.checked = true - compare(container.tb1.checked, true) - compare(container.tb2.checked, true) - - container.tb1.checked = false - compare(container.tb1.checked, false) - compare(container.tb2.checked, false) - - container.destroy() - } -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-background.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-background.qml deleted file mode 100644 index 1ae976f0..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-background.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "ToggleButton" - background: Rectangle { - color: "transparent" - border.color: "red" - } -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-checked.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-checked.qml deleted file mode 100644 index bbb60a05..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-checked.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "Checked" - checked: true -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-disabled.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-disabled.qml deleted file mode 100644 index 72bfbb39..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-disabled.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "Disabled" - enabled: false -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-focused.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-focused.qml deleted file mode 100644 index fdcb4d42..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-focused.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "Focused" - focus: true -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-indicator.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-indicator.qml deleted file mode 100644 index 7acbe8e4..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-indicator.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "ToggleButton" - Rectangle { - anchors.fill: indicator - color: "transparent" - border.color: "red" - } -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-label.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-label.qml deleted file mode 100644 index 1af32b9e..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-label.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "ToggleButton" - Rectangle { - anchors.fill: label - color: "transparent" - border.color: "red" - } -} diff --git a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-normal.qml b/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-normal.qml deleted file mode 100644 index fcdfdd7d..00000000 --- a/tests/auto/snippets/data/togglebutton/qtquickcontrols2-togglebutton-normal.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -ToggleButton { - text: "Normal" -} diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index f7432d2e..49400c22 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -221,10 +221,6 @@ void tst_ObjectCount::testCount_data() << QByteArray("import QtQuick.Controls 1.3; TextField { }") << QByteArray("import QtQuick.Controls 2.0; TextField { }"); - QTest::newRow("ToggleButton") - << QByteArray() - << QByteArray("import QtQuick.Controls 2.0; ToggleButton { }"); - QTest::newRow("ToolBar") << QByteArray("import QtQuick.Controls 1.3; ToolBar { }") << QByteArray("import QtQuick.Controls 2.0; ToolBar { }"); diff --git a/tests/manual/fonts/main.qml b/tests/manual/fonts/main.qml index d7c16ab0..978435c0 100644 --- a/tests/manual/fonts/main.qml +++ b/tests/manual/fonts/main.qml @@ -82,7 +82,6 @@ ApplicationWindow { } TextField { placeholder.text: "TextField" } TextArea { placeholder.text: "TextArea" } - ToggleButton { text: "ToggleButton" } ToolButton { text: "ToolButton" } Tumbler { model: 3 } } -- cgit v1.2.3