new settings added

This commit is contained in:
2024-03-10 13:42:41 +01:00
Unverified
parent 7f1163449c
commit 6246a96be7
15 changed files with 112 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Tasks;
using VDownload.Services.Data.Settings;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources;
@@ -21,6 +22,7 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService;
protected readonly ISettingsService _settingsService;
#endregion
@@ -39,13 +41,14 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService, ISettingsService settingsService)
{
_tasksManager = tasksManager;
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
_dialogsService = dialogsService;
_stringResourcesService = stringResourcesService;
_settingsService = settingsService;
_taskListIsEmpty = _tasksManager.Tasks.Count == 0;
}
@@ -77,7 +80,12 @@ namespace VDownload.Core.ViewModels.Home
}
bool continueEnqueue = true;
if (NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
if
(
_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings
&&
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -297,7 +297,14 @@ namespace VDownload.Core.ViewModels.Home
protected async Task CreateTasks(bool download)
{
if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
if
(
download
&&
_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings
&&
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -175,7 +175,14 @@ namespace VDownload.Core.ViewModels.Home
protected async Task CreateTask(bool download)
{
if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
if
(
download
&&
_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings
&&
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");

View File

@@ -342,26 +342,34 @@ namespace VDownload.Core.ViewModels.Home
[RelayCommand]
public async Task Download()
{
if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
if (_downloadTaskManager.Tasks.Count > 0)
{
ShowError(ErrorNoInternetConnection());
return;
}
if (_downloadTaskManager.Tasks.Count > 0 && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
if (result == DialogResultYesNo.No)
if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable)
{
ShowError(ErrorNoInternetConnection());
return;
}
}
foreach (DownloadTask task in _downloadTaskManager.Tasks)
{
task.Enqueue();
if
(
_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings
&&
NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection
)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
if (result == DialogResultYesNo.No)
{
return;
}
}
foreach (DownloadTask task in _downloadTaskManager.Tasks)
{
task.Enqueue();
}
}
}

View File

@@ -65,6 +65,12 @@ namespace VDownload.Core.ViewModels.Settings
set => SetProperty(_settingsService.Data.Common.Tasks.FilenameTemplate, value, _settingsService.Data.Common.Tasks, (u, n) => u.FilenameTemplate = n);
}
public bool TasksMeteredConnectionWarning
{
get => _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings;
set => SetProperty(_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings, value, _settingsService.Data.Common.Tasks, (u, n) => u.ShowMeteredConnectionWarnings = n);
}
public bool TasksSaveLastOutputDirectory
{
get => _settingsService.Data.Common.Tasks.SaveLastOutputDirectory;
@@ -77,6 +83,12 @@ namespace VDownload.Core.ViewModels.Settings
set => SetProperty(_settingsService.Data.Common.Tasks.DefaultOutputDirectory, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultOutputDirectory = n);
}
public bool TasksReplaceOutputFile
{
get => _settingsService.Data.Common.Tasks.ReplaceOutputFileIfExists;
set => SetProperty(_settingsService.Data.Common.Tasks.ReplaceOutputFileIfExists, value, _settingsService.Data.Common.Tasks, (u, n) => u.ReplaceOutputFileIfExists = n);
}
public string ProcessingFFmpegLocation
{
get => _settingsService.Data.Common.Processing.FFmpegLocation;