Merge branch 'master' of https://github.com/microsoft/PowerToys into microsoft-master

This commit is contained in:
Den Delimarsky
2021-04-07 17:12:51 -07:00
610 changed files with 21033 additions and 18367 deletions

View File

@@ -247,11 +247,28 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
ColorFormats.Add(remainingColorFormat);
}
// Reordering colors with buttons: disable first and last buttons
ColorFormats[0].CanMoveUp = false;
ColorFormats[ColorFormats.Count - 1].CanMoveDown = false;
ColorFormats.CollectionChanged += ColorFormats_CollectionChanged;
}
private void ColorFormats_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
// Reordering colors with buttons: update buttons availability depending on order
if (ColorFormats.Count > 0)
{
foreach (var color in ColorFormats)
{
color.CanMoveUp = true;
color.CanMoveDown = true;
}
ColorFormats[0].CanMoveUp = false;
ColorFormats[ColorFormats.Count - 1].CanMoveDown = false;
}
UpdateColorFormats();
ScheduleSavingOfSettings();
}

View File

@@ -71,6 +71,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
_openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
_restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
_quickLayoutSwitch = Settings.Properties.FancyzonesQuickLayoutSwitch.Value;
_flashZonesOnQuickLayoutSwitch = Settings.Properties.FancyzonesFlashZonesOnQuickSwitch.Value;
_useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
_showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
_spanZonesAcrossMonitors = Settings.Properties.FancyzonesSpanZonesAcrossMonitors.Value;
@@ -107,6 +109,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _openWindowOnActiveMonitor;
private bool _spanZonesAcrossMonitors;
private bool _restoreSize;
private bool _quickLayoutSwitch;
private bool _flashZonesOnQuickLayoutSwitch;
private bool _useCursorPosEditorStartupScreen;
private bool _showOnAllMonitors;
private bool _makeDraggedWindowTransparent;
@@ -138,6 +142,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
SendConfigMSG(snd.ToString());
OnPropertyChanged(nameof(IsEnabled));
OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
OnPropertyChanged(nameof(QuickSwitchEnabled));
}
}
}
@@ -150,6 +155,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool QuickSwitchEnabled
{
get
{
return _isEnabled && _quickLayoutSwitch;
}
}
public bool ShiftDrag
{
get
@@ -374,6 +387,43 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool QuickLayoutSwitch
{
get
{
return _quickLayoutSwitch;
}
set
{
if (value != _quickLayoutSwitch)
{
_quickLayoutSwitch = value;
Settings.Properties.FancyzonesQuickLayoutSwitch.Value = value;
NotifyPropertyChanged();
OnPropertyChanged(nameof(QuickSwitchEnabled));
}
}
}
public bool FlashZonesOnQuickSwitch
{
get
{
return _flashZonesOnQuickLayoutSwitch;
}
set
{
if (value != _flashZonesOnQuickLayoutSwitch)
{
_flashZonesOnQuickLayoutSwitch = value;
Settings.Properties.FancyzonesFlashZonesOnQuickSwitch.Value = value;
NotifyPropertyChanged();
}
}
}
public bool UseCursorPosEditorStartupScreen
{
get

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
@@ -22,9 +21,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _isLightThemeRadioButtonChecked;
private bool _isSystemThemeRadioButtonChecked;
private GeneralSettings GeneralSettingsConfig { get; set; }
private bool _isCursorPositionRadioButtonChecked;
private bool _isPrimaryMonitorPositionRadioButtonChecked;
private bool _isFocusPositionRadioButtonChecked;
private readonly ISettingsUtils _settingsUtils;
private GeneralSettings GeneralSettingsConfig { get; set; }
private PowerLauncherSettings settings;
@@ -36,9 +37,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private Func<string, int> SendConfigMSG { get; }
public PowerLauncherViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, int defaultKeyCode, Func<bool> isDark)
public PowerLauncherViewModel(PowerLauncherSettings settings, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc, Func<bool> isDark)
{
_settingsUtils = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));
if (settings == null)
{
throw new ArgumentException("settings argument can not be null");
}
this.settings = settings;
this.isDark = isDark;
// To obtain the general Settings configurations of PowerToys
@@ -51,7 +57,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
// set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
callback = (PowerLauncherSettings settings) =>
callback = (PowerLauncherSettings s) =>
{
// Propagate changes to Power Launcher through IPC
// Using InvariantCulture as this is an IPC message
@@ -60,22 +66,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
PowerLauncherSettings.ModuleName,
JsonSerializer.Serialize(settings)));
JsonSerializer.Serialize(s)));
};
if (_settingsUtils.SettingsExists(PowerLauncherSettings.ModuleName))
{
settings = _settingsUtils.GetSettingsOrDefault<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
}
else
{
settings = new PowerLauncherSettings();
settings.Properties.OpenPowerLauncher.Alt = true;
settings.Properties.OpenPowerLauncher.Code = defaultKeyCode;
settings.Properties.MaximumNumberOfResults = 4;
callback(settings);
}
switch (settings.Properties.Theme)
{
case Theme.Light:
@@ -89,6 +82,19 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
break;
}
switch (settings.Properties.Position)
{
case StartupPosition.Cursor:
_isCursorPositionRadioButtonChecked = true;
break;
case StartupPosition.PrimaryMonitor:
_isPrimaryMonitorPositionRadioButtonChecked = true;
break;
case StartupPosition.Focus:
_isFocusPositionRadioButtonChecked = true;
break;
}
foreach (var plugin in Plugins)
{
plugin.PropertyChanged += OnPluginInfoChange;
@@ -129,6 +135,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
GeneralSettingsConfig.Enabled.PowerLauncher = value;
OnPropertyChanged(nameof(EnablePowerLauncher));
OnPropertyChanged(nameof(ShowAllPluginsDisabledWarning));
OnPropertyChanged(nameof(ShowPluginsLoadingMessage));
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
SendConfigMSG(outgoing.ToString());
}
@@ -243,6 +250,60 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool IsCursorPositionRadioButtonChecked
{
get
{
return _isCursorPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.Cursor;
_isCursorPositionRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsPrimaryMonitorPositionRadioButtonChecked
{
get
{
return _isPrimaryMonitorPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.PrimaryMonitor;
_isPrimaryMonitorPositionRadioButtonChecked = value;
UpdateSettings();
}
}
}
public bool IsFocusPositionRadioButtonChecked
{
get
{
return _isFocusPositionRadioButtonChecked;
}
set
{
if (value == true)
{
settings.Properties.Position = StartupPosition.Focus;
_isFocusPositionRadioButtonChecked = value;
UpdateSettings();
}
}
}
public HotkeySettings OpenPowerLauncher
{
get
@@ -379,7 +440,17 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
public bool ShowAllPluginsDisabledWarning
{
get => EnablePowerLauncher && Plugins.All(x => x.Disabled);
get => EnablePowerLauncher && Plugins.Any() && Plugins.All(x => x.Disabled);
}
public bool ShowPluginsLoadingMessage
{
get => EnablePowerLauncher && !Plugins.Any();
}
public bool IsUpToDate(PowerLauncherSettings settings)
{
return this.settings.Equals(settings);
}
}
}

View File

@@ -20,6 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private Func<string, int> SendConfigMSG { get; }
private string _settingsConfigFileFolder = string.Empty;
private string _disabledApps;
public ShortcutGuideViewModel(ISettingsRepository<GeneralSettings> settingsRepository, ISettingsRepository<ShortcutGuideSettings> moduleSettingsRepository, Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{
@@ -49,6 +50,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_isEnabled = GeneralSettingsConfig.Enabled.ShortcutGuide;
_pressTime = Settings.Properties.PressTime.Value;
_opacity = Settings.Properties.OverlayOpacity.Value;
_disabledApps = Settings.Properties.DisabledApps.Value;
string theme = Settings.Properties.Theme.Value;
@@ -170,6 +172,24 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public string DisabledApps
{
get
{
return _disabledApps;
}
set
{
if (value != _disabledApps)
{
_disabledApps = value;
Settings.Properties.DisabledApps.Value = value;
NotifyPropertyChanged();
}
}
}
public string GetSettingsSubPath()
{
return _settingsConfigFileFolder + "\\" + ModuleName;