Skip to content

Commit

Permalink
Implemented specific files shortcuts.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantasjasikenas committed Jun 6, 2023
1 parent b0aef44 commit 8ebf24a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .idea/.idea.ShortcutPlugin/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Flow.Launcher.Plugin.ShortcutPlugin/Resources/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<data name="Utils_OpenFolder_Directory_does_not_exist" xml:space="preserve">
<value>Directory does not exist! ({0})</value>
</data>
<data name="Utils_OpenFileOrFolder_File_or_directory_does_not_exist" xml:space="preserve">
<value>Directory or file does not exist! ({0})</value>
</data>
<data name="Import_shortcuts" xml:space="preserve">
<value>Import shortcuts</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public List<Result> OpenShortcut(string shortcut)
return Utils.Utils.SingleResult(
string.Format(Resources.ShortcutsManager_OpenShortcut_Open_shortcut, shortcut.ToUpper()),
_shortcutsRepository.GetShortcuts()[shortcut],
() => { Utils.Utils.OpenFolder(_shortcutsRepository.GetShortcuts()[shortcut]); });
() => { Utils.Utils.OpenFileOrFolder(_shortcutsRepository.GetShortcuts()[shortcut]); });
}

public List<Result> ImportShortcuts()
Expand All @@ -84,7 +84,7 @@ public List<Result> ListShortcuts()
IcoPath = "images\\icon.png",
Action = _ =>
{
Utils.Utils.OpenFolder(shortcut.Value);
Utils.Utils.OpenFileOrFolder(shortcut.Value);
return true;
}
})
Expand Down
40 changes: 35 additions & 5 deletions Flow.Launcher.Plugin.ShortcutPlugin/Src/Utils/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
Expand All @@ -10,20 +11,49 @@ namespace Flow.Launcher.Plugin.ShortcutPlugin.Utils;

public static class Utils
{
public static void OpenFolder(string folderPath)
public static void OpenFileOrFolder(string path)
{
if (!Directory.Exists(folderPath))
if (IsFile(path))
{
MessageBox.Show(string.Format(Resources.Utils_OpenFolder_Directory_does_not_exist, folderPath));
return;
OpenFile(path);
}
else if (IsDirectory(path))
{
OpenFolder(path);
}
else
{
MessageBox.Show(string.Format(Resources.Utils_OpenFileOrFolder_File_or_directory_does_not_exist, path));
}

}

private static void OpenFile(string path) {
var processStartInfo = new ProcessStartInfo
{
FileName = path,
UseShellExecute = true
};
Process.Start(processStartInfo);
}


private static void OpenFolder(string path)
{
Cli.Wrap("explorer.exe")
.WithArguments(folderPath)
.WithArguments(path)
.ExecuteAsync();
}


private static bool IsFile(string path) =>
File.Exists(path);


private static bool IsDirectory(string path) =>
Directory.Exists(path);


public static Command Split(string query)
{
try
Expand Down
1 change: 1 addition & 0 deletions Flow.Launcher.Plugin.ShortcutPlugin/release.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
taskkill /im Flow.Launcher.exe /F
dotnet publish Flow.Launcher.Plugin.ShortcutPlugin -c Release -r win-x64 --no-self-contained
Copy-Item "C:\Users\tutta\Storage\Dev\Projects\ShortcutPlugin\Flow.Launcher.Plugin.ShortcutPlugin\bin\Release\win-x64\publish/*" "C:\Users\tutta\AppData\Roaming\FlowLauncher\Plugins\ShortcutManager" -Recurse -Force
Copy-Item "C:\Users\tutta\Storage\Dev\Projects\ShortcutPlugin\Flow.Launcher.Plugin.ShortcutPlugin\bin\Release\win-x64\publish/*" "C:\Users\tutta\Desktop\ShortcutManager" -Recurse -Force
Start-Process C:\Users\tutta\AppData\Local\FlowLauncher\Flow.Launcher.exe


0 comments on commit 8ebf24a

Please sign in to comment.