2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Remove app module. Support delayed quit by Cmd+Q on macOS.

This commit is contained in:
John Preston
2022-01-27 15:48:51 +03:00
parent b8f1cebeb6
commit 28f2c213f7
38 changed files with 319 additions and 350 deletions

View File

@@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/qt/qt_common_adapters.h"
#include "ui/ui_utility.h"
#include "ui/effects/animations.h"
#include "app.h"
#include <QtCore/QLockFile>
#include <QtGui/QSessionManager>
@@ -196,7 +195,7 @@ void Sandbox::QuitWhenStarted() {
void Sandbox::launchApplication() {
InvokeQueued(this, [=] {
if (App::quitting()) {
if (Quitting()) {
quit();
} else if (_application) {
return;
@@ -261,12 +260,12 @@ void Sandbox::setupScreenScale() {
Sandbox::~Sandbox() = default;
bool Sandbox::event(QEvent *e) {
if (e->type() == QEvent::Quit && !App::quitting()) {
App::quit();
if (e->type() == QEvent::Quit && !Quitting()) {
Quit(QuitReason::QtQuitEvent);
e->ignore();
return false;
} else if (e->type() == QEvent::Close) {
App::quit();
Quit();
}
return QApplication::event(e);
}
@@ -318,16 +317,16 @@ void Sandbox::socketReading() {
psActivateProcess(pid);
}
LOG(("Show command response received, pid = %1, activating and quitting...").arg(pid));
return App::quit();
return Quit();
}
}
void Sandbox::socketError(QLocalSocket::LocalSocketError e) {
if (App::quitting()) return;
if (Quitting()) return;
if (_secondInstance) {
LOG(("Could not write show command, error %1, quitting...").arg(e));
return App::quit();
return Quit();
}
if (e == QLocalSocket::ServerNotFoundError) {
@@ -343,7 +342,7 @@ void Sandbox::socketError(QLocalSocket::LocalSocketError e) {
if (!_localServer.listen(_localServerName)) {
LOG(("Failed to start listening to %1 server: %2").arg(_localServerName, _localServer.errorString()));
return App::quit();
return Quit();
}
#endif // !Q_OS_WINRT
@@ -352,11 +351,11 @@ void Sandbox::socketError(QLocalSocket::LocalSocketError e) {
&& Core::checkReadyUpdate()) {
cSetRestartingUpdate(true);
DEBUG_LOG(("Sandbox Info: installing update instead of starting app..."));
return App::quit();
return Quit();
}
if (cQuit()) {
return App::quit();
return Quit();
}
singleInstanceChecked();
@@ -407,7 +406,7 @@ void Sandbox::singleInstanceChecked() {
void Sandbox::socketDisconnected() {
if (_secondInstance) {
DEBUG_LOG(("Sandbox Error: socket disconnected before command response received, quitting..."));
return App::quit();
return Quit();
}
}
@@ -499,7 +498,7 @@ void Sandbox::removeClients() {
}
void Sandbox::checkForQuit() {
if (App::quitting()) {
if (Quitting()) {
quit();
}
}
@@ -633,10 +632,10 @@ MTP::ProxyData Sandbox::sandboxProxy() const {
}
void Sandbox::closeApplication() {
if (App::launchState() == App::QuitProcessed) {
if (CurrentLaunchState() == LaunchState::QuitProcessed) {
return;
}
App::setLaunchState(App::QuitProcessed);
SetLaunchState(LaunchState::QuitProcessed);
_application = nullptr;
@@ -660,7 +659,7 @@ void Sandbox::execExternal(const QString &cmd) {
PreLaunchWindow::instance()->activate();
}
} else if (cmd == "quit") {
App::quit();
Quit();
}
}