Update stats as proper signal, only return values from backend
This commit is contained in:
parent
0ff355737c
commit
ccd4a4dc17
4 changed files with 26 additions and 13 deletions
|
@ -35,6 +35,7 @@ Python {
|
||||||
signal updatedPodcast(var podcast)
|
signal updatedPodcast(var podcast)
|
||||||
signal episodeListChanged(int podcast_id)
|
signal episodeListChanged(int podcast_id)
|
||||||
signal updatedEpisode(var episode)
|
signal updatedEpisode(var episode)
|
||||||
|
signal updateStats()
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
setHandler('hello', function (coreversion, uiversion) {
|
setHandler('hello', function (coreversion, uiversion) {
|
||||||
|
@ -52,6 +53,7 @@ Python {
|
||||||
setHandler('refreshing', function(v) { py.refreshing = v; });
|
setHandler('refreshing', function(v) { py.refreshing = v; });
|
||||||
setHandler('episode-list-changed', py.episodeListChanged);
|
setHandler('episode-list-changed', py.episodeListChanged);
|
||||||
setHandler('updated-episode', py.updatedEpisode);
|
setHandler('updated-episode', py.updatedEpisode);
|
||||||
|
setHandler('update-stats', py.updateStats);
|
||||||
|
|
||||||
addImportPath(Qt.resolvedUrl('../..'));
|
addImportPath(Qt.resolvedUrl('../..'));
|
||||||
|
|
||||||
|
|
|
@ -69,3 +69,9 @@ function disableUntilReturn(item, py, func, args) {
|
||||||
item.enabled = true;
|
item.enabled = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function format(s, d) {
|
||||||
|
return s.replace(/{([^}]*)}/g, function (m, k) {
|
||||||
|
return (k in d) ? d[k] : m;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
12
main.py
12
main.py
|
@ -96,12 +96,12 @@ class gPotherSide:
|
||||||
downloaded += do
|
downloaded += do
|
||||||
unplayed += un
|
unplayed += un
|
||||||
|
|
||||||
return '\n'.join([
|
return {
|
||||||
'%d podcasts' % len(podcasts),
|
'podcasts': len(podcasts),
|
||||||
'%d episodes' % total,
|
'episodes': total,
|
||||||
'%d new episodes' % new,
|
'newEpisodes': new,
|
||||||
'%d downloads' % downloaded,
|
'downloaded': downloaded,
|
||||||
])
|
}
|
||||||
|
|
||||||
def _get_cover(self, podcast):
|
def _get_cover(self, podcast):
|
||||||
filename = self.core.cover_downloader.get_cover(podcast)
|
filename = self.core.cover_downloader.get_cover(podcast)
|
||||||
|
|
|
@ -22,6 +22,7 @@ import QtQuick 2.0
|
||||||
|
|
||||||
import 'icons/icons.js' as Icons
|
import 'icons/icons.js' as Icons
|
||||||
import 'common/constants.js' as Constants
|
import 'common/constants.js' as Constants
|
||||||
|
import 'common/util.js' as Util
|
||||||
|
|
||||||
SlidePage {
|
SlidePage {
|
||||||
id: startPage
|
id: startPage
|
||||||
|
@ -29,7 +30,12 @@ SlidePage {
|
||||||
|
|
||||||
function update_stats() {
|
function update_stats() {
|
||||||
py.call('main.get_stats', [], function (result) {
|
py.call('main.get_stats', [], function (result) {
|
||||||
stats.text = result;
|
stats.text = Util.format(
|
||||||
|
'{podcasts} podcasts\n' +
|
||||||
|
'{episodes} episodes\n' +
|
||||||
|
'{newEpisodes} new episodes\n' +
|
||||||
|
'{downloaded} downloaded',
|
||||||
|
result);
|
||||||
});
|
});
|
||||||
|
|
||||||
py.call('main.get_fresh_episodes_summary', [3], function (episodes) {
|
py.call('main.get_fresh_episodes_summary', [3], function (episodes) {
|
||||||
|
@ -37,12 +43,11 @@ SlidePage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Item {
|
||||||
py.setHandler('update-stats', startPage.update_stats);
|
Connections {
|
||||||
|
target: py
|
||||||
|
onUpdateStats: startPage.update_stats();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
|
||||||
py.setHandler('update-stats', undefined);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue