Skip to content

Commit 7de5991

Browse files
committed
code_review: PR #1415
- Column for hotkey in `Reset` popup should use `Auto` for width - Add `SelectionBoxItemTemplate` for current selected mode in `Reset` popup Signed-off-by: leo <[email protected]>
1 parent ffac71b commit 7de5991

File tree

6 files changed

+15
-28
lines changed

6 files changed

+15
-28
lines changed

src/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ private string FixFontFamilyName(string input)
681681
}
682682

683683
var name = sb.ToString();
684-
if (name.Contains('#'))
684+
if (name.Contains('#', StringComparison.Ordinal))
685685
{
686686
if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) &&
687687
!name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal))

src/Native/Windows.cs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,17 @@ public string FindGitExecutable()
127127
Microsoft.Win32.RegistryHive.LocalMachine,
128128
Microsoft.Win32.RegistryView.Registry64);
129129

130-
var git = reg.OpenSubKey("SOFTWARE\\GitForWindows");
130+
var git = reg.OpenSubKey(@"SOFTWARE\GitForWindows");
131131
if (git?.GetValue("InstallPath") is string installPath)
132-
{
133132
return Path.Combine(installPath, "bin", "git.exe");
134-
}
135133

136134
var builder = new StringBuilder("git.exe", 259);
137135
if (!PathFindOnPath(builder, null))
138-
{
139136
return null;
140-
}
141137

142138
var exePath = builder.ToString();
143139
if (!string.IsNullOrEmpty(exePath))
144-
{
145140
return exePath;
146-
}
147141

148142
return null;
149143
}
@@ -299,9 +293,7 @@ private string FindVSCode()
299293
// VSCode (system)
300294
var systemVScode = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
301295
if (systemVScode != null)
302-
{
303296
return systemVScode.GetValue("DisplayIcon") as string;
304-
}
305297

306298
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
307299
Microsoft.Win32.RegistryHive.CurrentUser,
@@ -310,9 +302,7 @@ private string FindVSCode()
310302
// VSCode (user)
311303
var vscode = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{771FD6B0-FA20-440A-A002-3B3BAC16DC50}_is1");
312304
if (vscode != null)
313-
{
314305
return vscode.GetValue("DisplayIcon") as string;
315-
}
316306

317307
return string.Empty;
318308
}
@@ -326,9 +316,7 @@ private string FindVSCodeInsiders()
326316
// VSCode - Insiders (system)
327317
var systemVScodeInsiders = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
328318
if (systemVScodeInsiders != null)
329-
{
330319
return systemVScodeInsiders.GetValue("DisplayIcon") as string;
331-
}
332320

333321
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
334322
Microsoft.Win32.RegistryHive.CurrentUser,
@@ -337,9 +325,7 @@ private string FindVSCodeInsiders()
337325
// VSCode - Insiders (user)
338326
var vscodeInsiders = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{217B4C08-948D-4276-BFBB-BEE930AE5A2C}_is1");
339327
if (vscodeInsiders != null)
340-
{
341328
return vscodeInsiders.GetValue("DisplayIcon") as string;
342-
}
343329

344330
return string.Empty;
345331
}
@@ -353,9 +339,7 @@ private string FindVSCodium()
353339
// VSCodium (system)
354340
var systemVSCodium = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{88DA3577-054F-4CA1-8122-7D820494CFFB}_is1");
355341
if (systemVSCodium != null)
356-
{
357342
return systemVSCodium.GetValue("DisplayIcon") as string;
358-
}
359343

360344
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
361345
Microsoft.Win32.RegistryHive.CurrentUser,
@@ -364,9 +348,7 @@ private string FindVSCodium()
364348
// VSCodium (user)
365349
var vscodium = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2E1F05D1-C245-4562-81EE-28188DB6FD17}_is1");
366350
if (vscodium != null)
367-
{
368351
return vscodium.GetValue("DisplayIcon") as string;
369-
}
370352

371353
return string.Empty;
372354
}
@@ -409,9 +391,7 @@ private string FindVisualStudio()
409391
if (launcher.GetValue(string.Empty) is string CLSID &&
410392
localMachine.OpenSubKey(@$"SOFTWARE\Classes\CLSID\{CLSID}\LocalServer32") is Microsoft.Win32.RegistryKey devenv &&
411393
devenv.GetValue(string.Empty) is string localServer32)
412-
{
413394
return localServer32!.Trim('\"');
414-
}
415395
}
416396

417397
return string.Empty;

src/ViewModels/ConfigureWorkspace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public bool CanDeleteSelected
2929

3030
public ConfigureWorkspace()
3131
{
32-
Workspaces = new AvaloniaList<Workspace>(Preferences.Instance.Workspaces);
32+
Workspaces = new(Preferences.Instance.Workspaces);
3333
}
3434

3535
public void Add()

src/ViewModels/Launcher.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ public void CloseTab(LauncherPage page)
296296
var removeIdx = Pages.IndexOf(page);
297297
var activeIdx = Pages.IndexOf(_activePage);
298298
if (removeIdx == activeIdx)
299-
{
300299
ActivePage = Pages[removeIdx > 0 ? removeIdx - 1 : removeIdx + 1];
301-
}
302300

303301
CloseRepositoryInTab(page);
304302
Pages.RemoveAt(removeIdx);

src/ViewModels/ScanRepositories.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public override Task<bool> Sure()
6464
}
6565

6666
Preferences.Instance.AutoRemoveInvalidNode();
67-
Preferences.Instance.SortNodes(Preferences.Instance.RepositoryNodes);
6867
Preferences.Instance.Save();
6968

7069
Welcome.Instance.Refresh();
@@ -154,8 +153,8 @@ private RepositoryNode FindOrCreateGroup(List<RepositoryNode> collection, string
154153
IsExpanded = true,
155154
};
156155
collection.Add(added);
157-
Preferences.Instance.SortNodes(collection);
158156

157+
Preferences.Instance.SortNodes(collection);
159158
return added;
160159
}
161160

src/Views/Reset.axaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,24 @@
4545
KeyDown="OnResetModeKeyDown">
4646
<ComboBox.ItemTemplate>
4747
<DataTemplate DataType="m:ResetMode">
48-
<Grid ColumnDefinitions="16,60,*,*">
48+
<Grid ColumnDefinitions="16,60,*,Auto">
4949
<Ellipse Grid.Column="0" Width="12" Height="12" Fill="{Binding Color}"/>
5050
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2,0,0,0"/>
5151
<TextBlock Grid.Column="2" Text="{Binding Desc}" Margin="2,0,16,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
5252
<TextBlock Grid.Column="3" Text="{Binding Key}" FontSize="11" FontWeight="Bold" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
5353
</Grid>
5454
</DataTemplate>
5555
</ComboBox.ItemTemplate>
56+
57+
<ComboBox.SelectionBoxItemTemplate>
58+
<DataTemplate DataType="m:ResetMode">
59+
<Grid ColumnDefinitions="16,60,*">
60+
<Ellipse Grid.Column="0" Width="12" Height="12" Fill="{Binding Color}"/>
61+
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="2,0,0,0"/>
62+
<TextBlock Grid.Column="2" Text="{Binding Desc}" Margin="2,0,16,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
63+
</Grid>
64+
</DataTemplate>
65+
</ComboBox.SelectionBoxItemTemplate>
5666
</ComboBox>
5767
</Grid>
5868
</StackPanel>

0 commit comments

Comments
 (0)