88using Avalonia . Platform . Storage ;
99using FluentAvalonia . UI . Controls ;
1010using MsBox . Avalonia ;
11+ using SkiaSharp ;
1112
1213namespace UnityHubNative . Net ;
1314
@@ -27,7 +28,9 @@ class MainWindow : Window
2728
2829 static DockPanel s_transparentPanel ;
2930 static Slider s_backgroundBlurIntensitySlider ;
30- static private Key s_lastKey ;
31+ static TextBox s_openInTerminalFormatText ;
32+ static Key s_lastKey ;
33+ private static TabControl s_tabControl ;
3134
3235 public MainWindow ( object data )
3336 {
@@ -55,29 +58,32 @@ protected override void OnKeyDown(KeyEventArgs e)
5558
5659 s_lastKey = e . Key ;
5760
58- // focus on searchbar if typed a character
59- if ( e . KeyModifiers is KeyModifiers . None or KeyModifiers . Shift && ( int ) e . Key >= ( int ) Key . A && ( int ) e . Key <= ( int ) Key . Z )
61+ if ( s_tabControl . SelectedIndex == 0 )
6062 {
61- if ( ! s_projectSearchBoxAutoComplete . IsKeyboardFocusWithin )
63+ // focus on searchbar if typed a character
64+ if ( e . KeyModifiers is KeyModifiers . None or KeyModifiers . Shift && ( int ) e . Key >= ( int ) Key . A && ( int ) e . Key <= ( int ) Key . Z )
6265 {
63- s_projectSearchBoxAutoComplete . Focus ( ) ;
64- s_projectSearchBoxAutoComplete . Text += e . KeyModifiers == KeyModifiers . Shift ? e . Key . ToString ( ) : e . Key . ToString ( ) . ToLower ( ) ;
65- s_projectSearchBoxAutoComplete . CaretIndex = s_projectSearchBoxAutoComplete . Text . Length ;
66- e . Handled = true ;
66+ if ( ! s_projectSearchBoxAutoComplete . IsKeyboardFocusWithin )
67+ {
68+ s_projectSearchBoxAutoComplete . Focus ( ) ;
69+ s_projectSearchBoxAutoComplete . Text += e . KeyModifiers == KeyModifiers . Shift ? e . Key . ToString ( ) : e . Key . ToString ( ) . ToLower ( ) ;
70+ s_projectSearchBoxAutoComplete . CaretIndex = s_projectSearchBoxAutoComplete . Text . Length ;
71+ e . Handled = true ;
72+ }
73+ return ;
6774 }
68- return ;
69- }
7075
71- // focus on the list of escaped
72- if ( e . Key == Key . Escape )
73- {
74- if ( s_unityProjectsParent . SelectedItem != null )
76+ // focus on the list of escaped
77+ if ( e . Key == Key . Escape )
7578 {
76- s_unityProjectsParent . ContainerFromIndex ( GetUnityProjectSelectedIndex ( ) ) ! . Focus ( ) ;
77- s_projectSearchBoxAutoComplete . Text = string . Empty ;
78- }
79+ if ( s_unityProjectsParent . SelectedItem != null )
80+ {
81+ s_unityProjectsParent . ContainerFromIndex ( GetUnityProjectSelectedIndex ( ) ) ! . Focus ( ) ;
82+ s_projectSearchBoxAutoComplete . Text = string . Empty ;
83+ }
7984
80- return ;
85+ return ;
86+ }
8187 }
8288 }
8389
@@ -247,7 +253,7 @@ public static void MoveSelectedProjectDown()
247253 {
248254 } . AddChildren
249255 ( [
250- new TabControl
256+ s_tabControl = new TabControl
251257 {
252258 TabStripPlacement = Dock . Top ,
253259 } . AddItems
@@ -526,14 +532,39 @@ public static void MoveSelectedProjectDown()
526532 VerticalAlignment = VerticalAlignment . Center ,
527533 } . OnCheckChanged ( OnCloseAfterOpenProjectCheckboxChanged ) . SetDock ( Dock . Right )
528534 ] )
529- } . SetTooltip ( "If checked, the app will close after opening a project" )
535+ } . SetTooltip ( "If checked, the app will close after opening a project" ) ,
536+ new SettingsExpanderItem
537+ {
538+ Content = new DockPanel
539+ {
540+ } . AddChildren
541+ ( [
542+ new TextBlock
543+ {
544+ Text = "Format to open project in Terminal" ,
545+ VerticalAlignment = VerticalAlignment . Center ,
546+ Margin = new ( 0 , 0 , 10 , 0 ) ,
547+ } . SetDock ( Dock . Left ) ,
548+ s_openInTerminalFormatText = new TextBox
549+ {
550+ Text = UnityHubNativeNetApp . Config . openInTerminalFormat ,
551+ VerticalAlignment = VerticalAlignment . Center ,
552+ } . OnTextChanged ( OnOpenInTerminalFormatChanged ) . SetDock ( Dock . Right )
553+ ] )
554+ } . SetTooltip ( "Defines the process format of when opening a project in terminal. {path} will be replaced by the project path" ) ,
530555 ] )
531556 ] )
532557 }
533558 ] )
534559 ] )
535560 ] ) ;
536561
562+ static void OnOpenInTerminalFormatChanged ( )
563+ {
564+ UnityHubNativeNetApp . Config . openInTerminalFormat = s_openInTerminalFormatText . Text ;
565+ UnityHubNativeNetApp . SaveConfig ( UnityHubNativeNetApp . Config ) ;
566+ }
567+
537568 static void OnExtendToTitlebarCheckChanged ( )
538569 {
539570 UnityHubNativeNetApp . Config . extendToTitlebar = ! UnityHubNativeNetApp . Config . extendToTitlebar ;
0 commit comments