Skip to content

Commit

Permalink
Add a Flyout to explain what the Manual Scan button will do, add a me…
Browse files Browse the repository at this point in the history
…ssage dialog for when new shortcuts were not found
  • Loading branch information
marticliment committed Feb 9, 2025
1 parent 0d58c00 commit 27bbb01
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 55 deletions.
132 changes: 79 additions & 53 deletions src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,92 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
<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"
Click="ManualScanButton_Click">
<widgets:TranslatedTextBlock Text="Manual scan"/>
</Button>
<Button
Grid.Column="2"
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
13 changes: 11 additions & 2 deletions src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;

Expand Down Expand Up @@ -80,11 +81,19 @@ private void DeletableDesktopShortcutsList_DoubleTapped(object sender, DoubleTap
}
}

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

private void CloseButton_Click(object sender, RoutedEventArgs e)
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);
}
}

0 comments on commit 27bbb01

Please sign in to comment.