Changeset 81171 in vbox for trunk/src/VBox
- Timestamp:
- Oct 9, 2019 8:54:46 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 133807
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc
r79596 r81171 8 8 <file alias="us_international.xml">xml/us_international.xml</file> 9 9 <file alias="numpad.xml">xml/numpad.xml</file> 10 <file alias="multimedia_keys.xml">xml/multimedia_keys.xml</file> 10 11 <file alias="german.xml">xml/german.xml</file> 11 12 <file alias="us.xml">xml/us.xml</file> -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81125 r81171 102 102 KeyboardRegion_Main = 0, 103 103 KeyboardRegion_NumPad, 104 KeyboardRegion_Multimedia ,105 KeyboardRegion_OSMenu ,104 KeyboardRegion_MultimediaKeys, 105 KeyboardRegion_OSMenuKeys, 106 106 KeyboardRegion_Max 107 107 }; … … 302 302 int defaultHeight() const; 303 303 304 int MaximumHeight() const; 305 304 306 QVector<UISoftKeyboardKey> &keys(); 305 307 const QVector<UISoftKeyboardKey> &keys() const; … … 313 315 int m_iDefaultWidth; 314 316 int m_iDefaultHeight; 317 int m_iMaximumHeight; 318 315 319 QVector<UISoftKeyboardKey> m_keys; 316 320 int m_iSpaceHeightAfter; … … 477 481 478 482 void drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter); 479 void drawTextInRect( int iKeyPosition, const QRect &keyGeometry, QPainter &painter);483 void drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter); 480 484 481 485 private: … … 609 613 * Window key press for start menu opening. This works orthogonal to left clicks.*/ 610 614 void modifierKeyPressRelease(UISoftKeyboardKey *pKey, bool fRelease); 611 bool loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false);615 bool loadPhysicalLayout(const QString &strLayoutFileName, KeyboardRegion keyboardRegion = KeyboardRegion_Main); 612 616 bool loadKeyboardLayout(const QString &strLayoutName); 613 617 void prepareObjects(); … … 629 633 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts; 630 634 UISoftKeyboardPhysicalLayout m_numPadLayout; 635 UISoftKeyboardPhysicalLayout m_multiMediaKeysLayout; 631 636 QVector<UISoftKeyboardLayout> m_layouts; 632 637 UISoftKeyboardLayout *m_pCurrentKeyboardLayout; … … 647 652 bool m_fHideOSMenuKeys; 648 653 bool m_fHideNumPad; 654 bool m_fHideMultimediaKeys; 649 655 }; 650 656 … … 1857 1863 } 1858 1864 1859 void UISoftKeyboardLayout::drawTextInRect(int iKeyPosition, const QRect &keyGeometry, QPainter &painter) 1860 { 1865 void UISoftKeyboardLayout::drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter) 1866 { 1867 int iKeyPosition = key.position(); 1868 const QRect &keyGeometry = key.keyGeometry(); 1861 1869 QFont painterFont(painter.font()); 1862 int iFontSize = 25;1870 int iFontSize = 30; 1863 1871 1864 1872 const QString &strBaseCaption = baseCaption(iKeyPosition); … … 1894 1902 iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart)); 1895 1903 int iTextWidth = 2 * iMargin + qMax(iTopWidth, iBottomWidth); 1896 int iTextHeight = 2 * iMargin + 2 * fontMetrics.height(); 1904 int iTextHeight = 0; 1905 1906 if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys) 1907 iTextHeight = 2 * iMargin + fontMetrics.height(); 1908 else 1909 iTextHeight = 2 * iMargin + 2 * fontMetrics.height(); 1897 1910 1898 1911 if (iTextWidth >= keyGeometry.width() || iTextHeight >= keyGeometry.height()) … … 1909 1922 painter.drawText(iMargin, iMargin + fontMetrics.height(), QString::number(iKeyPosition)); 1910 1923 #else 1911 QRect textRect(iMargin, iMargin, 1912 keyGeometry.width() - 2 * iMargin, 1913 keyGeometry.height() - 2 * iMargin); 1924 QRect textRect; 1925 if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys) 1926 textRect = QRect(2 * iMargin, iMargin, 1927 keyGeometry.width() - 2 * iMargin, 1928 keyGeometry.height() - 2 * iMargin); 1929 else 1930 textRect = QRect(iMargin, iMargin, 1931 keyGeometry.width() - 2 * iMargin, 1932 keyGeometry.height() - 2 * iMargin); 1914 1933 1915 1934 painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString); … … 2038 2057 , m_fHideOSMenuKeys(false) 2039 2058 , m_fHideNumPad(false) 2059 , m_fHideMultimediaKeys(false) 2040 2060 { 2041 2061 prepareObjects(); … … 2089 2109 { 2090 2110 UISoftKeyboardKey &key = keys[j]; 2091 if (m_fHideOSMenuKeys && key.keyboardRegion() == KeyboardRegion_OSMenu) 2111 2112 if (m_fHideOSMenuKeys && key.keyboardRegion() == KeyboardRegion_OSMenuKeys) 2092 2113 continue; 2093 2114 2094 2115 if (m_fHideNumPad && key.keyboardRegion() == KeyboardRegion_NumPad) 2116 continue; 2117 2118 if (m_fHideMultimediaKeys && key.keyboardRegion() == KeyboardRegion_MultimediaKeys) 2095 2119 continue; 2096 2120 … … 2111 2135 painter.drawPolygon(key.polygon()); 2112 2136 2113 m_pCurrentKeyboardLayout->drawTextInRect(key .position(), key.keyGeometry(), painter);2137 m_pCurrentKeyboardLayout->drawTextInRect(key, painter); 2114 2138 2115 2139 if (key.type() != KeyType_Ordinary) … … 2612 2636 } 2613 2637 2614 bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad /* = false*/)2638 bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName, KeyboardRegion keyboardRegion /* = KeyboardRegion_Main */) 2615 2639 { 2616 2640 if (strLayoutFileName.isEmpty()) … … 2618 2642 UIPhysicalLayoutReader reader; 2619 2643 UISoftKeyboardPhysicalLayout *newPhysicalLayout = 0; 2620 if ( !isNumPad)2644 if (keyboardRegion == KeyboardRegion_Main) 2621 2645 { 2622 2646 m_physicalLayouts.append(UISoftKeyboardPhysicalLayout()); 2623 2647 newPhysicalLayout = &(m_physicalLayouts.back()); 2624 2648 } 2649 else if (keyboardRegion == KeyboardRegion_NumPad) 2650 newPhysicalLayout = &(m_numPadLayout); 2651 else if (keyboardRegion == KeyboardRegion_MultimediaKeys) 2652 newPhysicalLayout = &(m_multiMediaKeysLayout); 2625 2653 else 2626 newPhysicalLayout = &(m_numPadLayout);2654 return false; 2627 2655 2628 2656 if (!reader.parseXMLFile(strLayoutFileName, *newPhysicalLayout)) … … 2632 2660 } 2633 2661 2634 if (isNumPad) 2635 { 2636 /* Mark all the key as numpad keys: */ 2637 for (int i = 0; i < m_numPadLayout.rows().size(); ++i) 2638 { 2639 UISoftKeyboardRow &row = m_numPadLayout.rows()[i]; 2640 for (int j = 0; j < row.keys().size(); ++j) 2641 { 2642 row.keys()[j].setKeyboardRegion(KeyboardRegion_NumPad); 2643 } 2644 } 2662 for (int i = 0; i < newPhysicalLayout->rows().size(); ++i) 2663 { 2664 UISoftKeyboardRow &row = newPhysicalLayout->rows()[i]; 2665 for (int j = 0; j < row.keys().size(); ++j) 2666 row.keys()[j].setKeyboardRegion(keyboardRegion); 2667 } 2668 2669 if (keyboardRegion == KeyboardRegion_NumPad || keyboardRegion == KeyboardRegion_MultimediaKeys) 2645 2670 return true; 2646 } 2671 2647 2672 /* Go thru all the keys row by row and construct their geometries: */ 2648 2673 int iY = m_iTopMargin; … … 2651 2676 const QVector<UISoftKeyboardRow> &numPadRows = m_numPadLayout.rows(); 2652 2677 QVector<UISoftKeyboardRow> &rows = newPhysicalLayout->rows(); 2653 int iKeyCount = 0; 2678 2679 /* Prepend the multimedia rows to the layout */ 2680 const QVector<UISoftKeyboardRow> &multimediaRows = m_multiMediaKeysLayout.rows(); 2681 for (int i = multimediaRows.size() - 1; i >= 0; --i) 2682 rows.prepend(multimediaRows[i]); 2683 2654 2684 for (int i = 0; i < rows.size(); ++i) 2655 2685 { 2656 2686 UISoftKeyboardRow &row = rows[i]; 2657 /* Start adding the numpad keys after the 0th row: */ 2658 if (i > 0) 2687 /* Insert the numpad rows at the end of keyboard rows starting with appending 0th numpad row to the 2688 end of (1 + multimediaRows.size())th layout row: */ 2689 if (i > multimediaRows.size()) 2659 2690 { 2660 int iNumPadRowIndex = i - 1;2661 if (iNumPadRowIndex < numPadRows.size())2691 int iNumPadRowIndex = i - (1 + multimediaRows.size()); 2692 if (iNumPadRowIndex >= 0 && iNumPadRowIndex < numPadRows.size()) 2662 2693 { 2663 2694 for (int m = 0; m < numPadRows[iNumPadRowIndex].keys().size(); ++m) … … 2671 2702 for (int j = 0; j < row.keys().size(); ++j) 2672 2703 { 2673 ++iKeyCount;2674 2704 UISoftKeyboardKey &key = (row.keys())[j]; 2675 2705 if (key.position() == iScrollLockPosition || … … 2777 2807 void UISoftKeyboardWidget::loadLayouts() 2778 2808 { 2779 /* Load physical layouts from resources: */ 2780 loadPhysicalLayout(":/numpad.xml", true); 2809 /* Load physical layouts from resources: Numpad and multimedia layout files should be read first 2810 since we insert these to other layouts: */ 2811 loadPhysicalLayout(":/numpad.xml", KeyboardRegion_NumPad); 2812 loadPhysicalLayout(":/multimedia_keys.xml", KeyboardRegion_MultimediaKeys); 2781 2813 QStringList physicalLayoutNames; 2782 2814 physicalLayoutNames << ":/101_ansi.xml" … … 3055 3087 { 3056 3088 if (m_xmlReader.readElementText() == "true") 3057 key.setKeyboardRegion(KeyboardRegion_OSMenu );3089 key.setKeyboardRegion(KeyboardRegion_OSMenuKeys); 3058 3090 } 3059 3091 else -
trunk/src/VBox/Frontends/VirtualBox/xml/multimedia_keys.xml
r81097 r81171 1 1 <?xml version="1.0"?> 2 <physicallayout defaultHeight=" 50" defaultWidth="50">3 <name> numpad</name>4 <id> 7ae32801-76c2-4aad-be0a-fd160eb50f26</id>2 <physicallayout defaultHeight="30" defaultWidth="50"> 3 <name>multimedia keys</name> 4 <id>80b4c26e-43fc-44f8-b515-351cff9269ce</id> 5 5 <row> 6 <key> 7 <position>90</position> 8 <usageid>0x53</usageid> 9 <usagepage>0x7</usagepage> 10 <type>lock</type> 11 <scancode>0x45</scancode> 6 <key><!-- WWW back --> 7 <position>300</position> 8 <usageid>0x2224</usageid> 9 <usagepage>0x0C</usagepage> 10 <scancode>0x20</scancode> 12 11 </key> 13 12 <key> 14 <position> 95</position>13 <position>301</position> 15 14 <usageid>0x54</usageid> 16 15 <usagepage>0x7</usagepage> … … 19 18 </key> 20 19 <key> 21 <position> 100</position>20 <position>302</position> 22 21 <usageid>0x55</usageid> 23 22 <usagepage>0x7</usagepage> 24 23 <scancode>0x37</scancode> 25 24 </key> 26 <key> 27 <position> 105</position>28 <usageid>0x 56</usageid>29 <usagepage>0x 7</usagepage>25 <key><!-- Mute --> 26 <position>303</position> 27 <usageid>0xE2</usageid> 28 <usagepage>0x0C</usagepage> 30 29 <scancode>0x4a</scancode> 31 30 </key> 32 31 </row> 33 <row>34 <key>35 <position>91</position>36 <usageid>0x5f</usageid>37 <usagepage>0x7</usagepage>38 <scancode>0x47</scancode>39 </key>40 <key>41 <position>96</position>42 <usageid>0x60</usageid>43 <usagepage>0x7</usagepage>44 <scancode>0x48</scancode>45 </key>46 <key>47 <position>101</position>48 <usageid>0x61</usageid>49 <usagepage>0x7</usagepage>50 <scancode>0x49</scancode>51 </key>52 <key>53 <position>106</position>54 <usageid>0x57</usageid>55 <usagepage>0x7</usagepage>56 <scancode>0x4e</scancode>57 <height>105</height>58 </key>59 </row>60 <row>61 <key>62 <position>92</position>63 <usageid>0x5c</usageid>64 <usagepage>0x7</usagepage>65 <scancode>0x4b</scancode>66 </key>67 <key>68 <position>97</position>69 <usageid>0x5d</usageid>70 <usagepage>0x7</usagepage>71 <scancode>0x4c</scancode>72 </key>73 <key>74 <position>102</position>75 <usageid>0x5e</usageid>76 <usagepage>0x7</usagepage>77 <scancode>0x4d</scancode>78 </key>79 </row>80 <row>81 <key>82 <position>93</position>83 <usageid>0x59</usageid>84 <usagepage>0x7</usagepage>85 <scancode>0x4f</scancode>86 </key>87 <key>88 <position>98</position>89 <usageid>0x5a</usageid>90 <usagepage>0x7</usagepage>91 <scancode>0x50</scancode>92 </key>93 <key>94 <position>103</position>95 <usageid>0x5b</usageid>96 <usagepage>0x7</usagepage>97 <scancode>0x51</scancode>98 </key>99 <key>100 <position>108</position>101 <usageid>0x58</usageid>102 <usagepage>0x7</usagepage>103 <scancode>0x1c</scancode>104 <scancodeprefix>0xe0</scancodeprefix>105 <height>105</height>106 </key>107 </row>108 <row>109 <key>110 <position>99</position>111 <usageid>0x62</usageid>112 <usagepage>0x7</usagepage>113 <scancode>0x52</scancode>114 <width>105</width>115 </key>116 <key>117 <position>104</position>118 <usageid>0x63</usageid>119 <usagepage>0x7</usagepage>120 <scancode>0x53</scancode>121 </key>122 </row>123 32 </physicallayout> -
trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml
r79722 r81171 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> 6 21 <key> 7 22 <position>110</position>
Note:
See TracChangeset
for help on using the changeset viewer.