Skip to content

Commit

Permalink
added loading indicator to podcastlist, added loading indicator to ep…
Browse files Browse the repository at this point in the history
…isode list, added refresh option to episode list, persisting filter for episodelist to config, using persisted filter
  • Loading branch information
Thilo Kogge committed Sep 19, 2020
1 parent 9243a0f commit bd9317d
Show file tree
Hide file tree
Showing 35 changed files with 1,259 additions and 140 deletions.
1 change: 0 additions & 1 deletion gpodder-ui-qml
Submodule gpodder-ui-qml deleted from ed036a
45 changes: 45 additions & 0 deletions gpodder-ui-qml/common/GPodderAutoFire.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2015, Thomas Perl <[email protected]>
*
* 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

Timer {
property int triggerCount: 0
property int initialInterval: 1500
property int autoFireInterval: 200

signal fired()

interval: triggerCount > 1 ? autoFireInterval : initialInterval

repeat: true
triggeredOnStart: true

onRunningChanged: {
if (!running) {
triggerCount = 0
}
}

onTriggered: {
triggerCount += 1
fired()
}
}
97 changes: 97 additions & 0 deletions gpodder-ui-qml/common/GPodderCore.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* 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 io.thp.pyotherside 1.3


Python {
id: py

property string progname: 'gpodder'
property bool ready: false
property bool refreshing: false

property string coreversion
property string uiversion
property string parserversion

signal downloadProgress(int episode_id, real progress)
signal playbackProgress(int episode_id, real progress)
signal podcastListChanged()
signal updatingPodcast(int podcast_id)
signal updatedPodcast(var podcast)
signal episodeListChanged(int podcast_id)
signal updatedEpisode(var episode)
signal updateStats()
signal configChanged(string key, var value)

Component.onCompleted: {
setHandler('hello', function (coreversion, uiversion, parserversion) {
py.coreversion = coreversion;
py.uiversion = uiversion;
py.parserversion = parserversion;

console.log('gPodder Core ' + py.coreversion);
console.log('gPodder QML UI ' + py.uiversion);
console.log('Podcastparser ' + py.parserversion);
console.log('PyOtherSide ' + py.pluginVersion());
console.log('Python ' + py.pythonVersion());
});

setHandler('download-progress', py.downloadProgress);
setHandler('playback-progress', py.playbackProgress);
setHandler('podcast-list-changed', py.podcastListChanged);
setHandler('updating-podcast', py.updatingPodcast);
setHandler('updated-podcast', py.updatedPodcast);
setHandler('refreshing', function(v) { py.refreshing = v; });
setHandler('episode-list-changed', py.episodeListChanged);
setHandler('updated-episode', py.updatedEpisode);
setHandler('update-stats', py.updateStats);
setHandler('config-changed', py.configChanged);

addImportPath(Qt.resolvedUrl('../..'));

// Load the Python side of things
importModule('main', function() {
py.call('main.initialize', [py.progname], function() {
py.ready = true;
});
});
}

function setConfig(key, value) {
py.call('main.set_config_value', [key, value]);
}

function getConfig(key, callback) {
py.call('main.get_config_value', [key], function (result) {
callback(result);
});
}

onReceived: {
console.log('unhandled message: ' + data);
}

onError: {
console.log('Python failure: ' + traceback);
}
}
40 changes: 40 additions & 0 deletions gpodder-ui-qml/common/GPodderDirectorySearchModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* 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

ListModel {
id: directorySearchModel
property string provider

function search(query, callback) {
clear();

py.call('main.get_directory_entries', [directorySearchModel.provider, query], function (result) {
for (var i=0; i<result.length; i++) {
directorySearchModel.append(result[i]);
}

if (callback !== undefined) {
callback();
}
});
}
}
139 changes: 139 additions & 0 deletions gpodder-ui-qml/common/GPodderEpisodeListModel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, 2014, Thomas Perl <[email protected]>
*
* 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 'util.js' as Util
import 'constants.js' as Constants

