mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Simplify run-in-background option selection.
This commit is contained in:
parent
7d74d3da3a
commit
9dc947ecb6
5 changed files with 25 additions and 43 deletions
|
@ -593,10 +593,6 @@ bool SkipTaskbarSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RunInBackground() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ExecutablePathForShortcuts() {
|
QString ExecutablePathForShortcuts() {
|
||||||
if (Core::UpdaterDisabled()) {
|
if (Core::UpdaterDisabled()) {
|
||||||
const auto &arguments = Core::Launcher::Instance().arguments();
|
const auto &arguments = Core::Launcher::Instance().arguments();
|
||||||
|
|
|
@ -31,10 +31,6 @@ 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,7 +44,6 @@ 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();
|
||||||
|
|
|
@ -28,10 +28,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -575,35 +575,31 @@ void SetupSystemIntegrationContent(
|
||||||
Core::App().saveSettings();
|
Core::App().saveSettings();
|
||||||
}, roundIcon->lifetime());
|
}, roundIcon->lifetime());
|
||||||
#endif // OS_MAC_STORE
|
#endif // OS_MAC_STORE
|
||||||
#endif // Q_OS_MAC
|
#elif defined Q_OS_WIN // Q_OS_MAC
|
||||||
|
using Behavior = Core::Settings::CloseBehavior;
|
||||||
|
const auto closeToTaskbar = addSlidingCheckbox(
|
||||||
|
tr::lng_settings_close_to_taskbar(),
|
||||||
|
settings->closeBehavior() == Behavior::CloseToTaskbar);
|
||||||
|
|
||||||
if (!Platform::RunInBackground()) {
|
const auto closeToTaskbarShown = std::make_shared<
|
||||||
using Behavior = Core::Settings::CloseBehavior;
|
rpl::variable<bool>
|
||||||
const auto closeToTaskbar = addSlidingCheckbox(
|
>(false);
|
||||||
tr::lng_settings_close_to_taskbar(),
|
settings->workModeValue(
|
||||||
settings->closeBehavior() == Behavior::CloseToTaskbar);
|
) | rpl::start_with_next([=](WorkMode workMode) {
|
||||||
|
*closeToTaskbarShown = !Core::App().tray().has();
|
||||||
|
}, closeToTaskbar->lifetime());
|
||||||
|
|
||||||
const auto closeToTaskbarShown = std::make_shared<
|
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
||||||
rpl::variable<bool>
|
closeToTaskbar->entity()->checkedChanges(
|
||||||
>(false);
|
) | rpl::map([=](bool checked) {
|
||||||
settings->workModeValue(
|
return checked ? Behavior::CloseToTaskbar : Behavior::Quit;
|
||||||
) | rpl::start_with_next([=](WorkMode workMode) {
|
}) | rpl::filter([=](Behavior value) {
|
||||||
*closeToTaskbarShown = !Core::App().tray().has();
|
return (settings->closeBehavior() != value);
|
||||||
}, closeToTaskbar->lifetime());
|
}) | rpl::start_with_next([=](Behavior value) {
|
||||||
|
settings->setCloseBehavior(value);
|
||||||
closeToTaskbar->toggleOn(closeToTaskbarShown->value());
|
Local::writeSettings();
|
||||||
closeToTaskbar->entity()->checkedChanges(
|
}, closeToTaskbar->lifetime());
|
||||||
) | rpl::map([=](bool checked) {
|
#endif // Q_OS_MAC || Q_OS_WIN
|
||||||
return checked ? Behavior::CloseToTaskbar : Behavior::Quit;
|
|
||||||
}) | rpl::filter([=](Behavior value) {
|
|
||||||
return (settings->closeBehavior() != value);
|
|
||||||
}) | rpl::start_with_next([=](Behavior value) {
|
|
||||||
settings->setCloseBehavior(value);
|
|
||||||
Local::writeSettings();
|
|
||||||
}, closeToTaskbar->lifetime());
|
|
||||||
} else if (!Platform::IsMac()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Platform::AutostartSupported() && controller) {
|
if (Platform::AutostartSupported() && controller) {
|
||||||
const auto minimizedToggled = [=] {
|
const auto minimizedToggled = [=] {
|
||||||
|
@ -968,9 +964,7 @@ void SetupWindowTitle(
|
||||||
void SetupWindowCloseBehavior(
|
void SetupWindowCloseBehavior(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
if (Platform::IsMac() || !Platform::RunInBackground()) {
|
#if !defined Q_OS_WIN && !defined Q_OS_MAC
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto wrap = container->add(
|
const auto wrap = container->add(
|
||||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
container,
|
container,
|
||||||
|
@ -1023,6 +1017,7 @@ void SetupWindowCloseBehavior(
|
||||||
}) | rpl::distinct_until_changed(), anim::type::normal);
|
}) | rpl::distinct_until_changed(), anim::type::normal);
|
||||||
wrap->finishAnimating();
|
wrap->finishAnimating();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupSystemIntegration(
|
void SetupSystemIntegration(
|
||||||
|
|
Loading…
Add table
Reference in a new issue