Skip to content
This repository has been archived by the owner on Aug 7, 2019. It is now read-only.

Add option to remove all images. Remove some out commented code. #31

Open
wants to merge 3 commits into
base: config
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions qml/components/CommonHeader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Ubuntu.Components.Popups 1.3

PageHeader {
title: i18n.tr('Camera Scanner')

signal deleteAllImage()

StyleHints {
foregroundColor: fgColor
Expand All @@ -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"));
}
}
]
Expand Down
41 changes: 41 additions & 0 deletions qml/components/DeleteAllImgDialog.qml
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
75 changes: 15 additions & 60 deletions qml/components/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Page {
}

function imageAdded ( id ) {
//console.log("imageAdded() mit " + id +" aufgerufen")
imageModel.append (
{
imageID: id,
Expand All @@ -27,14 +26,27 @@ Page {
)
}

Component {
id: deleteAllDialog

DeleteAllImgDialog {}
}

Connections {
target: mainHeader

onDeleteAllImage: {
PopupUtils.open(deleteAllDialog)
}
}

Connections {
target: ImageProcessing
onImageAdded: imageAdded (id)
}

ListModel {
id: imageModel
//ListElement {imgout: "/home/phablet/.cache/camerascanner.jonius/jd-da-02.jpg"}
}

Component {
Expand Down Expand Up @@ -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
Expand Down