mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
added new dialogue box for renaming files
This commit is contained in:
parent
39366b7a69
commit
459d85d395
4 changed files with 254 additions and 8 deletions
|
|
@ -10,6 +10,7 @@ using Flow.Launcher.Plugin.Explorer.Search;
|
|||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||
using Flow.Launcher.Plugin.Explorer.Helper;
|
||||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||
using Flow.Launcher.Plugin.Explorer.Views;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer
|
||||
{
|
||||
|
|
@ -188,6 +189,24 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
IcoPath = icoPath,
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uf12b")
|
||||
});
|
||||
contextMenus.Add(new Result
|
||||
{
|
||||
Title = "Rename",
|
||||
SubTitle = "Opens a dialogue to this",
|
||||
Action = _ =>
|
||||
{
|
||||
|
||||
RenameFile window = new(Context.API);
|
||||
Context.API.FocusQueryTextBox();
|
||||
if (!(window.ShowDialog() ?? false))
|
||||
{
|
||||
Context.API.FocusQueryTextBox();
|
||||
return false;
|
||||
}
|
||||
Context.API.FocusQueryTextBox();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (record.Type is ResultType.File or ResultType.Folder)
|
||||
|
|
|
|||
|
|
@ -190,4 +190,9 @@
|
|||
<system:String x:Key="MonthsAgo">{0} months ago</system:String>
|
||||
<system:String x:Key="OneYearAgo">1 year ago</system:String>
|
||||
<system:String x:Key="YearsAgo">{0} years ago</system:String>
|
||||
|
||||
<!--Rename File Dialog-->
|
||||
<system:String x:Key="plugin_explorer_new_file_name">New File name:</system:String>
|
||||
<system:String x:Key="plugin_explorer_rename_file_done">Rename</system:String>
|
||||
<system:String x:Key="plugin_explorer_rename_a_file">Rename</system:String>
|
||||
</ResourceDictionary>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,120 @@
|
|||
<Window
|
||||
x:Class="namespace Flow.Launcher.Plugin.Explorer.Views.RenameFile"
|
||||
<Window
|
||||
x:Class="Flow.Launcher.Plugin.Explorer.Views.RenameFile"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Rename A file" Height="350" Width="525">
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="{DynamicResource plugin_explorer_manageactionkeywords_header}"
|
||||
Width="Auto"
|
||||
Height="160"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Width"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="32"
|
||||
ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}"/>
|
||||
</WindowChrome.WindowChrome>
|
||||
<Grid>
|
||||
<Button Content="Open Window" Click="ButtonClicked" Height="25" HorizontalAlignment="Left" Margin="379,264,0,0" Name="button1" VerticalAlignment="Top" Width="100" />
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0">
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button
|
||||
Grid.Column="4"
|
||||
Click="BtnCancel"
|
||||
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 0 26 0">
|
||||
<StackPanel Margin="0 0 0 0">
|
||||
<TextBlock
|
||||
Margin="0 0 0 0"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource plugin_explorer_rename_a_file}"
|
||||
TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0 10 0 0"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
MinWidth="150"
|
||||
Margin="0 10 15 10"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
Text="{DynamicResource plugin_explorer_new_file_name}"/>
|
||||
<TextBox
|
||||
Name="RenameTb"
|
||||
Width="135"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
DataObject.Pasting="TextBox_Pasting"
|
||||
PreviewKeyDown="TxtCurrentActionKeyword_OnKeyDown"
|
||||
Text="{Binding NewFileName}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Background="{DynamicResource PopupButtonAreaBGColor}"
|
||||
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
|
||||
BorderThickness="0 1 0 0">
|
||||
<StackPanel HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="0 0 5 0"
|
||||
Click="BtnCancel"
|
||||
Content="{DynamicResource cancel}"/>
|
||||
<Button
|
||||
Name="btnDone"
|
||||
Width="145"
|
||||
Height="30"
|
||||
Margin="5 0 0 0"
|
||||
Click="OnDoneButtonClick"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
<TextBlock x:Name="lblAdd"
|
||||
Text="{DynamicResource plugin_explorer_rename_file_done}"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
|
@ -1,8 +1,119 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Views;
|
||||
|
||||
public partial class RenameFile
|
||||
namespace Flow.Launcher.Plugin.Explorer.Views
|
||||
{
|
||||
|
||||
[INotifyPropertyChanged]
|
||||
public partial class RenameFile : Window
|
||||
{
|
||||
|
||||
|
||||
public string NewFileName
|
||||
{
|
||||
get => newFileName;
|
||||
set
|
||||
{
|
||||
_ = SetProperty(ref newFileName, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string newFileName = "gayTest";
|
||||
private string renamingText = "fes";
|
||||
public string RenamingText
|
||||
{
|
||||
get => renamingText;
|
||||
set
|
||||
{
|
||||
_ = SetProperty(ref renamingText, value);
|
||||
}
|
||||
}
|
||||
private readonly IPublicAPI _api;
|
||||
|
||||
|
||||
public RenameFile(IPublicAPI api)
|
||||
{
|
||||
_api = api;
|
||||
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
RenameTb.Focus();
|
||||
Deactivated += (s, e) =>
|
||||
{
|
||||
DialogResult = false;
|
||||
Close();
|
||||
|
||||
};
|
||||
ShowInTaskbar = false;
|
||||
RenameTb.Select(RenameTb.Text.Length, 0);
|
||||
}
|
||||
|
||||
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// if (ActionKeyword == Query.GlobalPluginWildcardSign)
|
||||
// switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled)
|
||||
// {
|
||||
// case (Settings.ActionKeyword.FileContentSearchActionKeyword, true):
|
||||
// _api.ShowMsgBox(_api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
|
||||
// return;
|
||||
// case (Settings.ActionKeyword.QuickAccessActionKeyword, true):
|
||||
// _api.ShowMsgBox(_api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!KeywordEnabled || !_api.ActionKeywordAssigned(ActionKeyword))
|
||||
// {
|
||||
// DialogResult = true;
|
||||
// Close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// The keyword is not valid, so show message
|
||||
_api.ShowMsgBox("new action keyword");
|
||||
}
|
||||
|
||||
private void BtnCancel(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
btnDone.Focus();
|
||||
OnDoneButtonClick(sender, e);
|
||||
e.Handled = true;
|
||||
}
|
||||
if (e.Key == Key.Space)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
|
||||
{
|
||||
if (e.DataObject.GetDataPresent(DataFormats.Text))
|
||||
{
|
||||
string text = e.DataObject.GetData(DataFormats.Text) as string;
|
||||
if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace))
|
||||
{
|
||||
e.CancelCommand();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
e.CancelCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue