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', label: 'Add new podcast',
callback: function () { 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 { delegate: PodcastItem {
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title}); 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 * 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 * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * 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 import 'common/constants.js' as Constants
Dialog { Dialog {
id: subscribe id: textInputDialog
property string buttonText
property string placeholderText
property string text
property var callback
contentHeight: contentColumn.height contentHeight: contentColumn.height
function accepted() { function accept() {
loading.visible = true; textInputDialog.callback(input.text);
button.visible = false; textInputDialog.closePage();
input.visible = false;
py.call('main.subscribe', [input.text], function () {
subscribe.closePage();
});
} }
Column { Column {
@ -44,9 +45,10 @@ Dialog {
PTextField { PTextField {
id: input id: input
width: subscribe.width *.8 width: textInputDialog.width *.8
placeholderText: 'Feed URL' placeholderText: textInputDialog.placeholderText
onAccepted: subscribe.accepted(); text: textInputDialog.text
onAccepted: textInputDialog.accept();
} }
ButtonArea { ButtonArea {
@ -56,16 +58,10 @@ Dialog {
PLabel { PLabel {
anchors.centerIn: parent anchors.centerIn: parent
text: 'Subscribe' text: textInputDialog.buttonText
} }
onClicked: subscribe.accepted(); onClicked: textInputDialog.accept();
}
PBusyIndicator {
id: loading
visible: false
anchors.horizontalCenter: parent.horizontalCenter
} }
} }
} }