2020-04-17 21:45:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : SettingsViewModel.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// View model and code 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
|
using System.Windows.Input;
|
2020-04-16 20:40:25 +01:00
|
|
|
|
using Aaru.Gui.Views.Dialogs;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
using Aaru.Settings;
|
2025-08-20 21:19:43 +01:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Gui.ViewModels.Dialogs;
|
|
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
|
public sealed partial class SettingsViewModel : ViewModelBase
|
2020-04-10 22:33:27 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
readonly SettingsDialog _view;
|
2025-08-20 21:19:43 +01:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _commandStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _deviceStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _filesystemStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _filterStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _gdprVisible;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _mediaImageStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _mediaScanStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _mediaStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _partitionStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _saveReportsGloballyChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _saveStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _shareReportsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _shareStatsChecked;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
int _tabControlSelectedIndex;
|
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
bool _verifyStatsChecked;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
public SettingsViewModel(SettingsDialog view, bool gdprChange)
|
2020-04-10 22:33:27 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_view = view;
|
|
|
|
|
|
GdprVisible = gdprChange;
|
2022-11-15 15:58:43 +00:00
|
|
|
|
SaveReportsGloballyChecked = Settings.Settings.Current.SaveReportsGlobally;
|
|
|
|
|
|
ShareReportsChecked = Settings.Settings.Current.ShareReports;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
if(Settings.Settings.Current.Stats != null)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
SaveStatsChecked = true;
|
2022-11-15 15:58:43 +00:00
|
|
|
|
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;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
|
|
|
|
|
SaveStatsChecked = false;
|
|
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
|
CancelCommand = new RelayCommand(Cancel);
|
|
|
|
|
|
SaveCommand = new RelayCommand(Save);
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(!_gdprVisible) _tabControlSelectedIndex = 1;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Show Preferences in macOS
|
2025-08-20 21:19:43 +01:00
|
|
|
|
public ICommand CancelCommand { get; }
|
|
|
|
|
|
public ICommand SaveCommand { get; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
|
void Save()
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked;
|
|
|
|
|
|
Settings.Settings.Current.ShareReports = ShareReportsChecked;
|
2020-04-10 22:33:27 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(SaveStatsChecked)
|
2023-10-03 23:27:57 +01:00
|
|
|
|
{
|
2022-11-15 15:58:43 +00:00
|
|
|
|
Settings.Settings.Current.Stats = new StatsSettings
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
ShareStats = ShareStatsChecked,
|
|
|
|
|
|
CommandStats = CommandStatsChecked,
|
|
|
|
|
|
DeviceStats = DeviceStatsChecked,
|
|
|
|
|
|
FilesystemStats = FilesystemStatsChecked,
|
|
|
|
|
|
FilterStats = FilterStatsChecked,
|
|
|
|
|
|
MediaImageStats = MediaImageStatsChecked,
|
|
|
|
|
|
MediaScanStats = MediaScanStatsChecked,
|
|
|
|
|
|
PartitionStats = PartitionStatsChecked,
|
|
|
|
|
|
MediaStats = MediaStatsChecked,
|
|
|
|
|
|
VerifyStats = VerifyStatsChecked
|
|
|
|
|
|
};
|
2023-10-03 23:27:57 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2022-11-15 15:58:43 +00:00
|
|
|
|
Settings.Settings.Current.Stats = null;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
|
|
|
|
|
|
Settings.Settings.SaveSettings();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
_view.Close();
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
|
void Cancel() => _view.Close();
|
2020-04-10 22:33:27 +01:00
|
|
|
|
}
|