From 04a8905a834b1c5dcc489353ae69de596d48b44b Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 10 Nov 2023 14:33:03 +0100 Subject: [PATCH] Allow opening Syncthing directly when clicking on tray icon This might be useful if minimalism is desired or to avoid positioning issues on Wayland. --- README.md | 3 +++ syncthingwidgets/settings/appearanceoptionpage.ui | 5 +++++ tray/gui/traymenu.cpp | 8 +++++++- tray/gui/traymenu.h | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 318c080..b560662 100644 --- a/README.md +++ b/README.md @@ -544,6 +544,9 @@ the appearance settings. That doesn't fix the positioning issue but then it looks just like a normal application so not being positioned in the tray area is less problematic. +You can also select the window type "None". This disables Syncthing Tray's own UI +completely and instead opens Syncthing directly when the tray icon is clicked. + ### Workaround broken High-DPI scaling of Plasmoid under X11 Setting the environment variable `PLASMA_USE_QT_SCALING=1` should fix the [issue](https://bugs.kde.org/show_bug.cgi?id=356446) on recent Plasma versions but diff --git a/syncthingwidgets/settings/appearanceoptionpage.ui b/syncthingwidgets/settings/appearanceoptionpage.ui index e6f23d0..9df828c 100644 --- a/syncthingwidgets/settings/appearanceoptionpage.ui +++ b/syncthingwidgets/settings/appearanceoptionpage.ui @@ -388,6 +388,11 @@ Window without titlebar + + + None - open Syncthing directly + + diff --git a/tray/gui/traymenu.cpp b/tray/gui/traymenu.cpp index b79f18d..6ec1725 100644 --- a/tray/gui/traymenu.cpp +++ b/tray/gui/traymenu.cpp @@ -64,6 +64,10 @@ static void moveInside(QPoint &point, const QSize &innerRect, const QRect &outer void TrayMenu::showUsingPositioningSettings() { + if (m_windowType == WindowType::None) { + widget().showWebUI(); + return; + } resize(sizeHint()); auto pos = Settings::values().appearance.positioning.positionToUse(); if (pos.has_value()) { @@ -77,7 +81,7 @@ void TrayMenu::showUsingPositioningSettings() void TrayMenu::setWindowType(int windowType) { - if (windowType >= 0 && windowType <= 2) { + if (windowType >= 0 && windowType <= 3) { setWindowType(static_cast(windowType)); } } @@ -98,6 +102,8 @@ void TrayMenu::setWindowType(WindowType windowType) case WindowType::CustomWindow: flags = Qt::Dialog | Qt::CustomizeWindowHint; break; + case WindowType::None: + break; } setWindowFlags(flags); } diff --git a/tray/gui/traymenu.h b/tray/gui/traymenu.h index 8956d09..1065347 100644 --- a/tray/gui/traymenu.h +++ b/tray/gui/traymenu.h @@ -16,6 +16,7 @@ public: Popup, NormalWindow, CustomWindow, + None, }; explicit TrayMenu(TrayIcon *trayIcon = nullptr, QWidget *parent = nullptr);