Podcast list context menu, TextInputDialog

This commit is contained in:
Thomas Perl 2014-03-17 17:58:26 +01:00
parent 7bdf6b783a
commit 0a6531d77b
2 changed files with 64 additions and 21 deletions

View file

@ -54,7 +54,14 @@ SlidePage {
{
label: 'Add new podcast',
callback: function () {
pgst.loadPage('Subscribe.qml');
var ctx = { py: py };
pgst.loadPage('TextInputDialog.qml', {
buttonText: 'Subscribe',
placeholderText: 'Feed URL',
callback: function (url) {
ctx.py.call('main.subscribe', [url]);
}
});
},
},
{
@ -82,6 +89,46 @@ SlidePage {
delegate: PodcastItem {
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title});
onPressAndHold: {
pgst.showSelection([
{
label: 'Unsubscribe',
callback: function () {
var ctx = { py: py, id: id };
pgst.showConfirmation('Unsubscribe', Icons.trash, function () {
ctx.py.call('main.unsubscribe', [ctx.id]);
});
} },
{
label: 'Rename',
callback: function () {
var ctx = { py: py, id: id };
pgst.loadPage('TextInputDialog.qml', {
buttonText: 'Rename',
placeholderText: 'New name',
text: title,
callback: function (new_title) {
ctx.py.call('main.rename_podcast', [ctx.id, new_title]);
}
});
}
},
{
label: 'Change section',
callback: function () {
var ctx = { py: py, id: id };
pgst.loadPage('TextInputDialog.qml', {
buttonText: 'Change section',
placeholderText: 'New section',
text: section,
callback: function (new_section) {
ctx.py.call('main.change_section', [ctx.id, new_section]);
}
});
}
},
], title);
}
}
}
}

View file

@ -2,7 +2,7 @@
/**
*
* gPodder QML UI Reference Implementation
* Copyright (c) 2013, Thomas Perl <m@thp.io>
* 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
@ -23,17 +23,18 @@ import QtQuick 2.0
import 'common/constants.js' as Constants
Dialog {
id: subscribe
id: textInputDialog
property string buttonText
property string placeholderText
property string text
property var callback
contentHeight: contentColumn.height
function accepted() {
loading.visible = true;
button.visible = false;
input.visible = false;
py.call('main.subscribe', [input.text], function () {
subscribe.closePage();
});
function accept() {
textInputDialog.callback(input.text);
textInputDialog.closePage();
}
Column {
@ -44,9 +45,10 @@ Dialog {
PTextField {
id: input
width: subscribe.width *.8
placeholderText: 'Feed URL'
onAccepted: subscribe.accepted();
width: textInputDialog.width *.8
placeholderText: textInputDialog.placeholderText
text: textInputDialog.text
onAccepted: textInputDialog.accept();
}
ButtonArea {
@ -56,16 +58,10 @@ Dialog {
PLabel {
anchors.centerIn: parent
text: 'Subscribe'
text: textInputDialog.buttonText
}
onClicked: subscribe.accepted();
}
PBusyIndicator {
id: loading
visible: false
anchors.horizontalCenter: parent.horizontalCenter
onClicked: textInputDialog.accept();
}
}
}