Merge remote-tracking branch 'upstream/main' into KBM]-Alt-Right-Shortcut-Reset

This commit is contained in:
Gokce Kantarci
2024-06-28 14:37:20 +03:00
19 changed files with 210 additions and 96 deletions

View File

@@ -221,3 +221,8 @@ artanh
arsinh arsinh
arcosh arcosh
# Linux
dbus
anypass
gpg

View File

@@ -95,6 +95,7 @@ AUTOUPDATE
AValid AValid
awakeness awakeness
AWAYMODE AWAYMODE
azcliversion
azman azman
backtracer backtracer
bbwe bbwe
@@ -119,6 +120,7 @@ BLURREGION
bmi bmi
bms bms
BNumber BNumber
BODGY
BOKMAL BOKMAL
bootstrapper bootstrapper
BOOTSTRAPPERINSTALLFOLDER BOOTSTRAPPERINSTALLFOLDER
@@ -165,6 +167,7 @@ CENTERALIGN
ceq ceq
certlm certlm
certmgr certmgr
cfp
cguid cguid
CHANGECBCHAIN CHANGECBCHAIN
changecursor changecursor
@@ -754,6 +757,7 @@ KEYEVENTF
KEYIMAGE KEYIMAGE
keynum keynum
keyremaps keyremaps
keyvault
KILLFOCUS KILLFOCUS
killrunner killrunner
Knownfolders Knownfolders

View File

@@ -5,56 +5,80 @@ on:
release: release:
types: [published] types: [published]
permissions:
id-token: write
jobs: jobs:
microsoft_store: microsoft_store:
name: Publish Microsoft Store name: Publish Microsoft Store
environment: store
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: BODGY - Set up Gnome Keyring for future Cert Auth
run: |-
sudo apt-get install -y gnome-keyring
export $(dbus-launch --sh-syntax)
export $(echo 'anypass_just_to_unlock' | gnome-keyring-daemon --unlock)
export $(echo 'anypass_just_to_unlock' | gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh)
- name: Log in to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Get latest URL from public releases - name: Get latest URL from public releases
id: releaseVars id: releaseVars
run: | run: |
release=$(curl https://api.github.com/repos/Microsoft/PowerToys/releases | jq '[.[]|select(.name | contains("Release"))][0]') release=$(curl https://api.github.com/repos/Microsoft/PowerToys/releases | jq '[.[]|select(.name | contains("Release"))][0]')
assets=$(jq -n "$release" | jq '.assets') assets=$(jq -n "$release" | jq '.assets')
powerToysSetup=$(jq -n "$assets" | jq '[.[]|select(.name | contains("PowerToysUserSetup"))]') powerToysSetup=$(jq -n "$assets" | jq '[.[]|select(.name | contains("PowerToysUserSetup"))]')
echo ::set-output name=powerToysInstallerX64Url::$(jq -n "$powerToysSetup" | jq -r '[.[]|select(.name | contains("x64"))][0].browser_download_url') echo powerToysInstallerX64Url=$(jq -n "$powerToysSetup" | jq -r '[.[]|select(.name | contains("x64"))][0].browser_download_url') >> $GITHUB_OUTPUT
echo ::set-output name=powerToysInstallerArm64Url::$(jq -n "$powerToysSetup" | jq -r '[.[]|select(.name | contains("arm64"))][0].browser_download_url') echo powerToysInstallerArm64Url=$(jq -n "$powerToysSetup" | jq -r '[.[]|select(.name | contains("arm64"))][0].browser_download_url') >> $GITHUB_OUTPUT
- uses: microsoft/setup-msstore-cli@v1
- name: Fetch Store Credential
uses: azure/cli@v2
with:
azcliversion: latest
inlineScript: |-
az keyvault secret download --vault-name ${{ secrets.AZURE_KEYVAULT_NAME }} -n ${{ secrets.AZURE_AUTH_CERT_NAME }} -f cert.pfx.b64
base64 -d < cert.pfx.b64 > cert.pfx
- name: Configure Store Credentials - name: Configure Store Credentials
uses: microsoft/store-submission@v1 run: |-
with: msstore reconfigure -cfp cert.pfx -c ${{ secrets.AZURE_CLIENT_ID }} -t ${{ secrets.AZURE_TENANT_ID }} -s ${{ secrets.SELLER_ID }}
command: configure
type: win32
seller-id: ${{ secrets.SELLER_ID }}
product-id: ${{ secrets.PRODUCT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
client-id: ${{ secrets.CLIENT_ID }}
client-secret: ${{ secrets.CLIENT_SECRET }}
- name: Update draft submission - name: Update draft submission
uses: microsoft/store-submission@v1 run: |-
with: msstore submission update ${{ secrets.PRODUCT_ID }} '{
command: update "packages":[
product-update: '{ {
"packages":[ "packageUrl":"${{ steps.releaseVars.outputs.powerToysInstallerX64Url }}",
{ "languages":["zh-hans", "zh-hant", "en", "cs", "nl", "fr", "pt", "pt-br", "de", "hu", "it", "ja", "ko", "pl", "ru", "es", "tr"],
"packageUrl":"${{ steps.releaseVars.outputs.powerToysInstallerX64Url }}", "architectures":["X64"],
"languages":["zh-hans", "zh-hant", "en", "cs", "nl", "fr", "pt", "pt-br", "de", "hu", "it", "ja", "ko", "pl", "ru", "es", "tr"], "installerParameters":"/quiet /norestart",
"architectures":["X64"], "isSilentInstall":true
"installerParameters":"/quiet /norestart", },
"isSilentInstall":true {
}, "packageUrl":"${{ steps.releaseVars.outputs.powerToysInstallerArm64Url }}",
{ "languages":["zh-hans", "zh-hant", "en", "cs", "nl", "fr", "pt", "pt-br", "de", "hu", "it", "ja", "ko", "pl", "ru", "es", "tr"],
"packageUrl":"${{ steps.releaseVars.outputs.powerToysInstallerArm64Url }}", "architectures":["Arm64"],
"languages":["zh-hans", "zh-hant", "en", "cs", "nl", "fr", "pt", "pt-br", "de", "hu", "it", "ja", "ko", "pl", "ru", "es", "tr"], "installerParameters":"/quiet /norestart",
"architectures":["Arm64"], "isSilentInstall":true
"installerParameters":"/quiet /norestart", }
"isSilentInstall":true ]
} }'
]
}'
- name: Publish Submission - name: Publish Submission
uses: microsoft/store-submission@v1 run: |-
with: msstore submission publish ${{ secrets.PRODUCT_ID }}
command: publish
- name: Clean up auth certificate
if: always()
run: |-
rm -f cert.pfx cert.pfx.b64

View File

@@ -3,15 +3,14 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Threading.Tasks;
using AdvancedPaste.Helpers; using AdvancedPaste.Helpers;
using AdvancedPaste.Settings;
using AdvancedPaste.ViewModels; using AdvancedPaste.ViewModels;
using ManagedCommon; using ManagedCommon;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.UI.Windowing; using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Windows.ApplicationModel.DataTransfer;
using Windows.Graphics; using Windows.Graphics;
using WinUIEx; using WinUIEx;
using static AdvancedPaste.Helpers.NativeMethods; using static AdvancedPaste.Helpers.NativeMethods;
@@ -47,6 +46,7 @@ namespace AdvancedPaste
Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder().UseContentRoot(AppContext.BaseDirectory).ConfigureServices((context, services) => Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder().UseContentRoot(AppContext.BaseDirectory).ConfigureServices((context, services) =>
{ {
services.AddSingleton<OptionsViewModel>(); services.AddSingleton<OptionsViewModel>();
services.AddSingleton<IUserSettings, UserSettings>();
}).Build(); }).Build();
viewModel = GetService<OptionsViewModel>(); viewModel = GetService<OptionsViewModel>();

View File

@@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using AdvancedPaste.Helpers; using AdvancedPaste.Helpers;
@@ -20,14 +19,13 @@ namespace AdvancedPaste.Controls
public sealed partial class PromptBox : Microsoft.UI.Xaml.Controls.UserControl public sealed partial class PromptBox : Microsoft.UI.Xaml.Controls.UserControl
{ {
private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread(); private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
private readonly IUserSettings _userSettings;
private UserSettings _userSettings;
public static readonly DependencyProperty PromptProperty = DependencyProperty.Register( public static readonly DependencyProperty PromptProperty = DependencyProperty.Register(
nameof(Prompt), nameof(Prompt),
typeof(string), typeof(string),
typeof(PromptBox), typeof(PromptBox),
new PropertyMetadata(defaultValue: string.Empty)); new PropertyMetadata(defaultValue: string.Empty));
public OptionsViewModel ViewModel { get; private set; } public OptionsViewModel ViewModel { get; private set; }
@@ -38,10 +36,10 @@ namespace AdvancedPaste.Controls
} }
public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register( public static readonly DependencyProperty PlaceholderTextProperty = DependencyProperty.Register(
nameof(PlaceholderText), nameof(PlaceholderText),
typeof(string), typeof(string),
typeof(PromptBox), typeof(PromptBox),
new PropertyMetadata(defaultValue: string.Empty)); new PropertyMetadata(defaultValue: string.Empty));
public string PlaceholderText public string PlaceholderText
{ {
@@ -50,10 +48,10 @@ namespace AdvancedPaste.Controls
} }
public static readonly DependencyProperty FooterProperty = DependencyProperty.Register( public static readonly DependencyProperty FooterProperty = DependencyProperty.Register(
nameof(Footer), nameof(Footer),
typeof(object), typeof(object),
typeof(PromptBox), typeof(PromptBox),
new PropertyMetadata(defaultValue: null)); new PropertyMetadata(defaultValue: null));
public object Footer public object Footer
{ {
@@ -65,7 +63,7 @@ namespace AdvancedPaste.Controls
{ {
this.InitializeComponent(); this.InitializeComponent();
_userSettings = new UserSettings(); _userSettings = App.GetService<IUserSettings>();
ViewModel = App.GetService<OptionsViewModel>(); ViewModel = App.GetService<OptionsViewModel>();
} }
@@ -80,8 +78,6 @@ namespace AdvancedPaste.Controls
{ {
Logger.LogTrace(); Logger.LogTrace();
PowerToysTelemetry.Log.WriteEvent(new Telemetry.AdvancedPasteGenerateCustomFormatEvent());
VisualStateManager.GoToState(this, "LoadingState", true); VisualStateManager.GoToState(this, "LoadingState", true);
string inputInstructions = InputTxtBox.Text; string inputInstructions = InputTxtBox.Text;
ViewModel.SaveQuery(inputInstructions); ViewModel.SaveQuery(inputInstructions);

View File

@@ -3,21 +3,20 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System; using System;
using System.Runtime.CompilerServices;
using AdvancedPaste.Helpers; using AdvancedPaste.Helpers;
using AdvancedPaste.Settings;
using ManagedCommon; using ManagedCommon;
using Microsoft.UI.Windowing; using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Windows.Graphics;
using WinUIEx; using WinUIEx;
using WinUIEx.Messaging; using WinUIEx.Messaging;
using static AdvancedPaste.Helpers.NativeMethods;
namespace AdvancedPaste namespace AdvancedPaste
{ {
public sealed partial class MainWindow : WindowEx, IDisposable public sealed partial class MainWindow : WindowEx, IDisposable
{ {
private WindowMessageMonitor _msgMonitor; private readonly WindowMessageMonitor _msgMonitor;
private readonly IUserSettings _userSettings;
private bool _disposedValue; private bool _disposedValue;
@@ -25,6 +24,8 @@ namespace AdvancedPaste
{ {
this.InitializeComponent(); this.InitializeComponent();
_userSettings = App.GetService<IUserSettings>();
AppWindow.SetIcon("Assets/AdvancedPaste/AdvancedPaste.ico"); AppWindow.SetIcon("Assets/AdvancedPaste/AdvancedPaste.ico");
this.ExtendsContentIntoTitleBar = true; this.ExtendsContentIntoTitleBar = true;
this.SetTitleBar(titleBar); this.SetTitleBar(titleBar);
@@ -32,6 +33,8 @@ namespace AdvancedPaste
var loader = ResourceLoaderInstance.ResourceLoader; var loader = ResourceLoaderInstance.ResourceLoader;
Title = loader.GetString("WindowTitle"); Title = loader.GetString("WindowTitle");
Activated += OnActivated;
_msgMonitor = new WindowMessageMonitor(this); _msgMonitor = new WindowMessageMonitor(this);
_msgMonitor.WindowMessageReceived += (_, e) => _msgMonitor.WindowMessageReceived += (_, e) =>
{ {
@@ -47,6 +50,14 @@ namespace AdvancedPaste
WindowHelpers.BringToForeground(this.GetWindowHandle()); WindowHelpers.BringToForeground(this.GetWindowHandle());
} }
private void OnActivated(object sender, WindowActivatedEventArgs args)
{
if (_userSettings.CloseAfterLosingFocus && args.WindowActivationState == WindowActivationState.Deactivated)
{
Hide();
}
}
private void Dispose(bool disposing) private void Dispose(bool disposing)
{ {
if (!_disposedValue) if (!_disposedValue)
@@ -66,11 +77,15 @@ namespace AdvancedPaste
private void WindowEx_Closed(object sender, Microsoft.UI.Xaml.WindowEventArgs args) private void WindowEx_Closed(object sender, Microsoft.UI.Xaml.WindowEventArgs args)
{ {
Windows.Win32.PInvoke.ShowWindow((Windows.Win32.Foundation.HWND)this.GetWindowHandle(), Windows.Win32.UI.WindowsAndMessaging.SHOW_WINDOW_CMD.SW_HIDE); Hide();
args.Handled = true; args.Handled = true;
} }
private void Hide()
{
Windows.Win32.PInvoke.ShowWindow(new Windows.Win32.Foundation.HWND(this.GetWindowHandle()), Windows.Win32.UI.WindowsAndMessaging.SHOW_WINDOW_CMD.SW_HIDE);
}
public void SetFocus() public void SetFocus()
{ {
MainPage.CustomFormatTextBox.InputTxtBox.Focus(FocusState.Programmatic); MainPage.CustomFormatTextBox.InputTxtBox.Focus(FocusState.Programmatic);

View File

@@ -231,6 +231,7 @@ namespace AdvancedPaste.Pages
var item = e.ClickedItem as ClipboardItem; var item = e.ClickedItem as ClipboardItem;
if (item is not null) if (item is not null)
{ {
PowerToysTelemetry.Log.WriteEvent(new Telemetry.AdvancedPasteClipboardItemClicked());
if (!string.IsNullOrEmpty(item.Content)) if (!string.IsNullOrEmpty(item.Content))
{ {
ClipboardHelper.SetClipboardTextContent(item.Content); ClipboardHelper.SetClipboardTextContent(item.Content);

View File

@@ -33,6 +33,8 @@ namespace AdvancedPaste.Helpers
private string _openAIKey; private string _openAIKey;
private string _modelName = "gpt-3.5-turbo-instruct";
public bool IsAIEnabled => !string.IsNullOrEmpty(this._openAIKey); public bool IsAIEnabled => !string.IsNullOrEmpty(this._openAIKey);
public AICompletionsHelper() public AICompletionsHelper()
@@ -69,14 +71,14 @@ namespace AdvancedPaste.Helpers
return string.Empty; return string.Empty;
} }
public string GetAICompletion(string systemInstructions, string userMessage) private Response<Completions> GetAICompletion(string systemInstructions, string userMessage)
{ {
OpenAIClient azureAIClient = new OpenAIClient(_openAIKey); OpenAIClient azureAIClient = new OpenAIClient(_openAIKey);
var response = azureAIClient.GetCompletions( var response = azureAIClient.GetCompletions(
new CompletionsOptions() new CompletionsOptions()
{ {
DeploymentName = "gpt-3.5-turbo-instruct", DeploymentName = _modelName,
Prompts = Prompts =
{ {
systemInstructions + "\n\n" + userMessage, systemInstructions + "\n\n" + userMessage,
@@ -90,7 +92,7 @@ namespace AdvancedPaste.Helpers
Console.WriteLine("Cut off due to length constraints"); Console.WriteLine("Cut off due to length constraints");
} }
return response.Value.Choices[0].Text; return response;
} }
public AICompletionsResponse AIFormatString(string inputInstructions, string inputString) public AICompletionsResponse AIFormatString(string inputInstructions, string inputString)
@@ -109,10 +111,16 @@ Output:
"; ";
string aiResponse = null; string aiResponse = null;
Response<Completions> rawAIResponse = null;
int apiRequestStatus = (int)HttpStatusCode.OK; int apiRequestStatus = (int)HttpStatusCode.OK;
try try
{ {
aiResponse = this.GetAICompletion(systemInstructions, userMessage); rawAIResponse = this.GetAICompletion(systemInstructions, userMessage);
aiResponse = rawAIResponse.Value.Choices[0].Text;
int promptTokens = rawAIResponse.Value.Usage.PromptTokens;
int completionTokens = rawAIResponse.Value.Usage.CompletionTokens;
PowerToysTelemetry.Log.WriteEvent(new Telemetry.AdvancedPasteGenerateCustomFormatEvent(promptTokens, completionTokens, _modelName));
} }
catch (Azure.RequestFailedException error) catch (Azure.RequestFailedException error)
{ {

View File

@@ -9,5 +9,7 @@ namespace AdvancedPaste.Settings
public bool ShowCustomPreview { get; } public bool ShowCustomPreview { get; }
public bool SendPasteKeyCombination { get; } public bool SendPasteKeyCombination { get; }
public bool CloseAfterLosingFocus { get; }
} }
} }

View File

@@ -24,12 +24,15 @@ namespace AdvancedPaste.Settings
public bool SendPasteKeyCombination { get; private set; } public bool SendPasteKeyCombination { get; private set; }
public bool CloseAfterLosingFocus { get; private set; }
public UserSettings() public UserSettings()
{ {
_settingsUtils = new SettingsUtils(); _settingsUtils = new SettingsUtils();
ShowCustomPreview = true; ShowCustomPreview = true;
SendPasteKeyCombination = true; SendPasteKeyCombination = true;
CloseAfterLosingFocus = false;
LoadSettingsFromJson(); LoadSettingsFromJson();
@@ -61,6 +64,7 @@ namespace AdvancedPaste.Settings
{ {
ShowCustomPreview = settings.Properties.ShowCustomPreview; ShowCustomPreview = settings.Properties.ShowCustomPreview;
SendPasteKeyCombination = settings.Properties.SendPasteKeyCombination; SendPasteKeyCombination = settings.Properties.SendPasteKeyCombination;
CloseAfterLosingFocus = settings.Properties.CloseAfterLosingFocus;
} }
retry = false; retry = false;

View File

@@ -0,0 +1,16 @@
// 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.Diagnostics.Tracing;
using Microsoft.PowerToys.Telemetry;
using Microsoft.PowerToys.Telemetry.Events;
namespace AdvancedPaste.Telemetry
{
[EventData]
public class AdvancedPasteClipboardItemClicked : EventBase, IEvent
{
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
}
}

View File

@@ -11,6 +11,19 @@ namespace AdvancedPaste.Telemetry
[EventData] [EventData]
public class AdvancedPasteGenerateCustomFormatEvent : EventBase, IEvent public class AdvancedPasteGenerateCustomFormatEvent : EventBase, IEvent
{ {
public int PromptTokens { get; set; }
public int CompletionTokens { get; set; }
public string ModelName { get; set; }
public AdvancedPasteGenerateCustomFormatEvent(int promptTokens, int completionTokens, string modelName)
{
this.PromptTokens = promptTokens;
this.CompletionTokens = completionTokens;
ModelName = modelName;
}
public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage; public PartA_PrivTags PartA_PrivTags => PartA_PrivTags.ProductAndServiceUsage;
} }
} }

View File

@@ -25,13 +25,12 @@ namespace AdvancedPaste.ViewModels
public partial class OptionsViewModel : ObservableObject public partial class OptionsViewModel : ObservableObject
{ {
private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread(); private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
private readonly IUserSettings _userSettings;
private App app = App.Current as App; private App app = App.Current as App;
private AICompletionsHelper aiHelper; private AICompletionsHelper aiHelper;
private UserSettings _userSettings;
public DataPackageView ClipboardData { get; set; } public DataPackageView ClipboardData { get; set; }
[ObservableProperty] [ObservableProperty]
@@ -50,10 +49,10 @@ namespace AdvancedPaste.ViewModels
[NotifyPropertyChangedFor(nameof(InputTxtBoxErrorText))] [NotifyPropertyChangedFor(nameof(InputTxtBoxErrorText))]
private int _apiRequestStatus; private int _apiRequestStatus;
public OptionsViewModel() public OptionsViewModel(IUserSettings userSettings)
{ {
aiHelper = new AICompletionsHelper(); aiHelper = new AICompletionsHelper();
_userSettings = new UserSettings(); _userSettings = userSettings;
IsCustomAIEnabled = IsClipboardDataText && aiHelper.IsAIEnabled; IsCustomAIEnabled = IsClipboardDataText && aiHelper.IsAIEnabled;

View File

@@ -1016,27 +1016,30 @@ namespace PowerLauncher.ViewModel
var window = Application.Current.MainWindow; var window = Application.Current.MainWindow;
Wpf.Ui.Controls.WindowBackdrop.RemoveBackground(window); Wpf.Ui.Controls.WindowBackdrop.RemoveBackground(window);
// Taken from WPFUI's fix for the title bar issue. We should be able to remove this fix when WPF UI 4 is integrated. if (OSVersionHelper.IsWindows11())
// https://github.com/lepoco/wpfui/pull/1122/files#diff-196b404f4db09632665ef546da6c8e57302b2f3e3d082eb4b5c295ae3482d94a
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
if (windowHandle == IntPtr.Zero)
{ {
return; // Taken from WPFUI's fix for the title bar issue. We should be able to remove this fix when WPF UI 4 is integrated.
} // https://github.com/lepoco/wpfui/pull/1122/files#diff-196b404f4db09632665ef546da6c8e57302b2f3e3d082eb4b5c295ae3482d94a
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
if (windowHandle == IntPtr.Zero)
{
return;
}
HwndSource windowSource = HwndSource.FromHwnd(windowHandle); HwndSource windowSource = HwndSource.FromHwnd(windowHandle);
// Remove background from client area // Remove background from client area
if (windowSource != null && windowSource.Handle != IntPtr.Zero && windowSource?.CompositionTarget != null) if (windowSource != null && windowSource.Handle != IntPtr.Zero && windowSource?.CompositionTarget != null)
{ {
// NOTE: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute // NOTE: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
// Specifying DWMWA_COLOR_DEFAULT (value 0xFFFFFFFF) for the color will reset the window back to using the system's default behavior for the caption color. // Specifying DWMWA_COLOR_DEFAULT (value 0xFFFFFFFF) for the color will reset the window back to using the system's default behavior for the caption color.
uint titlebarPvAttribute = 0xFFFFFFFE; uint titlebarPvAttribute = 0xFFFFFFFE;
_ = Wox.Plugin.Common.Win32.NativeMethods.DwmSetWindowAttribute( _ = Wox.Plugin.Common.Win32.NativeMethods.DwmSetWindowAttribute(
windowSource.Handle, windowSource.Handle,
(int)Wox.Plugin.Common.Win32.DwmWindowAttributes.CaptionColor, (int)Wox.Plugin.Common.Win32.DwmWindowAttributes.CaptionColor, // CaptionColor attribute is only available on Windows 11.
ref titlebarPvAttribute, ref titlebarPvAttribute,
Marshal.SizeOf(typeof(uint))); Marshal.SizeOf(typeof(uint)));
}
} }
} }
else else

View File

@@ -22,6 +22,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
PasteAsJsonShortcut = new(); PasteAsJsonShortcut = new();
ShowCustomPreview = true; ShowCustomPreview = true;
SendPasteKeyCombination = true; SendPasteKeyCombination = true;
CloseAfterLosingFocus = false;
} }
[JsonConverter(typeof(BoolPropertyJsonConverter))] [JsonConverter(typeof(BoolPropertyJsonConverter))]
@@ -31,6 +32,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[CmdConfigureIgnore] [CmdConfigureIgnore]
public bool SendPasteKeyCombination { get; set; } public bool SendPasteKeyCombination { get; set; }
[JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool CloseAfterLosingFocus { get; set; }
[JsonPropertyName("advanced-paste-ui-hotkey")] [JsonPropertyName("advanced-paste-ui-hotkey")]
public HotkeySettings AdvancedPasteUIShortcut { get; set; } public HotkeySettings AdvancedPasteUIShortcut { get; set; }

View File

@@ -81,7 +81,7 @@
Severity="Informational" /> Severity="Informational" />
</controls:SettingsGroup> </controls:SettingsGroup>
<controls:SettingsGroup x:Uid="AdvancedPaste_ClipboardHistorySettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}"> <controls:SettingsGroup x:Uid="AdvancedPaste_BehaviorSettingsGroup" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">
<tkcontrols:SettingsCard <tkcontrols:SettingsCard
x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard" x:Uid="AdvancedPaste_Clipboard_History_Enabled_SettingsCard"
HeaderIcon="{ui:FontIcon Glyph=&#xF0E3;}" HeaderIcon="{ui:FontIcon Glyph=&#xF0E3;}"
@@ -94,6 +94,9 @@
IsOpen="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}" IsOpen="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}"
IsTabStop="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}" IsTabStop="{x:Bind ViewModel.ShowClipboardHistoryIsGpoConfiguredInfoBar, Mode=OneWay}"
Severity="Informational" /> Severity="Informational" />
<tkcontrols:SettingsCard x:Uid="AdvancedPaste_CloseAfterLosingFocus" HeaderIcon="{ui:FontIcon Glyph=&#xED1A;}">
<ToggleSwitch IsOn="{x:Bind ViewModel.CloseAfterLosingFocus, Mode=TwoWay}" />
</tkcontrols:SettingsCard>
</controls:SettingsGroup> </controls:SettingsGroup>
<controls:SettingsGroup x:Uid="AdvancedPaste_Direct_Access_Hotkeys_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}"> <controls:SettingsGroup x:Uid="AdvancedPaste_Direct_Access_Hotkeys_GroupSettings" IsEnabled="{x:Bind ViewModel.IsEnabled, Mode=OneWay}">

View File

@@ -35,7 +35,7 @@
<tkcontrols:SettingsCard x:Uid="Peek_AlwaysRunNotElevated" HeaderIcon="{ui:FontIcon Glyph=&#xE7EF;}"> <tkcontrols:SettingsCard x:Uid="Peek_AlwaysRunNotElevated" HeaderIcon="{ui:FontIcon Glyph=&#xE7EF;}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.AlwaysRunNotElevated, Mode=TwoWay}" /> <ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.AlwaysRunNotElevated, Mode=TwoWay}" />
</tkcontrols:SettingsCard> </tkcontrols:SettingsCard>
<tkcontrols:SettingsCard x:Uid="Peek_CloseAfterLosingFocus"> <tkcontrols:SettingsCard x:Uid="Peek_CloseAfterLosingFocus" HeaderIcon="{ui:FontIcon Glyph=&#xED1A;}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.CloseAfterLosingFocus, Mode=TwoWay}" /> <ToggleSwitch x:Uid="ToggleSwitch" IsOn="{x:Bind ViewModel.CloseAfterLosingFocus, Mode=TwoWay}" />
</tkcontrols:SettingsCard> </tkcontrols:SettingsCard>
</controls:SettingsGroup> </controls:SettingsGroup>

View File

@@ -3763,8 +3763,8 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="AdvancedPaste_EnableAISettingsGroup.Header" xml:space="preserve"> <data name="AdvancedPaste_EnableAISettingsGroup.Header" xml:space="preserve">
<value>Paste with AI</value> <value>Paste with AI</value>
</data> </data>
<data name="AdvancedPaste_ClipboardHistorySettingsGroup.Header" xml:space="preserve"> <data name="AdvancedPaste_BehaviorSettingsGroup.Header" xml:space="preserve">
<value>Clipboard history</value> <value>Behavior</value>
</data> </data>
<data name="AdvancedPaste_ShowCustomPreviewSettingsCard.Header" xml:space="preserve"> <data name="AdvancedPaste_ShowCustomPreviewSettingsCard.Header" xml:space="preserve">
<value>Custom format preview</value> <value>Custom format preview</value>
@@ -4192,4 +4192,8 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="AdvancedPaste_EnableAIDialog_NoteAICreditsErrorText.Text" xml:space="preserve"> <data name="AdvancedPaste_EnableAIDialog_NoteAICreditsErrorText.Text" xml:space="preserve">
<value>If you do not have credits you will see an 'API key quota exceeded' error</value> <value>If you do not have credits you will see an 'API key quota exceeded' error</value>
</data> </data>
<data name="AdvancedPaste_CloseAfterLosingFocus.Header" xml:space="preserve">
<value>Automatically close the AdvancedPaste window after it loses focus</value>
<comment>AdvancedPaste is a product name, do not loc</comment>
</data>
</root> </root>

View File

@@ -304,6 +304,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public bool CloseAfterLosingFocus
{
get => _advancedPasteSettings.Properties.CloseAfterLosingFocus;
set
{
if (value != _advancedPasteSettings.Properties.CloseAfterLosingFocus)
{
_advancedPasteSettings.Properties.CloseAfterLosingFocus = value;
NotifySettingsChanged();
}
}
}
public bool IsConflictingCopyShortcut public bool IsConflictingCopyShortcut
{ {
get get
@@ -328,11 +341,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{ {
// Using InvariantCulture as this is an IPC message // Using InvariantCulture as this is an IPC message
SendConfigMSG( SendConfigMSG(
string.Format( string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{{ \"powertoys\": {{ \"{0}\": {1} }} }}", "{{ \"powertoys\": {{ \"{0}\": {1} }} }}",
AdvancedPasteSettings.ModuleName, AdvancedPasteSettings.ModuleName,
JsonSerializer.Serialize(_advancedPasteSettings))); JsonSerializer.Serialize(_advancedPasteSettings)));
} }
public void RefreshEnabledState() public void RefreshEnabledState()