public void Update(PowerLauncherPluginSettings setting, IPublicAPI api) { if (setting == null || api == null) { return; } if (Metadata.Disabled && !setting.Disabled) { Metadata.Disabled = false; InitializePlugin(api); if (!IsPluginInitialized) { var title = string.Format(CultureInfo.CurrentCulture, Resources.FailedToLoadPluginTitle, Metadata.Name); api.ShowMsg(title, Resources.FailedToLoadPluginDescription, string.Empty, false); } } else { Metadata.Disabled = setting.Disabled; } Metadata.ActionKeyword = setting.ActionKeyword; Metadata.IsGlobal = setting.IsGlobal; if (Plugin is ISettingProvider) { (Plugin as ISettingProvider).UpdateSettings(setting); } }
/// <summary> /// Return one <see cref="bool"/> setting of the given settings list with the given name. /// </summary> /// <param name="settings">The object that contain all settings.</param> /// <param name="name">The name of the setting.</param> /// <returns>A settings value.</returns> private static bool GetSettingOrDefault(PowerLauncherPluginSettings settings, string name) { var option = settings?.AdditionalOptions?.FirstOrDefault(x => x.Key == name); // If a setting isn't available, we use the value defined in the method GetAdditionalOptions() as fallback. // We can use First() instead of FirstOrDefault() because the values must exist. Otherwise, we made a mistake when defining the settings. return(option?.Value ?? GetAdditionalOptions().First(x => x.Key == name).Value); }
/// <summary> /// Return one <see cref="bool"/> setting of the given settings list with the given name. /// </summary> /// <param name="settings">The object that contain all settings.</param> /// <param name="name">The name of the setting.</param> /// <returns>A settings value.</returns> private static bool GetSettingOrDefault(PowerLauncherPluginSettings settings, string name) { var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == name); // As a fall-back if a setting isn't available, we use the value defined in the method GetAdditionalOptions() var settingsValue = option?.Value ?? GetAdditionalOptions().FirstOrDefault(x => x.Key == name)?.Value ?? default; return(settingsValue); }
/// <summary> /// Update this settings. /// </summary> /// <param name="settings">The settings for all power launcher plugin.</param> internal void UpdateSettings(PowerLauncherPluginSettings settings) { if (settings is null || settings.AdditionalOptions is null) { return; } ShowTimeZoneNames = GetSettingOrDefault(settings, "ShowTimeZoneNames"); ShowTimeNames = GetSettingOrDefault(settings, "ShowTimeNames"); ShowMilitaryTimeZoneNames = GetSettingOrDefault(settings, "ShowMilitaryTimeZoneNames"); }
/// <summary> /// Update this settings. /// </summary> /// <param name="settings">The settings for all power launcher plugins.</param> internal void UpdateSettings(PowerLauncherPluginSettings settings) { if ((settings is null || settings.AdditionalOptions is null) & _initialized) { return; } OnlyDateTimeNowGlobal = GetSettingOrDefault(settings, nameof(OnlyDateTimeNowGlobal)); TimeWithSeconds = GetSettingOrDefault(settings, nameof(TimeWithSeconds)); DateWithWeekday = GetSettingOrDefault(settings, nameof(DateWithWeekday)); HideNumberMessageOnGlobalQuery = GetSettingOrDefault(settings, nameof(HideNumberMessageOnGlobalQuery)); }
public void UpdateSettings(PowerLauncherPluginSettings settings) { var driveDetection = false; if (settings.AdditionalOptions != null) { var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == DisableDriveDetectionWarning); driveDetection = option == null ? false : option.Value; } _driveDetection.IsDriveDetectionWarningCheckBoxSelected = driveDetection; }
public void UpdateSettings(PowerLauncherPluginSettings settings) { var confirmSystemCommands = false; if (settings != null && settings.AdditionalOptions != null) { var option = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ConfirmSystemCommands); confirmSystemCommands = option == null ? false : option.Value; } _confirmSystemCommands = confirmSystemCommands; }
public void UpdateSettings(PowerLauncherPluginSettings settings) { var openNewTab = false; var showHiddenProfiles = false; if (settings != null && settings.AdditionalOptions != null) { openNewTab = settings.AdditionalOptions.FirstOrDefault(x => x.Key == OpenNewTab)?.Value ?? false; showHiddenProfiles = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ShowHiddenProfiles)?.Value ?? false; } _openNewTab = openNewTab; _showHiddenProfiles = showHiddenProfiles; }
/// <summary> /// Update this settings. /// </summary> /// <param name="settings">The settings for all power launcher plugins.</param> internal void UpdateSettings(PowerLauncherPluginSettings settings) { if ((settings is null || settings.AdditionalOptions is null) & _initialized) { return; } ResultsFromVisibleDesktopOnly = GetSettingOrDefault(settings, nameof(ResultsFromVisibleDesktopOnly)); SubtitleShowPid = GetSettingOrDefault(settings, nameof(SubtitleShowPid)); SubtitleShowDesktopName = GetSettingOrDefault(settings, nameof(SubtitleShowDesktopName)); ConfirmKillProcess = GetSettingOrDefault(settings, nameof(ConfirmKillProcess)); KillProcessTree = GetSettingOrDefault(settings, nameof(KillProcessTree)); OpenAfterKillAndClose = GetSettingOrDefault(settings, nameof(OpenAfterKillAndClose)); HideKillProcessOnElevatedProcesses = GetSettingOrDefault(settings, nameof(HideKillProcessOnElevatedProcesses)); HideExplorerSettingInfo = GetSettingOrDefault(settings, nameof(HideExplorerSettingInfo)); }
public PowerLauncherPluginViewModel(PowerLauncherPluginSettings settings, Func <bool> isDark) { if (settings == null) { throw new ArgumentNullException(nameof(settings), "PowerLauncherPluginSettings object is null"); } this.settings = settings; this.isDark = isDark; foreach (var item in AdditionalOptions) { item.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { NotifyPropertyChanged(nameof(AdditionalOptions)); }; } }
public void UpdateSettings(PowerLauncherPluginSettings settings) { var confirmSystemCommands = false; var localizeSystemCommands = true; if (settings != null && settings.AdditionalOptions != null) { var optionConfirm = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ConfirmSystemCommands); confirmSystemCommands = optionConfirm?.Value ?? false; var optionLocalize = settings.AdditionalOptions.FirstOrDefault(x => x.Key == LocalizeSystemCommands); localizeSystemCommands = optionLocalize?.Value ?? true; } _confirmSystemCommands = confirmSystemCommands; _localizeSystemCommands = localizeSystemCommands; }
public void UpdateSettings(PowerLauncherPluginSettings settings) { var confirmSystemCommands = false; var localizeSystemCommands = true; var reduceNetworkResultScore = true; if (settings != null && settings.AdditionalOptions != null) { var optionConfirm = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ConfirmSystemCommands"); confirmSystemCommands = optionConfirm?.Value ?? confirmSystemCommands; var optionLocalize = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "LocalizeSystemCommands"); localizeSystemCommands = optionLocalize?.Value ?? localizeSystemCommands; var optionNetworkScore = settings.AdditionalOptions.FirstOrDefault(x => x.Key == "ReduceNetworkResultScore"); reduceNetworkResultScore = optionNetworkScore?.Value ?? reduceNetworkResultScore; } _confirmSystemCommands = confirmSystemCommands; _localizeSystemCommands = localizeSystemCommands; _reduceNetworkResultScore = reduceNetworkResultScore; }
public void UpdateSettings(PowerLauncherPluginSettings settings) { TimeDateSettings.Instance.UpdateSettings(settings); }
public void UpdateSettings(PowerLauncherPluginSettings settings) { _notGlobalIfUri = settings?.AdditionalOptions?.FirstOrDefault(x => x.Key == NotGlobalIfUri)?.Value ?? false; }
/// <summary> /// Update the plugin settings /// </summary> /// <param name="settings">The settings for all power launcher plugin.</param> public void UpdateSettings(PowerLauncherPluginSettings settings) { _timeZoneSettings.UpdateSettings(settings); }
public void UpdateSettings(PowerLauncherPluginSettings settings) { WindowWalkerSettings.Instance.UpdateSettings(settings); }