PowerLauncher Settings

* Cherry Picked commit branch due to merge conflicts
* add HotkeySettingsControl
* add localization strings
* add PowerLauncherPage ViewModel
* fix build dependency - settings.ui.runner depends on TwoWayIPCLib
* uncomment IPC settings propagation
This commit is contained in:
Tomas Raies
2020-04-03 19:02:38 -07:00
committed by Tomas Agustin Raies
parent cea6b7067a
commit 443b3c8b82
9 changed files with 733 additions and 228 deletions

View File

@@ -1,11 +1,12 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerLauncherPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:Custom="using:Microsoft.PowerToys.Settings.UI.Controls"
x:Class="Microsoft.PowerToys.Settings.UI.Views.PowerLauncherPage"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@@ -42,79 +43,80 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBlock Text="A quick launcher that has additional capabilities without sacrificing performance." Style="{StaticResource BodyTextBlockStyle}"
<TextBlock x:Uid="PowerLauncher_Description" Style="{StaticResource BodyTextBlockStyle}"
TextWrapping="Wrap"/>
<ToggleSwitch Header="Enable PowerLauncher"
IsOn="True"
Margin="{StaticResource SmallTopMargin}" />
<ToggleSwitch x:Uid="PowerLauncher_EnablePowerLauncher"
IsOn="{x:Bind Mode=TwoWay, Path=ViewModel.EnablePowerLauncher}"
Margin="{StaticResource SmallTopMargin}"/>
<TextBlock Text="Search &amp; results"
<TextBlock x:Uid="PowerLauncher_SearchResults"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<ComboBox x:Uid="PowerLauncher_SearchResultPreference"
MinWidth="320"
Margin="{StaticResource SmallTopMargin}"
ItemsSource="{x:Bind SearchResultPreferencesOptions}"
SelectedItem="{x:Bind Mode=TwoWay, Path=SelectedSearchResultPreference}"
SelectedValuePath="Item2"
DisplayMemberPath="Item1"
/>
<ComboBox Header="Search result preference"
SelectedIndex="0"
MinWidth="320"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem>Most commonly used</ComboBoxItem>
<ComboBoxItem>Most recently used</ComboBoxItem>
<ComboBoxItem>Alphabetical order</ComboBoxItem>
<ComboBoxItem>Running processes/opened applications</ComboBoxItem>
</ComboBox>
<ComboBox x:Uid="PowerLauncher_SearchTypePreference"
MinWidth="320"
Margin="{StaticResource SmallTopMargin}"
ItemsSource="{x:Bind SearchTypePreferencesOptions}"
SelectedItem="{x:Bind Mode=TwoWay, Path=SelectedSearchTypePreference}"
SelectedValuePath="Item2"
DisplayMemberPath="Item1"
/>
<ComboBox Header="Search type preference"
SelectedIndex="0"
MinWidth="320"
Margin="{StaticResource SmallTopMargin}">
<ComboBoxItem>Application name</ComboBoxItem>
<ComboBoxItem>A string that is contained in the application</ComboBoxItem>
<ComboBoxItem>Executable name</ComboBoxItem>
</ComboBox>
<muxc:NumberBox Header="Maximum numbers of results"
Value="4"
<muxc:NumberBox x:Uid="PowerLauncher_MaximumNumberOfResults"
Value="{x:Bind Mode=TwoWay, Path=ViewModel.MaximumNumberOfResults}"
Width="320"
SpinButtonPlacementMode="Inline"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}" />
Margin="{StaticResource SmallTopMargin}"
Minimum="1"/>
<TextBlock Text="Shortcuts"
<TextBlock x:Uid="PowerLauncher_Shortcuts"
Width="320"
HorizontalAlignment="Left"
Style="{StaticResource SettingsGroupTitleStyle}"/>
<!-- TO DO: Add logic to only allow specific (or combination of) keys as entries -->
<TextBox Header="Open PowerLauncher"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"/>
<Custom:HotkeySettingsControl x:Uid="PowerLauncher_OpenPowerLauncher"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.OpenPowerLauncher, Mode=TwoWay}"
/>
<Custom:HotkeySettingsControl x:Uid="PowerLauncher_OpenFileLocation"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.OpenFileLocation, Mode=TwoWay}"
/>
<Custom:HotkeySettingsControl x:Uid="PowerLauncher_CopyPathLocation"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.CopyPathLocation, Mode=TwoWay}"
/>
<Custom:HotkeySettingsControl x:Uid="PowerLauncher_OpenConsole"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
HotkeySettings="{x:Bind Path=ViewModel.OpenConsole, Mode=TwoWay}"
/>
<!-- TO DO: Add logic to only allow specific (or combination of) keys as entries -->
<TextBox Header="Open file location"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="PowerLauncher_OverrideWinRKey"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.OverrideWinRKey}"/>
<!-- TO DO: Add logic to only allow specific (or combination of) keys as entries -->
<TextBox Header="Copy path location"
Width="320"
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox x:Uid="PowerLauncher_OverrideWinSKey"
Margin="{StaticResource SmallTopMargin}"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.OverrideWinSKey}" />
<!-- TO DO: Add logic to only allow specific (or combination of) keys as entries -->
<TextBox Header="Open console"
HorizontalAlignment="Left"
Width="320"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox Content="Override Win+R key"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}"/>
<CheckBox Content="Override Win+S key"
IsChecked="True"
Margin="{StaticResource SmallTopMargin}" />
</StackPanel>

View File

@@ -1,13 +1,14 @@
// Copyright (c) Microsoft Corporation
// 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.
using Microsoft.PowerToys.Settings.UI.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using System.Text;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
@@ -17,16 +18,63 @@ using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Microsoft.PowerToys.Settings.UI.Controls;
using System.Collections.ObjectModel;
namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class PowerLauncherPage : Page
{
public PowerLauncherViewModel ViewModel { get; } = new PowerLauncherViewModel();
ObservableCollection<Tuple<string, string>> SearchResultPreferencesOptions;
ObservableCollection<Tuple<string, string>> SearchTypePreferencesOptions;
public PowerLauncherPage()
{
this.InitializeComponent();
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
SearchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
SearchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
SearchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
SearchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));
SearchTypePreferencesOptions = new ObservableCollection<Tuple<string, string>>();
SearchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
SearchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
SearchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
}
public Tuple<string, string> SelectedSearchResultPreference
{
get
{
return SearchResultPreferencesOptions.First(item => item.Item2 == ViewModel.SearchResultPreference);
}
set
{
if (ViewModel.SearchResultPreference != value.Item2)
{
ViewModel.SearchResultPreference = value.Item2;
}
}
}
public Tuple<string, string> SelectedSearchTypePreference
{
get
{
return SearchTypePreferencesOptions.First(item => item.Item2 == ViewModel.SearchTypePreference);
}
set
{
if (ViewModel.SearchTypePreference != value.Item2)
{
ViewModel.SearchTypePreference = value.Item2;
}
}
}
}
}