diff --git a/touch/Confirmation.qml b/touch/Confirmation.qml new file mode 100644 index 0000000..dab6798 --- /dev/null +++ b/touch/Confirmation.qml @@ -0,0 +1,87 @@ + +/** + * + * gPodder QML UI Reference Implementation + * Copyright (c) 2013, Thomas Perl + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +import QtQuick 2.0 + +import 'common/constants.js' as Constants +import 'icons/icons.js' as Icons + +SlidePage { + id: confirmation + + property alias title: header.title + property alias icon: icon.icon + property alias color: header.color + property var callback: undefined + + SlidePageHeader { + id: header + color: Constants.colors.destructive + title: 'Confirmation' + } + + PIcon { + id: icon + size: 300 + anchors.centerIn: parent + color: header.color + + MouseArea { + anchors.fill: parent + onClicked: { + if (confirmation.callback !== undefined) { + confirmation.callback(); + confirmation.closePage(); + } + } + } + } + + PLabel { + anchors { + horizontalCenter: parent.horizontalCenter + top: icon.bottom + margins: 30 * pgst.scalef + } + + text: 'Tap to confirm' + color: header.color + } + + Row { + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + margins: 60 * pgst.scalef + } + + spacing: 30 * pgst.scalef + + PLabel { + text: 'Swipe right to cancel' + color: Constants.colors.text + } + + PIcon { + color: Constants.colors.text + icon: Icons.arrow_right + } + } +} diff --git a/touch/EpisodeItem.qml b/touch/EpisodeItem.qml index a2326cf..3932a86 100644 --- a/touch/EpisodeItem.qml +++ b/touch/EpisodeItem.qml @@ -75,7 +75,12 @@ Item { color: (episodeItem.isPlaying || progress > 0) ? titleLabel.color : Constants.colors.destructive icon: Icons.trash visible: downloadState != Constants.state.deleted - onClicked: py.call('main.delete_episode', [id]); + onClicked: { + var ctx = { py: py, id: id }; + pgst.showConfirmation('Delete episode', Icons.trash, function () { + ctx.py.call('main.delete_episode', [ctx.id]); + }); + } } IconMenuItem { diff --git a/touch/EpisodesPage.qml b/touch/EpisodesPage.qml index 87fa6a0..7fc004f 100644 --- a/touch/EpisodesPage.qml +++ b/touch/EpisodesPage.qml @@ -54,8 +54,13 @@ SlidePage { icon: Icons.trash color: Constants.colors.destructive onClicked: { - py.call('main.unsubscribe', [episodesPage.podcast_id]); - episodesPage.closePage(); + episodesPage.unPull(); + + var ctx = { py: py, id: episodesPage.podcast_id, page: episodesPage }; + pgst.showConfirmation('Unsubscribe', Icons.trash, function () { + ctx.py.call('main.unsubscribe', [ctx.id]); + ctx.page.closePage(); + }); } } } diff --git a/touch/Main.qml b/touch/Main.qml index 56dc7f5..3d75ff0 100644 --- a/touch/Main.qml +++ b/touch/Main.qml @@ -48,6 +48,14 @@ Item { property bool loadPageInProgress: false + function showConfirmation(title, icon, callback) { + loadPage('Confirmation.qml', { + title: title, + icon: icon, + callback: callback, + }); + } + function loadPage(filename, properties) { if (pgst.loadPageInProgress) { console.log('ignoring loadPage request while load in progress');