Linux improvements

This commit is contained in:
2022-02-04 00:49:25 +01:00
parent 96cba48f04
commit 2e43cca9fd
3 changed files with 27 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ using FileTime.Providers.Local;
using Syroot.Windows.IO; using Syroot.Windows.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
namespace FileTime.Avalonia.IconProviders namespace FileTime.Avalonia.IconProviders
{ {
@@ -23,13 +24,16 @@ namespace FileTime.Avalonia.IconProviders
public MaterialIconProvider() public MaterialIconProvider()
{ {
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Desktop.Path, GetAssetPath("desktop.svg"))); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Documents.Path, GetAssetPath("folder-resource.svg"))); {
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.DownloadsLocalized.Path, GetAssetPath("folder-download.svg"))); _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Desktop.Path, GetAssetPath("desktop.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.MusicLocalized.Path, GetAssetPath("folder-music.svg"))); _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Documents.Path, GetAssetPath("folder-resource.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Pictures.Path, GetAssetPath("folder-images.svg"))); _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.DownloadsLocalized.Path, GetAssetPath("folder-download.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Profile.Path, GetAssetPath("folder-home.svg"))); _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.MusicLocalized.Path, GetAssetPath("folder-music.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Videos.Path, GetAssetPath("folder-video.svg"))); _specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Pictures.Path, GetAssetPath("folder-images.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Profile.Path, GetAssetPath("folder-home.svg")));
_specialPaths.Add(new SpecialPathWithIcon(KnownFolders.Videos.Path, GetAssetPath("folder-video.svg")));
}
} }
public ImagePath GetImage(IItem item) public ImagePath GetImage(IItem item)
@@ -63,7 +67,7 @@ namespace FileTime.Avalonia.IconProviders
if (_iconsByFileName.TryGetValue(fileName, out var value)) possibleIcon = value; if (_iconsByFileName.TryGetValue(fileName, out var value)) possibleIcon = value;
else if (_iconsByExtension.FirstOrDefault(k => fileName.EndsWith("." + k.Key)) is KeyValuePair<string, string> matchingExtension && matchingExtension.Key != null) possibleIcon = matchingExtension.Value; else if (_iconsByExtension.FirstOrDefault(k => fileName.EndsWith("." + k.Key)) is KeyValuePair<string, string> matchingExtension && matchingExtension.Key != null) possibleIcon = matchingExtension.Value;
if(possibleIcon != null) if (possibleIcon != null)
{ {
icon = possibleIcon + ".svg"; icon = possibleIcon + ".svg";
} }

View File

@@ -1,9 +1,8 @@
using FileTime.Core.Models; using FileTime.Core.Models;
using FileTime.Providers.Local;
using MvvmGen; using MvvmGen;
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Runtime.InteropServices;
namespace FileTime.Avalonia.Models namespace FileTime.Avalonia.Models
{ {
@@ -33,7 +32,7 @@ namespace FileTime.Avalonia.Models
[PropertyInvalidate(nameof(Used))] [PropertyInvalidate(nameof(Used))]
[PropertyInvalidate(nameof(Size))] [PropertyInvalidate(nameof(Size))]
public long UsedPercentage => Used * 100 / Size; public long UsedPercentage => Size == 0 ? 0 : Used * 100 / Size;
public RootDriveInfo(DriveInfo driveInfo, IContainer container) public RootDriveInfo(DriveInfo driveInfo, IContainer container)
{ {
@@ -46,8 +45,8 @@ namespace FileTime.Avalonia.Models
private void Refresh() private void Refresh()
{ {
Name = _container.Name; Name = _container.Name;
FullName = _container.FullName; FullName = _container is LocalContentProvider ? "/" : _container.FullName;
Label = _driveInfo.VolumeLabel; Label = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? _driveInfo.VolumeLabel : null;
Size = _driveInfo.TotalSize; Size = _driveInfo.TotalSize;
Free = _driveInfo.AvailableFreeSpace; Free = _driveInfo.AvailableFreeSpace;
Used = _driveInfo.TotalSize - _driveInfo.AvailableFreeSpace; Used = _driveInfo.TotalSize - _driveInfo.AvailableFreeSpace;

View File

@@ -1,4 +1,4 @@
using FileTime.Core.Components; using FileTime.Core.Components;
using FileTime.Core.Extensions; using FileTime.Core.Extensions;
using FileTime.Core.Interactions; using FileTime.Core.Interactions;
using FileTime.Core.Models; using FileTime.Core.Models;
@@ -122,7 +122,15 @@ namespace FileTime.Avalonia.ViewModels
} }
var driveInfos = new List<RootDriveInfo>(); var driveInfos = new List<RootDriveInfo>();
foreach (var drive in DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed)) var drives = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Fixed)
: DriveInfo.GetDrives().Where(d =>
d.DriveType == DriveType.Fixed
&& d.DriveFormat != "pstorefs"
&& d.DriveFormat != "bpf_fs"
&& d.DriveFormat != "tracefs"
&& !d.RootDirectory.FullName.StartsWith("/snap/"));
foreach (var drive in drives)
{ {
var container = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) var container = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? await GetContainerForWindowsDrive(drive) ? await GetContainerForWindowsDrive(drive)