Skip to content

Commit 95e2930

Browse files
gave92Marco Gavelli
authored andcommitted
Added settings under experimental
1 parent 63bf435 commit 95e2930

File tree

8 files changed

+89
-19
lines changed

8 files changed

+89
-19
lines changed

src/Files.App/Data/Contracts/IGeneralSettingsService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
270270
/// </summary>
271271
bool ShowSystemTrayIcon { get; set; }
272272

273+
/// <summary>
274+
/// Gets or sets a value indicating whether to enable terminal integration.
275+
/// </summary>
276+
bool IsTerminalIntegrationEnabled { get; set; }
277+
273278
/// <summary>
274279
/// Gets or sets a value indicating the default option to resolve conflicts.
275280
/// </summary>

src/Files.App/Services/Settings/GeneralSettingsService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ public bool ShowSystemTrayIcon
333333
set => Set(value);
334334
}
335335

336+
public bool IsTerminalIntegrationEnabled
337+
{
338+
get => Get(false);
339+
set => Set(value);
340+
}
341+
336342
public FileNameConflictResolveOptionType ConflictsResolveOption
337343
{
338344
get => (FileNameConflictResolveOptionType)Get((long)FileNameConflictResolveOptionType.GenerateNewName);

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,4 +4332,7 @@
43324332
<data name="FailedToOpenLogFile" xml:space="preserve">
43334333
<value>Unable to open the log file</value>
43344334
</data>
4335+
<data name="SettingsTerminalIntegration" xml:space="preserve">
4336+
<value>Enable Terminal integration</value>
4337+
</data>
43354338
</root>

src/Files.App/UserControls/StatusBar.xaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,41 @@
305305
</Button.Flyout>
306306
</Button>
307307

308+
<StackPanel
309+
x:Name="TerminalPanel"
310+
Grid.Column="3"
311+
VerticalAlignment="Center"
312+
x:Load="{x:Bind MainPageViewModel.IsTerminalIntegrationEnabled, Mode=OneWay}"
313+
Orientation="Horizontal"
314+
Spacing="4">
315+
316+
<Button
317+
x:Name="SyncFolderUp"
318+
Height="24"
319+
Padding="8,0,8,0"
320+
VerticalAlignment="Center"
321+
x:Load="{x:Bind MainPageViewModel.IsTerminalViewOpen, Mode=OneWay}"
322+
Background="Transparent"
323+
BorderBrush="Transparent"
324+
Command="{x:Bind MainPageViewModel.TerminalSyncUpCommand}">
325+
<Button.Content>
326+
<FontIcon FontSize="12" Glyph="&#xE110;" />
327+
</Button.Content>
328+
</Button>
329+
330+
<Button
331+
x:Name="SyncFolderDown"
332+
Height="24"
333+
Padding="8,0,8,0"
334+
VerticalAlignment="Center"
335+
x:Load="{x:Bind MainPageViewModel.IsTerminalViewOpen, Mode=OneWay}"
336+
Background="Transparent"
337+
BorderBrush="Transparent"
338+
Command="{x:Bind MainPageViewModel.TerminalSyncDownCommand}">
339+
<Button.Content>
340+
<FontIcon FontSize="12" Glyph="&#xE74B;" />
341+
</Button.Content>
342+
</Button>
343+
308344
</Grid>
309345
</UserControl>

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using CommunityToolkit.WinUI;
2-
using CommunityToolkit.WinUI.Helpers;
32
using Files.App.Utils.Terminal;
43
using Files.App.Utils.Terminal.ConPTY;
54
using Microsoft.Extensions.Logging;
65
using Microsoft.UI.Xaml.Controls;
7-
using Microsoft.UI.Xaml.Media;
86
using Microsoft.Web.WebView2.Core;
97
using Newtonsoft.Json;
108
using Newtonsoft.Json.Serialization;
@@ -197,7 +195,7 @@ private Task<TerminalSize> CreateXtermViewAsync(TerminalOptions options, Termina
197195
var serializedKeyBindings = JsonConvert.SerializeObject(keyBindings, serializerSettings);
198196
return ExecuteScriptAsync(
199197
$"createTerminal('{serializedOptions}', '{serializedTheme}', '{serializedKeyBindings}')")
200-
.ContinueWith(t => JsonConvert.DeserializeObject<TerminalSize>(t.Result));
198+
.ContinueWith(t => JsonConvert.DeserializeObject<TerminalSize>(t.Result)!);
201199
}
202200

203201
private void WebViewControl_NavigationStarting(WebView2 sender, CoreWebView2NavigationStartingEventArgs args)
@@ -445,20 +443,6 @@ private async void TerminalView_ActualThemeChanged(Microsoft.UI.Xaml.FrameworkEl
445443
serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
446444
var profile = _mainPageModel.TerminalSelectedProfile;
447445
var theme = new DefaultValueProvider().GetPreInstalledThemes().First(x => x.Id == profile.TerminalThemeId);
448-
var backgroundColor = ActualTheme switch
449-
{
450-
Microsoft.UI.Xaml.ElementTheme.Dark => "#000000",
451-
_ => "#FFFFFF"
452-
};
453-
var foregroundColor = ActualTheme switch
454-
{
455-
Microsoft.UI.Xaml.ElementTheme.Dark => "#FFFFFF",
456-
_ => "#000000"
457-
};
458-
theme.Colors.Background = backgroundColor;
459-
theme.Colors.Foreground = foregroundColor;
460-
theme.Colors.CursorAccent = backgroundColor;
461-
theme.Colors.Cursor = foregroundColor;
462446

463447
WebViewControl.CoreWebView2.Profile.PreferredColorScheme = (ActualTheme == Microsoft.UI.Xaml.ElementTheme.Dark) ? CoreWebView2PreferredColorScheme.Dark : CoreWebView2PreferredColorScheme.Light;
464448

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public sealed partial class MainPageViewModel : ObservableObject
2727
private INetworkService NetworkService { get; } = Ioc.Default.GetRequiredService<INetworkService>();
2828
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
2929
private IResourcesService ResourcesService { get; } = Ioc.Default.GetRequiredService<IResourcesService>();
30+
private IGeneralSettingsService GeneralSettingsService { get; } = Ioc.Default.GetRequiredService<IGeneralSettingsService>();
3031
private DrivesViewModel DrivesViewModel { get; } = Ioc.Default.GetRequiredService<DrivesViewModel>();
3132
public ShelfViewModel ShelfViewModel { get; } = Ioc.Default.GetRequiredService<ShelfViewModel>();
3233

@@ -422,6 +423,8 @@ private async void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand(Keyboa
422423

423424
public List<ShellProfile> TerminalProfiles => new DefaultValueProvider().GetPreinstalledShellProfiles().ToList();
424425

426+
public bool IsTerminalIntegrationEnabled => GeneralSettingsService.IsTerminalIntegrationEnabled;
427+
425428
private bool _isTerminalViewOpen;
426429
public bool IsTerminalViewOpen
427430
{
@@ -433,7 +436,11 @@ public bool IsTerminalViewOpen
433436
public ShellProfile TerminalSelectedProfile
434437
{
435438
get => _terminalSelectedProfile;
436-
set => SetProperty(ref _terminalSelectedProfile, value);
439+
set
440+
{
441+
if (value is not null)
442+
SetProperty(ref _terminalSelectedProfile, value);
443+
}
437444
}
438445
}
439446
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,20 @@ public bool ShowFlattenOptions
356356
}
357357
}
358358

359+
public bool IsTerminalIntegrationEnabled
360+
{
361+
get => UserSettingsService.GeneralSettingsService.IsTerminalIntegrationEnabled;
362+
set
363+
{
364+
if (value != UserSettingsService.GeneralSettingsService.IsTerminalIntegrationEnabled)
365+
{
366+
UserSettingsService.GeneralSettingsService.IsTerminalIntegrationEnabled = value;
367+
368+
OnPropertyChanged();
369+
}
370+
}
371+
}
372+
359373
public async Task OpenFilesOnWindowsStartupAsync()
360374
{
361375
var stateMode = await ReadState();

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@
168168
</wctcontrols:SettingsCard.HeaderIcon>
169169
<ToggleSwitch AutomationProperties.Name="{helpers:ResourceString Name=ShowFlattenOptions}" IsOn="{x:Bind ViewModel.ShowFlattenOptions, Mode=TwoWay}" />
170170
</wctcontrols:SettingsCard>
171-
</StackPanel>
171+
172+
<!-- Enable terminal integration -->
173+
<local:SettingsBlockControl
174+
x:Name="TerminalIntegrationSettingsBlockControl"
175+
Title="{helpers:ResourceString Name=SettingsTerminalIntegration}"
176+
HorizontalAlignment="Stretch">
177+
<local:SettingsBlockControl.Icon>
178+
<FontIcon Glyph="&#xE756;" />
179+
</local:SettingsBlockControl.Icon>
180+
<ToggleSwitch
181+
AutomationProperties.Name="{helpers:ResourceString Name=SettingsTerminalIntegration}"
182+
IsOn="{x:Bind ViewModel.IsTerminalIntegrationEnabled, Mode=TwoWay}"
183+
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
184+
</local:SettingsBlockControl>
185+
</StackPanel>
186+
</StackPanel>
172187
</Grid>
173188
</Page>

0 commit comments

Comments
 (0)