hotkey-config #1

Merged
scoped merged 10 commits from hotkey-config into master 2026-02-22 12:45:38 -05:00
Showing only changes of commit 6aa49c0b07 - Show all commits

View File

@@ -182,6 +182,8 @@ namespace ClipForge
QualityLabel.Text = $"{s.VideoQuality}%"; QualityLabel.Text = $"{s.VideoQuality}%";
FramerateCombo.SelectedIndex = s.Framerate == 30 ? 0 : 1; FramerateCombo.SelectedIndex = s.Framerate == 30 ? 0 : 1;
StartupToggle.IsOn = IsStartupEnabled(); StartupToggle.IsOn = IsStartupEnabled();
if (HotkeyRecorderText != null)
HotkeyRecorderText.Text = HotkeyHelper.ToDisplayString((uint)s.HotkeyModifiers, (uint)s.HotkeyVirtualKey);
} }
// --- STARTUP WITH WINDOWS --- // --- STARTUP WITH WINDOWS ---
@@ -248,6 +250,42 @@ namespace ClipForge
_ = ShowToastAsync("✅ Settings saved!"); _ = ShowToastAsync("✅ Settings saved!");
} }
// --- CUSTOM HOTKEY ---
private void HotkeyRecorderButton_Click(object sender, RoutedEventArgs e)
{
if (_isRecordingHotkey) return;
_isRecordingHotkey = true;
HotkeyRecorderText.Text = "Press any key...";
this.KeyDown += OnHotkeyCaptureKeyDown;
}
private void OnHotkeyCaptureKeyDown(object sender, KeyRoutedEventArgs e)
{
if (!_isRecordingHotkey) return;
e.Handled = true;
var key = e.Key;
if (HotkeyHelper.IsModifierKey(key))
return; // wait for a non-modifier key
uint mod = 0;
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0) mod |= HotkeyHelper.MOD_CONTROL;
if ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0) mod |= HotkeyHelper.MOD_ALT;
if ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0) mod |= HotkeyHelper.MOD_SHIFT;
if ((GetAsyncKeyState(VK_LWIN) & 0x8000) != 0) mod |= HotkeyHelper.MOD_WIN;
uint vk = (uint)key;
_settingsService.Settings.HotkeyModifiers = (int)mod;
_settingsService.Settings.HotkeyVirtualKey = (int)vk;
var ok = _hotkeyService.UpdateHotkey(mod, vk);
var display = HotkeyHelper.ToDisplayString(mod, vk);
HotkeyRecorderText.Text = ok ? display : display + " (in use?)";
this.KeyDown -= OnHotkeyCaptureKeyDown;
_isRecordingHotkey = false;
}
// --- NAV --- // --- NAV ---
private void NavClips_Click(object sender, RoutedEventArgs e) private void NavClips_Click(object sender, RoutedEventArgs e)
{ {