Create QSystemTrayIcon even when tray is not supported
QSystemTrayIcon provides no public API to know when tray icon support appears, but can subscribe to native events internally This should help for environments where a race condition between applications autostart and tray service autostart present in case Qt is subscribed internally
This commit is contained in:
parent
c18313614b
commit
12d8d193a1
|
@ -21,17 +21,13 @@ Tray::Tray() {
|
|||
void Tray::create() {
|
||||
rebuildMenu();
|
||||
using WorkMode = Settings::WorkMode;
|
||||
if (Platform::TrayIconSupported()
|
||||
&& (Core::App().settings().workMode() != WorkMode::WindowOnly)) {
|
||||
if (Core::App().settings().workMode() != WorkMode::WindowOnly) {
|
||||
_tray.createIcon();
|
||||
}
|
||||
|
||||
Core::App().settings().workModeValue(
|
||||
) | rpl::combine_previous(
|
||||
) | rpl::start_with_next([=](WorkMode previous, WorkMode state) {
|
||||
if (!Platform::TrayIconSupported()) {
|
||||
return;
|
||||
}
|
||||
const auto wasHasIcon = (previous != WorkMode::WindowOnly);
|
||||
const auto nowHasIcon = (state != WorkMode::WindowOnly);
|
||||
if (wasHasIcon != nowHasIcon) {
|
||||
|
@ -182,7 +178,7 @@ void Tray::toggleSoundNotifications() {
|
|||
}
|
||||
|
||||
bool Tray::has() const {
|
||||
return _tray.hasIcon();
|
||||
return _tray.hasIcon() && Platform::TrayIconSupported();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
Loading…
Reference in New Issue