mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Resolve conflicts
This commit is contained in:
parent
542d1eb3be
commit
622a3ab5fc
5 changed files with 30 additions and 31 deletions
|
|
@ -181,21 +181,21 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
});
|
||||
contextMenus.Add(new Result
|
||||
{
|
||||
Title = Context.API.GetTranslation("plugin_explorer_rename_a_file"),
|
||||
SubTitle = Context.API.GetTranslation("plugin_explorer_rename_subtitle"),
|
||||
Title = Localize.plugin_explorer_rename_a_file(),
|
||||
SubTitle = Localize.plugin_explorer_rename_subtitle(),
|
||||
Action = _ =>
|
||||
{
|
||||
RenameFile window;
|
||||
switch (record.Type)
|
||||
{
|
||||
case ResultType.Folder:
|
||||
window = new RenameFile(Context.API, new DirectoryInfo(record.FullPath));
|
||||
window = new RenameFile(new DirectoryInfo(record.FullPath));
|
||||
break;
|
||||
case ResultType.File:
|
||||
window = new RenameFile(Context.API, new FileInfo(record.FullPath));
|
||||
window = new RenameFile(new FileInfo(record.FullPath));
|
||||
break;
|
||||
default:
|
||||
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_cannot_rename"));
|
||||
Context.API.ShowMsgError(Localize.plugin_explorer_cannot_rename());
|
||||
return false;
|
||||
}
|
||||
window.ShowDialog();
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ public static class RenameThing
|
|||
/// <param name="NewFileName">The requested new name</param>
|
||||
/// <param name="oldInfo"> The <see cref="FileInfo"/> or <see cref="DirectoryInfo"/> representing the old file</param>
|
||||
/// <param name="api">An instance of <see cref="IPublicAPI"/>so this can create msgboxes</param>
|
||||
public static void Rename(string NewFileName, FileSystemInfo oldInfo, IPublicAPI api)
|
||||
public static void Rename(string NewFileName, FileSystemInfo oldInfo)
|
||||
{
|
||||
// if it's just whitespace and nothing else
|
||||
if (NewFileName.Trim() == "" || NewFileName == "")
|
||||
if (string.IsNullOrEmpty(NewFileName.Trim()) || string.IsNullOrEmpty(NewFileName))
|
||||
{
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_field_may_not_be_empty"), "New file name"));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_field_may_not_be_empty());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -77,33 +77,34 @@ public static class RenameThing
|
|||
switch (exception)
|
||||
{
|
||||
case FileNotFoundException:
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_item_not_found"), oldInfo.FullName));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_item_not_found(oldInfo.FullName));
|
||||
return;
|
||||
case NotANewNameException:
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_not_a_new_name"), NewFileName));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_not_a_new_name(NewFileName));
|
||||
return;
|
||||
case InvalidNameException:
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_invalid_name"), NewFileName));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_invalid_name(NewFileName));
|
||||
return;
|
||||
case ElementAlreadyExistsException:
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_element_already_exists"), NewFileName));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_element_already_exists(NewFileName));
|
||||
return;
|
||||
default:
|
||||
string msg = exception.Message;
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_exception"), exception.Message));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_exception(exception.Message));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
api.ShowMsgError(api.GetTranslation("plugin_explorer_no_reason_given_exception"));
|
||||
Main.Context.API.ShowMsgError(Localize.plugin_explorer_no_reason_given_exception());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
api.ShowMsg(string.Format(api.GetTranslation("plugin_explorer_successful_rename"), NewFileName));
|
||||
|
||||
Main.Context.API.ShowMsg(Localize.plugin_explorer_successful_rename(NewFileName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@
|
|||
<system:String x:Key="plugin_explorer_rename_file_done">Rename</system:String>
|
||||
<system:String x:Key="plugin_explorer_rename_a_file">Rename</system:String>
|
||||
<system:String x:Key="plugin_explorer_not_a_new_name">The given name: {0} was not new.</system:String>
|
||||
<system:String x:Key="plugin_explorer_field_may_not_be_empty">{0} may not be empty.</system:String>
|
||||
<system:String x:Key="plugin_explorer_field_may_not_be_empty">New file name should not be empty.</system:String>
|
||||
<system:String x:Key="plugin_explorer_invalid_name">{0} is an invalid name.</system:String>
|
||||
<system:String x:Key="plugin_explorer_item_not_found">The specified item: {0} was not found</system:String>
|
||||
<system:String x:Key="plugin_explorer_rename_subtitle">Open a dialog to rename file or folder</system:String>
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
new SearchWindowPluginHotkey()
|
||||
{
|
||||
Id = 0,
|
||||
Name = Context.API.GetTranslation("plugin_explorer_opencontainingfolder"),
|
||||
Description = Context.API.GetTranslation("plugin_explorer_opencontainingfolder_subtitle"),
|
||||
Name = Localize.plugin_explorer_opencontainingfolder(),
|
||||
Description = Localize.plugin_explorer_opencontainingfolder_subtitle(),
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue838"),
|
||||
DefaultHotkey = "Ctrl+Enter",
|
||||
Editable = false,
|
||||
|
|
@ -163,7 +163,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
{
|
||||
var message = $"Fail to open file at {record.FullPath}";
|
||||
Context.API.LogException(ClassName, message, e);
|
||||
Context.API.ShowMsgBox(e.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
|
||||
Context.API.ShowMsgBox(e.Message, Localize.plugin_explorer_opendir_error());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
new SearchWindowPluginHotkey()
|
||||
{
|
||||
Id = 1,
|
||||
Name = Context.API.GetTranslation("plugin_explorer_show_contextmenu_title"),
|
||||
Name = Localize.plugin_explorer_show_contextmenu_title(),
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"),
|
||||
DefaultHotkey = "Alt+Enter",
|
||||
Editable = false,
|
||||
|
|
@ -203,7 +203,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
new SearchWindowPluginHotkey()
|
||||
{
|
||||
Id = 2,
|
||||
Name = Context.API.GetTranslation("plugin_explorer_run_as_administrator"),
|
||||
Name = Localize.plugin_explorer_run_as_administrator(),
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE7EF"),
|
||||
DefaultHotkey = "Ctrl+Shift+Enter",
|
||||
Editable = false,
|
||||
|
|
@ -228,7 +228,7 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
{
|
||||
var message = $"Fail to open file at {record.FullPath}";
|
||||
Context.API.LogException(ClassName, message, ex);
|
||||
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
|
||||
Context.API.ShowMsgBox(ex.Message, Localize.plugin_explorer_opendir_error());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -241,8 +241,8 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
new SearchWindowPluginHotkey()
|
||||
{
|
||||
Id = 3,
|
||||
Name = Context.API.GetTranslation("plugin_explorer_rename_a_file"),
|
||||
Description = Context.API.GetTranslation("plugin_explorer_rename_subtitle"),
|
||||
Name = Localize.plugin_explorer_rename_a_file(),
|
||||
Description = Localize.plugin_explorer_rename_subtitle(),
|
||||
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue8ac"),
|
||||
DefaultHotkey = "F2",
|
||||
Editable = true,
|
||||
|
|
@ -255,13 +255,13 @@ namespace Flow.Launcher.Plugin.Explorer
|
|||
switch (record.Type)
|
||||
{
|
||||
case ResultType.Folder:
|
||||
window = new RenameFile(Context.API, new DirectoryInfo(record.FullPath));
|
||||
window = new RenameFile(new DirectoryInfo(record.FullPath));
|
||||
break;
|
||||
case ResultType.File:
|
||||
window = new RenameFile(Context.API, new FileInfo(record.FullPath));
|
||||
window = new RenameFile(new FileInfo(record.FullPath));
|
||||
break;
|
||||
default:
|
||||
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_cannot_rename"));
|
||||
Context.API.ShowMsgError(Localize.plugin_explorer_cannot_rename());
|
||||
return false;
|
||||
}
|
||||
window.ShowDialog();
|
||||
|
|
|
|||
|
|
@ -23,14 +23,12 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
private string _newFileName;
|
||||
|
||||
private readonly IPublicAPI _api;
|
||||
private readonly string _oldFilePath;
|
||||
|
||||
private readonly FileSystemInfo _info;
|
||||
|
||||
public RenameFile(IPublicAPI api, FileSystemInfo info)
|
||||
public RenameFile(FileSystemInfo info)
|
||||
{
|
||||
_api = api;
|
||||
_info = info;
|
||||
_oldFilePath = _info.FullName;
|
||||
NewFileName = _info.Name;
|
||||
|
|
@ -70,7 +68,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
|||
|
||||
private void OnDoneButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RenameThing.Rename(NewFileName, _info, _api);
|
||||
RenameThing.Rename(NewFileName, _info);
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue