VirtualBox

Ignore:
Timestamp:
Oct 10, 2019 2:30:06 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133881
Message:

FE/Qt: bugref:6143. Some keys get static captions.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81208 r81217  
    343343
    344344/** UISoftKeyboardKey is a place holder for a keyboard key. Graphical key represantations are drawn according to this class.
    345   * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey does not have
     345  * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey usually does not have
    346346  * caption field(s). Captions are kept by UISoftKeyboardLayout since same keys may (and usually do) have different captions in
    347   * different layouts. */
     347  * different layouts. So called static captions are exections. They are defined in physical layout files and kept as member of
     348  * UISoftKeyboardKey. When a static caption exits captions (if any) from the keyboard layout files are ignored. */
    348349class UISoftKeyboardKey
    349350{
     
    387388    KeyState state() const;
    388389    void setState(KeyState state);
     390
     391    void setStaticCaption(const QString &strCaption);
     392    const QString &staticCaption() const;
    389393
    390394    void setParentWidget(UISoftKeyboardWidget* pParent);
     
    437441    LONG m_iUsagePage;
    438442    KeyboardRegion m_enmKeyboardRegion;
     443    /** This is used for multimedia keys, OS key etc where we want to have a non-modifiable
     444      * caption (usually a single char). This caption is defined in the physical layout file
     445      * and has precedence over the captions defined in keyboard layout files. */
     446    QString m_strStaticCaption;
    439447};
    440448
     
    490498    QUuid uid() const;
    491499
    492     void drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter);
    493500    void drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter);
    494501
     
    15541561}
    15551562
     1563void UISoftKeyboardKey::setStaticCaption(const QString &strCaption)
     1564{
     1565    m_strStaticCaption = strCaption;
     1566}
     1567
     1568const QString &UISoftKeyboardKey::staticCaption() const
     1569{
     1570    return m_strStaticCaption;
     1571}
     1572
    15561573void UISoftKeyboardKey::setParentWidget(UISoftKeyboardWidget* pParent)
    15571574{
     
    18251842     QFont painterFont(painter.font());
    18261843
    1827      const QString &strBaseCaption = baseCaption(iKeyPosition);
    1828      const QString &strShiftCaption = shiftCaption(iKeyPosition);
    1829 
    1830      const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition);
    1831      const QString &strAltGrCaption = altGrCaption(iKeyPosition);
     1844     QString strBaseCaption;
     1845     QString strShiftCaption;
     1846     QString strShiftAltGrCaption;
     1847     QString strAltGrCaption;
     1848
     1849     /* Static captions which are define in the physical layout files have precedence over
     1850        the one define in the keyboard layouts. In effect they stay the same for all the
     1851        keyboard layouts sharing the same physical layout: */
     1852
     1853     if (key.staticCaption().isEmpty())
     1854     {
     1855         strBaseCaption = baseCaption(iKeyPosition);
     1856         strShiftCaption = shiftCaption(iKeyPosition);
     1857         strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition);
     1858         strAltGrCaption = altGrCaption(iKeyPosition);
     1859     }
     1860     else
     1861         strBaseCaption = key.staticCaption();
    18321862
    18331863     const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption;
     
    18951925                          keyGeometry.height() - 2 * iMargin);
    18961926
    1897      painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString);
    1898      painter.drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, strBottomleftString);
    1899      painter.drawText(textRect, Qt::AlignRight | Qt::AlignTop, strShiftAltGrCaption);
    1900      painter.drawText(textRect, Qt::AlignRight | Qt::AlignBottom, strAltGrCaption);
    1901 }
    1902 
    1903 void UISoftKeyboardLayout::drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter)
    1904 {
    1905     QFont painterFont(painter.font());
    1906 
    1907     painterFont.setPixelSize(15);
    1908     painterFont.setBold(true);
    1909     painter.setFont(painterFont);
    1910     QFontMetrics fontMetric = painter.fontMetrics();
    1911     int iSideMargin = 0.5 * fontMetric.width('X');
    1912 
    1913     int iX = 0;
    1914     int iY = fontMetric.height();
    1915 #if 0
    1916     Q_UNUSED(keyGeometry);
    1917     painter.drawText(iX + iSideMargin, iY, QString::number(iKeyPosition));
    1918 #else
    1919     const QString &strBaseCaption = baseCaption(iKeyPosition);
    1920     const QString &strShiftCaption = shiftCaption(iKeyPosition);
    1921     const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition);
    1922     const QString &strAltGrCaption = altGrCaption(iKeyPosition);
    1923 
    1924     if (!strShiftCaption.isEmpty())
    1925     {
    1926         painter.drawText(iX + iSideMargin, iY, strShiftCaption);
    1927         painter.drawText(iX + iSideMargin, 2 * iY, strBaseCaption);
    1928     }
    1929     else
    1930     {
    1931         int iSpaceIndex = strBaseCaption.indexOf(" " );
    1932         if (iSpaceIndex == -1)
    1933             painter.drawText(iX + iSideMargin, iY, strBaseCaption);
    1934         else
    1935         {
    1936             painter.drawText(iX + iSideMargin, iY, strBaseCaption.left(iSpaceIndex));
    1937             painter.drawText(iX + iSideMargin, 2 * iY, strBaseCaption.right(strBaseCaption.length() - iSpaceIndex - 1));
    1938         }
    1939     }
    1940 
    1941     if (!strShiftAltGrCaption.isEmpty())
    1942     {
    1943         painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, iY, strShiftAltGrCaption);
    1944         painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, 2 * iY, strAltGrCaption);
    1945     }
    1946     else
    1947         painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, 2 * iY, strAltGrCaption);
    1948 #endif
     1927     if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys)
     1928     {
     1929         painter.drawText(QRect(0, 0, keyGeometry.width(), keyGeometry.height()),
     1930                          Qt::AlignHCenter | Qt::AlignVCenter, strTopleftString);
     1931
     1932     }
     1933     else
     1934     {
     1935         painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString);
     1936         painter.drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, strBottomleftString);
     1937         painter.drawText(textRect, Qt::AlignRight | Qt::AlignTop, strShiftAltGrCaption);
     1938         painter.drawText(textRect, Qt::AlignRight | Qt::AlignBottom, strAltGrCaption);
     1939     }
    19491940}
    19501941
     
    30503041                key.setKeyboardRegion(KeyboardRegion_OSMenuKeys);
    30513042        }
     3043        else if (m_xmlReader.name() == "staticcaption")
     3044            key.setStaticCaption(m_xmlReader.readElementText());
    30523045        else
    30533046            m_xmlReader.skipCurrentElement();
  • trunk/src/VBox/Frontends/VirtualBox/xml/101_ansi.xml

    r79724 r81217  
    550550            <scancode>0x5b</scancode>
    551551            <osmenukey>true</osmenukey>
     552            <staticcaption>◆</staticcaption>
    552553        </key>
    553554        <key>
  • trunk/src/VBox/Frontends/VirtualBox/xml/102_iso.xml

    r79724 r81217  
    559559            <scancode>0x5b</scancode>
    560560            <osmenukey>true</osmenukey>
     561            <staticcaption>◆</staticcaption>
    561562        </key>
    562563        <key>
  • trunk/src/VBox/Frontends/VirtualBox/xml/103_ansi.xml

    r79724 r81217  
    546546            <scancode>0x5b</scancode>
    547547            <osmenukey>true</osmenukey>
     548            <staticcaption>◆</staticcaption>
    548549        </key>
    549550        <key>
  • trunk/src/VBox/Frontends/VirtualBox/xml/103_iso.xml

    r79724 r81217  
    564564            <scancode>0x5b</scancode>
    565565            <osmenukey>true</osmenukey>
     566            <staticcaption>◆</staticcaption>
    566567        </key>
    567568        <key>
  • trunk/src/VBox/Frontends/VirtualBox/xml/106_japanese.xml

    r79724 r81217  
    563563            <scancode>0x5b</scancode>
    564564            <osmenukey>true</osmenukey>
     565            <staticcaption>◆</staticcaption>
    565566        </key>
    566567        <key><!-- Alt -->
  • trunk/src/VBox/Frontends/VirtualBox/xml/multimedia_keys.xml

    r81171 r81217  
    44    <id>80b4c26e-43fc-44f8-b515-351cff9269ce</id>
    55    <row>
     6        <space>
     7            <width>50</width>
     8        </space>
     9
    610        <key><!-- WWW back -->
    711            <position>300</position>
     
    913            <usagepage>0x0C</usagepage>
    1014            <scancode>0x20</scancode>
     15            <staticcaption>⬅</staticcaption>
    1116        </key>
    1217        <key>
     
    2833            <usagepage>0x0C</usagepage>
    2934            <scancode>0x4a</scancode>
     35            <staticcaption>🔇</staticcaption>
     36        </key>
     37        <key><!-- Volume Down -->
     38            <position>304</position>
     39            <usageid>0xEA</usageid>
     40            <usagepage>0x0C</usagepage>
     41            <scancode>0x4a</scancode>
     42            <staticcaption>🔉</staticcaption>
     43        </key>
     44        <key><!-- Volume Up -->
     45            <position>305</position>
     46            <usageid>0xE9</usageid>
     47            <usagepage>0x0C</usagepage>
     48            <scancode>0x4a</scancode>
     49            <staticcaption>🔊</staticcaption>
    3050        </key>
    3151    </row>
  • trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml

    r81171 r81217  
    44    <id>3c7b7be7-4d2a-4f65-a21e-208ba2e4ecaf</id>
    55    <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid>
    6     <!-- multimedia keys -->
    7     <key>
    8         <position>300</position>
    9         <basecaption>⬅</basecaption>
    10         <shiftcaption></shiftcaption>
    11         <altgrcaption></altgrcaption>
    12         <shiftaltgrcaption></shiftaltgrcaption>
    13     </key>
    14     <key>
    15         <position>303</position>
    16         <basecaption>🔇</basecaption>
    17         <shiftcaption></shiftcaption>
    18         <altgrcaption></altgrcaption>
    19         <shiftaltgrcaption></shiftaltgrcaption>
    20     </key>
    216    <key>
    227        <position>110</position>
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