From e5cd8f9194bb9fdf299ff57166abfb0d3c2aded5 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Tue, 1 Sep 2026 08:43:01 +1000 Subject: [PATCH] linux: add persistent Start Hidden (Tray Only) setting Adds a 'Start Hidden' toggle in the settings page that persists to QSettings (window/startHidden). When enabled, the app starts with the main window hidden regardless of whether --hide was passed, which is useful for tiling window managers where the window otherwise appears as an overlay at startup. --- linux/Main.qml | 12 ++++++++++++ linux/main.cpp | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/linux/Main.qml b/linux/Main.qml index c7b235c33..cf16040ce 100644 --- a/linux/Main.qml +++ b/linux/Main.qml @@ -235,6 +235,18 @@ ApplicationWindow { onCheckedChanged: airPodsTrayApp.autoStartManager.autoStartEnabled = checked } + Switch { + text: qsTr("Start Hidden (Tray Only)") + checked: airPodsTrayApp.startHidden + onCheckedChanged: airPodsTrayApp.startHidden = checked + + ToolTip { + visible: parent.hovered + text: qsTr("Launch without showing the main window.\nOpen it from the tray icon instead.\nUseful for tiling window managers.") + delay: 500 + } + } + Switch { text: qsTr("Enable System Notifications") checked: airPodsTrayApp.notificationsEnabled diff --git a/linux/main.cpp b/linux/main.cpp index 7b1826b49..96d553d47 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -44,6 +44,7 @@ class AirPodsTrayApp : public QObject { Q_PROPERTY(bool notificationsEnabled READ notificationsEnabled WRITE setNotificationsEnabled NOTIFY notificationsEnabledChanged) Q_PROPERTY(int retryAttempts READ retryAttempts WRITE setRetryAttempts NOTIFY retryAttemptsChanged) Q_PROPERTY(bool hideOnStart READ hideOnStart CONSTANT) + Q_PROPERTY(bool startHidden READ startHidden WRITE setStartHidden NOTIFY startHiddenChanged) Q_PROPERTY(DeviceInfo *deviceInfo READ deviceInfo CONSTANT) Q_PROPERTY(QString phoneMacStatus READ phoneMacStatus NOTIFY phoneMacStatusChanged) Q_PROPERTY(bool hearingAidEnabled READ hearingAidEnabled WRITE setHearingAidEnabled NOTIFY hearingAidEnabledChanged) @@ -134,6 +135,12 @@ class AirPodsTrayApp : public QObject { void setNotificationsEnabled(bool enabled) { trayManager->setNotificationsEnabled(enabled); } int retryAttempts() const { return m_retryAttempts; } bool hideOnStart() const { return m_hideOnStart; } + bool startHidden() const { return loadStartHidden(); } + void setStartHidden(bool enabled) + { + saveStartHidden(enabled); + emit startHiddenChanged(enabled); + } DeviceInfo *deviceInfo() const { return m_deviceInfo; } QString phoneMacStatus() const { return m_phoneMacStatus; } bool hearingAidEnabled() const { return m_deviceInfo->hearingAidEnabled(); } @@ -407,6 +414,9 @@ public slots: bool loadNotificationsEnabled() const { return m_settings->value("notifications/enabled", true).toBool(); } void saveNotificationsEnabled(bool enabled) { m_settings->setValue("notifications/enabled", enabled); } + bool loadStartHidden() const { return m_settings->value("window/startHidden", false).toBool(); } + void saveStartHidden(bool enabled) { m_settings->setValue("window/startHidden", enabled); } + int loadRetryAttempts() const { return m_settings->value("bluetooth/retryAttempts", 3).toInt(); } void saveRetryAttempts(int attempts) { m_settings->setValue("bluetooth/retryAttempts", attempts); } @@ -965,6 +975,7 @@ private slots: void earDetectionBehaviorChanged(int behavior); void crossDeviceEnabledChanged(bool enabled); void notificationsEnabledChanged(bool enabled); + void startHiddenChanged(bool enabled); void retryAttemptsChanged(int attempts); void oneBudANCModeChanged(bool enabled); void phoneMacStatusChanged(); @@ -1042,6 +1053,11 @@ int main(int argc, char *argv[]) { hideOnStart = true; } + { + QSettings settings("AirPodsTrayApp", "AirPodsTrayApp"); + hideOnStart = hideOnStart || settings.value("window/startHidden", false).toBool(); + } + QQmlApplicationEngine engine; qmlRegisterType("me.kavishdevar.Battery", 1, 0, "Battery"); qmlRegisterType("me.kavishdevar.DeviceInfo", 1, 0, "DeviceInfo");