Add Platform::AutostartSupported

This commit is contained in:
Ilya Fedin 2020-05-29 21:49:39 +04:00 committed by John Preston
parent 413ddf285e
commit e098922a4b
6 changed files with 22 additions and 2 deletions

View File

@ -174,6 +174,10 @@ void Application::run() {
psNewVersion();
}
if (cAutoStart() && !Platform::AutostartSupported()) {
cSetAutoStart(false);
}
if (cLaunchMode() == LaunchModeAutoStart && !cAutoStart()) {
psAutoStart(false, true);
App::quit();

View File

@ -516,6 +516,13 @@ std::optional<crl::time> LastUserInputTime() {
return std::nullopt;
}
bool AutostartSupported() {
// snap sandbox doesn't allow creating files in folders with names started with a dot
// and doesn't provide any api to add an app to autostart
// thus, autostart isn't supported in snap
return !InSnap();
}
void FallbackFontConfigCheckBegin() {
if (!CheckFontConfigCrash()) {
return;

View File

@ -262,6 +262,10 @@ void IgnoreApplicationActivationRightNow() {
objc_ignoreApplicationActivationRightNow();
}
bool AutostartSupported() {
return false;
}
} // namespace Platform
void psNewVersion() {

View File

@ -40,6 +40,7 @@ bool OpenSystemSettings(SystemSettingsType type);
}
void IgnoreApplicationActivationRightNow();
bool AutostartSupported();
namespace ThirdParty {

View File

@ -381,6 +381,10 @@ std::optional<crl::time> LastUserInputTime() {
return LastTrackedWhen;
}
bool AutostartSupported() {
return !IsWindowsStoreBuild();
}
} // namespace Platform
namespace {

View File

@ -404,8 +404,7 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
}, taskbar->lifetime());
}
#ifndef OS_WIN_STORE
if (Platform::IsWindows() || Platform::IsLinux()) {
if (Platform::AutostartSupported()) {
const auto minimizedToggled = [] {
return cStartMinimized() && !Global::LocalPasscode();
};
@ -454,6 +453,7 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
}, minimized->lifetime());
}
#ifndef OS_WIN_STORE
if (Platform::IsWindows()) {
const auto sendto = addCheckbox(
tr::lng_settings_add_sendto(tr::now),