-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update path selection ui and logic
Use the executable instead of the folder for selection, which bypasses issues with old FreeDesktop file portal pickers not having support for folders. Closes #186, #177.
- Loading branch information
Showing
20 changed files
with
367 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
namespace Scarab.Util; | ||
|
||
public record ValidPath(string Root, string Suffix); | ||
public abstract record PathResult | ||
{ | ||
public string? Path => this switch | ||
{ | ||
// Not a failure | ||
ValidPath v => System.IO.Path.Combine(v.Root, v.Suffix), | ||
|
||
RootNotFoundError => null, | ||
SuffixNotFoundError s => s.Root, | ||
AssemblyNotFoundError a => a.Root, | ||
PathNotSelectedError => null, | ||
|
||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
} | ||
|
||
public record ValidPath(string Root, string Suffix) : PathResult; | ||
|
||
public record RootNotFoundError : PathResult; | ||
public record SuffixNotFoundError(string Root, string[] AttemptedSuffixes) : PathResult; | ||
public record AssemblyNotFoundError(string Root, string[] MissingFiles) : PathResult; | ||
public record PathNotSelectedError : PathResult; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Scarab.ViewModels; | ||
|
||
[UsedImplicitly] | ||
public partial class PathViewModel : ViewModelBase | ||
{ | ||
public string? Selection => Result.Path; | ||
|
||
[Notify] | ||
private PathResult _result; | ||
|
||
public ReactiveCommand<Unit, Unit> ChangePath { get; } | ||
|
||
public PathViewModel(PathResult res) | ||
{ | ||
ChangePath = ReactiveCommand.CreateFromTask(ChangePathAsync); | ||
Log.Debug("Result = {Result}", res); | ||
Result = _result = res; | ||
} | ||
|
||
private async Task ChangePathAsync() | ||
{ | ||
Result = await PathUtil.TrySelection(); | ||
|
||
Log.Information("Set selection to new path: {Path}", Selection); | ||
} | ||
} |
Oops, something went wrong.