ListModel {
id: episodeListModel

property var podcast_id: -1

property var cached: false

property var queries: ({
All: '',
Fresh: 'new or downloading',
Downloaded: 'downloaded or downloading',
UnplayedDownloads: 'downloaded and not played',
FinishedDownloads: 'downloaded and finished',
HideDeleted: 'not deleted',
Deleted: 'deleted',
ShortDownloads: 'downloaded and min > 0 and min < 10',
})

property var filters: ([
{ label: qsTr("All"), query: episodeListModel.queries.All },
{ label: qsTr("Fresh"), query: episodeListModel.queries.Fresh },
{ label: qsTr("Downloaded"), query: episodeListModel.queries.Downloaded },
{ label: qsTr("Unplayed downloads"), query: episodeListModel.queries.UnplayedDownloads },
{ label: qsTr("Finished downloads"), query: episodeListModel.queries.FinishedDownloads },
{ label: qsTr("Hide deleted"), query: episodeListModel.queries.HideDeleted },
{ label: qsTr("Deleted episodes"), query: episodeListModel.queries.Deleted },
{ label: qsTr("Short downloads (< 10 min)"), query: episodeListModel.queries.ShortDownloads },
])

property bool ready: false
property int currentFilterIndex: 0
property string currentCustomQuery: queries.All

Component.onCompleted: {
// Request filter, then load episodes
py.call('main.get_config_value', ['ui.qml.episode_list.filter_eql'], function (result) {
console.debug("got query from storage: '",result,"'")
setQueryFromUpdate(result);
reload();
});
}

function forEachEpisode(callback) {
// Go from bottom up (= chronological order)
for (var i=count-1; i>=0; i--) {
callback(get(i));
}
}

function setQueryFromIndex(index) {
setQueryEx(filters[index].query,true);
}

function setQueryFromUpdate(query) {
setQueryEx(query, false);
}

function setQuery(query) {
setQueryEx(query, true);
}

function setQueryEx(query, update) {
console.info("changing query from '",currentCustomQuery,"' to '",query,"',")
if(query === currentCustomQuery){
return;
}
for (var i=0; i<filters.length; i++) {
if (filters[i].query === query) {
currentCustomQuery = query;
if (update) {
updateConfig();
}
currentFilterIndex = i;
reload();
return;
}
}
console.error("could not find query: ",query);
}

function updateConfig(){
console.info("saving selected filter: '",currentCustomQuery,"'.")
py.call('main.set_config_value', ['ui.qml.episode_list.filter_eql', currentCustomQuery]);
}

function loadAllEpisodes(callback) {
episodeListModel.podcast_id = -1;
reload(callback);
}

function loadEpisodes(podcast_id, callback) {
episodeListModel.podcast_id = podcast_id;
reload(callback);
}

function reload(callback) {
var query;
if (currentFilterIndex !== -1) {
query = filters[currentFilterIndex].query;
} else {
query = currentCustomQuery;
}
console.info("reloading with query: '",query,"'.")

ready = false;
py.call('main.load_episodes', [podcast_id, query], function (episodes) {
Util.updateModelFrom(episodeListModel, episodes);
episodeListModel.ready = true;
if (callback !== undefined) {
callback();
}
});
}
}
56 changes: 56 additions & 0 deletions gpodder-ui-qml/common/GPodderEpisodeListModelConnections.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2014, Thomas Perl <[email protected]>
*
* 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 'util.js' as Util

Connections {
target: py

onDownloadProgress: {
Util.updateModelWith(episodeListModel, 'id', episode_id,
{'progress': progress});
}
onPlaybackProgress: {
Util.updateModelWith(episodeListModel, 'id', episode_id,
{'playbackProgress': progress});
}
onUpdatedEpisode: {
for (var i=0; i<episodeListModel.count; i++) {
if (episodeListModel.get(i).id == episode.id) {
episodeListModel.set(i, episode);
break;
}
}
}
onEpisodeListChanged: {
if (episodeListModel.podcast_id == podcast_id) {
episodeListModel.reload();
}
}

onConfigChanged: {
if (key === 'ui.qml.episode_list.filter_eql') {
episodeListModel.setQueryFromUpdate(value);
episodeListModel.reload();
}
}
}
Loading

0 comments on commit bd9317d

Please sign in to comment.