Use new directory provider support
This commit is contained in:
parent
54178ae4b9
commit
75f555f16f
9 changed files with 125 additions and 63 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 3f75aaf9ceda24dfede262a218168d28a163cba1
|
||||
Subproject commit dc92d3c1154ded37e76d7e57024950a5c23e5088
|
|
@ -1 +1 @@
|
|||
Subproject commit 77bac09899d07aa51579759dc42499e485edf424
|
||||
Subproject commit 4680751494b5fcbc2fd29f179d6b09751a27801d
|
|
@ -1 +1 @@
|
|||
Subproject commit 378327cc793223326cb87bb8f8f1a9819225fa95
|
||||
Subproject commit f98acd22b14bc8459f7f695cf5fd6fad50324b8f
|
|
@ -26,9 +26,18 @@ import 'common'
|
|||
Page {
|
||||
id: directory
|
||||
|
||||
property string provider
|
||||
property string query: '-'
|
||||
property var callback
|
||||
|
||||
function start(query, callback) {
|
||||
Component.onCompleted: {
|
||||
if (directory.query !== '-') {
|
||||
directory.start(directory.provider, directory.query, directory.callback);
|
||||
}
|
||||
}
|
||||
|
||||
function start(provider, query, callback) {
|
||||
directory.provider = provider;
|
||||
directory.callback = callback;
|
||||
directorySearchModel.search(query, function() {
|
||||
busyIndicator.visible = false;
|
||||
|
@ -39,12 +48,12 @@ Page {
|
|||
anchors.fill: parent
|
||||
|
||||
header: PageHeader {
|
||||
title: 'Search results'
|
||||
title: directory.provider
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
|
||||
model: GPodderDirectorySearchModel { id: directorySearchModel }
|
||||
model: GPodderDirectorySearchModel { id: directorySearchModel; provider: directory.provider }
|
||||
|
||||
delegate: DirectoryItem {
|
||||
onClicked: {
|
||||
|
|
|
@ -23,23 +23,24 @@ import Sailfish.Silica 1.0
|
|||
|
||||
Dialog {
|
||||
id: directory
|
||||
|
||||
property string provider
|
||||
property var callback
|
||||
|
||||
canAccept: input.text != ''
|
||||
|
||||
acceptDestination: Component { Directory { } }
|
||||
acceptDestinationAction: PageStackAction.Replace
|
||||
|
||||
onAccepted: {
|
||||
var ctx = { py: py };
|
||||
acceptDestinationInstance.start(input.text, function (url) {
|
||||
ctx.py.call('main.subscribe', [url]);
|
||||
});
|
||||
acceptDestinationInstance.start(directory.provider, input.text, directory.callback);
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
|
||||
DialogHeader {
|
||||
title: 'Search gpodder.net'
|
||||
title: directory.provider
|
||||
acceptText: 'Search'
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ ListItem {
|
|||
|
||||
Image {
|
||||
id: cover
|
||||
opacity: scaled_logo_url && status == Image.Ready
|
||||
opacity: image && status == Image.Ready
|
||||
Behavior on opacity { FadeAnimation { } }
|
||||
|
||||
anchors {
|
||||
|
@ -49,7 +49,7 @@ ListItem {
|
|||
width: Theme.iconSizeMedium
|
||||
height: Theme.iconSizeMedium
|
||||
|
||||
source: scaled_logo_url
|
||||
source: image
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
@ -73,12 +73,24 @@ ListItem {
|
|||
anchors {
|
||||
left: cover.right
|
||||
leftMargin: Theme.paddingSmall
|
||||
rightMargin: Theme.paddingSmall
|
||||
right: parent.right
|
||||
rightMargin: subs.text ? Theme.paddingSmall : 0
|
||||
right: subs.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
truncationMode: TruncationMode.Fade
|
||||
text: title
|
||||
}
|
||||
|
||||
Label {
|
||||
id: subs
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: Theme.paddingSmall
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
text: (subscribers > 0) ? subscribers : ''
|
||||
}
|
||||
}
|
||||
|
|
86
qml/DirectorySelectionDialog.qml
Normal file
86
qml/DirectorySelectionDialog.qml
Normal file
|
@ -0,0 +1,86 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* gPodder QML UI Reference Implementation
|
||||
* Copyright (c) 2014, Thomas Perl <m@thp.io>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Page {
|
||||
id: directorySelectionDialog
|
||||
|
||||
property var model
|
||||
property int selectedIndex: -1
|
||||
|
||||
Component.onCompleted: {
|
||||
py.call('main.get_directory_providers', [], function (result) {
|
||||
directorySelectionDialog.model = result;
|
||||
});
|
||||
}
|
||||
|
||||
SilicaListView {
|
||||
anchors.fill: parent
|
||||
|
||||
header: PageHeader {
|
||||
title: 'Select provider'
|
||||
}
|
||||
|
||||
model: directorySelectionDialog.model
|
||||
|
||||
delegate: ListItem {
|
||||
id: listItem
|
||||
|
||||
highlighted: down || (index == directorySelectionDialog.selectedIndex)
|
||||
|
||||
onClicked: {
|
||||
directorySelectionDialog.selectedIndex = index;
|
||||
var callback = (function (py) {
|
||||
return (function (url) {
|
||||
py.call('main.subscribe', [url]);
|
||||
});
|
||||
})(py);
|
||||
|
||||
if (!modelData.can_search) {
|
||||
pgst.loadPage('Directory.qml', {
|
||||
provider: modelData.label,
|
||||
query: '',
|
||||
callback: callback,
|
||||
}, true);
|
||||
} else {
|
||||
pgst.loadPage('DirectoryDialog.qml', {
|
||||
provider: modelData.label,
|
||||
callback: callback,
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors {
|
||||
left: parent.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
margins: Theme.paddingMedium
|
||||
}
|
||||
|
||||
color: listItem.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
text: modelData.label
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
/**
|
||||
*
|
||||
* gPodder QML UI Reference Implementation
|
||||
* Copyright (c) 2014, Thomas Perl <m@thp.io>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
id: episodeQueryControl
|
||||
|
||||
property var model
|
||||
property string title
|
||||
|
||||
function showSelectionDialog() {
|
||||
pgst.loadPage('SelectionDialog.qml', {
|
||||
title: episodeQueryControl.title,
|
||||
callback: function (index, result) {
|
||||
episodeQueryControl.model.currentFilterIndex = index;
|
||||
episodeQueryControl.model.reload();
|
||||
},
|
||||
items: function () {
|
||||
var labels = [];
|
||||
for (var i in episodeQueryControl.model.filters) {
|
||||
labels.push(episodeQueryControl.model.filters[i].label);
|
||||
}
|
||||
return labels;
|
||||
}(),
|
||||
selectedIndex: episodeQueryControl.model.currentFilterIndex,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -60,8 +60,8 @@ Page {
|
|||
}
|
||||
|
||||
MenuItem {
|
||||
text: 'Search gpodder.net'
|
||||
onClicked: pgst.loadPage('DirectoryDialog.qml');
|
||||
text: 'Discover new podcasts'
|
||||
onClicked: pgst.loadPage('DirectorySelectionDialog.qml');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue