mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed lock by local passcode for non-primary windows.
This commit is contained in:
parent
9861370b75
commit
16e61ae2b2
2 changed files with 22 additions and 17 deletions
|
@ -438,27 +438,29 @@ void Application::startSystemDarkModeViewer() {
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::enumerateWindows(Fn<void(
|
||||||
|
not_null<Window::Controller*>)> callback) const {
|
||||||
|
if (_primaryWindow) {
|
||||||
|
callback(_primaryWindow.get());
|
||||||
|
}
|
||||||
|
for (const auto &window : ranges::views::values(_secondaryWindows)) {
|
||||||
|
callback(window.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::startTray() {
|
void Application::startTray() {
|
||||||
using WindowRaw = not_null<Window::Controller*>;
|
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->create();
|
||||||
_tray->aboutToShowRequests(
|
_tray->aboutToShowRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
enumerate([&](WindowRaw w) { w->updateIsActive(); });
|
enumerateWindows([&](WindowRaw w) { w->updateIsActive(); });
|
||||||
_tray->updateMenuText();
|
_tray->updateMenuText();
|
||||||
}, _primaryWindow->widget()->lifetime());
|
}, _primaryWindow->widget()->lifetime());
|
||||||
|
|
||||||
_tray->showFromTrayRequests(
|
_tray->showFromTrayRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto last = _lastActiveWindow;
|
const auto last = _lastActiveWindow;
|
||||||
enumerate([&](WindowRaw w) { w->widget()->showFromTray(); });
|
enumerateWindows([&](WindowRaw w) { w->widget()->showFromTray(); });
|
||||||
if (last) {
|
if (last) {
|
||||||
last->widget()->showFromTray();
|
last->widget()->showFromTray();
|
||||||
}
|
}
|
||||||
|
@ -466,7 +468,7 @@ void Application::startTray() {
|
||||||
|
|
||||||
_tray->hideToTrayRequests(
|
_tray->hideToTrayRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
enumerate([&](WindowRaw w) { w->widget()->minimizeToTray(); });
|
enumerateWindows([&](WindowRaw w) { w->widget()->minimizeToTray(); });
|
||||||
}, _primaryWindow->widget()->lifetime());
|
}, _primaryWindow->widget()->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,18 +1014,18 @@ void Application::preventOrInvoke(Fn<void()> &&callback) {
|
||||||
|
|
||||||
void Application::lockByPasscode() {
|
void Application::lockByPasscode() {
|
||||||
preventOrInvoke([=] {
|
preventOrInvoke([=] {
|
||||||
if (_primaryWindow) {
|
enumerateWindows([&](not_null<Window::Controller*> w) {
|
||||||
_passcodeLock = true;
|
_passcodeLock = true;
|
||||||
_primaryWindow->setupPasscodeLock();
|
w->setupPasscodeLock();
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::unlockPasscode() {
|
void Application::unlockPasscode() {
|
||||||
clearPasscodeLock();
|
clearPasscodeLock();
|
||||||
if (_primaryWindow) {
|
enumerateWindows([&](not_null<Window::Controller*> w) {
|
||||||
_primaryWindow->clearPasscodeLock();
|
w->clearPasscodeLock();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::clearPasscodeLock() {
|
void Application::clearPasscodeLock() {
|
||||||
|
|
|
@ -324,6 +324,9 @@ private:
|
||||||
void startSystemDarkModeViewer();
|
void startSystemDarkModeViewer();
|
||||||
void startTray();
|
void startTray();
|
||||||
|
|
||||||
|
void enumerateWindows(
|
||||||
|
Fn<void(not_null<Window::Controller*>)> callback) const;
|
||||||
|
|
||||||
friend void QuitAttempt();
|
friend void QuitAttempt();
|
||||||
void quitDelayed();
|
void quitDelayed();
|
||||||
[[nodiscard]] bool readyToQuit();
|
[[nodiscard]] bool readyToQuit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue