Changeset 81217 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 10, 2019 2:30:06 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 133881
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81208 r81217 343 343 344 344 /** 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 have345 * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey usually does not have 346 346 * 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. */ 348 349 class UISoftKeyboardKey 349 350 { … … 387 388 KeyState state() const; 388 389 void setState(KeyState state); 390 391 void setStaticCaption(const QString &strCaption); 392 const QString &staticCaption() const; 389 393 390 394 void setParentWidget(UISoftKeyboardWidget* pParent); … … 437 441 LONG m_iUsagePage; 438 442 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; 439 447 }; 440 448 … … 490 498 QUuid uid() const; 491 499 492 void drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter);493 500 void drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter); 494 501 … … 1554 1561 } 1555 1562 1563 void UISoftKeyboardKey::setStaticCaption(const QString &strCaption) 1564 { 1565 m_strStaticCaption = strCaption; 1566 } 1567 1568 const QString &UISoftKeyboardKey::staticCaption() const 1569 { 1570 return m_strStaticCaption; 1571 } 1572 1556 1573 void UISoftKeyboardKey::setParentWidget(UISoftKeyboardWidget* pParent) 1557 1574 { … … 1825 1842 QFont painterFont(painter.font()); 1826 1843 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(); 1832 1862 1833 1863 const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption; … … 1895 1925 keyGeometry.height() - 2 * iMargin); 1896 1926 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 } 1949 1940 } 1950 1941 … … 3050 3041 key.setKeyboardRegion(KeyboardRegion_OSMenuKeys); 3051 3042 } 3043 else if (m_xmlReader.name() == "staticcaption") 3044 key.setStaticCaption(m_xmlReader.readElementText()); 3052 3045 else 3053 3046 m_xmlReader.skipCurrentElement(); -
trunk/src/VBox/Frontends/VirtualBox/xml/101_ansi.xml
r79724 r81217 550 550 <scancode>0x5b</scancode> 551 551 <osmenukey>true</osmenukey> 552 <staticcaption>◆</staticcaption> 552 553 </key> 553 554 <key> -
trunk/src/VBox/Frontends/VirtualBox/xml/102_iso.xml
r79724 r81217 559 559 <scancode>0x5b</scancode> 560 560 <osmenukey>true</osmenukey> 561 <staticcaption>◆</staticcaption> 561 562 </key> 562 563 <key> -
trunk/src/VBox/Frontends/VirtualBox/xml/103_ansi.xml
r79724 r81217 546 546 <scancode>0x5b</scancode> 547 547 <osmenukey>true</osmenukey> 548 <staticcaption>◆</staticcaption> 548 549 </key> 549 550 <key> -
trunk/src/VBox/Frontends/VirtualBox/xml/103_iso.xml
r79724 r81217 564 564 <scancode>0x5b</scancode> 565 565 <osmenukey>true</osmenukey> 566 <staticcaption>◆</staticcaption> 566 567 </key> 567 568 <key> -
trunk/src/VBox/Frontends/VirtualBox/xml/106_japanese.xml
r79724 r81217 563 563 <scancode>0x5b</scancode> 564 564 <osmenukey>true</osmenukey> 565 <staticcaption>◆</staticcaption> 565 566 </key> 566 567 <key><!-- Alt --> -
trunk/src/VBox/Frontends/VirtualBox/xml/multimedia_keys.xml
r81171 r81217 4 4 <id>80b4c26e-43fc-44f8-b515-351cff9269ce</id> 5 5 <row> 6 <space> 7 <width>50</width> 8 </space> 9 6 10 <key><!-- WWW back --> 7 11 <position>300</position> … … 9 13 <usagepage>0x0C</usagepage> 10 14 <scancode>0x20</scancode> 15 <staticcaption>⬅</staticcaption> 11 16 </key> 12 17 <key> … … 28 33 <usagepage>0x0C</usagepage> 29 34 <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> 30 50 </key> 31 51 </row> -
trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml
r81171 r81217 4 4 <id>3c7b7be7-4d2a-4f65-a21e-208ba2e4ecaf</id> 5 5 <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>21 6 <key> 22 7 <position>110</position>
Note:
See TracChangeset
for help on using the changeset viewer.