From 76a68f71a4c25297dd65266e1ad5f2da4d80bac1 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sat, 27 Oct 2018 10:21:40 +0300 Subject: Support for copy-pasting specific fields on mobile Initial implementation/prototype of copy-paste support for Subsurface-mobile. The UI part is really lacking; right now the copy button is initially visible and paste is achieved by long press on a dive and clicking the paste button when it appears. Delete is currently not possible at all, as I just failed to layout the buttons properly using QML. It just sounds so simple, to put all the copy-paste-delete buttons next to each other... The data to be copied is currently hard-coded. A dialog to choose inteded fields would be nice, but it'll take quite a bit effort to get used to QML enough to be able to hack something together. Anyway, this seems to work, even though the UI is not always reflecting the paste without switching dives (when testing on laptop). Signed-off-by: Miika Turkia --- mobile-widgets/qml/DiveList.qml | 81 ++++++++++++++++++++++++++++++++- mobile-widgets/qml/mobile-resources.qrc | 2 + 2 files changed, 82 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 6ffeee020..41b56601c 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -118,9 +118,13 @@ Kirigami.ScrollablePage { } property bool deleteButtonVisible: false + property bool copyButtonVisible: true // TODO: false + property bool pasteButtonVisible: false onPressAndHold: { - deleteButtonVisible = true + deleteButtonVisible = false // TODO: true + copyButtonVisible = false // TODO: true + pasteButtonVisible = true timer.restart() } Item { @@ -195,6 +199,77 @@ Kirigami.ScrollablePage { } } Rectangle { + id: copyButton + visible: copyButtonVisible + height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing + width: height - 3 * Kirigami.Units.smallSpacing + color: subsurfaceTheme.lightDrawerColor + antialiasing: true + radius: Kirigami.Units.smallSpacing + anchors { + left: diveListEntry.right + right: parent.right + verticalCenter: diveListEntry.verticalCenter + verticalCenterOffset: Kirigami.Units.smallSpacing / 2 + } + Kirigami.Icon { + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + source: ":/icons/edit-copy" + width: parent.height + height: width + } + MouseArea { + anchors.fill: parent + enabled: parent.visible + onClicked: { + deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false + timer.stop() + manager.copyDiveData(dive.id) + } + } + } + Rectangle { + id: pasteButton + visible: pasteButtonVisible + height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing + width: height - 3 * Kirigami.Units.smallSpacing + color: subsurfaceTheme.contrastAccentColor + antialiasing: true + radius: Kirigami.Units.smallSpacing + anchors { + left: diveListEntry.right + right: parent.right + verticalCenter: diveListEntry.verticalCenter + verticalCenterOffset: Kirigami.Units.smallSpacing / 2 + } + Kirigami.Icon { + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + source: ":/icons/edit-paste" + width: parent.height + height: width + } + MouseArea { + anchors.fill: parent + enabled: parent.visible + onClicked: { + deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false + timer.stop() + manager.pasteDiveData(dive.id) + } + } + } + Rectangle { + id: deleteButton visible: deleteButtonVisible height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing width: height - 3 * Kirigami.Units.smallSpacing @@ -221,6 +296,8 @@ Kirigami.ScrollablePage { enabled: parent.visible onClicked: { deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false timer.stop() manager.deleteDive(dive.id) } @@ -231,6 +308,8 @@ Kirigami.ScrollablePage { interval: 4000 onTriggered: { deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false } } } diff --git a/mobile-widgets/qml/mobile-resources.qrc b/mobile-widgets/qml/mobile-resources.qrc index a40f74b8d..beb1d93f0 100644 --- a/mobile-widgets/qml/mobile-resources.qrc +++ b/mobile-widgets/qml/mobile-resources.qrc @@ -75,6 +75,8 @@ kirigami/icons/list-add.svg kirigami/icons/overflow-menu.svg kirigami/icons/trash-empty.svg + kirigami/icons/edit-copy.svg + kirigami/icons/edit-paste.svg kirigami/icons/view-readermode.svg -- cgit v1.2.3-70-g09d2