feat: unify backends with QT - #145
Conversation
480db0e to
3d9f350
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #145 +/- ##
=========================================
Coverage ? 59.81%
=========================================
Files ? 5
Lines ? 443
Branches ? 162
=========================================
Hits ? 265
Misses ? 121
Partials ? 57
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Harness.
|
Screenshot ComparisonPR #145 screenshots vs Matrix:
|
| Image | Baseline | PR |
|---|---|---|
tray_icon_initial.png |
||
tray_menu_checkbox_checked.png |
![]() |
|
tray_menu_checkbox_unchecked.png |
![]() |
|
tray_menu_shown.png |
![]() |
|
tray_notification_displayed.png |
![]() |
Matrix: Windows-qt6
Matrix: macOS
| Image | Baseline | PR |
|---|---|---|
tray_icon_initial.png |
||
tray_menu_checkbox_checked.png |
![]() |
|
tray_menu_checkbox_unchecked.png |
![]() |
|
tray_menu_shown.png |
![]() |
|
tray_notification_displayed.png |
![]() |
Matrix: macOS-qt6
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
f7847a4 to
2b7b7f6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
14bb48a to
6fdb6b6
Compare
|
Just tested with 6fdb6b6 as I had to recompile to test something else and looks good to me on Linux. |
bc83e4b to
53869c1
Compare
This comment was marked as resolved.
This comment was marked as resolved.
640a03e to
13ba066
Compare
|
Add waitForNativeNotificationTimeout() (Windows-only sleep) in tests/utils.{cpp,h} and include chrono/thread headers. Update multiple tray unit tests to call this helper after clearing notifications to avoid races with native notification timeouts. Also tweak some Qt tests to use tooltip updates to exercise tray code paths and ensure events are pumped before waiting.
Add sonar-project.properties to set the Sonar project key and force C++17 for analysis. Remove inline NOSONAR suppressions on std::thread lambda usages in src/tray_qt.cpp and tests/unit/test_tray.cpp; the thread behavior is unchanged, only the comment-based suppressions were removed.
Add new tray icon assets (icons/icon2.ico, icons/icon2.png, icons/icon2.svg) and update example and tests to use icon2.png as TRAY_ICON2. Also replace/refresh existing icon.ico and icon.png binaries. This enables using a distinct second icon in the example and unit tests.
CMake: Only define default icon variables and install/copy helper when the project is top-level (TRAY_IS_TOP_LEVEL). Add a second set of default icons (icon2.*) and include them in TRAY_ICON_FILES. Gate the example target copying behind TRAY_IS_TOP_LEVEL as well. Tests: Convert many unit tests to parameterized tests over icon types (svg/ico/png/themed). Add icon constants for .ico and secondary icons, a TrayIconParam struct, helpers to print and name params, and a nativeNotificationSkipReason helper to conditionally skip notification tests on unsupported environments. Ensure test assets are copied only when an extension is present, update screenshot names to include the icon param, and instantiate the parameterized suites. Remove several redundant single-file icon tests and adjust a few tests to explicitly set SVG icons where needed. Overall this makes tests cover multiple icon formats and avoids top-level-only icon behavior when used as a subproject.
Add an "Icon formats" section to README describing how `icon` and `notification_icon` can be file paths or theme names, listing supported formats per backend and recommending SVG/PNG for cross-platform use (noting libnotify limitations). Replace direct QIcon construction with lookupIcon(trayStruct->icon) in QtTrayMenu to properly resolve theme icon names and paths when setting the tray icon, aligning runtime behavior with the documented expectations.
Convert the multiple-icon update unit test to a parameterized test (TEST_P) using TrayIconTest/GetParam. Set the initial testTray.icon from the parameter, use the parameter's alternateIcon for the first update, add WaitForTrayReady and captureScreenshot using the parameter name, then restore the original icon. This enables running the same test across different icon variants and capturing screenshots for each.
Drop libnotify integration and related build plumbing, simplify notification handling to use Qt only, and update docs/tests accordingly. Changes include: removed cmake/FindLibNotify.cmake and LibNotify detection/definitions from CMakeLists.txt; removed libnotify-dependent code paths, async threads, and notification bookkeeping from src/tray_qt.cpp and unused includes; simplified notify logic to always use QtTrayMenu; updated README to remove libnotify from platform dependency lists and simplified the icons table; and adjusted a unit test comment to reflect the new Qt-based callback behavior. Overall this removes the external libnotify dependency and cleans up associated code and build configuration.
tests/unit/test_tray.cpp: add <cstdlib> include and a new WaitForNotificationReady helper that calls WaitForTrayReady and, on Windows running in GitHub Actions (GITHUB_ACTIONS env var), pumps the tray loop multiple times with short sleeps to stabilize notification display. Replace direct WaitForTrayReady calls in the notification test with the new helper to reduce CI flakiness.
Introduce a cross-platform isGitHubActions() helper (uses _dupenv_s on Windows and getenv elsewhere) and declare it in tests/utils.h. Replace direct getenv usage in tests/unit/test_tray.cpp with the new helper and guard the Windows notification timeout to avoid unnecessary sleeps outside GitHub Actions. Also remove an unused <cstdlib> include.
Replace the detailed table describing tray and notification icon backends with a concise line stating that SVG, ICO, PNG, and Qt theme icon names are supported. Keeps the existing recommendation to prefer SVG/PNG for predictable cross-platform behavior and removes redundant/verbose table markup.
c7bb9e5 to
6b322bd
Compare
Introduce `tests/notification_utils.{h,cpp}` and include it in the test build so native notification cleanup/wait behavior is centralized across platforms (Linux DBus dismissal, Windows CI timeout handling). Update tray tests to use `lizardbyte::common::is_github_actions()` and pull in the new helper, with a `lizardbyte-common` submodule bump to support the shared env check.
6b322bd to
f1ff144
Compare
tray_update now marshals calls from non-Qt threads to the GUI thread using QMetaObject::invokeMethod with BlockingQueuedConnection, keeping the C API synchronous. A new test verifies that a worker-thread call blocks until the main thread processes the update.
Add a Windows-only appearance helper that reads the interactive user's AppsUseLightTheme setting, applies the corresponding Qt color scheme, and enables the Qt Windows 11 style when available. Wire it into QtTrayMenu startup, add the required Windows libraries/sources to CMake, and cover the mapping and integration behavior with unit tests.
33cf91b to
ee1440e
Compare
|
@Kishi85 It seems unlikely this is going to be fixed anytime soon. Can we detect if callbacks are supported and then make the message depend on that? |
|
I don't think there's a way to do that unfortunately as that is covered by the low-level Qt platform implementation and that does not provide feedback on the showMessage() call or provide other ways to get the necessary feedback (at least that i've found/know of). The only thing I can think of is that we handle the notification call per platform again for known bad cases like Linux. For that we could borrow from qBittorrent's notification implementation as that is a Qt-only implemenation that utilises the full possible DBus notification interface (which would IMHO be fine as it does not need additional non-Qt dependencies). I'll can have a look into that (and prepare a PR for it) if you want? |
Sounds good! Just FYI, I won't be able to look at or merge any PRs for a week or so. |
|
I've not forgotten about this I'm just a bit short on time atm but I'll put the PR up as soon as I get to it. |





































Description
Unify with QT for all platforms.
Required for LizardByte/Sunshine#5260
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage