From 8cbe44d78488783f5d1eb650c0ca886ced02bc1a Mon Sep 17 00:00:00 2001 From: Robert Schroll Date: Fri, 10 Apr 2015 17:24:21 -0400 Subject: [PATCH] Support pull imports from content hub Refs #61. --- ui/BookSources.qml | 10 ++++++++-- ui/Importer.qml | 40 +++++++++++++++++++++++++++++++++++++--- ui/LocalBooks.qml | 2 +- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ui/BookSources.qml b/ui/BookSources.qml index f39b48a..54dba3d 100644 --- a/ui/BookSources.qml +++ b/ui/BookSources.qml @@ -18,16 +18,22 @@ Page { model: sourcesModel delegate: Standard { - text: model.name + text: (model.url == "contenthub") ? i18n.tr("Import from Content Hub") : model.name progression: true onClicked: { - browserLoader.loadURL(model.url, model.murl, model.name, model.showAddressBar) + if (model.url == "contenthub") + pageStack.push(importer.pickerPage) + else + browserLoader.loadURL(model.url, model.murl, model.name, model.showAddressBar) } } } ListModel { id: sourcesModel + ListElement { + url: "contenthub" + } ListElement { name: "Project Gutenberg" url: "http://www.gutenberg.org" diff --git a/ui/Importer.qml b/ui/Importer.qml index 37ba417..4b88a35 100644 --- a/ui/Importer.qml +++ b/ui/Importer.qml @@ -7,7 +7,7 @@ import QtQuick 2.0 import Ubuntu.Components 1.1 import Ubuntu.Components.Popups 1.0 -import Ubuntu.Content 0.1 +import Ubuntu.Content 1.1 import "components" @@ -15,12 +15,23 @@ Item { id: importer property bool importError: false property bool openImport: true + property var activeTransfer + property var pickerPage: picker Connections { target: ContentHub onImportRequested: { - if (transfer.state === ContentTransfer.Charged) - importItems(transfer.items) + activeTransfer = transfer + if (activeTransfer.state === ContentTransfer.Charged) + importItems(activeTransfer.items) + } + } + + Connections { + target: activeTransfer + onStateChanged: { + if (activeTransfer.state === ContentTransfer.Charged) + importItems(activeTransfer.items) } } @@ -88,4 +99,27 @@ Item { } } } + + Page { + id: picker + visible: false + ContentPeerPicker { + handler: ContentHandler.Source + contentType: ContentType.Documents + headerText: i18n.tr("Import books from") + + onPeerSelected: { + peer.selectionType = ContentTransfer.Multiple + activeTransfer = peer.request() + pageStack.pop() + } + + onCancelPressed: pageStack.pop() + } + } + + ContentTransferHint { + anchors.fill: mainView + activeTransfer: importer.activeTransfer + } } diff --git a/ui/LocalBooks.qml b/ui/LocalBooks.qml index 042276c..2faa768 100644 --- a/ui/LocalBooks.qml +++ b/ui/LocalBooks.qml @@ -638,7 +638,7 @@ Page { actions: [ Action { text: i18n.tr("Get Books") - iconName: "search" + iconName: "save" onTriggered: pageStack.push(bookSources) },