Skip to content

Commit

Permalink
Merge branch 'main' into cpu-usage-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment authored Feb 9, 2025
2 parents e826281 + 840df8b commit 4959a2c
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 45 deletions.
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 Down Expand Up @@ -79,6 +81,21 @@ private void DeletableDesktopShortcutsList_DoubleTapped(object sender, DoubleTap
}
}

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);
}
}

0 comments on commit 4959a2c

Please sign in to comment.