Skip to content

feat: unify backends with QT#145

Open
ReenigneArcher wants to merge 15 commits into
masterfrom
feat/use-qt-for-all-platforms
Open

feat: unify backends with QT#145
ReenigneArcher wants to merge 15 commits into
masterfrom
feat/use-qt-for-all-platforms

Conversation

@ReenigneArcher
Copy link
Copy Markdown
Member

Description

Unify with QT for all platforms.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 2 times, most recently from 480db0e to 3d9f350 Compare June 5, 2026 01:29
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 61.71875% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.23%. Comparing base (21a0a14) to head (210bad0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tray_qt.cpp 60.55% 28 Missing and 15 partials ⚠️
src/QtTrayMenu.cpp 68.42% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #145      +/-   ##
==========================================
- Coverage   63.98%   59.23%   -4.75%     
==========================================
  Files           5        3       -2     
  Lines         647      368     -279     
  Branches      214      129      -85     
==========================================
- Hits          414      218     -196     
+ Misses        153      102      -51     
+ Partials       80       48      -32     
Flag Coverage Δ
Linux-qt5 55.21% <55.75%> (+1.18%) ⬆️
Linux-qt6 55.21% <55.75%> (+1.18%) ⬆️
Windows ?
Windows-qt6 55.90% <58.55%> (?)
macOS ?
macOS-qt6 53.78% <60.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/example.c 0.00% <ø> (ø)
src/QtTrayMenu.cpp 65.51% <68.42%> (+11.28%) ⬆️
src/tray_qt.cpp 60.55% <60.55%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21a0a14...210bad0. Read the comment docs.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Last Updated 2026-06-06 20:33:30 UTC
Source Run CI Run #681
Commit c7bb9e515bb2de3bb56448b3b070f3e72138868f

Screenshot Comparison

PR #145 screenshots vs screenshots baseline.

Matrix: Linux-qt5

Image Baseline PR
tray_icon_ico.png
tray_icon_initial.png
tray_icon_png.png
tray_icon_svg.png
tray_icon_themed.png
tray_icon_update_ico.png
tray_icon_update_png.png
tray_icon_update_svg.png
tray_icon_update_themed.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_left_click.png
tray_menu_shown.png
tray_notification_displayed.png
tray_notification_ico_icon.png
tray_notification_png_icon.png
tray_notification_svg_icon.png
tray_notification_themed_icon.png

Matrix: Linux-qt6

Image Baseline PR
tray_icon_ico.png
tray_icon_initial.png
tray_icon_png.png
tray_icon_svg.png
tray_icon_themed.png
tray_icon_update_ico.png
tray_icon_update_png.png
tray_icon_update_svg.png
tray_icon_update_themed.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_left_click.png
tray_menu_shown.png
tray_notification_displayed.png
tray_notification_ico_icon.png
tray_notification_png_icon.png
tray_notification_svg_icon.png
tray_notification_themed_icon.png

Matrix: Windows

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

Image Baseline PR
tray_icon_ico.png
tray_icon_initial.png
tray_icon_png.png
tray_icon_svg.png
tray_icon_themed.png
tray_icon_update_ico.png
tray_icon_update_png.png
tray_icon_update_svg.png
tray_icon_update_themed.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_left_click.png
tray_menu_shown.png
tray_notification_ico_icon.png
tray_notification_png_icon.png
tray_notification_svg_icon.png
tray_notification_themed_icon.png

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

Image Baseline PR
tray_icon_ico.png
tray_icon_initial.png
tray_icon_png.png
tray_icon_svg.png
tray_icon_themed.png
tray_icon_update_ico.png
tray_icon_update_png.png
tray_icon_update_svg.png
tray_icon_update_themed.png
tray_menu_checkbox_checked.png
tray_menu_checkbox_unchecked.png
tray_menu_left_click.png
tray_menu_shown.png
tray_notification_ico_icon.png
tray_notification_png_icon.png
tray_notification_svg_icon.png
tray_notification_themed_icon.png

@ReenigneArcher

This comment was marked as resolved.

@Kishi85

This comment was marked as resolved.

@Kishi85

This comment was marked as resolved.

@ReenigneArcher

This comment was marked as resolved.

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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from d9e7895 to 3c674d7 Compare June 5, 2026 22:47
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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 3 times, most recently from 3c558f8 to bdc4dd8 Compare June 6, 2026 01:41
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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from bdc4dd8 to 64a3ef2 Compare June 6, 2026 01:51
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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from f7847a4 to 2b7b7f6 Compare June 6, 2026 02:42
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.
@ReenigneArcher

This comment was marked as resolved.

@ReenigneArcher ReenigneArcher marked this pull request as ready for review June 6, 2026 03:44
@Kishi85

This comment was marked as resolved.

@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 2 times, most recently from 911e8e8 to 14bb48a Compare June 6, 2026 16:50
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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from 14bb48a to 6fdb6b6 Compare June 6, 2026 16:51
@Kishi85
Copy link
Copy Markdown

Kishi85 commented Jun 6, 2026

Just tested with 6fdb6b6 as I had to recompile to test something else and looks good to me on Linux.

@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from bc83e4b to 53869c1 Compare June 6, 2026 17:54
@ReenigneArcher
Copy link
Copy Markdown
Member Author

Just tested with 6fdb6b6 as I had to recompile to test something else and looks good to me on Linux.

Nice, thanks! I'm just trying to fix something with the screenshot timing/notifications on Windows in tests.

@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 5 times, most recently from 522e702 to 6fdb6b6 Compare June 6, 2026 19:05
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.
@ReenigneArcher ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from 640a03e to 13ba066 Compare June 6, 2026 20:15
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.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 6, 2026

@Kishi85
Copy link
Copy Markdown

Kishi85 commented Jun 7, 2026

Using Qt notifications on KDE also makes them appear in the notification history (IIRC that wasn't the case for libnotify).

Unfortunately there's one drawback and that is that notification callbacks do not fire anymore (at least on KDE/Wayland) but Qt does not guarantee that in the docs (as Implementation is dependent on the underlying platform).

This is reproducible with the following changes to the tray_example:

diff --git a/src/example.c b/src/example.c
index a432255..ad1e452 100644
--- a/src/example.c
+++ b/src/example.c
@@ -20,13 +20,22 @@ static void toggle_cb(struct tray_menu *item) {
   tray_update(&tray);
 }
 
+static void notification_cb() {
+  printf("notification cb\n");
+}
+
 static void hello_cb(struct tray_menu *item) {
   (void) item;
   printf("hello cb\n");
+  tray.notification_text = "... and goodbye!";
+  tray.notification_title = "Hello ...";
+  tray.notification_cb = notification_cb;
   if (strcmp(tray.icon, TRAY_ICON1) == 0) {
     tray.icon = TRAY_ICON2;
+    tray.notification_icon = TRAY_ICON2;
   } else {
     tray.icon = TRAY_ICON1;
+    tray.notification_icon = TRAY_ICON1;
   }
   tray_update(&tray);
 }

There's already bugreports on Qt's Jira for this, like QTBUG-120679 or QTBUG-87329

For Sunshine there's just one callback used and that's opening the Webpage for PIN entry so that's broken but changing the notification text so users can open Sunshine's configuration by themselves should be sufficient IMHO.

@ReenigneArcher
Copy link
Copy Markdown
Member Author

Thanks for testing that further. I'm also having issues with packaging on Windows and macOS dmg in LizardByte/Sunshine#5260

I assumed it would be as easy as our other dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants