MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 5 / 0 / 5
Functions: 100.0% 5 / 0 / 5
Branches: -% 0 / 0 / 0

presentation/QuickTrayController.h
Line Branch Exec Source
1 #pragma once
2
3 #include <QObject>
4 #include <QTimer>
5 #include <QIcon>
6 #include <QColor>
7 #include <QPointer>
8 #include <QQuickWindow>
9
10 #include <optional>
11
12 class QMenu;
13
14 // Q16: session-owned tray integration for the Quick frontend, ported from
15 // the Widgets MainWindow contract. Prefers the KDE StatusNotifierItem when
16 // the integration compiled and the session provides a watcher; falls back
17 // to QSystemTrayIcon. The tray toggles the window (activate) or raises it
18 // with a fresh composer (secondary/middle click), reflects the unread
19 // count as overlay and tooltip, and gates close-to-tray.
20 class QuickTrayController final : public QObject {
21 1610 Q_OBJECT
22 // Readable from QML bindings (the closing logic in Main.qml).
23 Q_PROPERTY(bool trayPresent READ trayPresent NOTIFY trayPresenceChanged)
24 Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadChanged)
25 Q_PROPERTY(bool closeToTray READ closeToTray WRITE setCloseToTray NOTIFY closeToTrayChanged)
26 public:
27 explicit QuickTrayController(QQuickWindow *window, QObject *parent = nullptr);
28 ~QuickTrayController() override;
29 // Rebinds to the loaded scene window (the host constructs the
30 // controller before the QML engine runs).
31 765 void setParentWindow(QQuickWindow *window) { m_window = window; }
32
33 // A real tray backend exists (or is simulated for tests/headless).
34 bool trayPresent() const;
35 // Test/headless seam: simulates the presence of a tray backend so the
36 // window-toggle and close-to-tray paths stay observable without a
37 // desktop. Production leaves this unset.
38 void setSimulatedTray(bool simulated);
39 // S106-213: whether a tray host still runs. Follows the session's
40 // org.kde.StatusNotifierWatcher (where the KDE item and Qt's D-Bus tray
41 // icon live); when it leaves, closing quits again instead of hiding the
42 // window with no icon to bring it back. Public as a test seam.
43 void setTrayHostPresent(bool present);
44
45 QMenu *contextMenu();
46 22 QIcon icon() const { return m_icon; }
47 void setBadgeColor(const QColor &color);
48 void showWindow();
49
50 7 int unreadCount() const { return m_unread; }
51 void setUnreadCount(int count); // emits unreadChanged
52
53 // Tray activate: visible-and-restored windows hide; hidden or minimized
54 // ones come to the front.
55 Q_INVOKABLE void toggleWindow();
56 // Secondary/middle activation: raise plus a fresh composer.
57 Q_INVOKABLE void secondaryActivate();
58
59 // "Keep in the system tray on close" preference (persisted elsewhere).
60 Q_INVOKABLE void setCloseToTray(bool on);
61 829 bool closeToTray() const { return m_closeToTray; }
62 // True when a window close request should hide to the tray instead of
63 // quitting. Only ever true with a present tray - without one, closing
64 // must quit or the session would become unreachable.
65 bool interceptClose() const;
66
67 signals:
68 void composeRequested();
69 void inboxRequested();
70 void checkMailRequested();
71 void quitRequested();
72 void closeToTrayChanged();
73 void trayPresenceChanged();
74 void unreadChanged();
75
76 private:
77 void rebuildBackend();
78 // Defined in the .cpp (emits trayPresenceChanged).
79 void updateOverlay();
80
81 QPointer<QQuickWindow> m_window;
82 QPointer<QMenu> m_menu;
83 QIcon m_icon;
84 QColor m_badgeColor;
85 class KdeBackend;
86 class FallbackBackend;
87 KdeBackend *m_kde = nullptr;
88 FallbackBackend *m_fallback = nullptr;
89 int m_unread = 0;
90 // Coalesces badge/icon renders (11 SVG sizes + D-Bus) out of the input frame.
91 QTimer m_overlayTimer;
92 static constexpr int OverlayCoalesceMs = 100;
93 bool m_closeToTray = true;
94 bool m_simulated = false;
95 bool m_hostPresent = true; // S106-213: until the watcher says otherwise
96 };
97