diff --git a/desktop/dialogs/AddPodcastDialog.qml b/desktop/dialogs/AddPodcastDialog.qml new file mode 100644 index 0000000..88defa1 --- /dev/null +++ b/desktop/dialogs/AddPodcastDialog.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.2 + +import '../common' +import '../common/util.js' as Util + +Dialog { + signal addUrl(string url) + + width: 300 + height: 100 + title: 'Add new podcast' + standardButtons: StandardButton.Open | StandardButton.Cancel + + RowLayout { + anchors.fill: parent + + Label { + text: 'URL:' + } + + TextField { + id: urlEntry + focus: true + + Layout.fillWidth: true + } + } + + onAccepted: { + addUrl(urlEntry.text); + visible = false; + } +} diff --git a/desktop/dialogs/EpisodeDetailsDialog.qml b/desktop/dialogs/EpisodeDetailsDialog.qml new file mode 100644 index 0000000..e8abe77 --- /dev/null +++ b/desktop/dialogs/EpisodeDetailsDialog.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.2 + +import '../common' +import '../common/util.js' as Util + +Rectangle { + property var episode + color: '#aa000000' + + anchors.fill: parent + + MouseArea { + anchors.fill: parent + onClicked: parent.destroy(); + } + + TextArea { + anchors.fill: parent + anchors.margins: 50 + readOnly: true + text: episode ? episode.description : '...' + } +} diff --git a/desktop/gpodder.qml b/desktop/gpodder.qml index 06329eb..f411fee 100644 --- a/desktop/gpodder.qml +++ b/desktop/gpodder.qml @@ -1,11 +1,16 @@ import QtQuick 2.0 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.2 + +import 'dialogs' import 'common' import 'common/util.js' as Util ApplicationWindow { + id: appWindow + width: 500 height: 400 @@ -15,47 +20,102 @@ ApplicationWindow { id: py } + function openDialog(filename, callback) { + var component = Qt.createComponent(filename); + + function createDialog() { + if (component.status === Component.Ready) { + var dialog = component.createObject(appWindow, {}); + dialog.visible = true; + callback(dialog); + } + } + + if (component.status == Component.Ready) { + createDialog(); + } else { + component.statusChanged.connect(createDialog); + } + } + menuBar: MenuBar { - Menu { title: 'File'; MenuItem { text: 'Quit' } } + Menu { + title: 'File' + + MenuItem { + text: 'Add podcast' + onTriggered: { + openDialog('dialogs/AddPodcastDialog.qml', function (dialog) { + dialog.addUrl.connect(function (url) { + py.call('main.subscribe', [url]); + }); + }); + } + } + + MenuItem { + text: 'Quit' + onTriggered: Qt.quit() + } + } } SplitView { anchors.fill: parent TableView { + id: podcastListView + width: 200 model: GPodderPodcastListModel { id: podcastListModel } GPodderPodcastListModelConnections {} headerVisible: false alternatingRowColors: false + Menu { + id: podcastContextMenu + MenuItem { + text: 'Unsubscribe' + onTriggered: { + var podcast_id = podcastListModel.get(podcastListView.currentRow).id; + py.call('main.unsubscribe', [podcast_id]); + } + } + } + rowDelegate: Rectangle { - height: 60 + height: 40 color: styleData.selected ? '#eee' : '#fff' + + MouseArea { + acceptedButtons: Qt.RightButton + anchors.fill: parent + onClicked: podcastContextMenu.popup() + } } TableViewColumn { role: 'coverart' title: 'Image' delegate: Item { - height: 60 - width: 60 + height: 32 + width: 32 Image { source: styleData.value - width: 50 - height: 50 + width: 32 + height: 32 anchors.centerIn: parent } } - width: 60 + width: 40 } TableViewColumn { role: 'title' title: 'Podcast' delegate: Item { - height: 60 + height: 40 Text { text: styleData.value anchors.verticalCenter: parent.verticalCenter @@ -75,6 +135,16 @@ ApplicationWindow { GPodderEpisodeListModelConnections {} TableViewColumn { role: 'title'; title: 'Title' } + + onActivated: { + var episode_id = episodeListModel.get(currentRow).id; + + openDialog('dialogs/EpisodeDetailsDialog.qml', function (dialog) { + py.call('main.show_episode', [episode_id], function (episode) { + dialog.episode = episode; + }); + }); + } } } }