From 872670bd3e2f01b6afcce453d8009f18e75dfee0 Mon Sep 17 00:00:00 2001 From: Sebastian Palencsar Date: Mon, 22 Jun 2026 17:04:46 +0200 Subject: [PATCH] fix: show window on startup and on MPRIS Raise (1.0.5 pkgrel 4) Register MPRIS only after QML loads, always connect raiseRequested to the main window (not only when the tray icon exists), and show or activate the window explicitly on launch. Fix circular dialog property aliases. --- PKGBUILD | 2 +- de.nerdbear.bearwave.metainfo.xml | 2 ++ src/main.cpp | 29 ++++++++++++++++++++--------- src/qml/Main.qml | 12 ++++++------ src/qml/components/AboutDialog.qml | 2 +- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index b6ec8c8..6d85282 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Sebastian Palencsar pkgname=bearwave-git pkgver=1.0.5 -pkgrel=3 +pkgrel=4 pkgdesc="KDE-focused desktop internet radio app" arch=('x86_64') url="https://github.com/spalencsar/bearwave" diff --git a/de.nerdbear.bearwave.metainfo.xml b/de.nerdbear.bearwave.metainfo.xml index c2ecf2c..47a7259 100644 --- a/de.nerdbear.bearwave.metainfo.xml +++ b/de.nerdbear.bearwave.metainfo.xml @@ -68,6 +68,8 @@
  • About dialog shows version and git build id; removed “Public beta” label
  • Fixed About, Add station, and Edit station dialogs not opening after QML refactor
  • Flatpak: grant GPU access via --device=dri (fixes EGL/MESA warnings)
  • +
  • Fixed startup when re-launching: MPRIS Raise now always shows the window
  • +
  • Fixed dialog property aliases and About version label binding
  • diff --git a/src/main.cpp b/src/main.cpp index 165d4de..9cf9b98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,7 @@ int main(int argc, char *argv[]) QStringLiteral("Raise") ); sessionBus.call(call); + qInfo() << "BearWave is already running; raised the existing window."; return 0; } app.setWindowIcon(QIcon::fromTheme(QStringLiteral("de.nerdbear.bearwave"))); @@ -64,15 +65,6 @@ int main(int argc, char *argv[]) Q_UNUSED(controlAdaptor) Q_UNUSED(notificationManager) - if (!sessionBus.registerObject(QStringLiteral("/org/mpris/MediaPlayer2"), &backend, QDBusConnection::ExportAdaptors)) { - qWarning() << "Failed to register MPRIS D-Bus object"; - } - if (!sessionBus.registerService(QStringLiteral("org.mpris.MediaPlayer2.bearwave"))) { - qWarning() << "Failed to register MPRIS D-Bus service org.mpris.MediaPlayer2.bearwave"; - } else { - mprisPlayer->publishState(); - } - const QUrl url(QStringLiteral("qrc:/qml/Main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [&app, url](QObject *obj, const QUrl &objUrl) { @@ -94,6 +86,25 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + QObject::connect(&backend, &RadioBackend::raiseRequested, mainWindow, [mainWindow]() { + mainWindow->show(); + mainWindow->raise(); + mainWindow->requestActivate(); + }); + + if (!sessionBus.registerObject(QStringLiteral("/org/mpris/MediaPlayer2"), &backend, QDBusConnection::ExportAdaptors)) { + qWarning() << "Failed to register MPRIS D-Bus object"; + } + if (!sessionBus.registerService(QStringLiteral("org.mpris.MediaPlayer2.bearwave"))) { + qWarning() << "Failed to register MPRIS D-Bus service org.mpris.MediaPlayer2.bearwave"; + } else { + mprisPlayer->publishState(); + } + + mainWindow->show(); + mainWindow->raise(); + mainWindow->requestActivate(); + SystemTrayManager trayManager(&backend, mainWindow, &app); Q_UNUSED(trayManager) diff --git a/src/qml/Main.qml b/src/qml/Main.qml index 05127aa..f19e5cf 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -34,9 +34,9 @@ ApplicationWindow { property string countrySearchText: "" property alias searchField: searchToolbar.searchField property alias stationList: stationPanel.stationList - property alias addDialog: addDialog - property alias editDialog: editDialog - property alias aboutDialog: aboutDialog + property alias addDialog: addDialogPane + property alias editDialog: editDialogPane + property alias aboutDialog: aboutDialogPane function toast(message) { toastPopup.show(message) @@ -231,19 +231,19 @@ ApplicationWindow { } AddStationDialog { - id: addDialog + id: addDialogPane app: root compactMode: root.compactMode } EditStationDialog { - id: editDialog + id: editDialogPane app: root compactMode: root.compactMode } AboutDialog { - id: aboutDialog + id: aboutDialogPane compactMode: root.compactMode appVersion: root.appVersion buildId: root.appBuildId diff --git a/src/qml/components/AboutDialog.qml b/src/qml/components/AboutDialog.qml index 615ca27..41be70f 100644 --- a/src/qml/components/AboutDialog.qml +++ b/src/qml/components/AboutDialog.qml @@ -55,7 +55,7 @@ Dialog { Label { Layout.alignment: Qt.AlignHCenter - text: qsTr("Version %1 · build %2").arg(root.appVersion, root.buildId) + text: qsTr("Version %1 · build %2").arg(String(root.appVersion), String(root.buildId)) color: BearTheme.textMuted font.pixelSize: 12 }