Skip to content

Commit

Permalink
Support pull imports from content hub
Browse files Browse the repository at this point in the history
Refs #61.
  • Loading branch information
rschroll committed Apr 10, 2015
1 parent 1e318d2 commit 8cbe44d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
10 changes: 8 additions & 2 deletions ui/BookSources.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 37 additions & 3 deletions ui/Importer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@
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"

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)
}
}

Expand Down Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion ui/LocalBooks.qml
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ Page {
actions: [
Action {
text: i18n.tr("Get Books")
iconName: "search"
iconName: "save"
onTriggered: pageStack.push(bookSources)
},

Expand Down

0 comments on commit 8cbe44d

Please sign in to comment.