Skip to content
Snippets Groups Projects
Commit 043a715c authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

systray: restore original behaviour for systrayicon check

In response to an issue that would cause a lost window when minimizing to tray on a system without a systray, commit 316750ad introduced a bug for versions of Qt that would return null icon geometry even when the icon was visible. Subsequently, this was byspassed with commit f25e66aa which only applied to GNU/Linux systems, leaving the hack inplace for Windows and macOS where the bug had not originally occured.

This commit:
- makes the "MinimizeOnClose" option always visible
- uses Qt's built-in method for "isSystemTrayIconVisible"
- changes the default "MinimizeOnClose" setting to true

Gitlab: #1623
Change-Id: I3b99c7fb952eedea63ae9c12d207ceb3c9bd4988
parent 5bd3ead2
No related branches found
Tags beta/202405151615
No related merge requests found
...@@ -116,7 +116,8 @@ ApplicationWindow { ...@@ -116,7 +116,8 @@ ApplicationWindow {
function close(force = false) { function close(force = false) {
// If we're in the onboarding wizard or 'MinimizeOnClose' // If we're in the onboarding wizard or 'MinimizeOnClose'
// is set, then we can quit // is set, then we can quit
if (force || !UtilsAdapter.getAppValue(Settings.MinimizeOnClose) || !UtilsAdapter.getAccountListSize()) { var minimizeToTray = UtilsAdapter.getAppValue(Settings.MinimizeOnClose) && UtilsAdapter.isSystemTrayIconVisible();
if (force || !minimizeToTray || !UtilsAdapter.getAccountListSize()) {
Qt.quit(); Qt.quit();
} else { } else {
layoutManager.closeToTray(); layoutManager.closeToTray();
......
...@@ -43,7 +43,7 @@ extern const QString defaultDownloadPath; ...@@ -43,7 +43,7 @@ extern const QString defaultDownloadPath;
// Common key-value pairs for both APPSTORE and non-APPSTORE builds // Common key-value pairs for both APPSTORE and non-APPSTORE builds
#define COMMON_KEYS \ #define COMMON_KEYS \
X(MinimizeOnClose, false) \ X(MinimizeOnClose, true) \
X(DownloadPath, defaultDownloadPath) \ X(DownloadPath, defaultDownloadPath) \
X(ScreenshotPath, {}) \ X(ScreenshotPath, {}) \
X(EnableNotifications, true) \ X(EnableNotifications, true) \
......
...@@ -101,8 +101,7 @@ SettingsPageBase { ...@@ -101,8 +101,7 @@ SettingsPageBase {
id: closeOrMinCheckBox id: closeOrMinCheckBox
Layout.fillWidth: true Layout.fillWidth: true
visible: UtilsAdapter.isSystemTrayIconVisible() checked: UtilsAdapter.getAppValue(Settings.MinimizeOnClose)
checked: UtilsAdapter.getAppValue(Settings.MinimizeOnClose) && UtilsAdapter.isSystemTrayIconVisible()
labelText: JamiStrings.keepMinimized labelText: JamiStrings.keepMinimized
onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.MinimizeOnClose, checked) onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.MinimizeOnClose, checked)
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "systemtray.h" #include "systemtray.h"
#include "utils.h" #include "utils.h"
#include "version.h" #include "version.h"
#include "global.h"
#include <api/datatransfermodel.h> #include <api/datatransfermodel.h>
#include <api/contact.h> #include <api/contact.h>
...@@ -229,7 +230,7 @@ UtilsAdapter::getConvIdForUri(const QString& accountId, const QString& uri) ...@@ -229,7 +230,7 @@ UtilsAdapter::getConvIdForUri(const QString& accountId, const QString& uri)
return {}; return {};
return convInfo->get().uid; return convInfo->get().uid;
} catch (const std::out_of_range& e) { } catch (const std::out_of_range& e) {
qDebug() << e.what(); C_DBG << e.what();
return ""; return "";
} }
} }
...@@ -242,7 +243,7 @@ UtilsAdapter::getPeerUri(const QString& accountId, const QString& uid) ...@@ -242,7 +243,7 @@ UtilsAdapter::getPeerUri(const QString& accountId, const QString& uid)
const auto& convInfo = convModel->getConversationForUid(uid).value(); const auto& convInfo = convModel->getConversationForUid(uid).value();
return convInfo.get().participants.front().uri; return convInfo.get().participants.front().uri;
} catch (const std::out_of_range& e) { } catch (const std::out_of_range& e) {
qDebug() << e.what(); C_DBG << e.what();
return ""; return "";
} }
} }
...@@ -745,7 +746,7 @@ UtilsAdapter::isSystemThemeDark() ...@@ -745,7 +746,7 @@ UtilsAdapter::isSystemThemeDark()
#endif #endif
return readAppsUseLightThemeRegistry(true); return readAppsUseLightThemeRegistry(true);
#else #else
qWarning("System theme detection is not implemented or is not supported"); C_WARN << "System theme detection is not implemented or is not supported";
return false; return false;
#endif // WIN32 #endif // WIN32
#endif // __has_include(<gio/gio.h>) #endif // __has_include(<gio/gio.h>)
...@@ -827,13 +828,7 @@ UtilsAdapter::isRTL() ...@@ -827,13 +828,7 @@ UtilsAdapter::isRTL()
bool bool
UtilsAdapter::isSystemTrayIconVisible() UtilsAdapter::isSystemTrayIconVisible()
{ {
if (!systemTray_) return QSystemTrayIcon::isSystemTrayAvailable() && systemTray_;
return false;
// https://bugreports.qt.io/browse/QTBUG-118656
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
return true;
#endif
return systemTray_->geometry() != QRect();
} }
QString QString
...@@ -891,7 +886,7 @@ UtilsAdapter::createDummyImage() const ...@@ -891,7 +886,7 @@ UtilsAdapter::createDummyImage() const
qInfo() << "Dummy image created" << QDir::tempPath() + "/dummy.png"; qInfo() << "Dummy image created" << QDir::tempPath() + "/dummy.png";
return QDir::tempPath() + "/dummy.png"; return QDir::tempPath() + "/dummy.png";
} else { } else {
qWarning() << "Could not create dummy image"; C_WARN << "Could not create dummy image";
return ""; return "";
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment