mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Returned lost method that checks tray existence.
This commit is contained in:
parent
ce39eb2da9
commit
57f769f358
9 changed files with 35 additions and 7 deletions
|
@ -419,6 +419,10 @@ rpl::producer<> Tray::iconClicks() const {
|
|||
return _iconClicks.events();
|
||||
}
|
||||
|
||||
bool Tray::hasIcon() const {
|
||||
return _icon;
|
||||
}
|
||||
|
||||
rpl::lifetime &Tray::lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<> hideToTrayRequests() const;
|
||||
[[nodiscard]] rpl::producer<> iconClicks() const;
|
||||
|
||||
[[nodiscard]] bool hasIcon() const;
|
||||
|
||||
void createIcon();
|
||||
void destroyIcon();
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<> hideToTrayRequests() const;
|
||||
[[nodiscard]] rpl::producer<> iconClicks() const;
|
||||
|
||||
[[nodiscard]] bool hasIcon() const;
|
||||
|
||||
void createIcon();
|
||||
void destroyIcon();
|
||||
|
||||
|
|
|
@ -413,6 +413,10 @@ rpl::producer<> Tray::iconClicks() const {
|
|||
return rpl::never<>();
|
||||
}
|
||||
|
||||
bool Tray::hasIcon() const {
|
||||
return _nativeIcon != nullptr;
|
||||
}
|
||||
|
||||
rpl::lifetime &Tray::lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
|
|
@ -231,6 +231,10 @@ rpl::producer<> Tray::iconClicks() const {
|
|||
return _iconClicks.events();
|
||||
}
|
||||
|
||||
bool Tray::hasIcon() const {
|
||||
return _icon;
|
||||
}
|
||||
|
||||
rpl::lifetime &Tray::lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<> hideToTrayRequests() const;
|
||||
[[nodiscard]] rpl::producer<> iconClicks() const;
|
||||
|
||||
[[nodiscard]] bool hasIcon() const;
|
||||
|
||||
void createIcon();
|
||||
void destroyIcon();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "platform/platform_specific.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
|
@ -19,17 +20,20 @@ Tray::Tray() {
|
|||
|
||||
void Tray::create() {
|
||||
rebuildMenu();
|
||||
if (Core::App().settings().workMode() != Settings::WorkMode::WindowOnly) {
|
||||
using WorkMode = Settings::WorkMode;
|
||||
if (Platform::TrayIconSupported()
|
||||
&& (Core::App().settings().workMode() != WorkMode::WindowOnly)) {
|
||||
_tray.createIcon();
|
||||
}
|
||||
|
||||
Core::App().settings().workModeValue(
|
||||
) | rpl::combine_previous(
|
||||
) | rpl::start_with_next([=](
|
||||
Settings::WorkMode previous,
|
||||
Settings::WorkMode state) {
|
||||
const auto wasHasIcon = (previous != Settings::WorkMode::WindowOnly);
|
||||
const auto nowHasIcon = (state != Settings::WorkMode::WindowOnly);
|
||||
) | 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) {
|
||||
if (nowHasIcon) {
|
||||
_tray.createIcon();
|
||||
|
@ -177,4 +181,8 @@ void Tray::toggleSoundNotifications() {
|
|||
}
|
||||
}
|
||||
|
||||
bool Tray::has() const {
|
||||
return _tray.hasIcon();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<> showFromTrayRequests() const;
|
||||
[[nodiscard]] rpl::producer<> hideToTrayRequests() const;
|
||||
|
||||
[[nodiscard]] bool has() const;
|
||||
|
||||
private:
|
||||
void rebuildMenu();
|
||||
void toggleSoundNotifications();
|
||||
|
|
|
@ -903,7 +903,7 @@ Core::WindowPosition MainWindow::SecondaryInitPosition() {
|
|||
}
|
||||
|
||||
bool MainWindow::minimizeToTray() {
|
||||
if (Core::Quitting()/* || !hasTrayIcon()*/) {
|
||||
if (Core::Quitting() || !Core::App().tray().has()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue