mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PastePlain] Introduce Paste as Plain Text module (#23645)
* [PastePlain] Introduce Paste as Plain Text module * fix build * add telemetry * update settings UI * spell * Add navigation items to Settings and OOBE * Add PastePlain to the Quick Access flyout * try to fix PastePlain not being enabled from runner/settings * load dll properly * installer files * Add PastePlain project name * Use win32 APIs in the module interface instead * Fix spellcheck * Fix build errors * Add success, error and invoke telemetry * Add Settings Telemetry * Add GPO definitions * Fix analyzer errors * Use static_cast instead of reinterpret_cast * Add images to Settings * Add note about replacing clipboard contents * Fix learn more text * Add link to readme * Remove unneeded C# app * Fix installer * Fix spellchecker --------- Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
@@ -279,6 +279,23 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
}
|
||||
}
|
||||
|
||||
private bool pastePlain = true;
|
||||
|
||||
[JsonPropertyName("PastePlain")]
|
||||
public bool PastePlain
|
||||
{
|
||||
get => pastePlain;
|
||||
set
|
||||
{
|
||||
if (pastePlain != value)
|
||||
{
|
||||
LogTelemetryEvent(value);
|
||||
pastePlain = value;
|
||||
NotifyChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool measureTool = true;
|
||||
|
||||
[JsonPropertyName("Measure Tool")]
|
||||
|
||||
21
src/settings-ui/Settings.UI.Library/PastePlainProperties.cs
Normal file
21
src/settings-ui/Settings.UI.Library/PastePlainProperties.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PastePlainProperties
|
||||
{
|
||||
public PastePlainProperties()
|
||||
{
|
||||
ActivationShortcut = new HotkeySettings(true, true, false, false, 0x56); // Ctrl+Win+V
|
||||
}
|
||||
|
||||
public HotkeySettings ActivationShortcut { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
=> JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
49
src/settings-ui/Settings.UI.Library/PastePlainSettings.cs
Normal file
49
src/settings-ui/Settings.UI.Library/PastePlainSettings.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PastePlainSettings : BasePTModuleSettings, ISettingsConfig
|
||||
{
|
||||
public const string ModuleName = "PastePlain";
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public PastePlainProperties Properties { get; set; }
|
||||
|
||||
public PastePlainSettings()
|
||||
{
|
||||
Properties = new PastePlainProperties();
|
||||
Version = "1";
|
||||
Name = ModuleName;
|
||||
}
|
||||
|
||||
public virtual void Save(ISettingsUtils settingsUtils)
|
||||
{
|
||||
// Save settings to file
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
if (settingsUtils == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(settingsUtils));
|
||||
}
|
||||
|
||||
settingsUtils.SaveSettings(JsonSerializer.Serialize(this, options), ModuleName);
|
||||
}
|
||||
|
||||
public string GetModuleName()
|
||||
=> Name;
|
||||
|
||||
// This can be utilized in the future if the settings.json file is to be modified/deleted.
|
||||
public bool UpgradeSettingsConfiguration()
|
||||
=> false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user