From 14ab4e7ef2b5ef022cfeae1d22c31e6fd2a30a30 Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 6 Aug 2019 11:33:19 +0200 Subject: [PATCH 1/3] Add option to remove all images. Remove some out commented code. --- qml/components/CommonHeader.qml | 15 ++++++-- qml/components/MainPage.qml | 61 +-------------------------------- 2 files changed, 14 insertions(+), 62 deletions(-) diff --git a/qml/components/CommonHeader.qml b/qml/components/CommonHeader.qml index 979d995..2e2d500 100644 --- a/qml/components/CommonHeader.qml +++ b/qml/components/CommonHeader.qml @@ -14,7 +14,7 @@ PageHeader { } trailingActionBar { - numberOfSlots: 3 + numberOfSlots: 4 actions: [ Action { @@ -37,7 +37,7 @@ PageHeader { pageStack.push(Qt.resolvedUrl("../SettingsPage.qml")); } }, - + Action { iconName: "add" shortcut: "Ctrl+a" @@ -48,6 +48,17 @@ PageHeader { pageStack.push(Qt.resolvedUrl("../ImportPage.qml"),{"contentType": ContentType.Pictures, "handler": ContentHandler.Source}) } }, + + Action { + iconName: "delete" + shortcut: "Ctrl+d" + text: i18n.tr("Delete all") + + onTriggered: { + ImageProcessing.removeAll() + mainPage.imageModel.clear(); + } + }, Action { iconName: "save" diff --git a/qml/components/MainPage.qml b/qml/components/MainPage.qml index a25d30e..af01e8a 100644 --- a/qml/components/MainPage.qml +++ b/qml/components/MainPage.qml @@ -18,7 +18,6 @@ Page { } function imageAdded ( id ) { - //console.log("imageAdded() mit " + id +" aufgerufen") imageModel.append ( { imageID: id, @@ -34,7 +33,6 @@ Page { ListModel { id: imageModel - //ListElement {imgout: "/home/phablet/.cache/camerascanner.jonius/jd-da-02.jpg"} } Component { @@ -153,76 +151,19 @@ Page { overlay.border.width = 10 mouse.accepted = false delegateRoot.drag.target = icon - deleteIcon.visible = true } onReleased: { - /* - if (deleteIcon.visible == true) - { - ImageProcessing.removeImage ( model.imageID ) - imageModel.remove( index ) - - overlay.border.width = 0 - delegateRoot.drag.target = undefined - deleteIcon.visible = false - } - else - { - var url = ImageProcessing.exportAsPdf( model.imageID ) - console.log("Share:",url) - var sharePopup = PopupUtils.open(shareDialog, mainPage, {"contentType" : ContentType.Documents}) - sharePopup.items.push(contentItemComponent.createObject(mainPage, {"url" : url, "text": model.imageID})) - } - */ pageStack.push(Qt.resolvedUrl("../single-image/SingleImage.qml"), {"currentImage": Qt.resolvedUrl(model.imgout), "currentID": model.imageID, "currentIndex": index}) } } } - Item { - id: topPanel - - anchors { - left: parent.left - right: parent.right - top: mainHeader.bottom - topMargin: units.gu(2) - } - - height: units.gu(5) - - DropArea { - id: deleteDragTarget - anchors.fill: parent - - Icon { - id: deleteIcon - name: "delete" - visible: false - color: UbuntuColors.red - anchors.horizontalCenter: parent.horizontalCenter - height: parent.height - } - - states: [ - State { - when: deleteDragTarget.containsDrag - - PropertyChanges { - target: deleteIcon - color: UbuntuColors.coolGrey - } - } - ] - } - } - GridView { id: gridview anchors { - top: topPanel.bottom + top: mainHeader.bottom left: parent.left right: parent.right bottom: parent.bottom From f5240f7e7c5fdd95245a40ab3e3106fbd173f99b Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 6 Aug 2019 15:00:05 +0200 Subject: [PATCH 2/3] add dialog befor delete all images --- qml/components/CommonHeader.qml | 5 ++-- qml/components/DeleteAllImgDialog.qml | 41 +++++++++++++++++++++++++++ qml/components/MainPage.qml | 14 +++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 qml/components/DeleteAllImgDialog.qml diff --git a/qml/components/CommonHeader.qml b/qml/components/CommonHeader.qml index 2e2d500..fa516f1 100644 --- a/qml/components/CommonHeader.qml +++ b/qml/components/CommonHeader.qml @@ -6,6 +6,8 @@ import Ubuntu.Components.Popups 1.3 PageHeader { title: i18n.tr('Camera Scanner') + + signal deleteAllImage() StyleHints { foregroundColor: fgColor @@ -55,8 +57,7 @@ PageHeader { text: i18n.tr("Delete all") onTriggered: { - ImageProcessing.removeAll() - mainPage.imageModel.clear(); + deleteAllImage() } }, diff --git a/qml/components/DeleteAllImgDialog.qml b/qml/components/DeleteAllImgDialog.qml new file mode 100644 index 0000000..4f4e9f6 --- /dev/null +++ b/qml/components/DeleteAllImgDialog.qml @@ -0,0 +1,41 @@ +import QtQuick 2.4 +import Ubuntu.Components 1.3 +import Ubuntu.Components.Popups 1.3 +import ImageProcessing 1.0 + +Dialog { + id: root + + title: i18n.tr("Delete all") + + Label { + text: i18n.tr("Are you sure you want to delete all images?") + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + } + + Button { + id: okButton + objectName: "okButton" + text: i18n.tr("OK") + color: UbuntuColors.red + + onClicked: { + ImageProcessing.removeAll() + mainPage.imageModel.clear(); + PopupUtils.close(root) + } + } + + Button { + id: cancelButton + objectName: "cancelButton" + text: i18n.tr("Cancel") + + color: UbuntuColors.graphite + + onClicked: { + PopupUtils.close(root) + } + } +} diff --git a/qml/components/MainPage.qml b/qml/components/MainPage.qml index af01e8a..b337972 100644 --- a/qml/components/MainPage.qml +++ b/qml/components/MainPage.qml @@ -26,6 +26,20 @@ Page { ) } + Component { + id: deleteAllDialog + + DeleteAllImgDialog {} + } + + Connections { + target: mainHeader + + onDeleteAllImage: { + PopupUtils.open(deleteAllDialog) + } + } + Connections { target: ImageProcessing onImageAdded: imageAdded (id) From 98a4b0eb86a4ae95a948d649fdfa2af91879b669 Mon Sep 17 00:00:00 2001 From: Stefan Weng Date: Tue, 6 Aug 2019 21:51:17 +0200 Subject: [PATCH 3/3] new sorting of the elements in the CommonHeader.qml trailingActionBar --- qml/components/CommonHeader.qml | 50 +++++++++++++-------------- qml/components/DeleteAllImgDialog.qml | 6 ++-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/qml/components/CommonHeader.qml b/qml/components/CommonHeader.qml index fa516f1..3e26f48 100644 --- a/qml/components/CommonHeader.qml +++ b/qml/components/CommonHeader.qml @@ -16,27 +16,19 @@ PageHeader { } trailingActionBar { - numberOfSlots: 4 + numberOfSlots: 3 actions: [ - - Action { - iconName: "info" - shortcut: "Ctrl+i" - text: i18n.tr("Information") - - onTriggered: { - pageStack.push(Qt.resolvedUrl("../InfoPage.qml")); - } - }, - + Action { - iconName: "settings" - shortcut: "Ctrl+e" - text: i18n.tr("Settings") + iconName: "save" + shortcut: "Ctrl+s" + text: i18n.tr("Save") onTriggered: { - Qt.inputMethod.hide(); - pageStack.push(Qt.resolvedUrl("../SettingsPage.qml")); + var url = ImageProcessing.exportAllAsPdf() + console.log("Share:",url) + var sharePopup = PopupUtils.open(shareDialog, mainPage, {"contentType" : ContentType.Documents}) + sharePopup.items.push(contentItemComponent.createObject(mainPage, {"url" : url, "text": "export"})) } }, @@ -54,23 +46,31 @@ PageHeader { Action { iconName: "delete" shortcut: "Ctrl+d" - text: i18n.tr("Delete all") + text: i18n.tr("New Session") onTriggered: { deleteAllImage() } }, + + Action { + iconName: "settings" + shortcut: "Ctrl+e" + text: i18n.tr("Settings") + + onTriggered: { + Qt.inputMethod.hide(); + pageStack.push(Qt.resolvedUrl("../SettingsPage.qml")); + } + }, Action { - iconName: "save" - shortcut: "Ctrl+s" - text: i18n.tr("Save") + iconName: "info" + shortcut: "Ctrl+i" + text: i18n.tr("Information") onTriggered: { - var url = ImageProcessing.exportAllAsPdf() - console.log("Share:",url) - var sharePopup = PopupUtils.open(shareDialog, mainPage, {"contentType" : ContentType.Documents}) - sharePopup.items.push(contentItemComponent.createObject(mainPage, {"url" : url, "text": "export"})) + pageStack.push(Qt.resolvedUrl("../InfoPage.qml")); } } ] diff --git a/qml/components/DeleteAllImgDialog.qml b/qml/components/DeleteAllImgDialog.qml index 4f4e9f6..3a7cb34 100644 --- a/qml/components/DeleteAllImgDialog.qml +++ b/qml/components/DeleteAllImgDialog.qml @@ -6,7 +6,7 @@ import ImageProcessing 1.0 Dialog { id: root - title: i18n.tr("Delete all") + title: i18n.tr("New Session") Label { text: i18n.tr("Are you sure you want to delete all images?") @@ -16,8 +16,8 @@ Dialog { Button { id: okButton - objectName: "okButton" - text: i18n.tr("OK") + objectName: "deleteButton" + text: i18n.tr("Delete") color: UbuntuColors.red onClicked: {