mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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 void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool RunInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,10 @@ inline bool SkipTaskbarSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool RunInBackground() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ActivateThisProcess();
|
void ActivateThisProcess();
|
||||||
|
|
||||||
inline uint64 ActivationWindowId(not_null<QWidget*> window) {
|
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 AutostartSkip();
|
||||||
[[nodiscard]] bool TrayIconSupported();
|
[[nodiscard]] bool TrayIconSupported();
|
||||||
[[nodiscard]] bool SkipTaskbarSupported();
|
[[nodiscard]] bool SkipTaskbarSupported();
|
||||||
|
[[nodiscard]] bool RunInBackground();
|
||||||
void WriteCrashDumpDetails();
|
void WriteCrashDumpDetails();
|
||||||
void NewVersionLaunched(int oldVersion);
|
void NewVersionLaunched(int oldVersion);
|
||||||
[[nodiscard]] QImage DefaultApplicationIcon();
|
[[nodiscard]] QImage DefaultApplicationIcon();
|
||||||
|
|
|
@ -27,6 +27,10 @@ inline bool SkipTaskbarSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool RunInBackground() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool PreventsQuit(Core::QuitReason reason) {
|
inline bool PreventsQuit(Core::QuitReason reason) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,28 +550,29 @@ void SetupSystemIntegrationContent(
|
||||||
Core::App().saveSettings();
|
Core::App().saveSettings();
|
||||||
}, roundIcon->lifetime());
|
}, roundIcon->lifetime());
|
||||||
#endif // OS_MAC_STORE
|
#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
|
#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) {
|
if (Platform::AutostartSupported() && controller) {
|
||||||
const auto minimizedToggled = [=] {
|
const auto minimizedToggled = [=] {
|
||||||
return cStartMinimized()
|
return cStartMinimized()
|
||||||
|
|
|
@ -416,8 +416,8 @@ bool MainWindow::hideNoQuit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Platform::IsMac() || Core::App().settings().closeToTaskbar()) {
|
if (Platform::RunInBackground() || Core::App().settings().closeToTaskbar()) {
|
||||||
if (Platform::IsMac()) {
|
if (Platform::RunInBackground()) {
|
||||||
closeWithoutDestroy();
|
closeWithoutDestroy();
|
||||||
} else {
|
} else {
|
||||||
setWindowState(window()->windowState() | Qt::WindowMinimized);
|
setWindowState(window()->windowState() | Qt::WindowMinimized);
|
||||||
|
|
Loading…
Add table
Reference in a new issue