From 66e7c50a8ea477db1ad456affb3d3dc3233540be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Mon, 9 Aug 2021 12:29:11 +0200 Subject: [PATCH] SEBWIN-428: Fixed bug where visibility of reload button wasn't according to the active settings. --- .../DataMapping/BrowserDataMapper.cs | 12 ++++++++++++ .../ConfigurationData/DataProcessor.cs | 6 ++---- SafeExamBrowser.Settings/Browser/WindowSettings.cs | 5 +++++ .../Windows/BrowserWindow.xaml.cs | 2 +- .../Windows/BrowserWindow.xaml.cs | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs index 98aff764..c0568c1d 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/BrowserDataMapper.cs @@ -147,6 +147,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping case Keys.Browser.ResetOnQuitUrl: MapResetOnQuitUrl(settings, value); break; + case Keys.Browser.ShowReloadButton: + MapShowReloadButton(settings, value); + break; case Keys.Browser.ShowToolbar: MapShowToolbar(settings, value); break; @@ -436,6 +439,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping } } + private void MapShowReloadButton(AppSettings settings, object value) + { + if (value is bool show) + { + settings.Browser.AdditionalWindow.ShowReloadButton = show; + settings.Browser.MainWindow.ShowReloadButton = show; + } + } + private void MapRequestFilter(IDictionary rawData, AppSettings settings) { var processMainRequests = rawData.TryGetValue(Keys.Browser.Filter.EnableMainRequestFilter, out var value) && value as bool? == true; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs index 45790129..1ef04eac 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataProcessor.cs @@ -29,14 +29,12 @@ namespace SafeExamBrowser.Configuration.ConfigurationData private void AllowBrowserToolbarForReloading(IDictionary rawData, AppSettings settings) { - var showReloadButton = rawData.TryGetValue(Keys.Browser.ShowReloadButton, out var v) && v is bool show && show; - - if (settings.Browser.AdditionalWindow.AllowReloading && showReloadButton) + if (settings.Browser.AdditionalWindow.AllowReloading && settings.Browser.AdditionalWindow.ShowReloadButton) { settings.Browser.AdditionalWindow.ShowToolbar = true; } - if (settings.Browser.MainWindow.AllowReloading && showReloadButton) + if (settings.Browser.MainWindow.AllowReloading && settings.Browser.MainWindow.ShowReloadButton) { settings.Browser.MainWindow.ShowToolbar = true; } diff --git a/SafeExamBrowser.Settings/Browser/WindowSettings.cs b/SafeExamBrowser.Settings/Browser/WindowSettings.cs index 958c2b58..38babe01 100644 --- a/SafeExamBrowser.Settings/Browser/WindowSettings.cs +++ b/SafeExamBrowser.Settings/Browser/WindowSettings.cs @@ -76,6 +76,11 @@ namespace SafeExamBrowser.Settings.Browser /// public bool ShowHomeButton { get; set; } + /// + /// Determines whether the reload button is visible. + /// + public bool ShowReloadButton { get; set; } + /// /// Determines whether the user will need to confirm every reload attempt. /// diff --git a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs index a529a3c7..ddef251e 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Desktop/Windows/BrowserWindow.xaml.cs @@ -343,7 +343,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed; MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole; ReloadButton.IsEnabled = WindowSettings.AllowReloading; - ReloadButton.Visibility = WindowSettings.AllowReloading ? Visibility.Visible : Visibility.Collapsed; + ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed; Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed; UrlTextBox.Visibility = WindowSettings.AllowAddressBar ? Visibility.Visible : Visibility.Hidden; ZoomMenuItem.Visibility = settings.AllowPageZoom ? Visibility.Visible : Visibility.Collapsed; diff --git a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs index defd4e7e..9b381bc0 100644 --- a/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs +++ b/SafeExamBrowser.UserInterface.Mobile/Windows/BrowserWindow.xaml.cs @@ -343,7 +343,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed; MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole; ReloadButton.IsEnabled = WindowSettings.AllowReloading; - ReloadButton.Visibility = WindowSettings.AllowReloading ? Visibility.Visible : Visibility.Collapsed; + ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed; Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed; UrlTextBox.Visibility = WindowSettings.AllowAddressBar ? Visibility.Visible : Visibility.Hidden; ZoomMenuItem.Visibility = settings.AllowPageZoom ? Visibility.Visible : Visibility.Collapsed;