desktop: Add/remove podcasts
This commit is contained in:
parent
cfed87916b
commit
f3fb2585dc
3 changed files with 140 additions and 8 deletions
36
desktop/dialogs/AddPodcastDialog.qml
Normal file
36
desktop/dialogs/AddPodcastDialog.qml
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
26
desktop/dialogs/EpisodeDetailsDialog.qml
Normal file
26
desktop/dialogs/EpisodeDetailsDialog.qml
Normal file
|
@ -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 : '...'
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue