mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve quit prevent management.
This commit is contained in:
parent
79a361ba43
commit
70fdc4eb39
2 changed files with 27 additions and 9 deletions
|
@ -939,18 +939,35 @@ void Application::refreshGlobalProxy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::QuitAttempt() {
|
void Application::QuitAttempt() {
|
||||||
auto prevents = false;
|
if (!IsAppLaunched()
|
||||||
if (IsAppLaunched() && !Sandbox::Instance().isSavingSession()) {
|
|| Sandbox::Instance().isSavingSession()
|
||||||
if (const auto session = App().maybeActiveSession()) {
|
|| App().readyToQuit()) {
|
||||||
if (session->updates().isQuitPrevent()
|
QApplication::quit();
|
||||||
|| session->api().isQuitPrevent()
|
}
|
||||||
|| App().calls().isQuitPrevent()) {
|
}
|
||||||
App().quitDelayed();
|
|
||||||
return;
|
bool Application::readyToQuit() {
|
||||||
|
auto prevented = false;
|
||||||
|
if (_calls->isQuitPrevent()) {
|
||||||
|
prevented = true;
|
||||||
|
}
|
||||||
|
if (_domain->started()) {
|
||||||
|
for (const auto &[index, account] : _domain->accounts()) {
|
||||||
|
if (const auto session = account->maybeSession()) {
|
||||||
|
if (session->updates().isQuitPrevent()) {
|
||||||
|
prevented = true;
|
||||||
|
}
|
||||||
|
if (session->api().isQuitPrevent()) {
|
||||||
|
prevented = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QApplication::quit();
|
if (prevented) {
|
||||||
|
quitDelayed();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::quitPreventFinished() {
|
void Application::quitPreventFinished() {
|
||||||
|
|
|
@ -297,6 +297,7 @@ private:
|
||||||
friend void App::quit();
|
friend void App::quit();
|
||||||
static void QuitAttempt();
|
static void QuitAttempt();
|
||||||
void quitDelayed();
|
void quitDelayed();
|
||||||
|
[[nodiscard]] bool readyToQuit();
|
||||||
|
|
||||||
void clearPasscodeLock();
|
void clearPasscodeLock();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue