Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/Command.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Text.Json.Serialization;

namespace Flow.Launcher.Plugin.Sys
{
public class Command : BaseModel
{
public string Key { get; set; }

private string name;
[JsonIgnore]
public string Name
{
get => name;
set
{
name = value;
OnPropertyChanged();
}
}

private string description;
[JsonIgnore]
public string Description
{
get => description;
set
{
description = value;
OnPropertyChanged();
}
}

private string keyword;
public string Keyword
{
get => keyword;
set
{
keyword = value;
OnPropertyChanged();
}
}
}
}
121 changes: 121 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<Window
x:Class="Flow.Launcher.Plugin.Sys.CommandKeywordSettingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource lowlauncher_plugin_sys_command_keyword_setting_window_title}"
Width="550"
Background="{DynamicResource PopupBGColor}"
Foreground="{DynamicResource PopupTextColor}"
ResizeMode="NoResize"
SizeToContent="Height"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="80" />
</Grid.RowDefinitions>

<StackPanel Grid.Row="0">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="1"
Click="OnCancelButtonClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26 12 26 0">
<StackPanel Margin="0 0 0 12">
<TextBlock
Grid.Column="0"
Margin="0 0 0 0"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource flowlauncher_plugin_sys_custom_command_keyword}"
TextAlignment="Left" />
</StackPanel>

<StackPanel>
<TextBlock
x:Name="CommandKeywordTips"
FontSize="14"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
</StackPanel>

<Grid Margin="0 24 0 24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource flowlauncher_plugin_sys_command_keyword}" />
<TextBox
x:Name="CommandKeyword"
Grid.Column="1"
Margin="10"
HorizontalAlignment="Stretch" />
<Button
x:Name="btnTestActionKeyword"
Grid.Row="1"
Grid.Column="2"
Margin="0 0 10 0"
Padding="10 5 10 5"
Click="OnResetButtonClick"
Content="{DynamicResource flowlauncher_plugin_sys_reset}" />
</Grid>
</StackPanel>
</StackPanel>
<Border
Grid.Row="1"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0 1 0 0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
MinWidth="140"
Margin="10 0 5 0"
Click="OnCancelButtonClick"
Content="{DynamicResource flowlauncher_plugin_sys_cancel}" />
<Button
MinWidth="140"
Margin="5 0 10 0"
Click="OnConfirmButtonClick"
Content="{DynamicResource flowlauncher_plugin_sys_confirm}"
Style="{DynamicResource AccentButtonStyle}" />
</StackPanel>
</Border>
</Grid>
</Window>
45 changes: 45 additions & 0 deletions Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Windows;

namespace Flow.Launcher.Plugin.Sys
{
public partial class CommandKeywordSettingWindow
{
private readonly Command _oldSearchSource;
private readonly PluginInitContext _context;

public CommandKeywordSettingWindow(PluginInitContext context, Command old)
{
_context = context;
_oldSearchSource = old;
InitializeComponent();
CommandKeyword.Text = old.Keyword;
CommandKeywordTips.Text = string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_custom_command_keyword_tip"), old.Name);
}

private void OnCancelButtonClick(object sender, RoutedEventArgs e)
{
Close();
}

private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
{
var keyword = CommandKeyword.Text;
if (string.IsNullOrEmpty(keyword))
{
var warning = _context.API.GetTranslation("flowlauncher_plugin_sys_input_command_keyword");
_context.API.ShowMsgBox(warning);
}
else
{
_oldSearchSource.Keyword = keyword;
Close();
}
}

private void OnResetButtonClick(object sender, RoutedEventArgs e)
{
// Key is the default value of this command
CommandKeyword.Text = _oldSearchSource.Key;
}
}
}
14 changes: 13 additions & 1 deletion Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
xmlns:system="clr-namespace:System;assembly=mscorlib">

<!-- Command List -->
<system:String x:Key="flowlauncher_plugin_sys_command">Command</system:String>
<system:String x:Key="flowlauncher_plugin_sys_name">Name</system:String>
<system:String x:Key="flowlauncher_plugin_sys_desc">Description</system:String>
<system:String x:Key="flowlauncher_plugin_sys_command">Command</system:String>

<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer_cmd">Shutdown</system:String>
<system:String x:Key="flowlauncher_plugin_sys_restart_computer_cmd">Restart</system:String>
Expand All @@ -29,6 +30,8 @@
<system:String x:Key="flowlauncher_plugin_sys_toggle_game_mode_cmd">Toggle Game Mode</system:String>
<system:String x:Key="flowlauncher_plugin_sys_theme_selector_cmd">Set the Flow Launcher Theme</system:String>

<system:String x:Key="flowlauncher_plugin_sys_edit">Edit</system:String>

<!-- Command Descriptions -->
<system:String x:Key="flowlauncher_plugin_sys_shutdown_computer">Shutdown Computer</system:String>
<system:String x:Key="flowlauncher_plugin_sys_restart_computer">Restart Computer</system:String>
Expand Down Expand Up @@ -61,6 +64,15 @@
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_restart_computer_advanced">Are you sure you want to restart the computer with Advanced Boot Options?</system:String>
<system:String x:Key="flowlauncher_plugin_sys_dlgtext_logoff_computer">Are you sure you want to log off?</system:String>

<system:String x:Key="flowlauncher_plugin_sys_command_keyword_setting_window_title">Command Keyword Setting</system:String>
<system:String x:Key="flowlauncher_plugin_sys_custom_command_keyword">Custom Command Keyword</system:String>
<system:String x:Key="flowlauncher_plugin_sys_custom_command_keyword_tip">Enter a keyword to search for command: {0}. This keyword is used to match your query.</system:String>
<system:String x:Key="flowlauncher_plugin_sys_command_keyword">Command Keyword</system:String>
<system:String x:Key="flowlauncher_plugin_sys_reset">Reset</system:String>
<system:String x:Key="flowlauncher_plugin_sys_confirm">Confirm</system:String>
<system:String x:Key="flowlauncher_plugin_sys_cancel">Cancel</system:String>
<system:String x:Key="flowlauncher_plugin_sys_input_command_keyword">Please enter a non-empty command keyword</system:String>

<system:String x:Key="flowlauncher_plugin_sys_plugin_name">System Commands</system:String>
<system:String x:Key="flowlauncher_plugin_sys_plugin_description">Provides System related commands. e.g. shutdown, lock, settings etc.</system:String>

Expand Down
Loading
Loading