2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Added common and macOS tray implementations.

This commit is contained in:
23rd
2022-04-21 01:39:01 +03:00
parent f67c3bbf65
commit 56fdc7d39a
7 changed files with 414 additions and 0 deletions

View File

@@ -414,6 +414,35 @@ void Application::startSystemDarkModeViewer() {
}
void Application::startTray() {
using WindowRaw = not_null<Window::Controller*>;
const auto enumerate = [=](Fn<void(WindowRaw)> c) {
if (_primaryWindow) {
c(_primaryWindow.get());
}
for (const auto &window : ranges::views::values(_secondaryWindows)) {
c(window.get());
}
};
_tray->create();
_tray->aboutToShowRequests(
) | rpl::start_with_next([=] {
enumerate([&](WindowRaw w) { w->updateIsActive(); });
_tray->updateMenuText();
}, _primaryWindow->widget()->lifetime());
_tray->showFromTrayRequests(
) | rpl::start_with_next([=] {
const auto last = _lastActiveWindow;
enumerate([&](WindowRaw w) { w->widget()->showFromTrayMenu(); });
if (last) {
last->widget()->showFromTrayMenu();
}
}, _primaryWindow->widget()->lifetime());
_tray->hideToTrayRequests(
) | rpl::start_with_next([=] {
enumerate([&](WindowRaw w) { w->widget()->minimizeToTray(); });
}, _primaryWindow->widget()->lifetime());
}
auto Application::prepareEmojiSourceImages()