From f81c0f96381ea6b439be6003659ac9c4d0132b12 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 10 Apr 2020 22:33:27 +0100 Subject: [PATCH] Migrate settings from Eto.Forms to Avalonia. --- .idea/.idea.Aaru/.idea/contentModel.xml | 7 +- Aaru.Gui/App.xaml | 3 +- Aaru.Gui/App.xaml.cs | 22 +- Aaru.Gui/Dialogs/dlgSettings.xeto | 91 ------- Aaru.Gui/Dialogs/dlgSettings.xeto.cs | 198 --------------- Aaru.Gui/Forms/frmMain.xeto.cs | 12 - Aaru.Gui/ViewModels/MainWindowViewModel.cs | 16 +- .../ViewModels/SettingsDialogViewModel.cs | 233 ++++++++++++++++++ Aaru.Gui/ViewModels/SplashWindowViewModel.cs | 26 +- Aaru.Gui/Views/MainWindow.xaml | 6 +- Aaru.Gui/Views/SettingsDialog.xaml | 101 ++++++++ Aaru.Gui/Views/SettingsDialog.xaml.cs | 19 ++ 12 files changed, 406 insertions(+), 328 deletions(-) delete mode 100644 Aaru.Gui/Dialogs/dlgSettings.xeto delete mode 100644 Aaru.Gui/Dialogs/dlgSettings.xeto.cs create mode 100644 Aaru.Gui/ViewModels/SettingsDialogViewModel.cs create mode 100644 Aaru.Gui/Views/SettingsDialog.xaml create mode 100644 Aaru.Gui/Views/SettingsDialog.xaml.cs diff --git a/.idea/.idea.Aaru/.idea/contentModel.xml b/.idea/.idea.Aaru/.idea/contentModel.xml index 10bec0772..5f07def8f 100644 --- a/.idea/.idea.Aaru/.idea/contentModel.xml +++ b/.idea/.idea.Aaru/.idea/contentModel.xml @@ -1218,10 +1218,6 @@ - - - - @@ -1296,6 +1292,7 @@ + @@ -1311,6 +1308,8 @@ + + diff --git a/Aaru.Gui/App.xaml b/Aaru.Gui/App.xaml index 9529272f4..2ae89fa86 100644 --- a/Aaru.Gui/App.xaml +++ b/Aaru.Gui/App.xaml @@ -10,7 +10,8 @@ - + + diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index fbba21863..cd8dd1b2d 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -16,13 +16,11 @@ namespace Aaru.Gui { if(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - var swvm = new SplashWindowViewModel(); - swvm.WorkFinished += OnSplashFinished; - - desktop.MainWindow = new SplashWindow - { - DataContext = swvm - }; + var splashWindow = new SplashWindow(); + var swvm = new SplashWindowViewModel(splashWindow); + swvm.WorkFinished += OnSplashFinished; + splashWindow.DataContext = swvm; + desktop.MainWindow = splashWindow; } base.OnFrameworkInitializationCompleted(); @@ -67,5 +65,15 @@ namespace Aaru.Gui mainWindowViewModel.ExecuteExitCommand(); } + + void OnPreferencesClicked(object sender, EventArgs args) + { + if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) || + !(desktop.MainWindow is MainWindow mainWindow) || + !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel)) + return; + + mainWindowViewModel.ExecuteSettingsCommand(); + } } } \ No newline at end of file diff --git a/Aaru.Gui/Dialogs/dlgSettings.xeto b/Aaru.Gui/Dialogs/dlgSettings.xeto deleted file mode 100644 index 8cb794baa..000000000 --- a/Aaru.Gui/Dialogs/dlgSettings.xeto +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Aaru.Gui/Dialogs/dlgSettings.xeto.cs b/Aaru.Gui/Dialogs/dlgSettings.xeto.cs deleted file mode 100644 index a92acdbd7..000000000 --- a/Aaru.Gui/Dialogs/dlgSettings.xeto.cs +++ /dev/null @@ -1,198 +0,0 @@ -// /*************************************************************************** -// Aaru Data Preservation Suite -// ---------------------------------------------------------------------------- -// -// Filename : dlgSettings.xeto.cs -// Author(s) : Natalia Portillo -// -// Component : Settings dialog. -// -// --[ Description ] ---------------------------------------------------------- -// -// Implements the settings dialog. -// -// --[ License ] -------------------------------------------------------------- -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General public License for more details. -// -// You should have received a copy of the GNU General public License -// along with this program. If not, see . -// -// ---------------------------------------------------------------------------- -// Copyright © 2011-2020 Natalia Portillo -// ****************************************************************************/ - -using System; -using Aaru.Settings; -using Eto.Forms; -using Eto.Serialization.Xaml; - -namespace Aaru.Gui.Dialogs -{ - public class dlgSettings : Dialog - { - public dlgSettings(bool gdprChange) - { - XamlReader.Load(this); - - lblGdpr1.Text = - "In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),\n" + - "we must give you the following information about Aaru and ask if you want to opt-in\n" + - "in some information sharing."; - - lblGdpr2.Text = - "Disclaimer: Because Aaru is an open source software this information, and therefore,\n" + - "compliance with GDPR only holds true if you obtained a certificated copy from its original\n" + - "authors. In case of doubt, close Aaru now and ask in our IRC support channel."; - - lblGdpr3.Text = - "For any information sharing your IP address may be stored in our server, in a way that is not\n" + - "possible for any person, manual, or automated process, to link with your identity, unless\n" + - "specified otherwise."; - - tabGdpr.Visible = gdprChange; - - #region Device reports - lblSaveReportsGlobally.Text = - "With the 'device-report' command, Aaru creates a report of a device, that includes its\n" + - "manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands.\n" + - "The serial number of the device is not stored in the report. If used with the debug parameter,\n" + - "extra information about the device will be stored in the report. This information is known to contain\n" + - "the device serial number in non-standard places that prevent the automatic removal of it on a handful\n" + - "of devices. A human-readable copy of the report in XML format is always created in the same directory\n" + - "where Aaru is being run from."; - - chkSaveReportsGlobally.Text = - "Do you want to save device reports in shared folder of your computer? (Y/N): "; - - chkSaveReportsGlobally.Checked = Settings.Settings.Current.SaveReportsGlobally; - - lblShareReports.Text = - "Sharing a report with us will send it to our server, that's in the european union territory, where it\n" + - "will be manually analized by an european union citizen to remove any trace of personal identification\n" + - "from it. Once that is done, it will be shared in our stats website, https://www.aaru.app\n" + - "These report will be used to improve Aaru support, and in some cases, to provide emulation of the\n" + - "devices to other open-source projects. In any case, no information linking the report to you will be stored."; - - chkShareReports.Text = "Do you want to share your device reports with us? (Y/N): "; - chkShareReports.Checked = Settings.Settings.Current.ShareReports; - #endregion Device reports - - #region Statistics - lblStatistics.Text = - "Aaru can store some usage statistics. These statistics are limited to the number of times a\n" + - "command is executed, a filesystem, partition, or device is used, the operating system version, and other.\n" + - "In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the\n" + - "pool with no way of using them to identify you."; - - chkSaveStats.Text = "Do you want to save stats about your Aaru usage? (Y/N): "; - - if(Settings.Settings.Current.Stats != null) - { - chkSaveStats.Checked = true; - stkStatistics.Visible = true; - - chkShareStats.Text = "Do you want to share your stats anonymously? (Y/N): "; - chkShareStats.Checked = Settings.Settings.Current.Stats.ShareStats; - - chkCommandStats.Text = "Do you want to gather statistics about command usage? (Y/N): "; - chkCommandStats.Checked = Settings.Settings.Current.Stats.CommandStats; - - chkDeviceStats.Text = "Do you want to gather statistics about found devices? (Y/N): "; - chkDeviceStats.Checked = Settings.Settings.Current.Stats.DeviceStats; - - chkFilesystemStats.Text = "Do you want to gather statistics about found filesystems? (Y/N): "; - chkFilesystemStats.Checked = Settings.Settings.Current.Stats.FilesystemStats; - - chkFilterStats.Text = "Do you want to gather statistics about found file filters? (Y/N): "; - chkFilterStats.Checked = Settings.Settings.Current.Stats.FilterStats; - - chkMediaImageStats.Text = "Do you want to gather statistics about found media image formats? (Y/N): "; - - chkMediaImageStats.Checked = Settings.Settings.Current.Stats.MediaImageStats; - - chkMediaScanStats.Text = "Do you want to gather statistics about scanned media? (Y/N): "; - chkMediaScanStats.Checked = Settings.Settings.Current.Stats.MediaScanStats; - - chkPartitionStats.Text = "Do you want to gather statistics about found partitioning schemes? (Y/N): "; - - chkPartitionStats.Checked = Settings.Settings.Current.Stats.PartitionStats; - - chkMediaStats.Text = "Do you want to gather statistics about media types? (Y/N): "; - chkMediaStats.Checked = Settings.Settings.Current.Stats.MediaStats; - - chkVerifyStats.Text = "Do you want to gather statistics about media image verifications? (Y/N): "; - chkVerifyStats.Checked = Settings.Settings.Current.Stats.VerifyStats; - } - else - { - chkSaveStats.Checked = false; - stkStatistics.Visible = false; - } - #endregion Statistics - } - - protected void OnBtnCancel(object sender, EventArgs e) => Close(); - - protected void OnBtnSave(object sender, EventArgs e) - { - Settings.Settings.Current.SaveReportsGlobally = chkSaveReportsGlobally.Checked == true; - Settings.Settings.Current.ShareReports = chkShareReports.Checked == true; - - if(chkSaveStats.Checked == true) - Settings.Settings.Current.Stats = new StatsSettings - { - ShareStats = chkShareStats.Checked == true, - CommandStats = chkCommandStats.Checked == true, - DeviceStats = chkDeviceStats.Checked == true, - FilesystemStats = chkFilesystemStats.Checked == true, - FilterStats = chkFilterStats.Checked == true, - MediaImageStats = chkMediaImageStats.Checked == true, - MediaScanStats = chkMediaScanStats.Checked == true, - PartitionStats = chkPartitionStats.Checked == true, MediaStats = chkMediaStats.Checked == true, - VerifyStats = chkVerifyStats.Checked == true - }; - else - Settings.Settings.Current.Stats = null; - - Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel; - Settings.Settings.SaveSettings(); - Close(); - } - - #region XAML controls - Label lblGdpr1; - Label lblGdpr2; - Label lblGdpr3; - CheckBox chkSaveReportsGlobally; - CheckBox chkShareReports; - CheckBox chkSaveStats; - CheckBox chkShareStats; - CheckBox chkCommandStats; - CheckBox chkDeviceStats; - CheckBox chkFilesystemStats; - CheckBox chkFilterStats; - CheckBox chkMediaScanStats; - CheckBox chkPartitionStats; - CheckBox chkMediaStats; - CheckBox chkVerifyStats; - TabPage tabGdpr; - TabPage tabReports; - Label lblSaveReportsGlobally; - Label lblShareReports; - TabPage tabStatistics; - StackLayout stkButtons; - StackLayout stkStatistics; - Label lblStatistics; - CheckBox chkMediaImageStats; - #endregion - } -} \ No newline at end of file diff --git a/Aaru.Gui/Forms/frmMain.xeto.cs b/Aaru.Gui/Forms/frmMain.xeto.cs index eeb1c535d..036e0d727 100644 --- a/Aaru.Gui/Forms/frmMain.xeto.cs +++ b/Aaru.Gui/Forms/frmMain.xeto.cs @@ -44,9 +44,7 @@ using Aaru.Console; using Aaru.Core; using Aaru.Core.Media.Info; using Aaru.Devices; -using Aaru.Gui.Dialogs; using Aaru.Gui.Panels; -using Aaru.Settings; using Eto.Drawing; using Eto.Forms; using Eto.Serialization.Xaml; @@ -294,14 +292,6 @@ namespace Aaru.Gui.Forms // TODO void CloseAllImages(object sender, EventArgs eventArgs) => Eto.Forms.MessageBox.Show("Not yet implemented"); - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - if(Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) - new dlgSettings(true).ShowModal(this); - } - void OnClosing(object sender, CancelEventArgs e) { // This prevents an infinite loop of crashes :p @@ -581,8 +571,6 @@ namespace Aaru.Gui.Forms protected void OnDeviceRefresh(object sender, EventArgs e) => RefreshDevices(); - protected void OnMenuSettings(object sender, EventArgs e) => new dlgSettings(false).ShowModal(this); - protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); diff --git a/Aaru.Gui/ViewModels/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/MainWindowViewModel.cs index d81c1a81c..269db434b 100644 --- a/Aaru.Gui/ViewModels/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/MainWindowViewModel.cs @@ -20,7 +20,8 @@ namespace Aaru.Gui.ViewModels EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand); PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand); StatisticsCommand = ReactiveCommand.Create(ExecuteStatisticsCommand); - ExitCommand = ReactiveCommand.Create(ExecuteExitCommand); + ExitCommand = ReactiveCommand.Create(ExecuteExitCommand); + SettingsCommand = ReactiveCommand.Create(ExecuteSettingsCommand); _view = view; } @@ -34,7 +35,8 @@ namespace Aaru.Gui.ViewModels public ReactiveCommand EncodingsCommand { get; } public ReactiveCommand PluginsCommand { get; } public ReactiveCommand StatisticsCommand { get; } - public ReactiveCommand ExitCommand { get; } + public ReactiveCommand ExitCommand { get; } + public ReactiveCommand SettingsCommand { get; } internal void ExecuteAboutCommand() { @@ -79,6 +81,14 @@ namespace Aaru.Gui.ViewModels dialog.ShowDialog(_view); } - internal void ExecuteExitCommand() => (Application.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown(); + internal async void ExecuteSettingsCommand() + { + var dialog = new SettingsDialog(); + dialog.DataContext = new SettingsDialogViewModel(dialog, false); + await dialog.ShowDialog(_view); + } + + internal void ExecuteExitCommand() => + (Application.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown(); } } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/SettingsDialogViewModel.cs b/Aaru.Gui/ViewModels/SettingsDialogViewModel.cs new file mode 100644 index 000000000..b53f65292 --- /dev/null +++ b/Aaru.Gui/ViewModels/SettingsDialogViewModel.cs @@ -0,0 +1,233 @@ +using System.Reactive; +using Aaru.Gui.Views; +using Aaru.Settings; +using ReactiveUI; + +namespace Aaru.Gui.ViewModels +{ + public class SettingsDialogViewModel : ViewModelBase + { + readonly SettingsDialog _view; + bool _commandStatsChecked; + bool _deviceStatsChecked; + bool _filesystemStatsChecked; + bool _filterStatsChecked; + bool _gdprVisible; + bool _mediaImageStatsChecked; + bool _mediaScanStatsChecked; + bool _mediaStatsChecked; + bool _partitionStatsChecked; + bool _saveReportsGloballyChecked; + bool _saveStatsChecked; + bool _shareReportsChecked; + bool _shareStatsChecked; + int _tabControlSelectedIndex; + bool _verifyStatsChecked; + + public SettingsDialogViewModel(SettingsDialog view, bool gdprChange) + { + _view = view; + GdprVisible = gdprChange; + SaveReportsGloballyChecked = Settings.Settings.Current.SaveReportsGlobally; + ShareReportsChecked = Settings.Settings.Current.ShareReports; + + if(Settings.Settings.Current.Stats != null) + { + SaveStatsChecked = true; + ShareStatsChecked = Settings.Settings.Current.Stats.ShareStats; + CommandStatsChecked = Settings.Settings.Current.Stats.CommandStats; + DeviceStatsChecked = Settings.Settings.Current.Stats.DeviceStats; + FilesystemStatsChecked = Settings.Settings.Current.Stats.FilesystemStats; + FilterStatsChecked = Settings.Settings.Current.Stats.FilterStats; + MediaImageStatsChecked = Settings.Settings.Current.Stats.MediaImageStats; + MediaScanStatsChecked = Settings.Settings.Current.Stats.MediaScanStats; + PartitionStatsChecked = Settings.Settings.Current.Stats.PartitionStats; + MediaStatsChecked = Settings.Settings.Current.Stats.MediaStats; + VerifyStatsChecked = Settings.Settings.Current.Stats.VerifyStats; + } + else + SaveStatsChecked = false; + + CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand); + SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand); + + if(!_gdprVisible) + _tabControlSelectedIndex = 1; + } + + // TODO: Show Preferences in macOS + public string Title => "Settings"; + public string GdprLabel => "GDPR"; + public string ReportsLabel => "Reports"; + public string StatisticsLabel => "Statistics"; + public string SaveLabel => "Save"; + public string CancelLabel => "Cancel"; + public string GdprText1 => + @"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR), +we must give you the following information about Aaru and ask if you want to opt-in +in some information sharing."; + + public string GdprText2 => + @"Disclaimer: Because Aaru is an open source software this information, and therefore, +compliance with GDPR only holds true if you obtained a certificated copy from its original +authors. In case of doubt, close Aaru now and ask in our IRC support channel."; + + public string GdprText3 => + @"For any information sharing your IP address may be stored in our server, in a way that is not +possible for any person, manual, or automated process, to link with your identity, unless +specified otherwise."; + public string ReportsGloballyText => + @"With the 'device-report' command, Aaru creates a report of a device, that includes its +manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands. +The serial number of the device is not stored in the report. If used with the debug parameter, +extra information about the device will be stored in the report. This information is known to contain +the device serial number in non-standard places that prevent the automatic removal of it on a handful +of devices. A human-readable copy of the report in XML format is always created in the same directory +where Aaru is being run from."; + + public string SaveReportsGloballyText => "Save device reports in shared folder of your computer?"; + + public string ReportsText => + @"Sharing a report with us will send it to our server, that's in the european union territory, where it +will be manually analized by an european union citizen to remove any trace of personal identification +from it. Once that is done, it will be shared in our stats website, https://www.aaru.app +These report will be used to improve Aaru support, and in some cases, to provide emulation of the +devices to other open-source projects. In any case, no information linking the report to you will be stored."; + + public string ShareReportsText => "Share your device reports with us?"; + public string StatisticsText => + @"Aaru can store some usage statistics. These statistics are limited to the number of times a +command is executed, a filesystem, partition, or device is used, the operating system version, and other. +In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the +pool with no way of using them to identify you."; + + public string SaveStatsText => "Save stats about your Aaru usage?"; + public string ShareStatsText => "Share your stats anonymously?"; + public string CommandStatsText => "Gather statistics about command usage?"; + public string DeviceStatsText => "Gather statistics about found devices?"; + public string FilesystemStatsText => "Gather statistics about found filesystems?"; + public string FilterStatsText => "Gather statistics about found file filters?"; + public string MediaImageStatsText => "Gather statistics about found media image formats?"; + public string MediaScanStatsText => "Gather statistics about scanned media?"; + public string PartitionStatsText => "Gather statistics about found partitioning schemes?"; + public string MediaStatsText => "Gather statistics about media types?"; + public string VerifyStatsText => "Gather statistics about media image verifications?"; + + public ReactiveCommand CancelCommand { get; } + public ReactiveCommand SaveCommand { get; } + + public bool GdprVisible + { + get => _gdprVisible; + set => this.RaiseAndSetIfChanged(ref _gdprVisible, value); + } + + public bool SaveReportsGloballyChecked + { + get => _saveReportsGloballyChecked; + set => this.RaiseAndSetIfChanged(ref _saveReportsGloballyChecked, value); + } + + public bool ShareReportsChecked + { + get => _shareReportsChecked; + set => this.RaiseAndSetIfChanged(ref _shareReportsChecked, value); + } + + public bool SaveStatsChecked + { + get => _saveStatsChecked; + set => this.RaiseAndSetIfChanged(ref _saveStatsChecked, value); + } + + public bool ShareStatsChecked + { + get => _shareStatsChecked; + set => this.RaiseAndSetIfChanged(ref _shareStatsChecked, value); + } + + public bool CommandStatsChecked + { + get => _commandStatsChecked; + set => this.RaiseAndSetIfChanged(ref _commandStatsChecked, value); + } + + public bool DeviceStatsChecked + { + get => _deviceStatsChecked; + set => this.RaiseAndSetIfChanged(ref _deviceStatsChecked, value); + } + + public bool FilesystemStatsChecked + { + get => _filesystemStatsChecked; + set => this.RaiseAndSetIfChanged(ref _filesystemStatsChecked, value); + } + + public bool FilterStatsChecked + { + get => _filterStatsChecked; + set => this.RaiseAndSetIfChanged(ref _filterStatsChecked, value); + } + + public bool MediaImageStatsChecked + { + get => _mediaImageStatsChecked; + set => this.RaiseAndSetIfChanged(ref _mediaImageStatsChecked, value); + } + + public bool MediaScanStatsChecked + { + get => _mediaScanStatsChecked; + set => this.RaiseAndSetIfChanged(ref _mediaScanStatsChecked, value); + } + + public bool PartitionStatsChecked + { + get => _partitionStatsChecked; + set => this.RaiseAndSetIfChanged(ref _partitionStatsChecked, value); + } + + public bool MediaStatsChecked + { + get => _mediaStatsChecked; + set => this.RaiseAndSetIfChanged(ref _mediaStatsChecked, value); + } + + public bool VerifyStatsChecked + { + get => _verifyStatsChecked; + set => this.RaiseAndSetIfChanged(ref _verifyStatsChecked, value); + } + + public int TabControlSelectedIndex + { + get => _tabControlSelectedIndex; + set => this.RaiseAndSetIfChanged(ref _tabControlSelectedIndex, value); + } + + void ExecuteSaveCommand() + { + Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked; + Settings.Settings.Current.ShareReports = ShareReportsChecked; + + if(SaveStatsChecked) + Settings.Settings.Current.Stats = new StatsSettings + { + ShareStats = ShareStatsChecked, CommandStats = CommandStatsChecked, + DeviceStats = DeviceStatsChecked, FilesystemStats = FilesystemStatsChecked, + FilterStats = FilterStatsChecked, MediaImageStats = MediaImageStatsChecked, + MediaScanStats = MediaScanStatsChecked, PartitionStats = PartitionStatsChecked, + MediaStats = MediaStatsChecked, VerifyStats = VerifyStatsChecked + }; + else + Settings.Settings.Current.Stats = null; + + Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel; + Settings.Settings.SaveSettings(); + _view.Close(); + } + + void ExecuteCancelCommand() => _view.Close(); + } +} \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/SplashWindowViewModel.cs index c79ac6fca..0026fb195 100644 --- a/Aaru.Gui/ViewModels/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/SplashWindowViewModel.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Aaru.Console; using Aaru.Core; using Aaru.Database; +using Aaru.Gui.Views; using Aaru.Settings; using Avalonia.Threading; using Microsoft.EntityFrameworkCore; @@ -15,9 +16,12 @@ namespace Aaru.Gui.ViewModels { public class SplashWindowViewModel : ViewModelBase { - double _currentProgress; - double _maxProgress; - string _message; + readonly SplashWindow _view; + double _currentProgress; + double _maxProgress; + string _message; + + public SplashWindowViewModel(SplashWindow view) => _view = view; public string Message { @@ -130,19 +134,21 @@ namespace Aaru.Gui.ViewModels }); } - void CheckGdprCompliance() + async void CheckGdprCompliance() { CurrentProgress++; Message = "Checking GDPR compliance..."; - Task.Run(() => + if(Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) { - // TODO: Settings window - if(Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) - AaruConsole.ErrorWriteLine("Settings window not yet implemented"); + var settingsDialog = new SettingsDialog(); + var settingsDialogViewModel = new SettingsDialogViewModel(settingsDialog, true); + settingsDialog.DataContext = settingsDialogViewModel; + await settingsDialog.ShowDialog(_view); + AaruConsole.ErrorWriteLine("Settings window not yet implemented"); + } - Dispatcher.UIThread.Post(LoadStatistics); - }); + LoadStatistics(); } void LoadStatistics() diff --git a/Aaru.Gui/Views/MainWindow.xaml b/Aaru.Gui/Views/MainWindow.xaml index 0ffb11ae1..f3102885d 100644 --- a/Aaru.Gui/Views/MainWindow.xaml +++ b/Aaru.Gui/Views/MainWindow.xaml @@ -10,8 +10,10 @@ - - + + + diff --git a/Aaru.Gui/Views/SettingsDialog.xaml b/Aaru.Gui/Views/SettingsDialog.xaml new file mode 100644 index 000000000..d4b356809 --- /dev/null +++ b/Aaru.Gui/Views/SettingsDialog.xaml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Aaru.Gui/Views/SettingsDialog.xaml.cs b/Aaru.Gui/Views/SettingsDialog.xaml.cs new file mode 100644 index 000000000..f1fc3f3ca --- /dev/null +++ b/Aaru.Gui/Views/SettingsDialog.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Aaru.Gui.Views +{ + public class SettingsDialog : Window + { + public SettingsDialog() + { + InitializeComponent(); + #if DEBUG + this.AttachDevTools(); + #endif + } + + void InitializeComponent() => AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file