fix: Switch to Windows 11 keymap when running Windows 11. Closes #494

This commit is contained in:
2024-05-16 10:52:11 -06:00
parent a5cd118b99
commit fd1a64c7b8
4 changed files with 17 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: cp1252 -*-
import os
import sys
import config_utils
import paths
import logging
@@ -21,7 +22,10 @@ def setup ():
log.debug("Loading keymap...")
global keymap
if float(platform.version()[:2]) >= 10 and app["app-settings"]["load_keymap"] == "default.keymap":
app["app-settings"]["load_keymap"] = "Windows 10.keymap"
if sys.getwindowsversion().build > 22000:
app["app-settings"]["load_keymap"] = "Windows11.keymap"
else:
app["app-settings"]["load_keymap"] = "Windows 10.keymap"
app.write()
global changed_keymap
changed_keymap = True

View File

@@ -846,7 +846,14 @@ class Controller(object):
def register_invisible_keyboard_shorcuts(self, keymap):
if config.changed_keymap:
commonMessageDialogs.changed_keymap()
build_number = sys.getwindowsversion().build
if build_number > 22000:
system = "Windows 11"
keystroke_editor_shortcut = "Control+Win+Alt+K"
else:
system = "Windows 10"
keystroke_editor_shortcut = "Win+Alt+K"
commonMessageDialogs.changed_keymap(system, keystroke_editor_shortcut)
# Make sure we pass a keymap without undefined keystrokes.
new_keymap = {key: keymap[key] for key in keymap.keys() if keymap[key] != ""}
self.keyboard_handler = WXKeyboardHandler(self.view)

View File

@@ -29,8 +29,8 @@ def donation():
dlg = wx.MessageDialog(None, _(u"If you like {0} we need your help to keep it going. Help us by donating to the project. This will help us pay for the server, the domain and some other things to ensure that {0} will be actively maintained. Your donation will give us the means to continue the development of {0}, and to keep {0} free. Would you like to donate now?").format(application.name), _(u"We need your help"), wx.ICON_QUESTION|wx.YES_NO)
return dlg.ShowModal()
def changed_keymap():
return wx.MessageDialog(None, _(u"TWBlue has detected that you're running windows 10 and has changed the default keymap to the Windows 10 keymap. It means that some keyboard shorcuts could be different. Please check the keystroke editor by pressing Alt+Win+K to see all available keystrokes for this keymap."), _(u"Information"), wx.OK).ShowModal()
def changed_keymap(system, keystroke_editor_shortcut):
return wx.MessageDialog(None, _(f"TWBlue has detected that you're running {system} and has changed the default keymap to the {system} keymap. It means that some keyboard shorcuts could be different. Please check the keystroke editor by pressing {keystroke_editor_shortcut} to see all available keystrokes for this keymap."), _(u"Information"), wx.OK).ShowModal()
def invalid_configuration():
return wx.MessageDialog(None, _("The configuration file is invalid."), _("Error"), wx.ICON_ERROR).ShowModal()