mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Add a method to check whether to run in background instead of checking for macOS
This commit is contained in:
parent
0bf0fb29d2
commit
e8a1fc0300
6 changed files with 36 additions and 22 deletions
|
@ -24,6 +24,10 @@ inline void WriteCrashDumpDetails() {
|
|||
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||
}
|
||||
|
||||
inline bool RunInBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@ inline bool SkipTaskbarSupported() {
|
|||
return false;
|
||||
}
|
||||
|
||||
inline bool RunInBackground() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ActivateThisProcess();
|
||||
|
||||
inline uint64 ActivationWindowId(not_null<QWidget*> window) {
|
||||
|
|
|
@ -44,6 +44,7 @@ void AutostartToggle(bool enabled, Fn<void(bool)> done = nullptr);
|
|||
[[nodiscard]] bool AutostartSkip();
|
||||
[[nodiscard]] bool TrayIconSupported();
|
||||
[[nodiscard]] bool SkipTaskbarSupported();
|
||||
[[nodiscard]] bool RunInBackground();
|
||||
void WriteCrashDumpDetails();
|
||||
void NewVersionLaunched(int oldVersion);
|
||||
[[nodiscard]] QImage DefaultApplicationIcon();
|
||||
|
|
|
@ -27,6 +27,10 @@ inline bool SkipTaskbarSupported() {
|
|||
return true;
|
||||
}
|
||||
|
||||
inline bool RunInBackground() {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -550,28 +550,29 @@ void SetupSystemIntegrationContent(
|
|||
Core::App().saveSettings();
|
||||
}, roundIcon->lifetime());
|
||||
#endif // OS_MAC_STORE
|
||||
|
||||
#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 = !Core::App().tray().has();
|
||||
}, 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 (!Platform::RunInBackground()) {
|
||||
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 = !Core::App().tray().has();
|
||||
}, 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());
|
||||
}
|
||||
|
||||
if (Platform::AutostartSupported() && controller) {
|
||||
const auto minimizedToggled = [=] {
|
||||
return cStartMinimized()
|
||||
|
|
|
@ -416,8 +416,8 @@ bool MainWindow::hideNoQuit() {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (Platform::IsMac() || Core::App().settings().closeToTaskbar()) {
|
||||
if (Platform::IsMac()) {
|
||||
if (Platform::RunInBackground() || Core::App().settings().closeToTaskbar()) {
|
||||
if (Platform::RunInBackground()) {
|
||||
closeWithoutDestroy();
|
||||
} else {
|
||||
setWindowState(window()->windowState() | Qt::WindowMinimized);
|
||||
|
|
Loading…
Add table
Reference in a new issue