Skip to content

Commit 18bc784

Browse files
authored
Feature: Added restart teaching tip (#12425)
1 parent 052e010 commit 18bc784

File tree

4 files changed

+45
-131
lines changed

4 files changed

+45
-131
lines changed

src/Files.App/UserControls/RestartControl.xaml

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/Files.App/UserControls/RestartControl.xaml.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/Files.App/ViewModels/Settings/GeneralViewModel.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Windows.Globalization;
1010
using Windows.Storage;
1111
using Windows.Storage.Pickers;
12+
using Windows.System;
1213
using static Files.App.Helpers.MenuFlyoutHelper;
1314
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
1415

@@ -26,6 +27,8 @@ public class GeneralViewModel : ObservableObject, IDisposable
2627
public AsyncRelayCommand ChangePageCommand { get; }
2728
public RelayCommand RemovePageCommand { get; }
2829
public RelayCommand<string> AddPageCommand { get; }
30+
public RelayCommand RestartCommand { get; }
31+
public RelayCommand CancelRestartCommand { get; }
2932

3033
private bool showRestartControl;
3134
public bool ShowRestartControl
@@ -94,6 +97,8 @@ public GeneralViewModel()
9497
ChangePageCommand = new AsyncRelayCommand(ChangePage);
9598
RemovePageCommand = new RelayCommand(RemovePage);
9699
AddPageCommand = new RelayCommand<string>(async (path) => await AddPage(path));
100+
RestartCommand = new RelayCommand(DoRestart);
101+
CancelRestartCommand = new RelayCommand(DoCancelRestart);
97102

98103
AddSupportedAppLanguages();
99104

@@ -113,6 +118,19 @@ public GeneralViewModel()
113118
_ = DetectOpenFilesAtStartup();
114119
}
115120

121+
private async void DoRestart()
122+
{
123+
UserSettingsService.AppSettingsService.RestoreTabsOnStartup = true; // Tells the app to restore tabs when it's next launched
124+
App.SaveSessionTabs(); // Saves the open tabs
125+
await Launcher.LaunchUriAsync(new Uri("files-uwp:")); // Launches a new instance of Files
126+
Process.GetCurrentProcess().Kill(); // Closes the current instance
127+
}
128+
129+
private void DoCancelRestart()
130+
{
131+
ShowRestartControl = false;
132+
}
133+
116134
private void AddDateTimeOptions()
117135
{
118136
DateTimeOffset sampleDate1 = DateTime.Now.AddSeconds(-5);

src/Files.App/Views/Settings/GeneralPage.xaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<FontIcon Glyph="&#xF2B7;" />
4646
</local:SettingsBlockControl.Icon>
4747
<ComboBox
48+
x:Name="AppLanguagesComboBox"
4849
HorizontalAlignment="Left"
4950
AutomationProperties.Name="{helpers:ResourceString Name=Language}"
5051
ItemsSource="{x:Bind ViewModel.AppLanguages}"
@@ -56,7 +57,33 @@
5657
</ComboBox.ItemTemplate>
5758
</ComboBox>
5859
</local:SettingsBlockControl>
60+
<!-- Restart Teaching Tip -->
61+
<TeachingTip
62+
IsLightDismissEnabled="True"
63+
IsOpen="{x:Bind ViewModel.ShowRestartControl, Mode=TwoWay}"
64+
Subtitle="{helpers:ResourceString Name=RestartNotificationText/Text}"
65+
Target="{x:Bind AppLanguagesComboBox}">
66+
<StackPanel
67+
x:Name="ButtonsStackPanel"
68+
Padding="0,8,0,0"
69+
HorizontalAlignment="Right"
70+
Orientation="Horizontal"
71+
Spacing="8">
5972

73+
<Button
74+
x:Name="YesButton"
75+
MinWidth="140"
76+
Command="{x:Bind ViewModel.RestartCommand, Mode=OneWay}"
77+
Content="{helpers:ResourceString Name=Yes}"
78+
Style="{ThemeResource AccentButtonStyle}" />
79+
80+
<Button
81+
x:Name="NoButton"
82+
MinWidth="140"
83+
Command="{x:Bind ViewModel.CancelRestartCommand, Mode=OneWay}"
84+
Content="{helpers:ResourceString Name=No}" />
85+
</StackPanel>
86+
</TeachingTip>
6087

6188
<!-- Date settings -->
6289
<local:SettingsBlockControl
@@ -321,10 +348,5 @@
321348
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
322349
</local:SettingsBlockControl>
323350
</StackPanel>
324-
325-
<uc:RestartControl
326-
x:Name="RestartControl"
327-
VerticalAlignment="Bottom"
328-
ShowDialog="{x:Bind ViewModel.ShowRestartControl, Mode=TwoWay}" />
329351
</Grid>
330352
</Page>

0 commit comments

Comments
 (0)