Skip to content

Commit

Permalink
同步粒度开关,UI部分
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed Aug 9, 2024
1 parent d45514b commit 9a76284
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/SyncClipboard.Core/Clipboard/ClipboardFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ ex is JsonException ||
{
return await UploadAndReturnBlankProfile(cancelToken);
}
catch
catch (Exception ex)
{
Logger.Write("CreateFromRemote failed");
Logger.Write($"CreateFromRemote failed {ex}");
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ private void SetStatusOnError(ref int errorTimes, Exception ex)
private async Task PullLoop(CancellationToken cancelToken)
{
int errorTimes = 0;
await Task.Delay(TimeSpan.FromSeconds(0.5), cancelToken);
while (!cancelToken.IsCancellationRequested && (_isQuickDownload || SwitchOn))
{
await SyncService.remoteProfilemutex.WaitAsync(cancelToken);
Expand Down
5 changes: 5 additions & 0 deletions src/SyncClipboard.Core/ViewModels/SyncSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ public SyncSettingViewModel(ConfigManager configManager, MainViewModel mainViewM
notifyOnManualUpload = clientConfig.NotifyOnManualUpload;
doNotUploadWhenCut = clientConfig.DoNotUploadWhenCut;
trustInsecureCertificate = clientConfig.TrustInsecureCertificate;
uploadEnable = clientConfig.PushSwitchOn;
downloadEnable = clientConfig.PullSwitchOn;
textEnable = clientConfig.EnableUploadText;
singleFileEnable = clientConfig.EnableUploadSingleFile;
multiFileEnable = clientConfig.EnableUploadMultiFile;
}

public string? SetServerConfig(string portString, string username, string password)
Expand Down
25 changes: 25 additions & 0 deletions src/SyncClipboard.Desktop/Views/SyncSettingPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding NotifyOnDownloaded, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableDownload}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DownloadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUpload}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding UploadEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadText}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding TextEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem Content="{x:Static i18n:Strings.EnableUploadMultiFile}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsExpanderItem.Footer>
</ui:SettingsExpanderItem>
<ui:SettingsExpanderItem IsVisible="{OnPlatform Default=True, macOS=False}" Content="{x:Static i18n:Strings.DoNotUploadWhenCut}">
<ui:SettingsExpanderItem.Footer>
<ToggleSwitch OnContent="{x:Static i18n:Strings.On}" OffContent="{x:Static i18n:Strings.Off}" IsChecked="{Binding DoNotUploadWhenCut, Mode=TwoWay}" />
Expand Down
22 changes: 20 additions & 2 deletions src/SyncClipboard.WinUI3/Views/SyncSettingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@
<ui:SettingsExpander.HeaderIcon>
<FontIcon Glyph="&#xE117;" />
</ui:SettingsExpander.HeaderIcon>
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.ClientEnabled, Mode=TwoWay}" IsEnabled="{x:Bind _viewModel.IsNormalClientEnable, Mode=OneWay}"/>
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}"
OffContent="{x:Bind i18n:Strings.Off}"
IsOn="{x:Bind _viewModel.ClientEnabled, Mode=TwoWay}"
IsEnabled="{x:Bind _viewModel.IsNormalClientEnable, Mode=OneWay}" />
<ui:SettingsExpander.Items>
<ui:SettingsCard Description="{x:Bind i18n:Strings.UseBuiltInServerDescription}" Header="{x:Bind i18n:Strings.UseSelfHostServer}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.UseLocalServer, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.UseManulServer)}" Description="{x:Bind _viewModel.ClientConfigDescription, Mode=OneWay}">
<ui:SettingsCard Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.UseManulServer), Mode=OneWay}" Description="{x:Bind _viewModel.ClientConfigDescription, Mode=OneWay}">
<StackPanel Orientation="Horizontal" Spacing="5">
<ToggleButton IsChecked="{x:Bind _viewModel.ShowClientPassword, Mode=TwoWay}">
<FontIcon Glyph="{x:Bind _viewModel.ShowClientPassword, Mode=OneWay, Converter={StaticResource BoolToPasswordIconConverter}}" />
Expand Down Expand Up @@ -126,6 +129,21 @@
<ui:SettingsCard Header="{x:Bind i18n:Strings.SendNotificationAfterUpdateLocalClipboard}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.NotifyOnDownloaded, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableDownload}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.DownloadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUpload}" Visibility="{x:Bind vc:ConvertMethod.BoolToVisibility(_viewModel.IsNormalClientEnable), Mode=OneWay}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.UploadEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadText}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.TextEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.SingleFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.EnableUploadMultiFile}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.MultiFileEnable, Mode=TwoWay}" />
</ui:SettingsCard>
<ui:SettingsCard Header="{x:Bind i18n:Strings.DoNotUploadWhenCut}">
<ToggleSwitch OnContent="{x:Bind i18n:Strings.On}" OffContent="{x:Bind i18n:Strings.Off}" IsOn="{x:Bind _viewModel.DoNotUploadWhenCut, Mode=TwoWay}" />
</ui:SettingsCard>
Expand Down

0 comments on commit 9a76284

Please sign in to comment.