git.iko.soy/maciek134/podphoenix
on main help sign in
Do not turn off display during getting new episodes and add settings to adjust interval of autorefreshing podcasts
commit6c894539f78e3adafeebaf3523a42c2a8a9eee6f authorDaniel Kutka <dano.kutka@gmail.com> dateTue 12 Jan 2021, 22:16 (6 years ago) parentb4b2180
6 files changed+55−7
Podbird.apparmor+2−1 app/podbird.qml+11−1 app/ui/EpisodesPage.qml−2 app/ui/EpisodesTab.qml−1 app/ui/PodcastsTab.qml−2 app/ui/SettingsPage.qml+42
Podbird.apparmor+2−1
@@ -4,7 +4,8 @@
44 "audio",
55 "connectivity",
66 "usermetrics",
7− "content_exchange"
7+ "content_exchange",
8+ "keep-display-on"
89 ],
910 "policy_version": 16.04
1011}
app/podbird.qml+11−1
@@ -24,6 +24,7 @@ import Qt.labs.settings 1.0
2424import Ubuntu.Components 1.3
2525import QtQuick.LocalStorage 2.0
2626import Ubuntu.DownloadManager 1.2
27+import QtSystemInfo 5.5
2728import "ui"
2829import "themes" as Themes
2930import "podcasts.js" as Podcasts
@@ -42,6 +43,12 @@ MainView {
4243 theme.name: settings.themeName == "Dark.qml" ? "Ubuntu.Components.Themes.SuruDark"
4344 : "Ubuntu.Components.Themes.Ambiance"
4445
46+ property bool episodesUpdating: false;
47+
48+ ScreenSaver {
49+ id: screenSaver
50+ screenSaverEnabled: !episodesUpdating
51+ }
4552
4653 // RefreshModel function to call refreshModel() function of the tab currently
4754 // visible on application start.
@@ -51,6 +58,7 @@ MainView {
5158 } else if (tabs.selectedTab === podcastTab) {
5259 podcastPage.item.refreshModel()
5360 }
61+ episodesUpdating = false;
5462 }
5563
5664 Component.onCompleted: {
@@ -58,7 +66,8 @@ MainView {
5866
5967 var today = new Date()
6068 // Only automatically check for podcasts on launch once every 12 hours
61− if (Math.floor((today - settings.lastUpdate)/86400000) >= 0.5) {
69+ if (Math.floor((today - settings.lastUpdate)/86400000) >= settings.refreshEpisodes/24.0) {
70+ episodesUpdating = true;
6271 Podcasts.updateEpisodes(refreshModels)
6372 }
6473 loadingIndicator.opacity = 0
@@ -116,6 +125,7 @@ MainView {
116125 property bool showListView: true
117126 property int skipForward: 30
118127 property int skipBack: 10
128+ property int refreshEpisodes: 12
119129 property bool continueWhereStopped: true
120130 property int playlistIndex: -1
121131 property bool downloadOverWifiOnly: true
app/ui/EpisodesPage.qml−2
@@ -37,8 +37,6 @@ Page {
3737 property string tempGuid: "NULL"
3838 property string mode: "listened"
3939
40− property bool episodesUpdating: false;
41−
4240 Component.onCompleted: {
4341 loadEpisodes(episodeId, episodeArtist, episodeImage)
4442 if (downloader.downloadingGuid != "")
app/ui/EpisodesTab.qml−1
@@ -31,7 +31,6 @@ Tab {
3131 property var today: new Date()
3232 property int dayToMs: 86400000
3333 property string tempGuid: "NULL"
34− property bool episodesUpdating: false
3534
3635 TabsList {
3736 id: tabsList
app/ui/PodcastsTab.qml−2
@@ -28,8 +28,6 @@ import "../components"
2828Page {
2929 id: podcastPage
3030
31− property bool episodesUpdating: false;
32−
3331 TabsList {
3432 id: tabsList
3533 }
app/ui/SettingsPage.qml+42
@@ -126,6 +126,41 @@ Page {
126126 }
127127 }
128128
129+ Component {
130+ id: refreshDialog
131+ Dialog {
132+ id: dialogInternal
133+ // TRANSLATORS: This strings refers to refreshing podcasts. Users can set how often they
134+ // want to check for new episodes.
135+ title: i18n.tr("Refresh podcasts after")
136+ Slider {
137+ id: slider
138+ width: parent.width
139+ minimumValue: 0
140+ maximumValue: 72
141+ value: podbird.settings.refreshEpisodes
142+ function formatValue(v) { return i18n.tr("%1 hours").arg(Math.round(v)) }
143+ StyleHints { foregroundColor: podbird.appTheme.focusText }
144+ }
145+
146+ Button {
147+ text: i18n.tr("OK")
148+ color: podbird.appTheme.positiveActionButton
149+ onClicked: {
150+ podbird.settings.refreshEpisodes = Math.round(slider.value)
151+ PopupUtils.close(dialogInternal)
152+ }
153+ }
154+ Button {
155+ text: i18n.tr("Cancel")
156+ color: podbird.appTheme.neutralActionButton
157+ onClicked: {
158+ PopupUtils.close(dialogInternal)
159+ }
160+ }
161+ }
162+ }
163+
129164 Column {
130165 id: settingsColumn
131166
@@ -198,6 +233,13 @@ Page {
198233 title.text: i18n.tr("Podcast Episode Settings")
199234 }
200235
236+ SingleValueListItem {
237+ divider.visible: false
238+ title.text: i18n.tr("Refresh podcasts after")
239+ value: i18n.tr("%1 hours").arg(podbird.settings.refreshEpisodes)
240+ onClicked: PopupUtils.open(refreshDialog, settingsPage);
241+ }
242+
201243 ListItem {
202244 ListItemLayout {
203245 id: deleteLayout