2020-08-18 01:00:56 +08:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
// See the LICENSE file in the project root for more information.
|
2020-08-19 23:12:07 +08:00
|
|
|
|
|
|
|
using System;
|
2021-02-26 19:21:58 +08:00
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.ComponentModel;
|
2020-10-20 04:32:05 +08:00
|
|
|
using System.Globalization;
|
2021-02-26 19:21:58 +08:00
|
|
|
using System.Linq;
|
2020-08-18 01:00:56 +08:00
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Text.Json;
|
2021-08-12 20:53:12 +08:00
|
|
|
using System.Windows.Input;
|
2022-10-26 21:02:31 +08:00
|
|
|
using global::PowerToys.GPOWrapper;
|
2020-10-24 06:05:07 +08:00
|
|
|
using ManagedCommon;
|
2022-10-26 21:02:31 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.Library;
|
2020-10-23 00:45:48 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
2021-08-12 20:53:12 +08:00
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
|
2020-08-18 01:00:56 +08:00
|
|
|
|
2022-10-26 21:02:31 +08:00
|
|
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
|
|
|
public class PowerLauncherViewModel : Observable
|
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
private int _themeIndex;
|
|
|
|
private int _monitorPositionIndex;
|
2021-03-10 01:20:49 +08:00
|
|
|
|
2022-10-26 21:02:31 +08:00
|
|
|
private GpoRuleConfigured _enabledGpoRuleConfiguration;
|
|
|
|
private bool _enabledStateIsGPOConfigured;
|
|
|
|
private bool _isEnabled;
|
2021-08-12 20:53:12 +08:00
|
|
|
private string _searchText;
|
|
|
|
|
2020-09-24 04:20:32 +08:00
|
|
|
private GeneralSettings GeneralSettingsConfig { get; set; }
|
|
|
|
|
2020-08-18 01:00:56 +08:00
|
|
|
private PowerLauncherSettings settings;
|
|
|
|
|
|
|
|
public delegate void SendCallback(PowerLauncherSettings settings);
|
|
|
|
|
|
|
|
private readonly SendCallback callback;
|
|
|
|
|
2021-02-26 19:21:58 +08:00
|
|
|
private readonly Func<bool> isDark;
|
|
|
|
|
2020-08-19 23:12:07 +08:00
|
|
|
private Func<string, int> SendConfigMSG { get; }
|
|
|
|
|
2022-10-13 15:46:30 +08:00
|
|
|
public PowerLauncherViewModel(
|
|
|
|
PowerLauncherSettings settings,
|
|
|
|
ISettingsRepository<GeneralSettings> settingsRepository,
|
|
|
|
Func<string, int> ipcMSGCallBackFunc,
|
|
|
|
Func<bool> isDark)
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
2021-03-15 20:52:03 +08:00
|
|
|
if (settings == null)
|
|
|
|
{
|
|
|
|
throw new ArgumentException("settings argument can not be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.settings = settings;
|
2021-02-26 19:21:58 +08:00
|
|
|
this.isDark = isDark;
|
2020-09-22 01:14:44 +08:00
|
|
|
|
2020-09-24 04:20:32 +08:00
|
|
|
// To obtain the general Settings configurations of PowerToys
|
2020-10-20 04:32:05 +08:00
|
|
|
if (settingsRepository == null)
|
|
|
|
{
|
|
|
|
throw new ArgumentNullException(nameof(settingsRepository));
|
|
|
|
}
|
|
|
|
|
2020-09-24 04:20:32 +08:00
|
|
|
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
|
|
|
|
2023-01-31 07:00:11 +08:00
|
|
|
InitializeEnabledValue();
|
2022-10-26 21:02:31 +08:00
|
|
|
|
2020-09-11 00:44:10 +08:00
|
|
|
// set the callback functions value to hangle outgoing IPC message.
|
|
|
|
SendConfigMSG = ipcMSGCallBackFunc;
|
2021-03-15 20:52:03 +08:00
|
|
|
callback = (PowerLauncherSettings s) =>
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
2020-09-11 00:44:10 +08:00
|
|
|
// Propagate changes to Power Launcher through IPC
|
2020-10-20 04:32:05 +08:00
|
|
|
// Using InvariantCulture as this is an IPC message
|
2020-09-11 00:44:10 +08:00
|
|
|
SendConfigMSG(
|
2020-10-20 04:32:05 +08:00
|
|
|
string.Format(
|
|
|
|
CultureInfo.InvariantCulture,
|
|
|
|
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
|
|
|
|
PowerLauncherSettings.ModuleName,
|
2021-03-15 20:52:03 +08:00
|
|
|
JsonSerializer.Serialize(s)));
|
2020-09-11 00:44:10 +08:00
|
|
|
};
|
2020-09-24 04:20:32 +08:00
|
|
|
|
2020-10-24 06:05:07 +08:00
|
|
|
switch (settings.Properties.Theme)
|
|
|
|
{
|
|
|
|
case Theme.Dark:
|
2021-08-24 01:48:52 +08:00
|
|
|
_themeIndex = 0;
|
|
|
|
break;
|
|
|
|
case Theme.Light:
|
|
|
|
_themeIndex = 1;
|
2020-10-24 06:05:07 +08:00
|
|
|
break;
|
|
|
|
case Theme.System:
|
2021-08-24 01:48:52 +08:00
|
|
|
_themeIndex = 2;
|
2020-10-24 06:05:07 +08:00
|
|
|
break;
|
|
|
|
}
|
2021-02-26 19:21:58 +08:00
|
|
|
|
2021-03-10 01:20:49 +08:00
|
|
|
switch (settings.Properties.Position)
|
|
|
|
{
|
|
|
|
case StartupPosition.Cursor:
|
2021-08-24 01:48:52 +08:00
|
|
|
_monitorPositionIndex = 0;
|
2021-03-10 01:20:49 +08:00
|
|
|
break;
|
|
|
|
case StartupPosition.PrimaryMonitor:
|
2021-08-24 01:48:52 +08:00
|
|
|
_monitorPositionIndex = 1;
|
2021-03-10 01:20:49 +08:00
|
|
|
break;
|
|
|
|
case StartupPosition.Focus:
|
2021-08-24 01:48:52 +08:00
|
|
|
_monitorPositionIndex = 2;
|
2021-03-10 01:20:49 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-08-12 20:53:12 +08:00
|
|
|
SearchPluginsCommand = new RelayCommand(SearchPlugins);
|
2021-02-26 19:21:58 +08:00
|
|
|
}
|
|
|
|
|
2023-01-31 07:00:11 +08:00
|
|
|
private void InitializeEnabledValue()
|
|
|
|
{
|
|
|
|
_enabledGpoRuleConfiguration = GPOWrapper.GetConfiguredPowerLauncherEnabledValue();
|
|
|
|
if (_enabledGpoRuleConfiguration == GpoRuleConfigured.Disabled || _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled)
|
|
|
|
{
|
|
|
|
// Get the enabled state from GPO.
|
|
|
|
_enabledStateIsGPOConfigured = true;
|
|
|
|
_isEnabled = _enabledGpoRuleConfiguration == GpoRuleConfigured.Enabled;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_isEnabled = GeneralSettingsConfig.Enabled.PowerLauncher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-26 19:21:58 +08:00
|
|
|
private void OnPluginInfoChange(object sender, PropertyChangedEventArgs e)
|
|
|
|
{
|
2022-04-01 21:50:16 +08:00
|
|
|
if (
|
|
|
|
e.PropertyName == nameof(PowerLauncherPluginViewModel.ShowNotAccessibleWarning)
|
2022-08-24 04:28:41 +08:00
|
|
|
|| e.PropertyName == nameof(PowerLauncherPluginViewModel.ShowBadgeOnPluginSettingError)
|
2022-04-01 21:50:16 +08:00
|
|
|
)
|
|
|
|
{
|
|
|
|
// Don't trigger a settings update if the changed property is for visual notification.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-26 19:21:58 +08:00
|
|
|
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
|
|
|
UpdateSettings();
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)
|
|
|
|
{
|
|
|
|
this.settings = settings;
|
|
|
|
this.callback = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UpdateSettings([CallerMemberName] string propertyName = null)
|
|
|
|
{
|
|
|
|
// Notify UI of property change
|
|
|
|
OnPropertyChanged(propertyName);
|
|
|
|
|
|
|
|
callback(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool EnablePowerLauncher
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2022-10-26 21:02:31 +08:00
|
|
|
return _isEnabled;
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
2022-10-26 21:02:31 +08:00
|
|
|
if (_enabledStateIsGPOConfigured)
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
2022-10-26 21:02:31 +08:00
|
|
|
// If it's GPO configured, shouldn't be able to change this state.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_isEnabled != value)
|
|
|
|
{
|
|
|
|
_isEnabled = value;
|
2020-09-24 04:20:32 +08:00
|
|
|
GeneralSettingsConfig.Enabled.PowerLauncher = value;
|
2020-08-18 01:00:56 +08:00
|
|
|
OnPropertyChanged(nameof(EnablePowerLauncher));
|
2021-02-26 19:21:58 +08:00
|
|
|
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
2021-03-15 20:52:03 +08:00
|
|
|
OnPropertyChanged(nameof(ShowPluginsLoadingMessage));
|
2020-09-24 04:20:32 +08:00
|
|
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
2020-08-19 23:12:07 +08:00
|
|
|
SendConfigMSG(outgoing.ToString());
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-31 07:00:11 +08:00
|
|
|
public void RefreshEnabledState()
|
|
|
|
{
|
|
|
|
InitializeEnabledValue();
|
|
|
|
OnPropertyChanged(nameof(EnablePowerLauncher));
|
|
|
|
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
|
|
|
|
OnPropertyChanged(nameof(ShowPluginsLoadingMessage));
|
|
|
|
}
|
|
|
|
|
2022-10-26 21:02:31 +08:00
|
|
|
public bool IsEnabledGpoConfigured
|
|
|
|
{
|
|
|
|
get => _enabledStateIsGPOConfigured;
|
|
|
|
}
|
|
|
|
|
2020-08-18 01:00:56 +08:00
|
|
|
public string SearchResultPreference
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchResultPreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchResultPreference != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchResultPreference = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string SearchTypePreference
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchTypePreference;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchTypePreference != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchTypePreference = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int MaximumNumberOfResults
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.MaximumNumberOfResults;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.MaximumNumberOfResults != value)
|
|
|
|
{
|
|
|
|
settings.Properties.MaximumNumberOfResults = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-24 01:48:52 +08:00
|
|
|
public int ThemeIndex
|
2021-03-10 01:20:49 +08:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
return _themeIndex;
|
2021-03-10 01:20:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
switch (value)
|
2021-03-10 01:20:49 +08:00
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
case 0: settings.Properties.Theme = Theme.Dark; break;
|
|
|
|
case 1: settings.Properties.Theme = Theme.Light; break;
|
|
|
|
case 2: settings.Properties.Theme = Theme.System; break;
|
2021-03-10 01:20:49 +08:00
|
|
|
}
|
|
|
|
|
2021-08-24 01:48:52 +08:00
|
|
|
_themeIndex = value;
|
|
|
|
UpdateSettings();
|
2021-03-10 01:20:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-24 01:48:52 +08:00
|
|
|
public int MonitorPositionIndex
|
2021-03-10 01:20:49 +08:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
return _monitorPositionIndex;
|
2021-03-10 01:20:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
if (_monitorPositionIndex != value)
|
2021-03-10 01:20:49 +08:00
|
|
|
{
|
2021-08-24 01:48:52 +08:00
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case 0: settings.Properties.Position = StartupPosition.Cursor; break;
|
|
|
|
case 1: settings.Properties.Position = StartupPosition.PrimaryMonitor; break;
|
|
|
|
case 2: settings.Properties.Position = StartupPosition.Focus; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_monitorPositionIndex = value;
|
2021-04-01 02:54:10 +08:00
|
|
|
UpdateSettings();
|
2021-03-10 01:20:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-12 20:53:12 +08:00
|
|
|
public string SearchText
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return _searchText;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (_searchText != value)
|
|
|
|
{
|
|
|
|
_searchText = value;
|
|
|
|
OnPropertyChanged(nameof(SearchText));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ICommand SearchPluginsCommand { get; }
|
|
|
|
|
2020-08-18 01:00:56 +08:00
|
|
|
public HotkeySettings OpenPowerLauncher
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.OpenPowerLauncher;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.OpenPowerLauncher != value)
|
|
|
|
{
|
|
|
|
settings.Properties.OpenPowerLauncher = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
2021-10-01 21:59:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool UseCentralizedKeyboardHook
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.UseCentralizedKeyboardHook;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.UseCentralizedKeyboardHook != value)
|
|
|
|
{
|
|
|
|
settings.Properties.UseCentralizedKeyboardHook = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
|
2022-06-12 21:12:10 +08:00
|
|
|
public bool SearchQueryResultsWithDelay
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchQueryResultsWithDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchQueryResultsWithDelay != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchQueryResultsWithDelay = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-10 18:07:53 +08:00
|
|
|
public int SearchInputDelayFast
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchInputDelayFast;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchInputDelayFast != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchInputDelayFast = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-12 21:12:10 +08:00
|
|
|
public int SearchInputDelay
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchInputDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchInputDelay != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchInputDelay = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-04 22:12:56 +08:00
|
|
|
public bool SearchQueryTuningEnabled
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchQueryTuningEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchQueryTuningEnabled != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchQueryTuningEnabled = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool SearchWaitForSlowResults
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchWaitForSlowResults;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchWaitForSlowResults != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchWaitForSlowResults = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int SearchClickedItemWeight
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.SearchClickedItemWeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.SearchClickedItemWeight != value)
|
|
|
|
{
|
|
|
|
settings.Properties.SearchClickedItemWeight = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 01:00:56 +08:00
|
|
|
public HotkeySettings OpenFileLocation
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.OpenFileLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.OpenFileLocation != value)
|
|
|
|
{
|
|
|
|
settings.Properties.OpenFileLocation = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public HotkeySettings CopyPathLocation
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.CopyPathLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.CopyPathLocation != value)
|
|
|
|
{
|
|
|
|
settings.Properties.CopyPathLocation = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OverrideWinRKey
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.OverrideWinkeyR;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.OverrideWinkeyR != value)
|
|
|
|
{
|
|
|
|
settings.Properties.OverrideWinkeyR = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OverrideWinSKey
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.OverrideWinkeyS;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.OverrideWinkeyS != value)
|
|
|
|
{
|
|
|
|
settings.Properties.OverrideWinkeyS = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IgnoreHotkeysInFullScreen
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.IgnoreHotkeysInFullscreen;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.IgnoreHotkeysInFullscreen != value)
|
|
|
|
{
|
|
|
|
settings.Properties.IgnoreHotkeysInFullscreen = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool ClearInputOnLaunch
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.ClearInputOnLaunch;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.ClearInputOnLaunch != value)
|
|
|
|
{
|
|
|
|
settings.Properties.ClearInputOnLaunch = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-10 22:04:50 +08:00
|
|
|
public bool TabSelectsContextButtons
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.TabSelectsContextButtons;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.TabSelectsContextButtons != value)
|
|
|
|
{
|
|
|
|
settings.Properties.TabSelectsContextButtons = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-07 06:57:52 +08:00
|
|
|
public bool GenerateThumbnailsFromFiles
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return settings.Properties.GenerateThumbnailsFromFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (settings.Properties.GenerateThumbnailsFromFiles != value)
|
|
|
|
{
|
|
|
|
settings.Properties.GenerateThumbnailsFromFiles = value;
|
|
|
|
UpdateSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-26 19:21:58 +08:00
|
|
|
private ObservableCollection<PowerLauncherPluginViewModel> _plugins;
|
|
|
|
|
|
|
|
public ObservableCollection<PowerLauncherPluginViewModel> Plugins
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-02-26 19:21:58 +08:00
|
|
|
if (_plugins == null)
|
2020-08-18 01:00:56 +08:00
|
|
|
{
|
2021-02-26 19:21:58 +08:00
|
|
|
_plugins = new ObservableCollection<PowerLauncherPluginViewModel>(settings.Plugins.Select(x => new PowerLauncherPluginViewModel(x, isDark)));
|
2022-06-02 17:47:53 +08:00
|
|
|
foreach (var plugin in Plugins)
|
|
|
|
{
|
|
|
|
plugin.PropertyChanged += OnPluginInfoChange;
|
|
|
|
}
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
2021-02-26 19:21:58 +08:00
|
|
|
|
|
|
|
return _plugins;
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
}
|
2021-02-26 19:21:58 +08:00
|
|
|
|
|
|
|
public bool ShowAllPluginsDisabledWarning
|
|
|
|
{
|
2022-06-02 17:47:53 +08:00
|
|
|
get => EnablePowerLauncher && settings.Plugins.Any() && settings.Plugins.All(x => x.Disabled);
|
2021-03-15 20:52:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool ShowPluginsLoadingMessage
|
|
|
|
{
|
|
|
|
get => EnablePowerLauncher && !Plugins.Any();
|
2021-02-26 19:21:58 +08:00
|
|
|
}
|
2021-03-24 22:13:33 +08:00
|
|
|
|
|
|
|
public bool IsUpToDate(PowerLauncherSettings settings)
|
|
|
|
{
|
|
|
|
return this.settings.Equals(settings);
|
|
|
|
}
|
2021-08-12 20:53:12 +08:00
|
|
|
|
|
|
|
public void SearchPlugins()
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrWhiteSpace(SearchText))
|
|
|
|
{
|
|
|
|
var plugins = settings.Plugins.Where(p => p.Name.StartsWith(SearchText, StringComparison.OrdinalIgnoreCase) || p.Name.IndexOf($" {SearchText}", StringComparison.OrdinalIgnoreCase) > 0);
|
|
|
|
_plugins = new ObservableCollection<PowerLauncherPluginViewModel>(plugins.Select(x => new PowerLauncherPluginViewModel(x, isDark)));
|
2022-04-01 21:50:16 +08:00
|
|
|
foreach (var plugin in _plugins)
|
|
|
|
{
|
|
|
|
plugin.PropertyChanged += OnPluginInfoChange;
|
|
|
|
}
|
2021-08-12 20:53:12 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_plugins = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
OnPropertyChanged(nameof(Plugins));
|
|
|
|
}
|
2020-08-18 01:00:56 +08:00
|
|
|
}
|
|
|
|
}
|