diff --git a/qml/components/CommonHeader.qml b/qml/components/CommonHeader.qml index 979d995..3e26f48 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 @@ -16,49 +18,59 @@ PageHeader { trailingActionBar { numberOfSlots: 3 actions: [ - + Action { - iconName: "info" - shortcut: "Ctrl+i" - text: i18n.tr("Information") + iconName: "save" + shortcut: "Ctrl+s" + text: i18n.tr("Save") onTriggered: { - pageStack.push(Qt.resolvedUrl("../InfoPage.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"})) } }, - + Action { - iconName: "settings" - shortcut: "Ctrl+e" - text: i18n.tr("Settings") + iconName: "add" + shortcut: "Ctrl+a" + text: i18n.tr("Add") onTriggered: { Qt.inputMethod.hide(); - pageStack.push(Qt.resolvedUrl("../SettingsPage.qml")); + pageStack.push(Qt.resolvedUrl("../ImportPage.qml"),{"contentType": ContentType.Pictures, "handler": ContentHandler.Source}) } }, + + Action { + iconName: "delete" + shortcut: "Ctrl+d" + text: i18n.tr("New Session") + onTriggered: { + deleteAllImage() + } + }, + Action { - iconName: "add" - shortcut: "Ctrl+a" - text: i18n.tr("Add") + iconName: "settings" + shortcut: "Ctrl+e" + text: i18n.tr("Settings") onTriggered: { Qt.inputMethod.hide(); - pageStack.push(Qt.resolvedUrl("../ImportPage.qml"),{"contentType": ContentType.Pictures, "handler": ContentHandler.Source}) + 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 new file mode 100644 index 0000000..3a7cb34 --- /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("New Session") + + Label { + text: i18n.tr("Are you sure you want to delete all images?") + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + } + + Button { + id: okButton + objectName: "deleteButton" + text: i18n.tr("Delete") + 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 a25d30e..b337972 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, @@ -27,6 +26,20 @@ Page { ) } + Component { + id: deleteAllDialog + + DeleteAllImgDialog {} + } + + Connections { + target: mainHeader + + onDeleteAllImage: { + PopupUtils.open(deleteAllDialog) + } + } + Connections { target: ImageProcessing onImageAdded: imageAdded (id) @@ -34,7 +47,6 @@ Page { ListModel { id: imageModel - //ListElement {imgout: "/home/phablet/.cache/camerascanner.jonius/jd-da-02.jpg"} } Component { @@ -153,76 +165,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