mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Add SVG Thumbnail Provider for Windows Explorer (#5048)
* Add SVG Thumbnail Provider * Some cleanup * Small settings changes * Update PowerToys.sln Remove Any CPU entries * Fix project configuration issues * Fix bad merge * Update output path for SVG thumbnail provider * Sync with latest
This commit is contained in:
@@ -12,36 +12,53 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
public class PowerPreviewProperties
|
||||
{
|
||||
private bool enableSvg = true;
|
||||
private bool enableSvgPreview = true;
|
||||
|
||||
[JsonPropertyName("svg-previewer-toggle-setting")]
|
||||
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
||||
public bool EnableSvg
|
||||
public bool EnableSvgPreview
|
||||
{
|
||||
get => this.enableSvg;
|
||||
get => this.enableSvgPreview;
|
||||
set
|
||||
{
|
||||
if (value != this.enableSvg)
|
||||
if (value != this.enableSvgPreview)
|
||||
{
|
||||
LogTelemetryEvent(value);
|
||||
this.enableSvg = value;
|
||||
this.enableSvgPreview = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool enableSvgThumbnail = true;
|
||||
|
||||
[JsonPropertyName("svg-thumbnail-toggle-setting")]
|
||||
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
||||
public bool EnableSvgThumbnail
|
||||
{
|
||||
get => this.enableSvgThumbnail;
|
||||
set
|
||||
{
|
||||
if (value != this.enableSvgThumbnail)
|
||||
{
|
||||
LogTelemetryEvent(value);
|
||||
this.enableSvgThumbnail = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool enableMd = true;
|
||||
private bool enableMdPreview = true;
|
||||
|
||||
[JsonPropertyName("md-previewer-toggle-setting")]
|
||||
[JsonConverter(typeof(BoolPropertyJsonConverter))]
|
||||
public bool EnableMd
|
||||
public bool EnableMdPreview
|
||||
{
|
||||
get => this.enableMd;
|
||||
get => this.enableMdPreview;
|
||||
set
|
||||
{
|
||||
if (value != this.enableMd)
|
||||
if (value != this.enableMdPreview)
|
||||
{
|
||||
LogTelemetryEvent(value);
|
||||
this.enableMd = value;
|
||||
this.enableMdPreview = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,6 +422,9 @@
|
||||
</data>
|
||||
<data name="FileExplorerPreview_ToggleSwitch_Preview_SVG.Header" xml:space="preserve">
|
||||
<value>Enable SVG (.svg) preview</value>
|
||||
</data>
|
||||
<data name="FileExplorerPreview_ToggleSwitch_SVG_Thumbnail.Header" xml:space="preserve">
|
||||
<value>Enable SVG (.svg) thumbnails</value>
|
||||
</data>
|
||||
<data name="FileExplorerPreview_Description.Text" xml:space="preserve">
|
||||
<value>These settings allow you to manage your Windows File Explorer custom preview handlers.</value>
|
||||
|
||||
@@ -27,12 +27,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
}
|
||||
|
||||
this._svgRenderIsEnabled = Settings.properties.EnableSvg;
|
||||
this._mdRenderIsEnabled = Settings.properties.EnableMd;
|
||||
this._svgRenderIsEnabled = Settings.properties.EnableSvgPreview;
|
||||
this._svgThumbnailIsEnabled = Settings.properties.EnableSvgThumbnail;
|
||||
this._mdRenderIsEnabled = Settings.properties.EnableMdPreview;
|
||||
}
|
||||
|
||||
private bool _svgRenderIsEnabled = false;
|
||||
private bool _mdRenderIsEnabled = false;
|
||||
private bool _svgThumbnailIsEnabled = false;
|
||||
|
||||
public bool SVGRenderIsEnabled
|
||||
{
|
||||
@@ -46,7 +48,25 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _svgRenderIsEnabled)
|
||||
{
|
||||
_svgRenderIsEnabled = value;
|
||||
Settings.properties.EnableSvg = value;
|
||||
Settings.properties.EnableSvgPreview = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool SVGThumbnailIsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return _svgThumbnailIsEnabled;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _svgThumbnailIsEnabled)
|
||||
{
|
||||
_svgThumbnailIsEnabled = value;
|
||||
Settings.properties.EnableSvgThumbnail = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -64,7 +84,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
if (value != _mdRenderIsEnabled)
|
||||
{
|
||||
_mdRenderIsEnabled = value;
|
||||
Settings.properties.EnableMd = value;
|
||||
Settings.properties.EnableMdPreview = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
Margin="{StaticResource MediumTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=SVGRenderIsEnabled}" />
|
||||
|
||||
<ToggleSwitch x:Uid="FileExplorerPreview_ToggleSwitch_SVG_Thumbnail"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=SVGThumbnailIsEnabled}" />
|
||||
|
||||
<ToggleSwitch x:Uid="FileExplorerPreview_ToggleSwitch_Preview_MD"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsOn="{Binding Mode=TwoWay, Path=MDRenderIsEnabled}" />
|
||||
|
||||
@@ -59,13 +59,30 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableSvg);
|
||||
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableSvgPreview);
|
||||
};
|
||||
|
||||
// act
|
||||
viewModel.SVGRenderIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SVGThumbnailIsEnabled_ShouldPrevHandler_WhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
PowerPreviewViewModel viewModel = new PowerPreviewViewModel();
|
||||
|
||||
// Assert
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableSvgThumbnail);
|
||||
};
|
||||
|
||||
// act
|
||||
viewModel.SVGThumbnailIsEnabled = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MDRenderIsEnabled_ShouldPrevHandler_WhenSuccessful()
|
||||
{
|
||||
@@ -76,7 +93,7 @@ namespace ViewModelTests
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
|
||||
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableMd);
|
||||
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.properties.EnableMdPreview);
|
||||
};
|
||||
|
||||
// act
|
||||
|
||||
Reference in New Issue
Block a user