From fd1a64c7b86de97702c7bff1212b108afbb57965 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 16 May 2024 10:52:11 -0600 Subject: [PATCH] fix: Switch to Windows 11 keymap when running Windows 11. Closes #494 --- doc/changelog.md | 3 ++- src/config.py | 6 +++++- src/controller/mainController.py | 9 ++++++++- src/wxUI/commonMessageDialogs.py | 4 ++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 7d708f989..e075ef1d0 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -3,8 +3,9 @@ TWBlue Changelog ## changes in this version * Core: - * Added Initial Support to GoToSocial. + * Added Initial Support to GoToSocial. Some features are not fully implemented yet, although GoToXocial instances should be able to be used as normal sessions in TWBlue. Streaming, poll options and markdown are not supported but planned for the near future. * The translation module has been rewritten. Now, instead of offering translations with Google Translator, the user can choose between [LibreTranslate,](https://github.com/LibreTranslate/LibreTranslate) which requires no configuration thanks to the [instance of the NVDA Spanish community;](https://translate.nvda.es) or translate using [DeepL,](https://deepl.com) for which it is necessary to create an account on DeepL and [subscribe to a DeepL API Free plan](https://support.deepl.com/hc/en-us/articles/360021200939-DeepL-API-Free) to obtain the API key which can be used to translate up to 500000 characters every month. The API key can be entered in the global options dialog, under a new tab called translation services. When translating a text, the translation engine can be changed. When changing the translation engine, the target language must be selected again before translation takes place. + * TWBlue should be able to switch to Windows 11 Keymap when running under Windows 11. ([#494](https://github.com/mcv-software/twblue/issues/494)) * Mastodon: * Fixed an error that caused TWBlue to be unable to properly display the user action dialog from the followers or following buffer. ([#575](https://github.com/mcv-software/twblue/issues/575)) diff --git a/src/config.py b/src/config.py index 1954c628e..9ad73f959 100644 --- a/src/config.py +++ b/src/config.py @@ -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 diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 05c7cbede..ca6c24b23 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -846,7 +846,14 @@ def create_invisible_keyboard_shorcuts(self): 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) diff --git a/src/wxUI/commonMessageDialogs.py b/src/wxUI/commonMessageDialogs.py index 28e06a1b6..62f51f2a1 100644 --- a/src/wxUI/commonMessageDialogs.py +++ b/src/wxUI/commonMessageDialogs.py @@ -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()