mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Migrate settings from Eto.Forms to Avalonia.
This commit is contained in:
7
.idea/.idea.Aaru/.idea/contentModel.xml
generated
7
.idea/.idea.Aaru/.idea/contentModel.xml
generated
@@ -1218,10 +1218,6 @@
|
||||
<e p="LineChart.cs" t="Include" />
|
||||
<e p="SvgImageView.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Dialogs" t="Include">
|
||||
<e p="dlgSettings.xeto" t="Include" />
|
||||
<e p="dlgSettings.xeto.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Forms" t="Include">
|
||||
<e p="frmConsole.xeto" t="Include" />
|
||||
<e p="frmConsole.xeto.cs" t="Include" />
|
||||
@@ -1296,6 +1292,7 @@
|
||||
<e p="LicenseDialogViewModel.cs" t="Include" />
|
||||
<e p="MainWindowViewModel.cs" t="Include" />
|
||||
<e p="PluginsDialogViewModel.cs" t="Include" />
|
||||
<e p="SettingsDialogViewModel.cs" t="Include" />
|
||||
<e p="SplashWindowViewModel.cs" t="Include" />
|
||||
<e p="StatisticsDialogViewModel.cs" t="Include" />
|
||||
<e p="ViewModelBase.cs" t="Include" />
|
||||
@@ -1311,6 +1308,8 @@
|
||||
<e p="MainWindow.xaml.cs" t="Include" />
|
||||
<e p="PluginsDialog.xaml" t="Include" />
|
||||
<e p="PluginsDialog.xaml.cs" t="Include" />
|
||||
<e p="SettingsDialog.xaml" t="Include" />
|
||||
<e p="SettingsDialog.xaml.cs" t="Include" />
|
||||
<e p="SplashWindow.xaml" t="Include" />
|
||||
<e p="SplashWindow.xaml.cs" t="Include" />
|
||||
<e p="StatisticsDialog.xaml" t="Include" />
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
</Application.Styles>
|
||||
<NativeMenu.Menu>
|
||||
<NativeMenu>
|
||||
<NativeMenuItem Header="_About" Clicked="OnAboutClicked" /> <NativeMenuItem Header="_Preferences" />
|
||||
<NativeMenuItem Header="_About" Clicked="OnAboutClicked" />
|
||||
<NativeMenuItem Header="_Preferences" Clicked="OnPreferencesClicked" />
|
||||
<NativeMenuItem Header="_Quit" Clicked="OnQuitClicked" />
|
||||
</NativeMenu>
|
||||
</NativeMenu.Menu>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ============================================================================
|
||||
//
|
||||
// Filename : dlgSettings.xeto
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Settings dialog.
|
||||
//
|
||||
// ==[ Description ] ==========================================================
|
||||
//
|
||||
// Defines the structure for 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ============================================================================
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
-->
|
||||
<Dialog xmlns="http://schema.picoe.ca/eto.forms" Title="Settings" ClientSize="460, 160" Padding="10">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<TabControl>
|
||||
<TabPage ID="tabGdpr" Text="GDPR">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Expand="True">
|
||||
<StackLayout Orientation="Vertical" ID="stkGdpr">
|
||||
<Label ID="lblGdpr1"/>
|
||||
<Label/>
|
||||
<Label ID="lblGdpr2"/>
|
||||
<Label/>
|
||||
<Label ID="lblGdpr3"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
<TabPage ID="tabReports" Text="Reports">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label ID="lblSaveReportsGlobally"/>
|
||||
<CheckBox ID="chkSaveReportsGlobally"/>
|
||||
<Label/>
|
||||
<Label ID="lblShareReports"/>
|
||||
<CheckBox ID="chkShareReports"/>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
<TabPage ID="tabStatistics" Text="Statistics">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label ID="lblStatistics"/>
|
||||
<Label/>
|
||||
<CheckBox ID="chkSaveStats"/>
|
||||
<Label/>
|
||||
<StackLayout Orientation="Vertical" ID="stkStatistics">
|
||||
<CheckBox ID="chkShareStats"/>
|
||||
<CheckBox ID="chkCommandStats"/>
|
||||
<CheckBox ID="chkDeviceStats"/>
|
||||
<CheckBox ID="chkFilesystemStats"/>
|
||||
<CheckBox ID="chkFilterStats"/>
|
||||
<CheckBox ID="chkMediaImageStats"/>
|
||||
<CheckBox ID="chkMediaScanStats"/>
|
||||
<CheckBox ID="chkPartitionStats"/>
|
||||
<CheckBox ID="chkMediaStats"/>
|
||||
<CheckBox ID="chkVerifyStats"/>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</TabPage>
|
||||
</TabControl>
|
||||
<StackLayoutItem HorizontalAlignment="Right" VerticalAlignment="Bottom" Expand="True">
|
||||
<StackLayout Orientation="Horizontal" ID="stkButtons">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Button ID="btnCancel" Click="OnBtnCancel">Cancel</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Button ID="btnSave" Click="OnBtnSave">Save</Button>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Dialog>
|
||||
@@ -1,198 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// Aaru Data Preservation Suite
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : dlgSettings.xeto.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// 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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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<Unit, Unit> EncodingsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> PluginsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> StatisticsCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ExitCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> ExitCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> 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();
|
||||
}
|
||||
}
|
||||
233
Aaru.Gui/ViewModels/SettingsDialogViewModel.cs
Normal file
233
Aaru.Gui/ViewModels/SettingsDialogViewModel.cs
Normal file
@@ -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<Unit, Unit> CancelCommand { get; }
|
||||
public ReactiveCommand<Unit, Unit> 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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_Open" /> <Separator />
|
||||
<MenuItem Header="_Settings" IsVisible="{Binding NativeMenuNotSupported}" /> <Separator />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding NativeMenuNotSupported}" Command="{Binding ExitCommand}"/>
|
||||
<MenuItem Header="_Settings" IsVisible="{Binding NativeMenuNotSupported}"
|
||||
Command="{Binding SettingsCommand}" />
|
||||
<Separator />
|
||||
<MenuItem Header="E_xit" IsVisible="{Binding NativeMenuNotSupported}" Command="{Binding ExitCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Devices">
|
||||
<MenuItem Header="_Refresh" />
|
||||
|
||||
101
Aaru.Gui/Views/SettingsDialog.xaml
Normal file
101
Aaru.Gui/Views/SettingsDialog.xaml
Normal file
@@ -0,0 +1,101 @@
|
||||
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels;assembly=Aaru.Gui"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800"
|
||||
d:DesignHeight="450" Width="675" Height="432" x:Class="Aaru.Gui.Views.SettingsDialog"
|
||||
Icon="/Assets/aaru-logo.png" CanResize="False" Title="{Binding Title}">
|
||||
<Design.DataContext>
|
||||
<vm:SettingsDialogViewModel />
|
||||
</Design.DataContext>
|
||||
<Border Padding="15">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" /> <RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
SelectedIndex="{Binding TabControlSelectedIndex}">
|
||||
<TabItem IsVisible="{Binding GdprVisible}">
|
||||
<TabItem.Header>
|
||||
<TextBlock Text="{Binding GdprLabel}" />
|
||||
</TabItem.Header>
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Text="{Binding GdprText1}" /> <Border Padding="10" />
|
||||
<TextBlock Text="{Binding GdprText2}" /> <Border Padding="10" />
|
||||
<TextBlock Text="{Binding GdprText3}" />
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem>
|
||||
<TabItem.Header>
|
||||
<TextBlock Text="{Binding ReportsLabel}" />
|
||||
</TabItem.Header>
|
||||
<StackPanel Spacing="15">
|
||||
<StackPanel Spacing="5">
|
||||
<TextBlock Text="{Binding ReportsGloballyText}" />
|
||||
<CheckBox IsChecked="{Binding SaveReportsGloballyChecked}">
|
||||
<TextBlock Text="{Binding SaveReportsGloballyText}" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding ReportsText}" />
|
||||
<CheckBox IsChecked="{Binding ShareReportsChecked}">
|
||||
<TextBlock Text="{Binding ShareReportsText}" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem>
|
||||
<TabItem.Header>
|
||||
<TextBlock Text="{Binding StatisticsLabel}" />
|
||||
</TabItem.Header>
|
||||
<StackPanel Spacing="15">
|
||||
<TextBlock Text="{Binding StatisticsText}" />
|
||||
<CheckBox IsChecked="{Binding SaveStatsChecked}">
|
||||
<TextBlock Text="{Binding SaveStatsText}" />
|
||||
</CheckBox>
|
||||
<StackPanel IsVisible="{Binding SaveStatsChecked}" Spacing="5">
|
||||
<CheckBox IsChecked="{Binding ShareStatsChecked}">
|
||||
<TextBlock Text="{Binding ShareStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding CommandStatsChecked}">
|
||||
<TextBlock Text="{Binding CommandStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding DeviceStatsChecked}">
|
||||
<TextBlock Text="{Binding DeviceStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding FilesystemStatsChecked}">
|
||||
<TextBlock Text="{Binding FilesystemStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding FilesystemStatsChecked}">
|
||||
<TextBlock Text="{Binding FilterStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding MediaImageStatsChecked}">
|
||||
<TextBlock Text="{Binding MediaImageStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding MediaScanStatsChecked}">
|
||||
<TextBlock Text="{Binding MediaScanStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding PartitionStatsChecked}">
|
||||
<TextBlock Text="{Binding PartitionStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding MediaStatsChecked}">
|
||||
<TextBlock Text="{Binding MediaStatsText}" />
|
||||
</CheckBox>
|
||||
<CheckBox IsChecked="{Binding VerifyStatsChecked}">
|
||||
<TextBlock Text="{Binding VerifyStatsText}" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<StackPanel Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"
|
||||
Spacing="5">
|
||||
<Button Command="{Binding SaveCommand}">
|
||||
<TextBlock Text="{Binding SaveLabel}" />
|
||||
</Button>
|
||||
<Button Command="{Binding CancelCommand}">
|
||||
<TextBlock Text="{Binding CancelLabel}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
19
Aaru.Gui/Views/SettingsDialog.xaml.cs
Normal file
19
Aaru.Gui/Views/SettingsDialog.xaml.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user