VirtualBox

Changeset 2802 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 23, 2007 12:57:12 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
21412
Message:

Fixed the host key name display in the X11 GUI

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r2431 r2802  
    2424TEMPLATE        = app
    2525LANGUAGE        = C++
     26
     27SOURCES = src/QIHotKeyEdit.cpp
    2628
    2729FORMS   = ui/VBoxDiskImageManagerDlg.ui \
  • trunk/src/VBox/Frontends/VirtualBox/include/QIHotKeyEdit.h

    r1285 r2802  
    2525
    2626#include <qlabel.h>
    27 #ifdef Q_WS_MAC
     27#if defined(Q_WS_X11)
     28#include <qmap.h>
     29#endif
     30#if defined(Q_WS_MAC)
    2831#include <Carbon/Carbon.h>
    2932#endif
     
    4750    QSize minimumSizeHint() const;
    4851
     52#if defined(Q_WS_X11)
     53    static void languageChange(void);
     54#endif
    4955    static QString keyName (int key);
    5056    static bool isValidKey (int k);
     
    8086    QColorGroup true_acg;
    8187
     88#if defined(Q_WS_X11)
     89    static QMap<QString, QString> keyNames;
     90#endif
     91
    8292#if defined(Q_WS_MAC)
    8393    /** Event handler reference. NULL if the handler isn't installed. */
  • trunk/src/VBox/Frontends/VirtualBox/src/QIHotKeyEdit.cpp

    r1319 r2802  
    6060#endif
    6161#include "XKeyboard.h"
     62QMap<QString, QString> QIHotKeyEdit::keyNames;
    6263#endif
    6364
     
    224225    return QSize( w + m, h + m );
    225226}
     227
     228#if defined(Q_WS_X11)
     229/**
     230 * Updates the associative array containing the translations of X11 key strings to human
     231 * readable key names.
     232 */
     233// static
     234void QIHotKeyEdit::languageChange(void)
     235{
     236    keyNames["Shift_L"]          = tr ("Left Shift");
     237    keyNames["Shift_R"]          = tr ("Right Shift");
     238    keyNames["Control_L"]        = tr ("Left Ctrl");
     239    keyNames["Control_R"]        = tr ("Right Ctrl");
     240    keyNames["Alt_L"]            = tr ("Left Alt");
     241    keyNames["Alt_R"]            = tr ("Right Alt");
     242    keyNames["Super_L"]          = tr ("Left WinKey");
     243    keyNames["Super_R"]          = tr ("Right WinKey");
     244    keyNames["Menu"]             = tr ("Menu key");
     245    keyNames["ISO_Level3_Shift"] = tr ("Alt Gr");
     246    keyNames["Caps_Lock"]        = tr ("Caps Lock");
     247    keyNames["Scroll_Lock"]      = tr ("Scroll Lock");
     248}
     249#endif
    226250
    227251/**
     
    260284        char *sn = ::XKeysymToString( (KeySym) key );
    261285        if ( sn )
    262             name = sn;
     286        {
     287            if ( keyNames.contains(sn) )
     288                name = keyNames[sn];
     289            else
     290                name = sn;
     291        }
    263292        else
    264             name = QString( "<key_%1>" ).arg( key );
     293            name = QString( tr ("<key_%1>") ).arg( key );
    265294#elif defined(Q_WS_MAC)
    266295        UInt32 modMask = DarwinKeyCodeToDarwinModifierMask( key );
     
    437466            char *name = ::XKeysymToString( ks );
    438467            if ( name )
    439                 symbname = name;
     468            {
     469                if ( keyNames.contains(name) )
     470                    symbname = keyNames[name];
     471                else
     472                    symbname = name;
     473            }
    440474            else
    441                 symbname = QString( "<key_%1>" ).arg( (int) ks );
     475                symbname = QString( tr ("<key_%1>") ).arg( (int) ks );
    442476            // update the display
    443477            updateText();
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r2726 r2802  
    2727#include "VBoxConsoleWnd.h"
    2828#include "VBoxProblemReporter.h"
     29#include "QIHotKeyEdit.h"
    2930
    3031#include <qapplication.h>
     
    18501851
    18511852    detailReportTemplatesReady = false;
     1853#if defined(Q_WS_X11)
     1854    /* As X11 does not (to my knowledge) have functionality for providing human readable
     1855     * key names, we keep a table of them, which must be updated when the language is
     1856     * changed. */
     1857    QIHotKeyEdit::languageChange();
     1858#endif
    18521859}
    18531860
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette