Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Manual Scanning of Desktop Shortcuts #3284

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 79 additions & 45 deletions src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,91 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Vertical" Spacing="4">
<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="1"
HorizontalAlignment="Stretch"
Margin="10,0,0,0">
<widgets:TranslatedTextBlock Text="Reset list"/>
<Button.Flyout>
<Flyout
x:Name="ConfirmResetFlyout"
LightDismissOverlayMode="Off"
Placement="Bottom">
<Grid Width="300" ColumnSpacing="8" RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.ColumnSpan="2"
Text="Do you really want to reset this list? This action cannot be reverted."
Margin="0,0,0,0"
TextWrapping="WrapWholeWords"
/>
<Button
Name="NoResetButton"
Click="NoResetButton_Click"
Grid.Row="1" Grid.Column="1"
HorizontalAlignment="Stretch"
Style="{ThemeResource AccentButtonStyle}">
<widgets:TranslatedTextBlock Text="No"/>
</Button>
<Button
Name="YesResetButton"
Click="YesResetButton_Click"
Grid.Row="1" Grid.Column="0"
HorizontalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="Yes"/>
</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="4" VerticalAlignment="Bottom">
<Button
HorizontalAlignment="Stretch"
Margin="10,0,0,0">
<widgets:TranslatedTextBlock Text="Manual scan"/>
<Button.Flyout>
<Flyout
x:Name="ManualScanFlyout"
LightDismissOverlayMode="Off"
Placement="Bottom">
<Grid Width="300" ColumnSpacing="8" RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.ColumnSpan="2"
Text="Existing shortcuts on your desktop will be scanned, and you will need to pick which ones to keep and which ones to remove."
Margin="0,0,0,0"
TextWrapping="WrapWholeWords"
/>
<Button
Click="ManualScanButton_Click"
Style="{ThemeResource AccentButtonStyle}"
Grid.Row="1" Grid.Column="1"
HorizontalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="Continue"/>
</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
<Button
HorizontalAlignment="Stretch"
Margin="10,0,0,0">
<widgets:TranslatedTextBlock Text="Reset list"/>
<Button.Flyout>
<Flyout
x:Name="ConfirmResetFlyout"
LightDismissOverlayMode="Off"
Placement="Bottom">
<Grid Width="300" ColumnSpacing="8" RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.ColumnSpan="2"
Text="Do you really want to reset this list? This action cannot be reverted."
Margin="0,0,0,0"
TextWrapping="WrapWholeWords"
/>
<Button
Click="NoResetButton_Click"
Grid.Row="1" Grid.Column="1"
HorizontalAlignment="Stretch"
Style="{ThemeResource AccentButtonStyle}">
<widgets:TranslatedTextBlock Text="No"/>
</Button>
<Button
Click="YesResetButton_Click"
Grid.Row="1" Grid.Column="0"
HorizontalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="Yes"/>
</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
</Grid>
<ScrollViewer>
<ListView
Expand Down
17 changes: 17 additions & 0 deletions src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using UniGetUI.Core.Tools;
using UniGetUI.PackageEngine.Classes.Packages.Classes;
using UniGetUI.Pages.DialogPages;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -20,7 +22,7 @@
public event EventHandler? Close;
private readonly ObservableCollection<ShortcutEntry> desktopShortcuts = [];

private readonly bool NewOnly;

Check warning on line 25 in src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs

View workflow job for this annotation

GitHub Actions / test-codebase

The field 'DesktopShortcutsManager.NewOnly' is assigned but its value is never used

public DesktopShortcutsManager(List<string>? NewShortcuts)
{
Expand Down Expand Up @@ -79,6 +81,21 @@
}
}

private async void ManualScanButton_Click(object sender, RoutedEventArgs e)
{
DesktopShortcutsDatabase.TryRemoveNewShortcuts([]);
Close?.Invoke(this, EventArgs.Empty);
var shortcuts = DesktopShortcutsDatabase.GetUnknownShortcuts();
if (shortcuts.Any())
{
await DialogHelper.ManageDesktopShortcuts(shortcuts);
}
else
{
await DialogHelper.NoDesktopShortcutsFound();
}
}

private void CloseButton_Click(object sender, RoutedEventArgs e)
{
Close?.Invoke(this, EventArgs.Empty);
Expand Down
9 changes: 9 additions & 0 deletions src/UniGetUI/Pages/DialogPages/DialogHelper_Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,5 +587,14 @@ public static void ShowTelemetryBanner()
Window.TelemetryWarner.CloseButtonClick += (_, _) => Settings.Set("ShownTelemetryBanner", true);

}

public static async Task NoDesktopShortcutsFound()
{
var dialog = DialogFactory.Create();
dialog.Title = CoreTools.Translate("Manual scan");
dialog.Content = CoreTools.Translate("No new shortcuts were found during the scan.");
dialog.CloseButtonText = CoreTools.Translate("Close");
await Window.ShowDialogAsync(dialog);
}
}

Loading