Skip to content

feat: unify backends with QT - #145

Merged
ReenigneArcher merged 19 commits into
masterfrom
feat/use-qt-for-all-platforms
Jul 28, 2026
Merged

feat: unify backends with QT#145
ReenigneArcher merged 19 commits into
masterfrom
feat/use-qt-for-all-platforms

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Jun 5, 2026

Copy link
Copy Markdown
Member

Description

Unify with QT for all platforms.

Required for LizardByte/Sunshine#5260

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

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.91371% with 77 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@6f97db2). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tray_qt.cpp 63.79% 26 Missing and 16 partials ⚠️
src/WindowsAppearance.cpp 49.12% 20 Missing and 9 partials ⚠️
src/QtTrayMenu.cpp 73.91% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #145   +/-   ##
=========================================
  Coverage          ?   59.81%           
=========================================
  Files             ?        5           
  Lines             ?      443           
  Branches          ?      162           
=========================================
  Hits              ?      265           
  Misses            ?      121           
  Partials          ?       57           
Flag Coverage Δ
Linux-qt5 56.45% <59.16%> (?)
Linux-qt6 56.45% <59.16%> (?)
Windows-qt6 56.41% <58.65%> (?)
macOS-qt6 55.52% <62.50%> (?)

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

Files with missing lines Coverage Δ
src/QtTrayMenu.h 100.00% <100.00%> (ø)
src/example.c 0.00% <ø> (ø)
src/QtTrayMenu.cpp 66.10% <73.91%> (ø)
src/WindowsAppearance.cpp 49.12% <49.12%> (ø)
src/tray_qt.cpp 63.79% <63.79%> (ø)

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 6f97db2...355bf73. Read the comment docs.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Last Updated 2026-07-28 00:08:22 UTC
Source Run CI Run #733
Commit 355bf735b8b6b6c3120937d9e61b55c0296c817a

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.

@ReenigneArcher
ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 6 times, most recently from f7847a4 to 2b7b7f6 Compare June 6, 2026 02:42
@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 3 times, most recently from 14bb48a to 6fdb6b6 Compare June 6, 2026 16:51
@Kishi85

Kishi85 commented Jun 6, 2026

Copy link
Copy Markdown

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

This comment was marked as resolved.

@ReenigneArcher
ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch 6 times, most recently from 640a03e to 13ba066 Compare June 6, 2026 20:15
@sonarqubecloud

sonarqubecloud Bot commented Jun 6, 2026

Copy link
Copy Markdown

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.
@ReenigneArcher
ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from c7bb9e5 to 6b322bd Compare July 27, 2026 14:33
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.
@ReenigneArcher
ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from 6b322bd to f1ff144 Compare July 27, 2026 15:02
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.
@ReenigneArcher
ReenigneArcher force-pushed the feat/use-qt-for-all-platforms branch from 33cf91b to ee1440e Compare July 27, 2026 22:59
@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher merged commit 7ee861c into master Jul 28, 2026
18 checks passed
@ReenigneArcher
ReenigneArcher deleted the feat/use-qt-for-all-platforms branch July 28, 2026 00:14
@ReenigneArcher

Copy link
Copy Markdown
Member Author

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.

@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?

@Kishi85

Kishi85 commented Jul 29, 2026

Copy link
Copy Markdown

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?

@ReenigneArcher

Copy link
Copy Markdown
Member Author

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.

@Kishi85

Kishi85 commented Aug 5, 2026

Copy link
Copy Markdown

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.

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