Add a busy indicator to the toolbar (pull request 53)

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
Edited-by: Thomas Perl <thp@gpodder.org>
This commit is contained in:
Nelson Ferreira 2012-12-30 17:09:07 -05:00 committed by Thomas Perl
parent d84dfa941b
commit ec929821d7
2 changed files with 36 additions and 3 deletions

View file

@ -42,6 +42,13 @@ PageStackWindow {
visible: mainObject.canGoBack
}
BusyIndicator {
id: updatingBusy
anchors.left: parent.left
visible: !toolBack.visible && controller.busy
running: visible
}
ToolIcon {
id: toolFlattr
iconSource: 'artwork/flattr.png'
@ -62,7 +69,6 @@ PageStackWindow {
controller.updateFlattrButtonText(mainObject.showNotesEpisode);
}
}
Label {
id: labelFlattr
color: 'white'

View file

@ -137,6 +137,8 @@ class Controller(QObject):
self.root.config.add_observer(self.on_config_changed)
self._flattr = self.root.core.flattr
self.flattr_button_text = u''
self._busy = False
self.updating_podcasts = 0
def on_config_changed(self, name, old_value, new_value):
logger.info('Config changed: %s (%s -> %s)', name,
@ -150,6 +152,18 @@ class Controller(QObject):
elif name == 'mygpo.device.caption':
self.myGpoDeviceCaptionChanged.emit()
busyChanged = Signal()
def getBusy(self):
return self._busy
def setBusy(self, busy):
if self._busy != busy:
self._busy = busy
self.busyChanged.emit()
busy = Property(bool, getBusy, setBusy, notify=busyChanged)
episodeListTitleChanged = Signal()
def setEpisodeListTitle(self, title):
@ -462,6 +476,12 @@ class Controller(QObject):
self.context_menu_actions = actions
self.root.open_context_menu(self.context_menu_actions)
def finished_update(self):
if self.updating_podcasts > 0:
self.updating_podcasts -= 1
self.setBusy(self.updating_podcasts > 0)
self.update_subset_stats()
def update_subset_stats(self):
# This should be called when an episode changes state,
# so that all subset views (e.g. "All episodes") can
@ -481,8 +501,11 @@ class Controller(QObject):
@Slot()
def updateAllPodcasts(self):
if not self.request_connection():
self.setBusy(False)
return
self.setBusy(True)
# Process episode actions received from gpodder.net
def merge_proc(self):
self.root.start_progress(_('Merging episode actions...'))
@ -503,8 +526,12 @@ class Controller(QObject):
util.run_in_background(lambda: merge_proc(self))
for podcast in self.root.podcast_model.get_objects():
if not podcast.pause_subscription:
podcast.qupdate(finished_callback=self.update_subset_stats)
if not podcast.pause_subscription and not podcast.qupdating:
if podcast.qtitle != 'All episodes':
self.updating_podcasts += 1
podcast.qupdate(finished_callback=self.finished_update)
self.setBusy(self.updating_podcasts > 0)
def request_connection(self):
"""Request an internet connection