QML UI: Indicator for adding podcasts

This commit is contained in:
Thomas Perl 2011-10-30 12:25:02 +01:00
parent 70daba073f
commit 5fd3925c78
2 changed files with 62 additions and 10 deletions

View file

@ -57,6 +57,15 @@ Image {
contextMenu.items = items
}
function startProgress(text) {
progressIndicator.text = text
progressIndicator.opacity = 1
}
function endProgress() {
progressIndicator.opacity = 0
}
states: [
State {
name: 'podcasts'
@ -159,10 +168,10 @@ Image {
Item {
id: overlayInteractionBlockWall
anchors.fill: parent
anchors.topMargin: (nowPlayingThrobber.opened || messageDialog.opacity > 0 || inputDialog.opacity > 0)?0:Config.headerHeight
anchors.topMargin: (nowPlayingThrobber.opened || messageDialog.opacity > 0 || inputDialog.opacity > 0 || progressIndicator.opacity > 0)?0:titleBar.height
z: (contextMenu.state != 'opened')?2:0
opacity: (nowPlayingThrobber.opened || contextMenu.state == 'opened' || messageDialog.opacity || inputDialog.opacity)?1:0
opacity: (nowPlayingThrobber.opened || contextMenu.state == 'opened' || messageDialog.opacity || inputDialog.opacity || progressIndicator.opacity)?1:0
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
MouseArea {
@ -170,6 +179,8 @@ Image {
onClicked: {
if (contextMenu.state == 'opened') {
// do nothing
} else if (progressIndicator.opacity) {
// do nothing
} else if (inputDialog.opacity) {
inputDialog.close()
} else if (messageDialog.opacity) {
@ -488,5 +499,23 @@ Image {
}
}
}
Column {
id: progressIndicator
property string text: '...'
anchors.centerIn: parent
opacity: 0
spacing: Config.largeSpacing * 2
z: 40
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Text {
text: parent.text
color: 'white'
font.pixelSize: 30 * Config.scale
anchors.horizontalCenter: parent.horizontalCenter
}
}
}

View file

@ -291,14 +291,16 @@ class Controller(QObject):
return
def subscribe_proc(self, url):
# TODO: Show progress indicator
podcast = self.root.model.load_podcast(url=url, \
create=True, \
max_episodes=self.root.config.max_episodes_per_feed, \
mimetype_prefs=self.root.config.mimetype_prefs)
podcast.save()
self.root.insert_podcast(model.QPodcast(podcast))
# TODO: Present the podcast to the user
self.root.start_progress(_('Adding podcast...'))
try:
podcast = self.root.model.load_podcast(url=url, \
create=True, \
max_episodes=self.root.config.max_episodes_per_feed, \
mimetype_prefs=self.root.config.mimetype_prefs)
podcast.save()
self.root.insert_podcast(model.QPodcast(podcast))
finally:
self.root.end_progress()
t = threading.Thread(target=subscribe_proc, args=[self, url])
t.start()
@ -472,6 +474,9 @@ class qtPodder(QObject):
else:
self.view.show()
self.do_start_progress.connect(self.on_start_progress)
self.do_end_progress.connect(self.on_end_progress)
self.load_podcasts()
def add_active_episode(self, episode):
@ -520,6 +525,24 @@ class qtPodder(QObject):
def open_context_menu(self, items):
self.main.openContextMenu(items)
do_start_progress = Signal(str)
@Slot(str)
def on_start_progress(self, text):
self.main.startProgress(text)
def start_progress(self, text=_('Please wait...')):
self.do_start_progress.emit(text)
do_end_progress = Signal()
@Slot()
def on_end_progress(self):
self.main.endProgress()
def end_progress(self):
self.do_end_progress.emit()
def resort_podcast_list(self):
self.podcast_model.sort()