Skip to content

Commit 4a1ea78

Browse files
added open in terminal
1 parent 27f4767 commit 4a1ea78

File tree

5 files changed

+36
-21
lines changed

5 files changed

+36
-21
lines changed

UnityHubNative.Net/MainViewModel.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

UnityHubNative.Net/MainWindow.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public static void OpenSelectedProjectWith()
105105
}
106106
}
107107

108+
public static void OpenSelectedProjectInTerminal()
109+
{
110+
if (TryGetSelectedProject(out var unityProject))
111+
OsUtils.OpenInTerminal(unityProject.path);
112+
}
113+
108114
public static void OnRemoveProjectFromListClicked()
109115
{
110116
UnityHubUtils.UnityProjects.RemoveAt(GetUnityProjectSelectedIndex());
@@ -277,7 +283,7 @@ public static void MoveSelectedProjectDown()
277283
WrapSelection = true,
278284
SelectionMode = SelectionMode.AlwaysSelected | SelectionMode.Single,
279285
SelectedIndex = 0,
280-
}.AddOnSubmit(OnUnityProjectListSubmitted).OnSelectionChanged(UnityProjectSelectedIndexChanged)
286+
}.OnSelectionChanged(UnityProjectSelectedIndexChanged)
281287
},
282288
]),
283289
])
@@ -553,6 +559,12 @@ public static MenuItem[] CreateProjectMenuItems(Func<UnityProject> unityProjectG
553559
InputGesture = new(Key.Enter, KeyModifiers.Alt),
554560
}.OnClick(OpenSelectedProjectWith),
555561
new MenuItem
562+
{
563+
Header = "Open In Terminal",
564+
HotKey = new(Key.Enter, KeyModifiers.Alt | KeyModifiers.Shift),
565+
InputGesture = new(Key.Enter, KeyModifiers.Alt | KeyModifiers.Shift),
566+
}.OnClick(OpenSelectedProjectInTerminal),
567+
new MenuItem
556568
{
557569
Header = "_Reveal In File Explorer",
558570
HotKey = new KeyGesture(Key.F, KeyModifiers.Control),
@@ -627,13 +639,6 @@ static Task<IEnumerable<object>> PopulateUnityProjectSearchAutoCompletion(string
627639
}
628640
}
629641

630-
static void OnUnityProjectListSubmitted()
631-
{
632-
if (!IsAnyProjectSelected())
633-
return;
634-
((UnityProjectView)s_unityProjectsParent.Items[GetUnityProjectSelectedIndex()]!).OpenProject();
635-
}
636-
637642
static void RemoveSelectedUnitySearchPath(Button button, RoutedEventArgs args)
638643
{
639644
var index = GetSelectedUnityInstallationSearchPathsIndex();
@@ -707,6 +712,11 @@ static async void AddNewUnitySearchPath()
707712

708713
static bool TryGetSelectedProject(out UnityProject unityProject)
709714
{
715+
if (s_projectSearchBoxAutoComplete.SelectedItem is UnityProjectView view)
716+
{
717+
unityProject = view.unityProject;
718+
return true;
719+
}
710720
var ind = GetUnityProjectSelectedIndex();
711721
if (ind < 0 || ind >= UnityHubUtils.UnityProjects.Count)
712722
{

UnityHubNative.Net/OsUtils.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ static class OsUtils
66
{
77
public static void OpenExplorer(string dir)
88
{
9-
Process.Start(new ProcessStartInfo()
9+
Process.Start(new ProcessStartInfo
1010
{
1111
FileName = dir,
1212
UseShellExecute = true
1313
});
1414
}
15+
16+
public static void OpenInTerminal(string path)
17+
{
18+
#if Windows
19+
Process.Start(new ProcessStartInfo
20+
{
21+
FileName = "cmd.exe",
22+
Arguments = $"/K cd /d \"{path}\""
23+
});
24+
#endif
25+
}
1526
}

UnityHubNative.Net/UnityHubNative.Net.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636

3737
<ItemGroup>
3838
<PackageReference Include="Avalonia" Version="11.2.5" />
39-
<!--<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.4" />-->
4039
<PackageReference Include="Avalonia.Desktop" Version="11.2.5" />
40+
<PackageReference Include="FluentAvaloniaUI" Version="2.3.0" />
41+
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
42+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.5" />
43+
<!--<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.2.4" />-->
4144
<!--<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.5" />-->
4245
<!--<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.4" />-->
4346
<!--<PackageReference Include="Avalonia.Themes.Simple" Version="11.2.4" />-->
4447
<!--<PackageReference Include="Classic.Avalonia.Theme" Version="11.2.0.7" />-->
45-
<PackageReference Include="FluentAvaloniaUI" Version="2.2.0" />
4648
<!--<PackageReference Include="FluentIcons.Avalonia" Version="1.1.271" />-->
4749
<!--<PackageReference Include="GridExtra.Avalonia" Version="0.9.1" />-->
4850
<!--<PackageReference Include="Material.Avalonia" Version="3.9.2" />-->
49-
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
50-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.5" />
5151
<!--<PackageReference Include="Semi.Avalonia" Version="11.2.1.4" />-->
5252
</ItemGroup>
5353

UnityHubNative.Net/UnityHubNativeNetApp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public override void Initialize()
3636
public override void OnFrameworkInitializationCompleted()
3737
{
3838
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
39-
desktop.MainWindow = new MainWindow(new MainViewModel());
39+
desktop.MainWindow = new MainWindow(null);
4040
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewApplication)
41-
singleViewApplication.MainView = new MainWindow(new MainViewModel());
41+
singleViewApplication.MainView = new MainWindow(null);
4242
base.OnFrameworkInitializationCompleted();
4343
}
4444

0 commit comments

Comments
 (0)