Skip to content

Commit 01f88cf

Browse files
committed
feat: Update deps
1 parent 8e21106 commit 01f88cf

20 files changed

Lines changed: 377 additions & 214 deletions

Nickvision.Application.GNOME/Nickvision.Application.GNOME.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<Nullable>enable</Nullable>
99
<OutputType>Exe</OutputType>
1010
<Platforms>AnyCPU;ARM64;x64</Platforms>
11-
<Version>2026.3.0</Version>
11+
<Version>2026.4.0</Version>
1212
<PublishAot>true</PublishAot>
1313
</PropertyGroup>
1414

1515
<ItemGroup>
1616
<PackageReference Include="GirCore.Adw-1" Version="0.7.0" />
17-
<PackageReference Include="Nickvision.Desktop.GNOME" Version="2026.3.6" />
17+
<PackageReference Include="Nickvision.Desktop.GNOME" Version="2026.4.0" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<ProjectReference Include="..\Nickvision.Application.Shared\Nickvision.Application.Shared.csproj" />

Nickvision.Application.GNOME/Views/MainWindow.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using System.Diagnostics.CodeAnalysis;
1414
using System.IO;
1515
using System.Linq;
16+
using System.Threading.Tasks;
1617

1718
namespace Nickvision.Application.GNOME.Views;
1819

