Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-40030

Special keys like Shift are not named in QKeySequence::toString.

    XMLWordPrintable

Details

    Description

      Many special unprintable keys are not named, causing QKeySequence::toString to fall back to their unicode value, which doesn't make sense to me (i.e. contains weird unicode surrogates) for the following keys:

      Key_Alt: b'\xe1\x9f\x80\\udc23'
      Key_AltGr: b'\xe1\x9f\x84\\udd03'
      Key_Blue: b'\xe1\x9f\x80\\udd17'
      Key_Calendar: b'\xe1\x9f\x80\\udce4'
      Key_ChannelDown: b'\xe1\x9f\x80\\udd19'
      Key_ChannelUp: b'\xe1\x9f\x80\\udd18'
      Key_ContrastAdjust: b'\xe1\x9f\x80\\udd0d'
      Key_Control: b'\xe1\x9f\x80\\udc21'
      Key_Dead_Abovedot: b'\xe1\x9f\x84\\ude56'
      Key_Dead_Abovering: b'\xe1\x9f\x84\\ude58'
      Key_Dead_Acute: b'\xe1\x9f\x84\\ude51'
      Key_Dead_Belowdot: b'\xe1\x9f\x84\\ude60'
      Key_Dead_Breve: b'\xe1\x9f\x84\\ude55'
      Key_Dead_Caron: b'\xe1\x9f\x84\\ude5a'
      Key_Dead_Cedilla: b'\xe1\x9f\x84\\ude5b'
      Key_Dead_Circumflex: b'\xe1\x9f\x84\\ude52'
      Key_Dead_Diaeresis: b'\xe1\x9f\x84\\ude57'
      Key_Dead_Doubleacute: b'\xe1\x9f\x84\\ude59'
      Key_Dead_Grave: b'\xe1\x9f\x84\\ude50'
      Key_Dead_Hook: b'\xe1\x9f\x84\\ude61'
      Key_Dead_Horn: b'\xe1\x9f\x84\\ude62'
      Key_Dead_Iota: b'\xe1\x9f\x84\\ude5d'
      Key_Dead_Macron: b'\xe1\x9f\x84\\ude54'
      Key_Dead_Ogonek: b'\xe1\x9f\x84\\ude5c'
      Key_Dead_Semivoiced_Sound: b'\xe1\x9f\x84\\ude5f'
      Key_Dead_Tilde: b'\xe1\x9f\x84\\ude53'
      Key_Dead_Voiced_Sound: b'\xe1\x9f\x84\\ude5e'
      Key_Direction_L: b'\xe1\x9f\x80\\udc59'
      Key_Direction_R: b'\xe1\x9f\x80\\udc60'
      Key_Exit: b'\xe1\xa1\x80\\udc0a'
      Key_Green: b'\xe1\x9f\x80\\udd15'
      Key_Guide: b'\xe1\x9f\x80\\udd1a'
      Key_Hyper_L: b'\xe1\x9f\x80\\udc56'
      Key_Hyper_R: b'\xe1\x9f\x80\\udc57'
      Key_Info: b'\xe1\x9f\x80\\udd1b'
      Key_LaunchG: b'\xe1\x9f\x80\\udd0e'
      Key_LaunchH: b'\xe1\x9f\x80\\udd0f'
      Key_MediaLast: b'\xe1\x9f\xbf\\udfff'
      Key_Memo: b'\xe1\x9f\x80\\udcbc'
      Key_Meta: b'\xe1\x9f\x80\\udc22'
      Key_MicMute: b'\xe1\x9f\x80\\udd13'
      Key_Mode_switch: b'\xe1\x9f\x84\\udd7e'
      Key_Multi_key: b'\xe1\x9f\x84\\udd20'
      Key_PowerDown: b'\xe1\x9f\x80\\udd0b'
      Key_Red: b'\xe1\x9f\x80\\udd14'
      Key_Settings: b'\xe1\x9f\x80\\udd1c'
      Key_Shift: b'\xe1\x9f\x80\\udc20'
      Key_SingleCandidate: b'\xe1\x9f\x84\\udd3c'
      Key_Super_L: b'\xe1\x9f\x80\\udc53'
      Key_Super_R: b'\xe1\x9f\x80\\udc54'
      Key_ToDoList: b'\xe1\x9f\x80\\udccc'
      Key_TouchpadOff: b'\xe1\x9f\x80\\udd12'
      Key_TouchpadOn: b'\xe1\x9f\x80\\udd11'
      Key_TouchpadToggle: b'\xe1\x9f\x80\\udd10'
      Key_Yellow: b'\xe1\x9f\x80\\udd16'
      

      I don't know what a sensible behaviour for the dead keys would be (their 'dead' character? A name?), but I believe all other non-printable keys in the Qt::Key enum should be named correctly.

      This is the PyQt-script I used to generate the above list:

      from PyQt5.QtCore import Qt
      from PyQt5.QtGui import QKeySequence
      
      keys = {name: value for name, value in vars(Qt).items()
              if isinstance(value, Qt.Key)}
      
      for name, key in sorted(keys.items()):
          try:
              string = QKeySequence(key).toString().encode('utf-8')
          except UnicodeEncodeError:
              string = QKeySequence(key).toString().encode('utf-8', errors='backslashreplace')
              print('{}: {}'.format(name, string))
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-40030
          # Subject Branch Project Status CR V

          Activity

            People

              liaqi Liang Qi
              the compiler Florian Bruhin
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes