mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Allow disable Cmd+Q warning on macOS.
This commit is contained in:
parent
9eb20ede33
commit
ca21b7efae
6 changed files with 60 additions and 23 deletions
|
@ -389,6 +389,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_settings_auto_start_disabled_uwp" = "Starting with the system was disabled in Windows Settings.\n\nPlease enable Telegram Desktop in the Startup Apps Settings.";
|
||||
"lng_settings_open_system_settings" = "Open Settings";
|
||||
"lng_settings_add_sendto" = "Place Telegram in \"Send to\" menu";
|
||||
"lng_settings_mac_warn_before_quit" = "Show warning before quitting with {text}";
|
||||
"lng_settings_section_scale" = "Interface Scale";
|
||||
"lng_settings_scale_auto" = "Auto ({cur})";
|
||||
|
||||
|
@ -3065,6 +3066,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_mac_menu_preferences" = "Preferences...";
|
||||
"lng_mac_menu_quit_telegram" = "Quit {telegram}";
|
||||
"lng_mac_menu_about_telegram" = "About {telegram}";
|
||||
//"lng_mac_menu_warn_before_quit" = "Warn Before Quitting ({text})";
|
||||
"lng_mac_menu_file" = "File";
|
||||
"lng_mac_menu_logout" = "Log Out";
|
||||
"lng_mac_menu_edit" = "Edit";
|
||||
|
|
|
@ -227,7 +227,8 @@ QByteArray Settings::serialize() const {
|
|||
<< qint32(_closeToTaskbar.current() ? 1 : 0)
|
||||
<< _customDeviceModel.current()
|
||||
<< qint32(_playerRepeatMode.current())
|
||||
<< qint32(_playerOrderMode.current());
|
||||
<< qint32(_playerOrderMode.current())
|
||||
<< qint32(_macWarnBeforeQuit ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -314,6 +315,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
QString customDeviceModel = _customDeviceModel.current();
|
||||
qint32 playerRepeatMode = static_cast<qint32>(_playerRepeatMode.current());
|
||||
qint32 playerOrderMode = static_cast<qint32>(_playerOrderMode.current());
|
||||
qint32 macWarnBeforeQuit = _macWarnBeforeQuit ? 1 : 0;
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (!stream.atEnd()) {
|
||||
|
@ -482,6 +484,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
>> playerRepeatMode
|
||||
>> playerOrderMode;
|
||||
}
|
||||
if (!stream.atEnd()) {
|
||||
stream >> macWarnBeforeQuit;
|
||||
}
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
|
@ -636,6 +641,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
case Media::Player::OrderMode::Reverse:
|
||||
case Media::Player::OrderMode::Shuffle: _playerOrderMode = uncheckedPlayerOrderMode; break;
|
||||
}
|
||||
_macWarnBeforeQuit = macWarnBeforeQuit ? 1 : 0;
|
||||
}
|
||||
|
||||
QString Settings::getSoundPath(const QString &key) const {
|
||||
|
|
|
@ -657,6 +657,13 @@ public:
|
|||
return _playerOrderMode.changes();
|
||||
}
|
||||
|
||||
void setMacWarnBeforeQuit(bool value) {
|
||||
_macWarnBeforeQuit = value;
|
||||
}
|
||||
[[nodiscard]] bool macWarnBeforeQuit() const {
|
||||
return _macWarnBeforeQuit;
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool ThirdColumnByDefault();
|
||||
[[nodiscard]] static float64 DefaultDialogsWidthRatio();
|
||||
[[nodiscard]] static qint32 SerializePlaybackSpeed(float64 speed) {
|
||||
|
@ -760,6 +767,7 @@ private:
|
|||
rpl::variable<QString> _customDeviceModel;
|
||||
rpl::variable<Media::Player::RepeatMode> _playerRepeatMode;
|
||||
rpl::variable<Media::Player::OrderMode> _playerOrderMode;
|
||||
bool _macWarnBeforeQuit = true;
|
||||
|
||||
bool _tabbedReplacedWithInfo = false; // per-window
|
||||
rpl::event_stream<bool> _tabbedReplacedWithInfoValue; // per-window
|
||||
|
|
|
@ -289,9 +289,13 @@ 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] == NSKeyDown)
|
||||
&& !Platform::ConfirmQuit::RunModal(
|
||||
tr::lng_mac_hold_to_quit(tr::now, lt_text, "{key}"));
|
||||
tr::lng_mac_hold_to_quit(
|
||||
tr::now,
|
||||
lt_text,
|
||||
Platform::ConfirmQuit::QuitKeysString()));
|
||||
}
|
||||
|
||||
void MainWindow::psTrayMenuUpdated() {
|
||||
|
|
|
@ -38,6 +38,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/facade.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "base/platform/mac/base_confirm_quit.h"
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_SPELLCHECK
|
||||
#include "boxes/dictionaries_manager.h"
|
||||
#include "chat_helpers/spellchecker_common.h"
|
||||
|
@ -399,7 +403,7 @@ void SetupSystemIntegrationContent(
|
|||
cSetSeenTrayTooltip(false);
|
||||
}
|
||||
Core::App().settings().setWorkMode(newMode);
|
||||
Local::writeSettings();
|
||||
Core::App().saveSettingsDelayed();
|
||||
};
|
||||
|
||||
tray->checkedChanges(
|
||||
|
@ -427,27 +431,40 @@ void SetupSystemIntegrationContent(
|
|||
}
|
||||
}
|
||||
|
||||
if (!Platform::IsMac()) {
|
||||
const auto closeToTaskbar = addSlidingCheckbox(
|
||||
tr::lng_settings_close_to_taskbar(),
|
||||
Core::App().settings().closeToTaskbar());
|
||||
#ifdef Q_OS_MAC
|
||||
const auto warnBeforeQuit = addCheckbox(
|
||||
tr::lng_settings_mac_warn_before_quit(
|
||||
lt_text,
|
||||
rpl::single(Platform::ConfirmQuit::QuitKeysString())),
|
||||
Core::App().settings().macWarnBeforeQuit());
|
||||
warnBeforeQuit->checkedChanges(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != Core::App().settings().macWarnBeforeQuit());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
Core::App().settings().setMacWarnBeforeQuit(checked);
|
||||
Core::App().saveSettingsDelayed();
|
||||
}, warnBeforeQuit->lifetime());
|
||||
#else // Q_OS_MAC
|
||||
const auto closeToTaskbar = addSlidingCheckbox(
|
||||
tr::lng_settings_close_to_taskbar(),
|
||||
Core::App().settings().closeToTaskbar());
|
||||
|
||||
const auto closeToTaskbarShown = std::make_shared<rpl::variable<bool>>(false);
|
||||
Core::App().settings().workModeValue(
|
||||
) | rpl::start_with_next([=](WorkMode workMode) {
|
||||
*closeToTaskbarShown = (workMode == WorkMode::WindowOnly)
|
||||
|| !Platform::TrayIconSupported();
|
||||
}, closeToTaskbar->lifetime());
|
||||
const auto closeToTaskbarShown = std::make_shared<rpl::variable<bool>>(false);
|
||||
Core::App().settings().workModeValue(
|
||||
) | rpl::start_with_next([=](WorkMode workMode) {
|
||||
*closeToTaskbarShown = (workMode == WorkMode::WindowOnly)
|
||||
|| !Platform::TrayIconSupported();
|
||||
}, closeToTaskbar->lifetime());
|
||||
|
||||
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
||||
closeToTaskbar->entity()->checkedChanges(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != Core::App().settings().closeToTaskbar());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
Core::App().settings().setCloseToTaskbar(checked);
|
||||
Local::writeSettings();
|
||||
}, closeToTaskbar->lifetime());
|
||||
}
|
||||
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
||||
closeToTaskbar->entity()->checkedChanges(
|
||||
) | rpl::filter([=](bool checked) {
|
||||
return (checked != Core::App().settings().closeToTaskbar());
|
||||
}) | rpl::start_with_next([=](bool checked) {
|
||||
Core::App().settings().setCloseToTaskbar(checked);
|
||||
Local::writeSettings();
|
||||
}, closeToTaskbar->lifetime());
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
if (Ui::Platform::NativeWindowFrameSupported()) {
|
||||
const auto nativeFrame = addCheckbox(
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fdd2714a2ae0a42ff1ee06c4ae6815a3fd575a2e
|
||||
Subproject commit 5d99fef79a9a311896199b223a0325c0998f9c9a
|
Loading…
Add table
Reference in a new issue