mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-04-03 14:06:27 +00:00
Add option to revert previous changes to windows defaults
This commit is contained in:
@@ -1484,6 +1484,57 @@ function Show-MainWindow {
|
||||
UpdateNavigationButtons
|
||||
})
|
||||
|
||||
# Handle Home Revert link button
|
||||
$homeRevertLinkBtn = $window.FindName('HomeRevertLinkBtn')
|
||||
if ($homeRevertLinkBtn) {
|
||||
if (-not (Test-Path $script:SavedSettingsFilePath)) {
|
||||
$homeRevertLinkBtn.Visibility = 'Collapsed'
|
||||
}
|
||||
|
||||
$homeRevertLinkBtn.Add_Click({
|
||||
$savedSettings = LoadJsonFile -filePath $script:SavedSettingsFilePath -expectedVersion "1.0" -optionalFile
|
||||
if (-not $savedSettings -or -not $savedSettings.Settings) {
|
||||
return
|
||||
}
|
||||
|
||||
$revertSelection = Show-RevertSettingsModal -Owner $window -LastUsedSettings $savedSettings
|
||||
$selectedFeatureIds = @($revertSelection.SelectedFeatureIds)
|
||||
$shouldRestartExplorer = ($revertSelection.RestartExplorer -eq $true)
|
||||
|
||||
if (-not $selectedFeatureIds -or $selectedFeatureIds.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
|
||||
# Keep runtime/control parameters and clear actionable selections before adding selected revert targets.
|
||||
$actionableKeys = @()
|
||||
foreach ($k in $script:Params.Keys) {
|
||||
if ($script:ControlParams -notcontains $k) {
|
||||
$actionableKeys += $k
|
||||
}
|
||||
}
|
||||
foreach ($k in $actionableKeys) {
|
||||
$script:Params.Remove($k)
|
||||
}
|
||||
|
||||
AddParameter 'Undo'
|
||||
|
||||
foreach ($featureId in $selectedFeatureIds) {
|
||||
if ($script:Features.ContainsKey($featureId)) {
|
||||
$feature = $script:Features[$featureId]
|
||||
if ($feature.RegistryUndoKey -and $feature.UndoAction) {
|
||||
AddParameter $featureId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Use the existing apply modal to execute and present progress/completion.
|
||||
Show-ApplyModal -Owner $window -RestartExplorer $shouldRestartExplorer
|
||||
|
||||
# Close the main window after the apply dialog closes
|
||||
$window.Close()
|
||||
})
|
||||
}
|
||||
|
||||
# Handle Home Default Mode button - apply defaults and navigate directly to overview
|
||||
$homeDefaultModeBtn = $window.FindName('HomeDefaultModeBtn')
|
||||
$homeDefaultModeBtn.Add_Click({
|
||||
|
||||
Reference in New Issue
Block a user