mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +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()
|
||||
|| downloadPreventsQuit()) {
|
||||
return true;
|
||||
} else if (const auto window = activeWindow()) {
|
||||
if (window->widget()->isActive()) {
|
||||
return window->widget()->preventsQuit(reason);
|
||||
}
|
||||
} else if ((!_mediaView
|
||||
|| _mediaView->isHidden()
|
||||
|| !_mediaView->isFullScreen())
|
||||
&& Platform::PreventsQuit(reason)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ inline void WriteCrashDumpDetails() {
|
|||
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||
}
|
||||
|
||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void ActivateThisProcess() {
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ public:
|
|||
|
||||
void updateWindowIcon() override;
|
||||
|
||||
bool preventsQuit(Core::QuitReason reason) override;
|
||||
|
||||
class Private;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -29,7 +29,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/platform_specific.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/platform/mac/base_confirm_quit.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/about_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -261,19 +260,6 @@ void MainWindow::hideAndDeactivate() {
|
|||
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() {
|
||||
updateDockCounter();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/window_controller.h"
|
||||
#include "mainwindow.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/base_platform_info.h"
|
||||
|
||||
|
@ -187,6 +188,19 @@ bool AutostartSkip() {
|
|||
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() {
|
||||
const auto window = Core::App().activeWindow();
|
||||
objc_activateProgram(window ? window->widget()->winId() : 0);
|
||||
|
|
|
@ -7,6 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Core {
|
||||
enum class QuitReason;
|
||||
} // namespace Core
|
||||
|
||||
namespace Platform {
|
||||
|
||||
void start();
|
||||
|
@ -43,6 +47,8 @@ bool SkipTaskbarSupported();
|
|||
void WriteCrashDumpDetails();
|
||||
void NewVersionLaunched(int oldVersion);
|
||||
|
||||
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
|
||||
|
||||
[[nodiscard]] std::optional<bool> IsDarkMode();
|
||||
[[nodiscard]] inline bool IsDarkModeSupported() {
|
||||
return IsDarkMode().has_value();
|
||||
|
|
|
@ -27,6 +27,10 @@ inline bool SkipTaskbarSupported() {
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void ActivateThisProcess() {
|
||||
}
|
||||
|
||||
|
|
|
@ -134,10 +134,6 @@ public:
|
|||
updateGlobalMenuHook();
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual bool preventsQuit(Core::QuitReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
void leaveEventHook(QEvent *e) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue