mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Cmd+Q quit prevention in windowed media viewer.
This commit is contained in:
parent
2a1e3c4453
commit
f9847090f9
8 changed files with 33 additions and 24 deletions
|
@ -983,10 +983,11 @@ bool Application::preventsQuit(QuitReason reason) {
|
||||||
|| uploadPreventsQuit()
|
|| uploadPreventsQuit()
|
||||||
|| downloadPreventsQuit()) {
|
|| downloadPreventsQuit()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (const auto window = activeWindow()) {
|
} else if ((!_mediaView
|
||||||
if (window->widget()->isActive()) {
|
|| _mediaView->isHidden()
|
||||||
return window->widget()->preventsQuit(reason);
|
|| !_mediaView->isFullScreen())
|
||||||
}
|
&& Platform::PreventsQuit(reason)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ inline void WriteCrashDumpDetails() {
|
||||||
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void ActivateThisProcess() {
|
inline void ActivateThisProcess() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ public:
|
||||||
|
|
||||||
void updateWindowIcon() override;
|
void updateWindowIcon() override;
|
||||||
|
|
||||||
bool preventsQuit(Core::QuitReason reason) override;
|
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/mac/base_confirm_quit.h"
|
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/about_box.h"
|
#include "boxes/about_box.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -261,19 +260,6 @@ void MainWindow::hideAndDeactivate() {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::preventsQuit(Core::QuitReason reason) {
|
|
||||||
// Thanks Chromium, see
|
|
||||||
// chromium.org/developers/design-documents/confirm-to-quit-experiment
|
|
||||||
return (reason == Core::QuitReason::QtQuitEvent)
|
|
||||||
&& Core::App().settings().macWarnBeforeQuit()
|
|
||||||
&& ([[NSApp currentEvent] type] == NSEventTypeKeyDown)
|
|
||||||
&& !Platform::ConfirmQuit::RunModal(
|
|
||||||
tr::lng_mac_hold_to_quit(
|
|
||||||
tr::now,
|
|
||||||
lt_text,
|
|
||||||
Platform::ConfirmQuit::QuitKeysString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::unreadCounterChangedHook() {
|
void MainWindow::unreadCounterChangedHook() {
|
||||||
updateDockCounter();
|
updateDockCounter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "history/history_location_manager.h"
|
#include "history/history_location_manager.h"
|
||||||
|
#include "base/platform/mac/base_confirm_quit.h"
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
|
@ -187,6 +188,19 @@ bool AutostartSkip() {
|
||||||
void NewVersionLaunched(int oldVersion) {
|
void NewVersionLaunched(int oldVersion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PreventsQuit(Core::QuitReason reason) {
|
||||||
|
// Thanks Chromium, see
|
||||||
|
// chromium.org/developers/design-documents/confirm-to-quit-experiment
|
||||||
|
return (reason == Core::QuitReason::QtQuitEvent)
|
||||||
|
&& Core::App().settings().macWarnBeforeQuit()
|
||||||
|
&& ([[NSApp currentEvent] type] == NSEventTypeKeyDown)
|
||||||
|
&& !ConfirmQuit::RunModal(
|
||||||
|
tr::lng_mac_hold_to_quit(
|
||||||
|
tr::now,
|
||||||
|
lt_text,
|
||||||
|
ConfirmQuit::QuitKeysString()));
|
||||||
|
}
|
||||||
|
|
||||||
void ActivateThisProcess() {
|
void ActivateThisProcess() {
|
||||||
const auto window = Core::App().activeWindow();
|
const auto window = Core::App().activeWindow();
|
||||||
objc_activateProgram(window ? window->widget()->winId() : 0);
|
objc_activateProgram(window ? window->widget()->winId() : 0);
|
||||||
|
|
|
@ -7,6 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
enum class QuitReason;
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
@ -43,6 +47,8 @@ bool SkipTaskbarSupported();
|
||||||
void WriteCrashDumpDetails();
|
void WriteCrashDumpDetails();
|
||||||
void NewVersionLaunched(int oldVersion);
|
void NewVersionLaunched(int oldVersion);
|
||||||
|
|
||||||
|
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
|
||||||
|
|
||||||
[[nodiscard]] std::optional<bool> IsDarkMode();
|
[[nodiscard]] std::optional<bool> IsDarkMode();
|
||||||
[[nodiscard]] inline bool IsDarkModeSupported() {
|
[[nodiscard]] inline bool IsDarkModeSupported() {
|
||||||
return IsDarkMode().has_value();
|
return IsDarkMode().has_value();
|
||||||
|
|
|
@ -27,6 +27,10 @@ inline bool SkipTaskbarSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void ActivateThisProcess() {
|
inline void ActivateThisProcess() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,6 @@ public:
|
||||||
updateGlobalMenuHook();
|
updateGlobalMenuHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual bool preventsQuit(Core::QuitReason reason) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void leaveEventHook(QEvent *e) override;
|
void leaveEventHook(QEvent *e) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue