mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-01 09:59:06 +08:00
[Shortcut Guide] Support delayed display of shortcuts except for taskbar shortcuts (#21762)
* Implement the delayed rendering * Impelement settings UI * Rename * Set the minimum of ShortcutGuide_PressTimeForTaskbarIconShortcuts to 100ms * Separate the animations of the global windows shortcuts and the taskbar icon shortcuts * Amend * Handle the case when the shortcut guide is not activated by win key long press * Remove .vscode * Keep the user's original setting of the win key press time * Revert the default press time to 900 ms * Restore default as 900
This commit is contained in:
parent
6767ff736b
commit
89330986f4
@ -8,5 +8,6 @@ struct ShortcutGuideSettings
|
||||
std::wstring theme = L"system";
|
||||
std::wstring disabledApps = L"";
|
||||
bool shouldReactToPressedWinKey = false;
|
||||
int windowsKeyPressTime = 900;
|
||||
int windowsKeyPressTimeForGlobalWindowsShortcuts = 900;
|
||||
int windowsKeyPressTimeForTaskbarIconShortcuts = 900;
|
||||
};
|
||||
|
@ -268,7 +268,11 @@ D2D1_RECT_F D2DOverlaySVG::get_snap_right() const
|
||||
}
|
||||
|
||||
D2DOverlayWindow::D2DOverlayWindow() :
|
||||
total_screen({}), animation(0.3), D2DWindow()
|
||||
total_screen({}),
|
||||
background_animation(0.3),
|
||||
global_windows_shortcuts_animation(0.3),
|
||||
taskbar_icon_shortcuts_animation(0.3),
|
||||
D2DWindow()
|
||||
{
|
||||
tasklist_thread = std::thread([&] {
|
||||
while (running)
|
||||
@ -356,7 +360,29 @@ void D2DOverlayWindow::show(HWND active_window, bool snappable)
|
||||
// Ignore errors, if this fails we will just not show the thumbnail
|
||||
DwmRegisterThumbnail(hwnd, active_window, &thumbnail);
|
||||
}
|
||||
animation.reset();
|
||||
|
||||
background_animation.reset();
|
||||
|
||||
if (milliseconds_press_time_for_global_windows_shortcuts < milliseconds_press_time_for_taskbar_icon_shortcuts)
|
||||
{
|
||||
global_windows_shortcuts_shown = true;
|
||||
taskbar_icon_shortcuts_shown = false;
|
||||
global_windows_shortcuts_animation.reset();
|
||||
}
|
||||
else if (milliseconds_press_time_for_global_windows_shortcuts > milliseconds_press_time_for_taskbar_icon_shortcuts)
|
||||
{
|
||||
global_windows_shortcuts_shown = false;
|
||||
taskbar_icon_shortcuts_shown = true;
|
||||
taskbar_icon_shortcuts_animation.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
global_windows_shortcuts_shown = true;
|
||||
taskbar_icon_shortcuts_shown = true;
|
||||
global_windows_shortcuts_animation.reset();
|
||||
taskbar_icon_shortcuts_animation.reset();
|
||||
}
|
||||
|
||||
auto primary_size = MonitorInfo::GetPrimaryMonitor().GetScreenSize(false);
|
||||
shown_start_time = std::chrono::steady_clock::now();
|
||||
lock.unlock();
|
||||
@ -422,6 +448,16 @@ void D2DOverlayWindow::apply_overlay_opacity(float opacity)
|
||||
overlay_opacity = opacity;
|
||||
}
|
||||
|
||||
void D2DOverlayWindow::apply_press_time_for_global_windows_shortcuts(int press_time)
|
||||
{
|
||||
milliseconds_press_time_for_global_windows_shortcuts = std::max(press_time, 0);
|
||||
}
|
||||
|
||||
void D2DOverlayWindow::apply_press_time_for_taskbar_icon_shortcuts(int press_time)
|
||||
{
|
||||
milliseconds_press_time_for_taskbar_icon_shortcuts = std::max(press_time, 0);
|
||||
}
|
||||
|
||||
void D2DOverlayWindow::set_theme(const std::wstring& theme)
|
||||
{
|
||||
if (theme == L"light")
|
||||
@ -524,7 +560,7 @@ void D2DOverlayWindow::resize()
|
||||
text.resize(font, use_overlay->get_scale());
|
||||
}
|
||||
|
||||
void render_arrow(D2DSVG& arrow, TasklistButton& button, RECT window, float max_scale, ID2D1DeviceContext5* d2d_dc)
|
||||
void render_arrow(D2DSVG& arrow, TasklistButton& button, RECT window, float max_scale, ID2D1DeviceContext5* d2d_dc, int x_offset, int y_offset)
|
||||
{
|
||||
int dx = 0, dy = 0;
|
||||
// Calculate taskbar orientation
|
||||
@ -558,8 +594,8 @@ void render_arrow(D2DSVG& arrow, TasklistButton& button, RECT window, float max_
|
||||
// assume button is 25% wider than taller, +10% to make room for each of the arrows that are hidden
|
||||
auto render_arrow_width = (int)(button.height * 1.25f * 1.2f);
|
||||
auto render_arrow_height = (int)(render_arrow_width * arrow_ratio);
|
||||
arrow.resize(button.x + (button.width - render_arrow_width) / 2,
|
||||
dy == -1 ? button.y - render_arrow_height : 0,
|
||||
arrow.resize((button.x + (button.width - render_arrow_width) / 2) + x_offset,
|
||||
(dy == -1 ? button.y - render_arrow_height : 0) + y_offset,
|
||||
render_arrow_width,
|
||||
render_arrow_height,
|
||||
0.95f,
|
||||
@ -571,8 +607,8 @@ void render_arrow(D2DSVG& arrow, TasklistButton& button, RECT window, float max_
|
||||
// same as above - make room for the hidden arrow
|
||||
auto render_arrow_height = (int)(button.height * 1.2f);
|
||||
auto render_arrow_width = (int)(render_arrow_height / arrow_ratio);
|
||||
arrow.resize(dx == -1 ? button.x - render_arrow_width : 0,
|
||||
button.y + (button.height - render_arrow_height) / 2,
|
||||
arrow.resize((dx == -1 ? button.x - render_arrow_width : 0) + x_offset,
|
||||
(button.y + (button.height - render_arrow_height) / 2) + y_offset,
|
||||
render_arrow_width,
|
||||
render_arrow_height,
|
||||
0.95f,
|
||||
@ -617,35 +653,15 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
}
|
||||
|
||||
d2d_dc->Clear();
|
||||
int x_offset = 0, y_offset = 0;
|
||||
auto current_anim_value = (float)animation.value(Animation::AnimFunctions::LINEAR);
|
||||
SetLayeredWindowAttributes(hwnd, 0, static_cast<byte>(255 * current_anim_value), LWA_ALPHA);
|
||||
double pos_anim_value = 1 - animation.value(Animation::AnimFunctions::EASE_OUT_EXPO);
|
||||
if (!tasklist_buttons.empty())
|
||||
{
|
||||
if (tasklist_buttons[0].x <= window_rect.left)
|
||||
{ // taskbar on left
|
||||
x_offset = (int)(-pos_anim_value * use_overlay->width() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].x >= window_rect.right)
|
||||
{ // taskbar on right
|
||||
x_offset = (int)(pos_anim_value * use_overlay->width() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].y <= window_rect.top)
|
||||
{ // taskbar on top
|
||||
y_offset = (int)(-pos_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].y >= window_rect.bottom)
|
||||
{ // taskbar on bottom
|
||||
y_offset = (int)(pos_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x_offset = 0;
|
||||
y_offset = (int)(pos_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
}
|
||||
int taskbar_icon_shortcuts_x_offset = 0, taskbar_icon_shortcuts_y_offset = 0;
|
||||
|
||||
float current_background_anim_value = (float)background_animation.value(Animation::AnimFunctions::LINEAR);
|
||||
float current_global_windows_shortcuts_anim_value = (float)global_windows_shortcuts_animation.value(Animation::AnimFunctions::LINEAR);
|
||||
float pos_global_windows_shortcuts_anim_value = 1 - (float)global_windows_shortcuts_animation.value(Animation::AnimFunctions::EASE_OUT_EXPO);
|
||||
float pos_taskbar_icon_shortcuts_anim_value = 1 - (float)taskbar_icon_shortcuts_animation.value(Animation::AnimFunctions::EASE_OUT_EXPO);
|
||||
|
||||
// Draw background
|
||||
SetLayeredWindowAttributes(hwnd, 0, static_cast<byte>(255 * current_background_anim_value), LWA_ALPHA);
|
||||
winrt::com_ptr<ID2D1SolidColorBrush> brush;
|
||||
float brush_opacity = get_overlay_opacity();
|
||||
D2D1_COLOR_F brushColor = light_mode ? D2D1::ColorF(1.0f, 1.0f, 1.0f, brush_opacity) : D2D1::ColorF(0, 0, 0, brush_opacity);
|
||||
@ -656,6 +672,53 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
d2d_dc->SetTransform(D2D1::Matrix3x2F::Identity());
|
||||
d2d_dc->FillRectangle(background_rect, brush.get());
|
||||
|
||||
// Draw the taskbar shortcuts (the arrows with numbers)
|
||||
if (taskbar_icon_shortcuts_shown)
|
||||
{
|
||||
if (!tasklist_buttons.empty())
|
||||
{
|
||||
if (tasklist_buttons[0].x <= window_rect.left)
|
||||
{
|
||||
// taskbar on left
|
||||
taskbar_icon_shortcuts_x_offset = (int)(-pos_taskbar_icon_shortcuts_anim_value * use_overlay->width() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].x >= window_rect.right)
|
||||
{
|
||||
// taskbar on right
|
||||
taskbar_icon_shortcuts_x_offset = (int)(pos_taskbar_icon_shortcuts_anim_value * use_overlay->width() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].y <= window_rect.top)
|
||||
{
|
||||
// taskbar on top
|
||||
taskbar_icon_shortcuts_y_offset = (int)(-pos_taskbar_icon_shortcuts_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
}
|
||||
if (tasklist_buttons[0].y >= window_rect.bottom)
|
||||
{
|
||||
// taskbar on bottom
|
||||
taskbar_icon_shortcuts_y_offset = (int)(pos_taskbar_icon_shortcuts_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
}
|
||||
for (auto&& button : tasklist_buttons)
|
||||
{
|
||||
if ((size_t)(button.keynum) - 1 >= arrows.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
render_arrow(arrows[(size_t)(button.keynum) - 1], button, window_rect, use_overlay->get_scale(), d2d_dc, taskbar_icon_shortcuts_x_offset, taskbar_icon_shortcuts_y_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto time_since_start = std::chrono::high_resolution_clock::now() - shown_start_time;
|
||||
if (time_since_start.count() / 1000000 > milliseconds_press_time_for_taskbar_icon_shortcuts - milliseconds_press_time_for_global_windows_shortcuts)
|
||||
{
|
||||
taskbar_icon_shortcuts_shown = true;
|
||||
taskbar_icon_shortcuts_animation.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (global_windows_shortcuts_shown)
|
||||
{
|
||||
// Thumbnail logic:
|
||||
auto window_state = get_window_state(active_window);
|
||||
auto thumb_window = get_window_pos(active_window);
|
||||
@ -715,7 +778,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
}
|
||||
// If the animation is done show the thumbnail
|
||||
// we cannot animate the thumbnail, the animation lags behind
|
||||
miniature_shown = show_thumbnail(thumbnail_pos, current_anim_value);
|
||||
miniature_shown = show_thumbnail(thumbnail_pos, current_global_windows_shortcuts_anim_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -728,7 +791,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
// render the monitors
|
||||
if (render_monitors)
|
||||
{
|
||||
brushColor = D2D1::ColorF(colors.start_color_menu, miniature_shown ? current_anim_value * 0.9f : current_anim_value * 0.3f);
|
||||
brushColor = D2D1::ColorF(colors.start_color_menu, miniature_shown ? current_global_windows_shortcuts_anim_value * 0.9f : current_global_windows_shortcuts_anim_value * 0.3f);
|
||||
brush = nullptr;
|
||||
winrt::check_hresult(d2d_dc->CreateSolidColorBrush(brushColor, brush.put()));
|
||||
for (auto& monitor : monitors)
|
||||
@ -752,7 +815,8 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
}
|
||||
|
||||
// Set the animation - move the draw window according to animation step
|
||||
auto popIn = D2D1::Matrix3x2F::Translation((float)x_offset, (float)y_offset);
|
||||
int global_windows_shortcuts_y_offset = (int)(pos_global_windows_shortcuts_anim_value * use_overlay->height() * use_overlay->get_scale());
|
||||
auto popIn = D2D1::Matrix3x2F::Translation(0, (float)global_windows_shortcuts_y_offset);
|
||||
d2d_dc->SetTransform(popIn);
|
||||
|
||||
// Animate keys
|
||||
@ -868,13 +932,14 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc)
|
||||
text.set_alignment_right().write(d2d_dc, text_color, use_overlay->get_snap_left(), left);
|
||||
use_overlay->find_element(L"KeyRightGroup")->SetAttributeValue(L"fill-opacity", right_disabled ? 0.3f : 1.0f);
|
||||
text.set_alignment_left().write(d2d_dc, text_color, use_overlay->get_snap_right(), right);
|
||||
// ... and the arrows with numbers
|
||||
for (auto&& button : tasklist_buttons)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((size_t)(button.keynum) - 1 >= arrows.size())
|
||||
auto time_since_start = std::chrono::high_resolution_clock::now() - shown_start_time;
|
||||
if (time_since_start.count() / 1000000 > milliseconds_press_time_for_global_windows_shortcuts - milliseconds_press_time_for_taskbar_icon_shortcuts)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
render_arrow(arrows[(size_t)(button.keynum) - 1], button, window_rect, use_overlay->get_scale(), d2d_dc);
|
||||
global_windows_shortcuts_shown = true;
|
||||
global_windows_shortcuts_animation.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
void show(HWND active_window, bool snappable);
|
||||
~D2DOverlayWindow();
|
||||
void apply_overlay_opacity(float opacity);
|
||||
void apply_press_time_for_global_windows_shortcuts(int press_time);
|
||||
void apply_press_time_for_taskbar_icon_shortcuts(int press_time);
|
||||
void set_theme(const std::wstring& theme);
|
||||
void quick_hide();
|
||||
|
||||
@ -78,7 +80,11 @@ private:
|
||||
int monitor_dx = 0, monitor_dy = 0;
|
||||
D2DText text;
|
||||
WindowsColors colors;
|
||||
Animation animation;
|
||||
Animation background_animation;
|
||||
Animation global_windows_shortcuts_animation;
|
||||
Animation taskbar_icon_shortcuts_animation;
|
||||
bool global_windows_shortcuts_shown = false;
|
||||
bool taskbar_icon_shortcuts_shown = false;
|
||||
RECT window_rect = {};
|
||||
Tasklist tasklist;
|
||||
std::vector<TasklistButton> tasklist_buttons;
|
||||
@ -103,4 +109,6 @@ private:
|
||||
System
|
||||
} theme_setting = System;
|
||||
bool light_mode = true;
|
||||
UINT milliseconds_press_time_for_global_windows_shortcuts = 900;
|
||||
UINT milliseconds_press_time_for_taskbar_icon_shortcuts = 900;
|
||||
};
|
||||
|
@ -198,6 +198,19 @@ void OverlayWindow::ShowWindow()
|
||||
winkey_popup = std::make_unique<D2DOverlayWindow>();
|
||||
winkey_popup->apply_overlay_opacity(((float)overlayOpacity.value) / 100.0f);
|
||||
winkey_popup->set_theme(theme.value);
|
||||
|
||||
// The press time only takes effect when the shortcut guide is activated by pressing the win key.
|
||||
if (shouldReactToPressedWinKey.value)
|
||||
{
|
||||
winkey_popup->apply_press_time_for_global_windows_shortcuts(windowsKeyPressTimeForGlobalWindowsShortcuts.value);
|
||||
winkey_popup->apply_press_time_for_taskbar_icon_shortcuts(windowsKeyPressTimeForTaskbarIconShortcuts.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
winkey_popup->apply_press_time_for_global_windows_shortcuts(0);
|
||||
winkey_popup->apply_press_time_for_taskbar_icon_shortcuts(0);
|
||||
}
|
||||
|
||||
target_state = std::make_unique<TargetState>();
|
||||
try
|
||||
{
|
||||
@ -310,6 +323,8 @@ void OverlayWindow::init_settings()
|
||||
theme.value = settings.theme;
|
||||
disabledApps.value = settings.disabledApps;
|
||||
shouldReactToPressedWinKey.value = settings.shouldReactToPressedWinKey;
|
||||
windowsKeyPressTimeForGlobalWindowsShortcuts.value = settings.windowsKeyPressTimeForGlobalWindowsShortcuts;
|
||||
windowsKeyPressTimeForTaskbarIconShortcuts.value = settings.windowsKeyPressTimeForTaskbarIconShortcuts;
|
||||
update_disabled_apps();
|
||||
}
|
||||
|
||||
@ -419,7 +434,15 @@ ShortcutGuideSettings OverlayWindow::GetSettings() noexcept
|
||||
|
||||
try
|
||||
{
|
||||
settings.windowsKeyPressTime = (int)properties.GetNamedObject(WindowsKeyPressTime::name).GetNamedNumber(L"value");
|
||||
settings.windowsKeyPressTimeForGlobalWindowsShortcuts = (int)properties.GetNamedObject(WindowsKeyPressTimeForGlobalWindowsShortcuts::name).GetNamedNumber(L"value");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
settings.windowsKeyPressTimeForTaskbarIconShortcuts = (int)properties.GetNamedObject(WindowsKeyPressTimeForTaskbarIconShortcuts::name).GetNamedNumber(L"value");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -84,10 +84,17 @@ private:
|
||||
bool value;
|
||||
} shouldReactToPressedWinKey;
|
||||
|
||||
struct WindowsKeyPressTime
|
||||
struct WindowsKeyPressTimeForGlobalWindowsShortcuts
|
||||
{
|
||||
static inline PCWSTR name = L"press_time";
|
||||
} windowsKeyPressTime;
|
||||
int value;
|
||||
} windowsKeyPressTimeForGlobalWindowsShortcuts;
|
||||
|
||||
struct WindowsKeyPressTimeForTaskbarIconShortcuts
|
||||
{
|
||||
static inline PCWSTR name = L"press_time_for_taskbar_icon_shortcuts";
|
||||
int value;
|
||||
} windowsKeyPressTimeForTaskbarIconShortcuts;
|
||||
|
||||
struct OpenShortcut
|
||||
{
|
||||
|
@ -40,7 +40,8 @@ void Trace::SendSettings(ShortcutGuideSettings settings) noexcept
|
||||
TraceLoggingWideString(settings.theme.c_str(), "Theme"),
|
||||
TraceLoggingWideString(settings.disabledApps.c_str(), "DisabledApps"),
|
||||
TraceLoggingBoolean(settings.shouldReactToPressedWinKey, "ShouldReactToPressedWinKey"),
|
||||
TraceLoggingInt32(settings.windowsKeyPressTime, "WindowsKeyPressTime"),
|
||||
TraceLoggingInt32(settings.windowsKeyPressTimeForGlobalWindowsShortcuts, "WindowsKeyPressTimeForGlobalWindowsShortcuts"),
|
||||
TraceLoggingInt32(settings.windowsKeyPressTimeForTaskbarIconShortcuts, "WindowsKeyPressTimeForTaskbarIconShortcuts"),
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
|
@ -171,7 +171,7 @@ public:
|
||||
|
||||
virtual UINT milliseconds_win_key_must_be_pressed() override
|
||||
{
|
||||
return m_millisecondsWinKeyShouldBePressed;
|
||||
return std::min(m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts, m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -185,9 +185,11 @@ private:
|
||||
HotkeyEx m_hotkey;
|
||||
|
||||
// If the module should be activated through the legacy pressing windows key behavior.
|
||||
const UINT DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED = 900;
|
||||
const UINT DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS = 900;
|
||||
const UINT DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS = 900;
|
||||
bool m_shouldReactToPressedWinKey = false;
|
||||
UINT m_millisecondsWinKeyShouldBePressed = DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED;
|
||||
UINT m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS;
|
||||
UINT m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS;
|
||||
|
||||
HANDLE exitEvent;
|
||||
|
||||
@ -280,7 +282,8 @@ private:
|
||||
void ParseSettings(PowerToysSettings::PowerToyValues& settings)
|
||||
{
|
||||
m_shouldReactToPressedWinKey = false;
|
||||
m_millisecondsWinKeyShouldBePressed = DEFAULT_MILLISECONDS_WIN_KEY_SHOULD_BE_PRESSED;
|
||||
m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_GLOBAL_WINDOWS_SHORTCUTS;
|
||||
m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = DEFAULT_MILLISECONDS_WIN_KEY_PRESS_TIME_FOR_TASKBAR_ICON_SHORTCUTS;
|
||||
|
||||
auto settingsObject = settings.get_raw_json();
|
||||
if (settingsObject.GetView().Size())
|
||||
@ -322,8 +325,10 @@ private:
|
||||
// Parse Legacy windows key press behavior settings
|
||||
auto jsonUseLegacyWinKeyBehaviorObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"use_legacy_press_win_key_behavior");
|
||||
m_shouldReactToPressedWinKey = (bool)jsonUseLegacyWinKeyBehaviorObject.GetNamedBoolean(L"value");
|
||||
auto jsonPressTimeObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time");
|
||||
m_millisecondsWinKeyShouldBePressed = (UINT)jsonPressTimeObject.GetNamedNumber(L"value");
|
||||
auto jsonPressTimeForGlobalWindowsShortcutsObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time");
|
||||
auto jsonPressTimeForTaskbarIconShortcutsObject = settingsObject.GetNamedObject(L"properties").GetNamedObject(L"press_time_for_taskbar_icon_shortcuts");
|
||||
m_millisecondsWinKeyPressTimeForGlobalWindowsShortcuts = (UINT)jsonPressTimeForGlobalWindowsShortcutsObject.GetNamedNumber(L"value");
|
||||
m_millisecondsWinKeyPressTimeForTaskbarIconShortcuts = (UINT)jsonPressTimeForTaskbarIconShortcutsObject.GetNamedNumber(L"value");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -12,7 +12,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
OverlayOpacity = new IntProperty(90);
|
||||
UseLegacyPressWinKeyBehavior = new BoolProperty(false);
|
||||
PressTime = new IntProperty(900);
|
||||
PressTimeForGlobalWindowsShortcuts = new IntProperty(900);
|
||||
PressTimeForTaskbarIconShortcuts = new IntProperty(900);
|
||||
Theme = new StringProperty("system");
|
||||
DisabledApps = new StringProperty();
|
||||
OpenShortcutGuide = new HotkeySettings(true, false, false, true, 0xBF);
|
||||
@ -28,7 +29,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
public BoolProperty UseLegacyPressWinKeyBehavior { get; set; }
|
||||
|
||||
[JsonPropertyName("press_time")]
|
||||
public IntProperty PressTime { get; set; }
|
||||
public IntProperty PressTimeForGlobalWindowsShortcuts { get; set; }
|
||||
|
||||
[JsonPropertyName("press_time_for_taskbar_icon_shortcuts")]
|
||||
public IntProperty PressTimeForTaskbarIconShortcuts { get; set; }
|
||||
|
||||
[JsonPropertyName("theme")]
|
||||
public StringProperty Theme { get; set; }
|
||||
|
@ -814,13 +814,10 @@
|
||||
<data name="ShortcutGuide.ModuleDescription" xml:space="preserve">
|
||||
<value>Shows a help overlay with Windows shortcuts.</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_PressTime.Header" xml:space="preserve">
|
||||
<value>Press duration before showing (ms)</value>
|
||||
<data name="ShortcutGuide_PressTimeForGlobalWindowsShortcuts.Header" xml:space="preserve">
|
||||
<value>Press duration before showing global Windows shortcuts (ms)</value>
|
||||
<comment>ms = milliseconds</comment>
|
||||
</data>
|
||||
<data name="ShortcutGuide_PressTime.Description" xml:space="preserve">
|
||||
<value>How long to press the Windows key to activate the module</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_ActivationMethod.Header" xml:space="preserve">
|
||||
<value>Activation method</value>
|
||||
</data>
|
||||
@ -2685,6 +2682,10 @@ Activate by holding the key for the character you want to add an accent to, then
|
||||
<data name="Hosts_Toggle_LaunchAdministrator.Header" xml:space="preserve">
|
||||
<value>Launch as administrator</value>
|
||||
</data>
|
||||
<data name="ShortcutGuide_PressTimeForTaskbarIconShortcuts.Header" xml:space="preserve">
|
||||
<value>Press duration before showing taskbar icon shortcuts (ms)</value>
|
||||
<comment>ms = milliseconds</comment>
|
||||
</data>
|
||||
<data name="FileLocksmith.ModuleDescription" xml:space="preserve">
|
||||
<value>A Windows shell extension to find out which processes are using the selected files and directories.</value>
|
||||
</data>
|
||||
|
@ -66,7 +66,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
|
||||
_useLegacyPressWinKeyBehavior = Settings.Properties.UseLegacyPressWinKeyBehavior.Value;
|
||||
_pressTime = Settings.Properties.PressTime.Value;
|
||||
_pressTimeForGlobalWindowsShortcuts = Settings.Properties.PressTimeForGlobalWindowsShortcuts.Value;
|
||||
_pressTimeForTaskbarIconShortcuts = Settings.Properties.PressTimeForTaskbarIconShortcuts.Value;
|
||||
_opacity = Settings.Properties.OverlayOpacity.Value;
|
||||
_disabledApps = Settings.Properties.DisabledApps.Value;
|
||||
|
||||
@ -83,7 +84,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private bool _isEnabled;
|
||||
private int _themeIndex;
|
||||
private bool _useLegacyPressWinKeyBehavior;
|
||||
private int _pressTime;
|
||||
private int _pressTimeForGlobalWindowsShortcuts;
|
||||
private int _pressTimeForTaskbarIconShortcuts;
|
||||
private int _opacity;
|
||||
|
||||
public bool IsEnabled
|
||||
@ -201,15 +203,33 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return _pressTime;
|
||||
return _pressTimeForGlobalWindowsShortcuts;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_pressTime != value)
|
||||
if (_pressTimeForGlobalWindowsShortcuts != value)
|
||||
{
|
||||
_pressTime = value;
|
||||
Settings.Properties.PressTime.Value = value;
|
||||
_pressTimeForGlobalWindowsShortcuts = value;
|
||||
Settings.Properties.PressTimeForGlobalWindowsShortcuts.Value = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int DelayTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _pressTimeForTaskbarIconShortcuts;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_pressTimeForTaskbarIconShortcuts != value)
|
||||
{
|
||||
_pressTimeForTaskbarIconShortcuts = value;
|
||||
Settings.Properties.PressTimeForTaskbarIconShortcuts.Value = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
|
||||
<controls:Setting x:Uid="ShortcutGuide_PressTime" Icon="" Visibility="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource TrueToVisibleConverter}}">
|
||||
<controls:Setting x:Uid="ShortcutGuide_PressTimeForGlobalWindowsShortcuts" Icon="" Visibility="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource TrueToVisibleConverter}}">
|
||||
<controls:Setting.ActionContent>
|
||||
<NumberBox
|
||||
Minimum="100"
|
||||
@ -67,6 +67,20 @@
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
|
||||
<controls:Setting x:Uid="ShortcutGuide_PressTimeForTaskbarIconShortcuts" Icon="" Visibility="{x:Bind Mode=OneWay, Path=ViewModel.UseLegacyPressWinKeyBehavior, Converter={StaticResource TrueToVisibleConverter}}">
|
||||
<controls:Setting.ActionContent>
|
||||
<NumberBox
|
||||
Minimum="100"
|
||||
Value="{x:Bind Mode=TwoWay, Path=ViewModel.DelayTime}"
|
||||
MinWidth="{StaticResource SettingActionControlMinWidth}"
|
||||
SpinButtonPlacementMode="Compact"
|
||||
HorizontalAlignment="Left"
|
||||
SmallChange="50"
|
||||
LargeChange="100"
|
||||
/>
|
||||
</controls:Setting.ActionContent>
|
||||
</controls:Setting>
|
||||
|
||||
<InfoBar
|
||||
x:Uid="ShortcutGuide_PressWinKeyWarning"
|
||||
Severity="Warning"
|
||||
|
Loading…
Reference in New Issue
Block a user