Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkdeclarative
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#259
  • Loading branch information
deepin-ci-robot committed Dec 21, 2023
1 parent df6517a commit a115dac
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
2 changes: 1 addition & 1 deletion misc/DtkDeclarativeConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ find_package(Qt@QT_VERSION_MAJOR@ COMPONENTS
Quick
REQUIRED
)
include(${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected])
include(${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected])
include(${CMAKE_CURRENT_LIST_DIR}/Dtk@[email protected])
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)
Expand Down
59 changes: 59 additions & 0 deletions qt6/src/qml/TextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,63 @@ 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: "Copy"
onTriggered: control.copy()
enabled: control.selectedText.length
}

MenuItem
{
text: "Cut"
onTriggered: control.cut()
enabled: control.selectedText.length
}

MenuItem
{
text: "Paste"
onTriggered:
{
var text = control.paste()
control.insert(control.cursorPosition, text)
}
}

MenuItem
{
text: "Select All"
onTriggered: control.selectAll()
enabled: control.text.length
}

MenuItem
{
text: "Undo"
onTriggered: control.undo()
enabled: control.canUndo
}

MenuItem
{
text: "Redo"
onTriggered: control.redo()
enabled: control.canRedo
}
}

}
59 changes: 59 additions & 0 deletions src/qml/TextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,63 @@ 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: "Copy"
onTriggered: control.copy()
enabled: control.selectedText.length
}

MenuItem
{
text: "Cut"
onTriggered: control.cut()
enabled: control.selectedText.length
}

MenuItem
{
text: "Paste"
onTriggered:
{
var text = control.paste()
control.insert(control.cursorPosition, text)
}
}

MenuItem
{
text: "Select All"
onTriggered: control.selectAll()
enabled: control.text.length
}

MenuItem
{
text: "Undo"
onTriggered: control.undo()
enabled: control.canUndo
}

MenuItem
{
text: "Redo"
onTriggered: control.redo()
enabled: control.canRedo
}
}

}

0 comments on commit a115dac

Please sign in to comment.