From 69be0689d688fe909a60596e38c15d9e52a29565 Mon Sep 17 00:00:00 2001 From: Niels Date: Sun, 8 Jun 2025 12:21:38 +0200 Subject: [PATCH] Added autoplay function (can be changed in settings) --- harbour-allradio.pro | 1 + qml/harbour-allradio.qml | 2 +- qml/items/RadioPlayer.qml | 1 + qml/items/Splash.qml | 22 ++++--- qml/pages/AllRadio.qml | 26 ++++++++ qml/pages/SettingsPage.qml | 96 +++++++++++++++-------------- qml/pages/SettingsPage__.qml | 59 ++++++++++++++++++ rpm/harbour-allradio.spec | 9 ++- translations/harbour-allradio-de.ts | 12 +--- translations/harbour-allradio.ts | 12 +--- 10 files changed, 162 insertions(+), 78 deletions(-) create mode 100644 qml/pages/SettingsPage__.qml diff --git a/harbour-allradio.pro b/harbour-allradio.pro index f10dfeb..f249379 100644 --- a/harbour-allradio.pro +++ b/harbour-allradio.pro @@ -29,6 +29,7 @@ DISTFILES += qml/harbour-allradio.qml \ qml/pages/SearchStationsPage.qml \ qml/pages/SecondPage.qml \ qml/pages/SettingsPage.qml \ + qml/pages/SettingsPage__.qml \ qml/pages/TagListPage.qml \ rpm/harbour-allradio.spec \ translations/*.ts \ diff --git a/qml/harbour-allradio.qml b/qml/harbour-allradio.qml index 72adada..e1a3a4e 100644 --- a/qml/harbour-allradio.qml +++ b/qml/harbour-allradio.qml @@ -9,7 +9,7 @@ import "helpers" ApplicationWindow { id: allRadio - property string _version: "2.0.17" + property string _version: "2.0.18" property string _language: Qt.locale().name.slice(0,2) property string _country: Qt.locale().name.slice(-2) property int sleepTime: 0 diff --git a/qml/items/RadioPlayer.qml b/qml/items/RadioPlayer.qml index d671f63..f63b78d 100644 --- a/qml/items/RadioPlayer.qml +++ b/qml/items/RadioPlayer.qml @@ -229,6 +229,7 @@ MediaPlayer { isPaused = false qdTimer.start() if (_favorite) Favorites.setSetting("playlistIndex",playlistIndex) + //appStartPlay = false } function tryagain() { diff --git a/qml/items/Splash.qml b/qml/items/Splash.qml index 628f4b6..838e512 100644 --- a/qml/items/Splash.qml +++ b/qml/items/Splash.qml @@ -6,7 +6,6 @@ import QtGraphicalEffects 1.0 Column { id: column spacing: Theme.paddingMedium - //property alias busy: busyIndicator.running anchors.centerIn: parent Image { @@ -21,27 +20,32 @@ Column { source: parent color: Theme.highlightColor } - // BusyIndicator { - // size: BusyIndicatorSize.Large - // anchors.centerIn: parent - // running: parent.visible - // } } - Label { - text: radioBrowser.serversModel.count > 0 ? qsTr("Found")+": "+radioBrowser.serversModel.count + " "+qsTr("servers") : qsTr("Searching for servers...") + BusyLabel { + text: radioBrowser.serversModel.count > 0 ? qsTr("Found")+": "+radioBrowser.serversModel.count + " "+qsTr("servers") : qsTr("Searching servers") + running: radioBrowser.serversModel.count < 1 anchors.horizontalCenter: parent.horizontalCenter } - Label { + BusyLabel { visible: radioBrowser.serversModel.count > 0 + running: visible text: qsTr("Connecting to:") anchors.horizontalCenter: parent.horizontalCenter } Label { + visible: radioBrowser.serversModel.count > 0 text: radioBrowser.server font.pixelSize: Theme.fontSizeSmall color: Theme.highlightColor anchors.horizontalCenter: parent.horizontalCenter } + Button { + visible: radioBrowser.serversModel.count > 1 + anchors.topMargin: Theme.paddingLarge + text: "Try another server" + onClicked: radioBrowser.getRandom() + anchors.horizontalCenter: parent.horizontalCenter + } } diff --git a/qml/pages/AllRadio.qml b/qml/pages/AllRadio.qml index d9fc500..44b766f 100644 --- a/qml/pages/AllRadio.qml +++ b/qml/pages/AllRadio.qml @@ -14,8 +14,10 @@ Page { anchors.fill: parent anchors.bottomMargin: mediaPlayerPanel.visibleSize + property int _appStart: Favorites.getSetting("appStart",0) property bool stationOk: radioPlayer.stationOk property bool online: radioBrowser.online + property bool _loading: radioBrowser.loading property GetCountryStations getTrending1: GetCountryStations {id: getTrending1} property GetCountryStations getTrending2: GetCountryStations {id: getTrending2} property GetCountryStations getTrendingWorld: GetCountryStations {id: getTrendingWorld} @@ -28,6 +30,12 @@ Page { onOnlineChanged: if (online) reloadDbData() onStationOkChanged: if (stationOk) reloadDbData() + on_LoadingChanged: { + if (!_loading) { + appAutoPlay() + console.log(" *** AUTOPLAY") + } else console.log(" *** INTE AUTOPLAY") + } Splash { id: splashItem @@ -388,6 +396,24 @@ Page { } } + function appAutoPlay() { + console.log( "*** appStart: "+_appStart ) + switch (_appStart) { + case 0: + break; + case 1: + radioPlayer.loadRecentPlay() + radioPlayer.playStream() + break; + case 2: + radioPlayer.loadRandomPlay() + radioPlayer.playStream() + break; + default: + break; + } + } + function reloadDbData() { Favorites.getTagsRecentClicked(playedTags,15) Favorites.getFavorites(favorites,"myclickcount",15) diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml index 94badc8..d6dd1b5 100644 --- a/qml/pages/SettingsPage.qml +++ b/qml/pages/SettingsPage.qml @@ -1,56 +1,62 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import QtQuick.LocalStorage 2.0 +import QtGraphicalEffects 1.0 import "../helpers/db.js" as Favorites -Page { - Flickable { - id: flick - width:parent.width - height: parent.height - Theme.paddingLarge * 3 - anchors.top: parent.top - anchors.topMargin: Theme.paddingLarge * 3 - contentHeight: column1.height +Dialog { + id: settingsDialog + // property bool aComp + // property bool aMag + // property int aR: anchorRadius - Column{ - id: column1 + Column { + //id: col1 + anchors.left: parent.left + anchors.right: parent.right + spacing: Theme.paddingMedium + + DialogHeader {} + + Label { + anchors.right: parent.right + anchors.rightMargin: Theme.paddingLarge + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeLarge + text: qsTr("App settings") + } + + Separator { + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: Theme.paddingMedium + color: Theme.highlightColor + } + + ComboBox { + id: appStart width: parent.width - spacing: Theme.paddingLarge - - Image{ - source: "../images/community.png" - height: Theme.itemSizeHuge - width: height - fillMode: Image.PreserveAspectFit - anchors { - horizontalCenter: parent.horizontalCenter - } - } - - Label { - width: parent.width-70 - font.pixelSize: Theme.fontSizeSmall - text: qsTr("Working on more settings.....") - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignHCenter - height: 200 - wrapMode: Text.WordWrap - } - Label { - width: parent.width-70 - font.pixelSize: Theme.fontSizeLarge - text: qsTr("WARNING! THis is for debugging or corrupt database. Only delete db if it is not working!!!") - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - } - Button { - text: qsTr("Delete DB") - onClicked: Favorites.dropTable() - anchors.horizontalCenter: parent.horizontalCenter + label: "Auto play" + anchors.margins: Theme.paddingLarge + description: "What to do when AllRadio2 starts" + currentIndex: Favorites.getSetting("appStart",0) + menu: ContextMenu { + MenuItem { text: "Off" } + MenuItem { text: "Last played" } + MenuItem { text: "Random favorite" } } } } + + onAccepted: { + //console.log(" *** APPSTART: "+appStart.currentIndex) + Favorites.setSetting("appStart",appStart.currentIndex) + /* activateNumbers.checked ? showCompasNumbers = 1 : showCompasNumbers = 0 + var scron + keepSon.checked ? scron = 1 : scron = 0 + keepScreenOn = keepSon.checked + settings.setSettingSetting(aComp,aMag,aR,showCompasNumbers,scron) + anchorRadius = aR */ + } } + diff --git a/qml/pages/SettingsPage__.qml b/qml/pages/SettingsPage__.qml new file mode 100644 index 0000000..6014043 --- /dev/null +++ b/qml/pages/SettingsPage__.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import QtQuick.LocalStorage 2.0 +import QtGraphicalEffects 1.0 +import "../helpers/db.js" as Favorites + +Page { + PageHeader { + id: pheader + title: "Settings" + } + + Flickable { + id: flick + width:parent.width + height: parent.height - Theme.paddingLarge * 3 + anchors.fill: parent + anchors.leftMargin: Theme.paddingLarge + anchors.rightMargin: Theme.paddingLarge + anchors.topMargin: pheader.height + Theme.paddingLarge + //contentHeight: column1.height + + + + TextSwitch { + id: activationSwitch + text: "Auto play" + description: "Play radio station on start" + onCheckedChanged: { + device.setStatus(checked ? DeviceState.Armed : DeviceState.Disarmed) + } + } + ComboBox { + width: parent.widht + label: "What to play" + menu: ContextMenu { + MenuItem { text: "Last played" } + MenuItem { text: "Random favorite" } + } + } + + + /* Label { + width: parent.width-70 + font.pixelSize: Theme.fontSizeLarge + text: qsTr("WARNING! THis is for debugging or corrupt database. Only delete db if it is not working!!!") + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + } + Button { + text: qsTr("Delete DB") + onClicked: Favorites.dropTable() + anchors.horizontalCenter: parent.horizontalCenter + } */ + + } +} diff --git a/rpm/harbour-allradio.spec b/rpm/harbour-allradio.spec index 6100d54..400188a 100644 --- a/rpm/harbour-allradio.spec +++ b/rpm/harbour-allradio.spec @@ -1,10 +1,10 @@ Name: harbour-allradio Summary: AllRadio -Version: 2.0.17 +Version: 2.0.18 Release: 1 Group: Qt/Qt -License: GPL2 +License: GPLv2 URL: https://gitea.nesnomis.nu/nesnomis/harbour-allradio/ Source0: %{name}-%{version}.tar.bz2 Requires: sailfishsilica-qt5 >= 0.10.9 @@ -29,6 +29,9 @@ BuildRequires: pkgconfig(dbus-1) AllRadio2 is a new version of AllRadio, an internet radio player. %if "%{?vendor}" == "chum" +PackageName: AllRadio2 +Type: desktop-application +PackagerName: Niels Simonsen (nesnomis) Categories: - Multimedia Icon: https://gitea.nesnomis.nu/nesnomis/harbour-allradio/src/branch/master/icons/128x128/harbour-allradio.png @@ -39,7 +42,7 @@ Screenshots: - https://gitea.nesnomis.nu/nesnomis/harbour-allradio/wiki/raw/Screenshot_20250522_222316_001.png - https://gitea.nesnomis.nu/nesnomis/harbour-allradio/wiki/raw/Screenshot_20250522_222349_001.png Url: - Homepage: https://openrepos.net/content/nesnomis/allradio2 + Homepage: http://gitea.nesnomis.nu/nesnomis/harbour-allradio %endif %prep diff --git a/translations/harbour-allradio-de.ts b/translations/harbour-allradio-de.ts index 401bde0..6acb724 100644 --- a/translations/harbour-allradio-de.ts +++ b/translations/harbour-allradio-de.ts @@ -1134,15 +1134,7 @@ SettingsPage - Working on more settings..... - - - - WARNING! THis is for debugging or corrupt database. Only delete db if it is not working!!! - - - - Delete DB + App settings @@ -1191,7 +1183,7 @@ - Searching for servers... + Searching servers diff --git a/translations/harbour-allradio.ts b/translations/harbour-allradio.ts index be6c0c1..6e1a0b1 100644 --- a/translations/harbour-allradio.ts +++ b/translations/harbour-allradio.ts @@ -1134,15 +1134,7 @@ SettingsPage - Working on more settings..... - - - - WARNING! THis is for debugging or corrupt database. Only delete db if it is not working!!! - - - - Delete DB + App settings @@ -1191,7 +1183,7 @@ - Searching for servers... + Searching servers