diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-02-28 20:05:55 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-07-09 12:51:34 +0200 |
commit | c4bb545458bcf62218eea7940f342c1a96a19f01 (patch) | |
tree | d823f32bc804f4df1a3a396a33568fc7a5fb9a4a /tests/manual | |
parent | 9c02a390c4c3dc94339499ce67557f59de4049f5 (diff) |
Test all 4 field types in the text manual test
- TextInput, TextField, TextEdit and TextArea: side-by-side comparison
- check whether mouse selection is already enabled, and allow changing
- check various other properties and signals
- stop using the shared examples code so we no longer need resources
- make CMakeLists.txt work for a standalone build on multiple platforms
Task-number: QTBUG-101205
Change-Id: I3dc7a91c9d129d185e976d02b010cb298e0ad737
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/text/CMakeLists.txt | 60 | ||||
-rw-r--r-- | tests/manual/text/Rule.qml | 20 | ||||
-rw-r--r-- | tests/manual/text/main.cpp | 10 | ||||
-rw-r--r-- | tests/manual/text/main.qml | 19 | ||||
-rw-r--r-- | tests/manual/text/textInputPropertiesAndSignals.qml | 395 |
5 files changed, 415 insertions, 89 deletions
diff --git a/tests/manual/text/CMakeLists.txt b/tests/manual/text/CMakeLists.txt index bfa596e4d9..afb2277a25 100644 --- a/tests/manual/text/CMakeLists.txt +++ b/tests/manual/text/CMakeLists.txt @@ -1,59 +1,35 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -# Generated from text.pro. +cmake_minimum_required(VERSION 3.16) +project(text_manual_test LANGUAGES CXX) -##################################################################### -## text Binary: -##################################################################### +set(CMAKE_INCLUDE_CURRENT_DIR ON) -qt_internal_add_manual_test(text - GUI - SOURCES - main.cpp - PUBLIC_LIBRARIES +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt6 COMPONENTS Core Gui Quick QuickControls2) + +qt_add_executable(text_manual_test + main.cpp +) +target_link_libraries(text_manual_test PUBLIC Qt::Gui - Qt::Qml Qt::Quick + Qt::QuickControls2 ) -# Resources: -set(qml_resource_files +set(qmake_immediate_resource_files + "Rule.qml" "SignalIndicator.qml" - "main.qml" "textInputPropertiesAndSignals.qml" ) -qt_internal_add_resource(text "qml" +qt6_add_resources(text_manual_test "qml" PREFIX "/" FILES - ${qml_resource_files} + ${qmake_immediate_resource_files} ) - -set(quick_shared_resource_files - "../../../examples/quick/shared/Button.qml" - "../../../examples/quick/shared/CheckBox.qml" - "../../../examples/quick/shared/Label.qml" - "../../../examples/quick/shared/LauncherList.qml" - "../../../examples/quick/shared/SimpleLauncherDelegate.qml" - "../../../examples/quick/shared/Slider.qml" - "../../../examples/quick/shared/TextField.qml" - "../../../examples/quick/shared/images/back.png" - "../../../examples/quick/shared/images/checkmark.png" - "../../../examples/quick/shared/images/next.png" - "../../../examples/quick/shared/images/slider_handle.png" -) - -qt_internal_add_resource(text "quick_shared" - PREFIX - "/quick/shared" - BASE - "../../../examples/quick/shared" - FILES - ${quick_shared_resource_files} -) - - -#### Keys ignored in scope 1:.:.:text.pro:<TRUE>: -# TEMPLATE = "app" diff --git a/tests/manual/text/Rule.qml b/tests/manual/text/Rule.qml new file mode 100644 index 0000000000..322f9f7cef --- /dev/null +++ b/tests/manual/text/Rule.qml @@ -0,0 +1,20 @@ +import QtQuick + +Text { + id: root + horizontalAlignment: Text.AlignHCenter + Rectangle { + id: leftRule + width: (root.width - root.contentWidth) / 2 - 5 + height: 4 + y: root.height / 2 + color: "steelblue" + } + Rectangle { + width: leftRule.width + height: 4 + x: root.width - width + y: root.height / 2 + color: "steelblue" + } +} diff --git a/tests/manual/text/main.cpp b/tests/manual/text/main.cpp index 1c79ce0ea9..bf8eea7618 100644 --- a/tests/manual/text/main.cpp +++ b/tests/manual/text/main.cpp @@ -1,14 +1,14 @@ // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QGuiApplication> -#include <QQmlApplicationEngine> +#include <QtQuick/QQuickView> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///textInputPropertiesAndSignals.qml")); + view.show(); return app.exec(); } diff --git a/tests/manual/text/main.qml b/tests/manual/text/main.qml deleted file mode 100644 index 80b7ec969d..0000000000 --- a/tests/manual/text/main.qml +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick 2.9 -import QtQuick.Window 2.2 -import "qrc:/quick/shared/" as Examples - -Window { - width: 800 - height: 600 - visible: true - Examples.LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("TextInput", "TextInput properties and signals", Qt.resolvedUrl("textInputPropertiesAndSignals.qml")) - } - } -} diff --git a/tests/manual/text/textInputPropertiesAndSignals.qml b/tests/manual/text/textInputPropertiesAndSignals.qml index d4a7392ebd..ec1664f311 100644 --- a/tests/manual/text/textInputPropertiesAndSignals.qml +++ b/tests/manual/text/textInputPropertiesAndSignals.qml @@ -1,25 +1,29 @@ // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -import QtQuick 2.9 -import QtQuick.Layouts 1.1 -import "qrc:/quick/shared/" as Shared +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Item { - width: 600; height: 600 + width: 600; height: 840 + GridLayout { columns: 3; rowSpacing: 6; columnSpacing: 6 anchors { left: parent.left; right: parent.right; top: parent.top; margins: 12 } - // ---------------------------------------------------- - Text { - text: "try typing and input methods in the TextInput below:" + // ==================================================== + Rule { Layout.columnSpan: 3 + Layout.fillWidth: true + text: "TextInput" } // ---------------------------------------------------- - Text { - text: "TextInput" + CheckBox { + id: textInputMouseSelCB + text: "mouse select" + onCheckedChanged: textInput.selectByMouse = checked } Rectangle { @@ -31,17 +35,18 @@ Item { TextInput { id: textInput anchors.fill: parent; anchors.margins: 4 + Component.onCompleted: textInputMouseSelCB.checked = selectByMouse - onTextEdited: textEditedInd.blip() - onTextChanged: textChangedInd.blip() - onPreeditTextChanged: preeditInd.blip() - onDisplayTextChanged: displayTextInd.blip() + onTextEdited: textInputTextEditedInd.blip() + onTextChanged: textInputTextChangedInd.blip() + onPreeditTextChanged: textInputPreeditInd.blip() + onDisplayTextChanged: textInputDisplayTextInd.blip() + onSelectedTextChanged: textInputSelectedTextChangedInd.blip() } - } SignalIndicator { - id: textEditedInd + id: textInputTextEditedInd label: "textEdited" } @@ -51,7 +56,7 @@ Item { Text { text: textInput.text; Layout.fillWidth: true } SignalIndicator { - id: textChangedInd + id: textInputTextChangedInd label: "textChanged" } @@ -61,7 +66,7 @@ Item { Text { text: textInput.preeditText; Layout.fillWidth: true } SignalIndicator { - id: preeditInd + id: textInputPreeditInd label: "preeditTextChanged" } @@ -71,27 +76,371 @@ Item { Text { text: textInput.displayText; Layout.fillWidth: true } SignalIndicator { - id: displayTextInd + id: textInputDisplayTextInd label: "displayTextChanged" } // ---------------------------------------------------- - Shared.TextField { + Text { text: "selectedText" } + + Text { text: textInput.selectedText; Layout.fillWidth: true } + + SignalIndicator { + id: textInputSelectedTextChangedInd + label: "selectedTextChanged" + } + + // ==================================================== + Rule { + Layout.columnSpan: 3 + Layout.fillWidth: true + text: "TextField" + } + + // ---------------------------------------------------- + CheckBox { + id: textFieldMouseSelCB + text: "mouse select" + onCheckedChanged: textField.selectByMouse = checked + } + + TextField { + id: textField + Layout.fillWidth: true + Component.onCompleted: textFieldMouseSelCB.checked = selectByMouse + + onTextEdited: textFieldEditedInd.blip() + onTextChanged: textFieldChangedInd.blip() + onPreeditTextChanged: textFieldPreeditInd.blip() + onDisplayTextChanged: textFieldDisplayTextInd.blip() + onSelectedTextChanged: textFieldSelectedTextChangedInd.blip() + } + + SignalIndicator { + id: textFieldEditedInd + label: "textEdited" + } + + // ---------------------------------------------------- + Text { text: "text" } + + Text { text: textField.text; Layout.fillWidth: true } + + SignalIndicator { + id: textFieldChangedInd + label: "textChanged" + } + + // ---------------------------------------------------- + Text { text: "preeditText" } + + Text { text: textField.preeditText; Layout.fillWidth: true } + + SignalIndicator { + id: textFieldPreeditInd + label: "preeditTextChanged" + } + + // ---------------------------------------------------- + Text { text: "displayText" } + + Text { text: textField.displayText; Layout.fillWidth: true } + + SignalIndicator { + id: textFieldDisplayTextInd + label: "displayTextChanged" + } + + // ---------------------------------------------------- + Text { text: "selectedText" } + + Text { text: textField.selectedText; Layout.fillWidth: true } + + SignalIndicator { + id: textFieldSelectedTextChangedInd + label: "selectedTextChanged" + } + + // ==================================================== + Rule { + Layout.columnSpan: 3 + Layout.fillWidth: true + text: "tools" + } + + // ---------------------------------------------------- + TextField { id: copyFrom Layout.column: 1 - Layout.row: 5 + Layout.row: 13 Layout.fillWidth: true text: "copy this" } - Shared.Button { - Layout.column: 2 - Layout.row: 5 + Button { text: "setText" + Layout.column: 2 + Layout.row: 13 onClicked: { Qt.inputMethod.reset() textInput.text = copyFrom.text + textField.text = copyFrom.text + textEdit.text = copyFrom.text + textArea.text = copyFrom.text + } + } + + // ==================================================== + Rule { + Layout.columnSpan: 3 + Layout.fillWidth: true + text: "TextEdit in Flickable" + } + + // ---------------------------------------------------- + ColumnLayout { + CheckBox { + id: textEditReadOnly + text: "read-only" } + CheckBox { + id: textEditMouseSelCB + text: "mouse select" + onCheckedChanged: textEdit.selectByMouse = checked + } + CheckBox { + id: textEditPressDelayCB + text: "press delay: " + flick.pressDelay + } + } + + Rectangle { + Layout.fillWidth: true + implicitHeight: 100 + radius: 4; antialiasing: true + border.color: "black"; color: "transparent" + + Flickable { + id: flick + anchors.fill: parent; anchors.margins: 4 + contentHeight: textEdit.paintedHeight + clip: true + pressDelay: textEditPressDelayCB.checked ? 500 : 0 + + function ensureVisible(r) + { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + ScrollBar.vertical: ScrollBar { } + + TextEdit { + id: textEdit + textFormat: TextArea.AutoText + width: flick.width - 10 + wrapMode: TextEdit.Wrap + readOnly: textEditReadOnly.checked + Component.onCompleted: textEditMouseSelCB.checked = selectByMouse + + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + onEditingFinished: textEditEditedInd.blip() + onTextChanged: textEditChangedInd.blip() + onPreeditTextChanged: preeditEditInd.blip() + onSelectedTextChanged: selectedTextChangedInd.blip() + onHoveredLinkChanged: hoveredLinkChangedInd.blip() + onLinkActivated: (text) => { + linkActivatedInd.blip() + linkActivatedText.text = text + } + } + } + } + + SignalIndicator { + id: textEditEditedInd + label: "editingFinished" + } + + // ---------------------------------------------------- + Text { text: "text" } + + Text { + text: textEdit.text + Layout.fillWidth: true + Layout.maximumHeight: textEditChangedInd.implicitHeight * 1.5 + clip: true + } + + SignalIndicator { + id: textEditChangedInd + label: "textChanged" + } + + // ---------------------------------------------------- + Text { text: "preeditText" } + + Text { text: textEdit.preeditText; Layout.fillWidth: true } + + SignalIndicator { + id: preeditEditInd + label: "preeditTextChanged" + } + + // ---------------------------------------------------- + Text { text: "selectedText" } + + Text { + text: textEdit.selectedText + Layout.fillWidth: true + Layout.maximumHeight: selectedTextChangedInd.implicitHeight * 1.5 + clip: true + } + + SignalIndicator { + id: selectedTextChangedInd + label: "selectedTextChanged" + } + + // ---------------------------------------------------- + Text { text: "hoveredLink" } + + Text { text: textEdit.hoveredLink; Layout.fillWidth: true } + + SignalIndicator { + id: hoveredLinkChangedInd + label: "hoveredLinkChanged" + } + + // ---------------------------------------------------- + Text { text: "linkActivated" } + + Text { id: linkActivatedText; Layout.fillWidth: true } + + SignalIndicator { + id: linkActivatedInd + label: "linkActivated" + } + + // ==================================================== + Rule { + Layout.columnSpan: 3 + Layout.fillWidth: true + text: "TextArea in ScrollView" + } + + // ---------------------------------------------------- + ColumnLayout { + CheckBox { + id: textAreaReadOnly + text: "read-only" + } + CheckBox { + id: textAreaMouseSelCB + text: "mouse select" + onCheckedChanged: textArea.selectByMouse = checked + } + } + + Rectangle { + Layout.fillWidth: true + implicitHeight: 100 + radius: 4; antialiasing: true + border.color: "black"; color: "transparent" + + ScrollView { + id: view + anchors.fill: parent; anchors.margins: 4 + // pressDelay is not directly possible: QTBUG-104794 + + TextArea { + id: textArea + textFormat: TextArea.AutoText + readOnly: textAreaReadOnly.checked + Component.onCompleted: textAreaMouseSelCB.checked = selectByMouse + + onEditingFinished: textAreaEditedInd.blip() + onTextChanged: textAreaChangedInd.blip() + onPreeditTextChanged: preeditAreaInd.blip() + onSelectedTextChanged: selectedTextChangedAreaInd.blip() + onHoveredLinkChanged: hoveredLinkChangedAreaInd.blip() + onLinkActivated: (text) => { + linkActivatedAreaInd.blip() + linkActivatedAreaText.text = text + } + } + } + } + + SignalIndicator { + id: textAreaEditedInd + label: "editingFinished" + } + + // ---------------------------------------------------- + Text { text: "text" } + + Text { + text: textArea.text + Layout.fillWidth: true + Layout.maximumHeight: textAreaChangedInd.implicitHeight * 1.5 + clip: true + } + + SignalIndicator { + id: textAreaChangedInd + label: "textChanged" + } + + // ---------------------------------------------------- + Text { text: "preeditText" } + + Text { text: textArea.preeditText; Layout.fillWidth: true } + + SignalIndicator { + id: preeditAreaInd + label: "preeditTextChanged" + } + + // ---------------------------------------------------- + Text { text: "selectedText" } + + Text { + text: textArea.selectedText + Layout.fillWidth: true + Layout.maximumHeight: selectedTextChangedAreaInd.implicitHeight * 1.5 + clip: true + } + + SignalIndicator { + id: selectedTextChangedAreaInd + label: "selectedTextChanged" + } + + // ---------------------------------------------------- + Text { text: "hoveredLink" } + + Text { text: textArea.hoveredLink; Layout.fillWidth: true } + + SignalIndicator { + id: hoveredLinkChangedAreaInd + label: "hoveredLinkChanged" + } + + // ---------------------------------------------------- + Text { text: "linkActivated" } + + Text { id: linkActivatedAreaText; Layout.fillWidth: true } + + SignalIndicator { + id: linkActivatedAreaInd + label: "linkActivated" } } } |