From 308fd2a032f25b321665c3b62d3cb86cd22a97e1 Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Fri, 22 Dec 2023 02:47:24 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkdeclarative Synchronize source files from linuxdeepin/dtkdeclarative. Source-pull-request: https://github.com/linuxdeepin/dtkdeclarative/pull/259 --- misc/DtkDeclarativeConfig.cmake.in | 2 +- qt6/src/qml/TextField.qml | 55 ++++++++++++++++++++++++++++++ src/qml/TextField.qml | 55 ++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/misc/DtkDeclarativeConfig.cmake.in b/misc/DtkDeclarativeConfig.cmake.in index e8aea894..d6b330fb 100644 --- a/misc/DtkDeclarativeConfig.cmake.in +++ b/misc/DtkDeclarativeConfig.cmake.in @@ -7,8 +7,8 @@ find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS Quick REQUIRED ) -include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativePropertiesTargets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativeTargets.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/Dtk@DTK_VERSION_MAJOR@DeclarativePropertiesTargets.cmake) set(DTK_QML_APP_PLUGIN_PATH @DTK_QML_APP_PLUGIN_PATH@) get_target_property(DtkDeclarative_INCLUDE_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_INCLUDE_DIRECTORIES) get_target_property(DtkDeclarative_LIBRARY_DIRS Dtk@DTK_VERSION_MAJOR@::Declarative INTERFACE_LINK_DIRECTORIES) diff --git a/qt6/src/qml/TextField.qml b/qt6/src/qml/TextField.qml index b0789328..a438f5f6 100644 --- a/qt6/src/qml/TextField.qml +++ b/qt6/src/qml/TextField.qml @@ -54,4 +54,59 @@ T.TextField { implicitWidth: DS.Style.edit.width implicitHeight: DS.Style.edit.textFieldHeight } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + + onClicked: { + contextMenu.popup(mouse.x, mouse.y) + } + } + + Menu { + id: contextMenu + + MenuItem + { + text: qsTr("Copy") + onTriggered: control.copy() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Cut") + onTriggered: control.cut() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Paste") + onTriggered: control.paste() + } + + MenuItem + { + text: qsTr("Select All") + onTriggered: control.selectAll() + enabled: control.text.length + } + + MenuItem + { + text: qsTr("Undo") + onTriggered: control.undo() + enabled: control.canUndo + } + + MenuItem + { + text: qsTr("Redo") + onTriggered: control.redo() + enabled: control.canRedo + } + } + } diff --git a/src/qml/TextField.qml b/src/qml/TextField.qml index 08ce9970..3f12f06b 100644 --- a/src/qml/TextField.qml +++ b/src/qml/TextField.qml @@ -53,4 +53,59 @@ T.TextField { implicitWidth: DS.Style.edit.width implicitHeight: DS.Style.edit.textFieldHeight } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton + + onClicked: { + contextMenu.popup(mouse.x, mouse.y) + } + } + + Menu { + id: contextMenu + + MenuItem + { + text: qsTr("Copy") + onTriggered: control.copy() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Cut") + onTriggered: control.cut() + enabled: control.selectedText.length + } + + MenuItem + { + text: qsTr("Paste") + onTriggered: control.paste() + } + + MenuItem + { + text: qsTr("Select All") + onTriggered: control.selectAll() + enabled: control.text.length + } + + MenuItem + { + text: qsTr("Undo") + onTriggered: control.undo() + enabled: control.canUndo + } + + MenuItem + { + text: qsTr("Redo") + onTriggered: control.redo() + enabled: control.canRedo + } + } + }