Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Dec 3, 2024
1 parent 1232867 commit 3342ede
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using System.Data;
using System.Text.Json;
using Microsoft.VisualBasic.CompilerServices;
using UniGetUI.Core.Data;
using UniGetUI.Core.Logging;
using UniGetUI.Core.SettingsEngine;
Expand Down Expand Up @@ -132,20 +133,11 @@ public static Status GetStatus(string shortcutPath)
/// <returns>A list of desktop shortcut paths</returns>
public static List<string> GetShortcuts()
{
List<string> shortcuts = new();
string UserDesktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string CommonDesktop = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
List<string> shortcuts = new();

foreach (var shortcut in Directory.EnumerateFiles(UserDesktop, "*.lnk"))
{
shortcuts.Add(Path.Join(UserDesktop, shortcut));
}

foreach (var shortcut in Directory.EnumerateFiles(CommonDesktop, "*.lnk"))
{
shortcuts.Add(Path.Join(CommonDesktop, shortcut));
}

shortcuts.AddRange(Directory.EnumerateFiles(UserDesktop, "*.lnk"));
shortcuts.AddRange(Directory.EnumerateFiles(CommonDesktop, "*.lnk"));
return shortcuts;
}

Expand Down Expand Up @@ -188,6 +180,7 @@ public static void TryRemoveNewShortcuts(IEnumerable<string> PreviousShortCutLis
Logger.Debug("Refraining from deleting new shortcut " + shortcut + ": user disabled its deletion");
break;
case Status.Unknown:
if(UnknownShortcuts.Contains(shortcut)) continue;
Logger.Info("Marking the shortcut " + shortcut + " to be asked to be deleted");
UnknownShortcuts.Add(shortcut);
break;
Expand Down
7 changes: 6 additions & 1 deletion src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<widgets:TranslatedTextBlock
FontWeight="Bold"
Text="UniGetUI has detected the following desktop shortcuts which can be removed automatically on future upgrades"/>
<widgets:TranslatedTextBlock
Text="Here you can change UniGetUI's behaviour regarding the following shortcuts. Checking a shortcut will make UniGetUI delete it if if gets created on a future upgrade. Unchecking it will keep the shortcut intact"/>
</StackPanel>
<Button
Grid.Column="2"
Grid.Column="1"
HorizontalAlignment="Stretch"
Margin="10,0,0,0">
<widgets:TranslatedTextBlock Text="Reset list"/>
Expand Down
11 changes: 5 additions & 6 deletions src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using UniGetUI.Core.Logging;
Expand All @@ -26,20 +27,18 @@ public sealed partial class DesktopShortcutsManager : Page
public event EventHandler? Close;
private ObservableCollection<ShortcutEntry> desktopShortcuts = new ObservableCollection<ShortcutEntry>();

private bool NewOnly = false;
private bool NewOnly;

public DesktopShortcutsManager(List<string>? NewShortcuts)
{
if (NewShortcuts is not null) NewOnly = true;


InitializeComponent();
DeletableDesktopShortcutsList.ItemsSource = desktopShortcuts;
DeletableDesktopShortcutsList.DoubleTapped += DeletableDesktopShortcutsList_DoubleTapped;
UpdateData(NewShortcuts);
}

public void UpdateData(List<string>? NewShortcuts)
private void UpdateData(List<string>? NewShortcuts)
{
desktopShortcuts.Clear();

Expand Down Expand Up @@ -73,12 +72,12 @@ private void DeletableDesktopShortcutsList_DoubleTapped(object sender, DoubleTap
}
}

private void CloseButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close?.Invoke(this, EventArgs.Empty);
}

private void YesResetButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
private void YesResetButton_Click(object sender, RoutedEventArgs e)
{
foreach (ShortcutEntry shortcut in desktopShortcuts.ToArray())
{
Expand Down

0 comments on commit 3342ede

Please sign in to comment.