MSIX: hide the "Run at Startup" option if running as packaged

This commit is contained in:
yuyoyuppe 2020-01-29 14:59:51 +03:00 committed by yuyoyuppe
parent ee8893a884
commit ca203435d1
3 changed files with 15 additions and 7 deletions

View File

@ -6,6 +6,7 @@
#include <common/settings_helpers.h> #include <common/settings_helpers.h>
#include "powertoy_module.h" #include "powertoy_module.h"
#include <common/windows_colors.h> #include <common/windows_colors.h>
#include <common/winstore.h>
static std::wstring settings_theme = L"system"; static std::wstring settings_theme = L"system";
static bool run_as_elevated = false; static bool run_as_elevated = false;
@ -25,6 +26,10 @@ json::JsonObject load_general_settings()
json::JsonObject get_general_settings() json::JsonObject get_general_settings()
{ {
json::JsonObject result; json::JsonObject result;
const bool packaged = running_as_packaged();
result.SetNamedValue(L"packaged", json::value(packaged));
const bool startup = is_auto_start_task_active_for_this_user(); const bool startup = is_auto_start_task_active_for_this_user();
result.SetNamedValue(L"startup", json::value(startup)); result.SetNamedValue(L"startup", json::value(startup));
@ -50,7 +55,7 @@ void apply_general_settings(const json::JsonObject& general_configs)
{ {
const bool startup = general_configs.GetNamedBoolean(L"startup"); const bool startup = general_configs.GetNamedBoolean(L"startup");
const bool current_startup = is_auto_start_task_active_for_this_user(); const bool current_startup = is_auto_start_task_active_for_this_user();
if (current_startup != startup) if (!running_as_packaged() && current_startup != startup)
{ {
if (startup) if (startup)
{ {

View File

@ -121,11 +121,14 @@ export class GeneralSettings extends React.Component <any, any> {
} }
<Separator /> <Separator />
<Text variant='xLarge'>General</Text> <Text variant='xLarge'>General</Text>
<BoolToggleSettingsControl {!this.state.settings.general.packaged &&
setting={{display_name: 'Run at Startup', value: this.state.settings.general.startup}} (
on_change={this.parent_on_change} <BoolToggleSettingsControl
ref={(input) => {this.startup_reference=input;}} setting={{display_name: 'Run at Startup', value: this.state.settings.general.startup}}
/> on_change={this.parent_on_change}
ref={(input) => {this.startup_reference=input;}}
/>
)}
<BoolToggleSettingsControl <BoolToggleSettingsControl
setting={{display_name: 'Always run as administrator', value: this.state.settings.general.run_elevated}} setting={{display_name: 'Always run as administrator', value: this.state.settings.general.run_elevated}}
on_change={this.parent_on_change} on_change={this.parent_on_change}

File diff suppressed because one or more lines are too long