@@ -77,10 +78,11 @@ private MainWindow(IServiceProvider serviceProvider, Adw.Application application
7778
OnCloseRequest += Window_OnCloseRequest;
7879
eventsService.AppNotificationSent += (sender, e) => GLib.Functions.IdleAdd(0, () =>
7980
{
80-
Controller_AppNotificationSent(sender, e);
81+
App_AppNotificationSent(sender, e);
8182
return false;
8283
});
83-
eventsService.FolderChanged += Controller_FolderChanged;
84+
eventsService.DatabasePasswordRequired += App_DatabasePasswordRequired;
85+
eventsService.FolderChanged += App_FolderChanged;
8486
// Drop target
8587
var dropTarget = Gtk.DropTarget.New(Gio.FileHelper.GetGType(), Gdk.DragAction.Copy);
8688
dropTarget.OnDrop += Window_OnDrop;
@@ -162,7 +164,7 @@ private bool Window_OnDrop(Gtk.DropTarget sender, Gtk.DropTarget.DropSignalArgs
162164
return true;
163165
}
164166

165-
private void Controller_AppNotificationSent(object? sender, AppNotificationSentEventArgs e)
167+
private void App_AppNotificationSent(object? sender, AppNotificationSentEventArgs e)
166168
{
167169
if (e.Notification is ShellNotification shellNotification)
168170
{
@@ -192,7 +194,34 @@ private void Controller_AppNotificationSent(object? sender, AppNotificationSentE
192194
_toastOverlay!.AddToast(toast);
193195
}
194196

195-
private void Controller_FolderChanged(object? sender, FolderChangedEventArgs e)
197+
private async void App_DatabasePasswordRequired(object? sender, PasswordRequiredEventArgs e)
198+
{
199+
var password = string.Empty;
200+
var passwordEntryRow = Adw.PasswordEntryRow.New();
201+
passwordEntryRow.Title = _("Password");
202+
var preferencesGroup = Adw.PreferencesGroup.New();
203+
preferencesGroup.Add(passwordEntryRow);
204+
var dialog = Adw.MessageDialog.New(this, _translationService._("Password Required"), _translationService._("This app stores data in an encrypted database. As the system credential manager (secret service) is not available, please provide a password to use to encrypt the database.\n\nIf you've already provided a password, please provide it again to unlock the database."));
205+
dialog.AddResponse("submit", _translationService._("Submit"));
206+
dialog.SetResponseAppearance("submit", Adw.ResponseAppearance.Suggested);
207+
dialog.SetDefaultResponse("submit");
208+
dialog.SetCloseResponse("submit");
209+
dialog.SetExtraChild(preferencesGroup);
210+
dialog.OnResponse += (_, args) =>
211+
{
212+
if (args.Response == "submit")
213+
{
214+
password = passwordEntryRow.Text_ ?? string.Empty;
215+
}
216+
};
217+
while (string.IsNullOrEmpty(password))
218+
{
219+
dialog.Present();
220+
await Task.Delay(100);
221+
}
222+
}
223+
224+
private void App_FolderChanged(object? sender, FolderChangedEventArgs e)
196225
{
197226
_windowTitle!.Subtitle = e.IsOpen ? e.Path : string.Empty;
198227
_btnOpenFolder!.Visible = e.IsOpen;

Nickvision.Application.Shared/Controllers/MainWindowController.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Nickvision.Application.Shared.Models;
44
using Nickvision.Application.Shared.Services;
55
using Nickvision.Desktop.Application;
6-
using Nickvision.Desktop.Filesystem;
76
using Nickvision.Desktop.Globalization;
87
using Nickvision.Desktop.Network;
98
using Nickvision.Desktop.Notifications;
@@ -16,24 +15,24 @@ public class MainWindowController
1615
{
1716
ILogger<MainWindowController> _logger;
1817
private readonly AppInfo _appInfo;
18+
private readonly IConfigurationService _configurationService;
1919
private readonly IFolderService _folderService;
20-
private readonly IJsonFileService _jsonFileService;
2120
private readonly INotificationService _notificationService;
2221
private readonly ITranslationService _translationService;
2322
private readonly IUpdaterService _updaterService;
2423
private AppVersion _latestVersion;
2524

26-
public MainWindowController(ILogger<MainWindowController> logger, AppInfo appInfo, IArgumentsService argumentsService, IFolderService folderService, IJsonFileService jsonFileService, INotificationService notificationService, ITranslationService translationService, IUpdaterService updaterService)
25+
public MainWindowController(ILogger<MainWindowController> logger, AppInfo appInfo, IArgumentsService argumentsService, IConfigurationService configurationService, IFolderService folderService, INotificationService notificationService, ITranslationService translationService, IUpdaterService updaterService)
2726
{
2827
_logger = logger;
2928
_appInfo = appInfo;
29+
_configurationService = configurationService;
3030
_folderService = folderService;
31-
_jsonFileService = jsonFileService;
3231
_notificationService = notificationService;
3332
_translationService = translationService;
3433
_updaterService = updaterService;
3534
_latestVersion = appInfo.Version!;
36-
_translationService.Language = _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key).TranslationLanguage;
35+
_translationService.Language = _configurationService.TranslationLanguage;
3736
_logger.LogInformation($"Received command-line arguments: [{string.Join(", ", argumentsService.Data)}]");
3837
// Translate strings
3938
_appInfo.ShortName = _translationService._("Application");
@@ -61,30 +60,28 @@ public MainWindowController(ILogger<MainWindowController> logger, AppInfo appInf
6160
var _ => _translationService._("Good Day!")
6261
};
6362

64-
public Theme Theme => _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key).Theme;
63+
public Theme Theme => _configurationService.Theme;
6564

6665
public WindowGeometry WindowGeometry
6766
{
68-
get => _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key).WindowGeometry;
67+
get => _configurationService.WindowGeometry;
6968

7069
set
7170
{
72-
var config = _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key);
73-
config.WindowGeometry = value;
74-
_jsonFileService.Save(config, ApplicationJsonContext.Default.Configuration, Configuration.Key);
71+
_configurationService.WindowGeometry = value;
72+
_configurationService.Save();
7573
}
7674
}
7775

7876
public async Task CheckForUpdatesAsync(bool showNotificationForNoUpdates)
7977
{
8078
_logger.LogInformation("Checking for updates...");
81-
var config = _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key);
8279
var stableVersion = await _updaterService.GetLatestStableVersionAsync();
8380
if (stableVersion is not null)
8481
{
8582
_latestVersion = stableVersion;
8683
}
87-
if (config.AllowPreviewUpdates)
84+
if (_configurationService.AllowPreviewUpdates)
8885
{
8986
var previewVersion = await _updaterService.GetLatestPreviewVersionAsync();
9087
if (previewVersion is not null && previewVersion > stableVersion)
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Nickvision.Application.Shared.Helpers;
22
using Nickvision.Application.Shared.Models;
33
using Nickvision.Desktop.Application;
4-
using Nickvision.Desktop.Filesystem;
54
using Nickvision.Desktop.Globalization;
65
using System.Collections;
76
using System.Collections.Generic;
@@ -12,52 +11,50 @@ namespace Nickvision.Application.Shared.Controllers;
1211

1312
public class PreferencesViewController
1413
{
15-
private readonly IJsonFileService _jsonFileService;
14+
private readonly IConfigurationService _configurationService;
1615
private readonly ITranslationService _translationService;
17-
private readonly Configuration _configuration;
1816

1917
public IReadOnlyList<SelectionItem<string>> AvailableTranslationLanguages { get; }
2018
public IReadOnlyList<SelectionItem<Theme>> Themes { get; }
2119

22-
public PreferencesViewController(IJsonFileService jsonFileService, ITranslationService translationService)
20+
public PreferencesViewController(IConfigurationService configurationService, ITranslationService translationService)
2321
{
24-
_jsonFileService = jsonFileService;
22+
_configurationService = configurationService;
2523
_translationService = translationService;
26-
_configuration = _jsonFileService.Load(ApplicationJsonContext.Default.Configuration, Configuration.Key);
2724
AvailableTranslationLanguages = new List<SelectionItem<string>>()
2825
{
29-
new SelectionItem<string>(string.Empty, _translationService._("System"), string.IsNullOrEmpty(_configuration.TranslationLanguage)),
30-
new SelectionItem<string>("C", "en_US", _configuration.TranslationLanguage == "C")
26+
new SelectionItem<string>(string.Empty, _translationService._("System"), string.IsNullOrEmpty(_configurationService.TranslationLanguage)),
27+
new SelectionItem<string>("C", "en_US", _configurationService.TranslationLanguage == "C")
3128
};
3229
var languages = _translationService.AvailableLanguages.ToList();
3330
languages.Sort();
3431
foreach (var language in languages)
3532
{
36-
(AvailableTranslationLanguages as IList)!.Add(new SelectionItem<string>(language, language, _configuration.TranslationLanguage == language));
33+
(AvailableTranslationLanguages as IList)!.Add(new SelectionItem<string>(language, language, _configurationService.TranslationLanguage == language));
3734
}
3835
Themes = new List<SelectionItem<Theme>>()
3936
{
40-
new SelectionItem<Theme>(Models.Theme.Light, _translationService._p("Theme", "Light"), _configuration.Theme == Models.Theme.Light),
41-
new SelectionItem<Theme>(Models.Theme.Dark, _translationService._p("Theme", "Dark"), _configuration.Theme == Models.Theme.Dark),
42-
new SelectionItem<Theme>(Models.Theme.System, _translationService._p("Theme", "System"), _configuration.Theme == Models.Theme.System),
37+
new SelectionItem<Theme>(Models.Theme.Light, _translationService._p("Theme", "Light"), _configurationService.Theme == Models.Theme.Light),
38+
new SelectionItem<Theme>(Models.Theme.Dark, _translationService._p("Theme", "Dark"), _configurationService.Theme == Models.Theme.Dark),
39+
new SelectionItem<Theme>(Models.Theme.System, _translationService._p("Theme", "System"), _configurationService.Theme == Models.Theme.System),
4340
};
4441
}
4542
public SelectionItem<Theme> Theme
4643
{
47-
set => _configuration.Theme = value.Value;
44+
set => _configurationService.Theme = value.Value;
4845
}
4946

5047
public SelectionItem<string> TranslationLanguage
5148
{
52-
set => _configuration.TranslationLanguage = value.Value;
49+
set => _configurationService.TranslationLanguage = value.Value;
5350
}
5451

5552
public bool AllowPreviewUpdates
5653
{
57-
get => _configuration.AllowPreviewUpdates;
54+
get => _configurationService.AllowPreviewUpdates;
5855

59-
set => _configuration.AllowPreviewUpdates = value;
56+
set => _configurationService.AllowPreviewUpdates = value;
6057
}
6158

62-
public Task SaveConfigurationAsync() => _jsonFileService.SaveAsync(_configuration, ApplicationJsonContext.Default.Configuration, Configuration.Key);
59+
public Task SaveConfigurationAsync() => _configurationService.SaveAsync();
6360
}

Nickvision.Application.Shared/Helpers/ApplicationJsonContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using Nickvision.Application.Shared.Models;
1+
using Nickvision.Desktop.Application;
22
using System.Text.Json.Serialization;
33

44
namespace Nickvision.Application.Shared.Helpers;
55

66
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true)]
7-
[JsonSerializable(typeof(Configuration))]
7+
[JsonSerializable(typeof(WindowGeometry))]
88
public partial class ApplicationJsonContext : JsonSerializerContext
99
{
1010

Nickvision.Application.Shared/Helpers/HostApplicationBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public IHostApplicationBuilder ConfigureApplication(string[] args)
1818
{
1919
var appInfo = new AppInfo("org.nickvision.application", "Nickvision Application", "Application")
2020
{
21-
Version = new AppVersion("2026.3.0-next"),
21+
Version = new AppVersion("2026.4.0-next"),
2222
Changelog = "- Initial release",
2323
SourceRepository = new Uri("https://github.com/NickvisionApps/Application"),
2424
IssueTracker = new Uri("https://github.com/NickvisionApps/Application/issues/new"),
@@ -32,6 +32,7 @@ public IHostApplicationBuilder ConfigureApplication(string[] args)
3232
builder.Services.AddSingleton<IFolderService, FolderService>();
3333
builder.Services.AddSingleton<MainWindowController>();
3434
builder.Services.AddTransient<PreferencesViewController>();
35+
builder.Services.AddHostedService<ConfigurationMigrationService>();
3536
return builder;
3637
}
3738
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Nickvision.Application.Shared.Models;
2+
using Nickvision.Desktop.Application;
3+
4+
namespace Nickvision.Application.Shared.Helpers;
5+
6+
public static class IConfigurationServiceExtensions
7+
{
8+
extension(IConfigurationService configurationService)
9+
{
10+
public bool AllowPreviewUpdates
11+
{
12+
get => configurationService.Get("AllowPreviewUpdates", false);
13+
14+
set => configurationService.Set("AllowPreviewUpdates", value);
15+
}
16+
17+
public Theme Theme
18+
{
19+
get => (Theme)configurationService.Get("Theme", 2);
20+
21+
set => configurationService.Set("Theme", (int)value);
22+
}
23+
24+
public string TranslationLanguage
25+
{
26+
get => configurationService.Get("TranslationLanguage", string.Empty);
27+
28+
set => configurationService.Set("TranslationLanguage", value);
29+
}
30+
31+
public WindowGeometry WindowGeometry
32+
{
33+
get => configurationService.Get("WindowGeometry", new WindowGeometry(), ApplicationJsonContext.Default.WindowGeometry);
34+
35+
set => configurationService.Set("WindowGeometry", value, ApplicationJsonContext.Default.WindowGeometry);
36+
}
37+
}
38+
}

Nickvision.Application.Shared/Models/Configuration.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

Nickvision.Application.Shared/Nickvision.Application.Shared.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<ImplicitUsings>disable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
<Platforms>AnyCPU;ARM64;x64</Platforms>
10-
<Version>2026.3.0</Version>
10+
<Version>2026.4.0</Version>
1111
<IsAotCompatible>true</IsAotCompatible>
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Nickvision.Desktop" Version="2026.3.10" />
15+
<PackageReference Include="Nickvision.Desktop" Version="2026.4.0" />
1616
<PackageReference Include="NReco.Logging.File" Version="1.3.1" />
1717
</ItemGroup>
1818

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Microsoft.Extensions.Hosting;
2+
using Microsoft.Extensions.Logging;
3+
using Nickvision.Desktop.Application;
4+
using Nickvision.Desktop.Filesystem;
5+
using Nickvision.Desktop.System;
6+
using System.IO;
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
10+
namespace Nickvision.Application.Shared.Services;
11+
12+
public class ConfigurationMigrationService : IHostedService
13+
{
14+
private readonly ILogger<ConfigurationMigrationService> _logger;
15+
private readonly IConfigurationService _configurationService;
16+
private readonly string _directory;
17+
18+
public ConfigurationMigrationService(ILogger<ConfigurationMigrationService> logger, AppInfo appInfo, IConfigurationService configurationService)
19+
{
20+
_logger = logger;
21+
_configurationService = configurationService;
22+
_directory = appInfo.IsPortable ? Environment.ExecutingDirectory : Path.Combine(UserDirectories.Config, appInfo.Name);
23+
}
24+
25+
public async Task StartAsync(CancellationToken cancellationToken)
26+
{
27+
_logger.LogInformation("Starting configuration migration...");
28+
var configPath = Path.Combine(_directory, "config.json");
29+
if (File.Exists(configPath))
30+
{
31+
_logger.LogInformation($"Migrating configuration file ({configPath})...");
32+
var res = await _configurationService.ImportFromJsonFileAsync(configPath);
33+
_logger.LogInformation($"Migrated {res} properties from configuration file ({configPath}).");
34+
File.Delete(configPath);
35+
}
36+
_logger.LogInformation("Finished configuration migration.");
37+
}
38+
39+
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
40+
}

0 commit comments

Comments
 (0)