Changeset 79314 in vbox
- Timestamp:
- Jun 24, 2019 4:55:42 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131532
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc
r79248 r79314 6 6 <file alias="german.xml">xml/german.xml</file> 7 7 <file alias="us.xml">xml/us.xml</file> 8 <file alias="numpad.xml">xml/numpad.xml</file> 8 9 </qresource> 9 10 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79295 r79314 115 115 QUuid m_uId; 116 116 117 const QVector<UISoftKeyboardRow> &rows() const 118 { 119 return m_rows; 120 } 121 122 QVector<UISoftKeyboardRow> &rows() 123 { 124 return m_rows; 125 } 126 127 private: 128 129 QString m_strName; 117 130 QVector<UISoftKeyboardRow> m_rows; 118 119 private:120 121 QString m_strName;122 131 }; 123 132 … … 466 475 void saveCurentLayoutToFile(); 467 476 void copyCurentLayout(); 477 float layoutAspectRation(); 468 478 469 479 protected: … … 490 500 void handleKeyPress(UISoftKeyboardKey *pKey); 491 501 void handleKeyRelease(UISoftKeyboardKey *pKey); 492 bool loadPhysicalLayout(const QString &strLayoutFileName );502 bool loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false); 493 503 bool loadKeyboardLayout(const QString &strLayoutName); 494 504 void reset(); … … 501 511 /** Looks under the default keyboard layout folder and add the file names to the fileList. */ 502 512 void lookAtDefaultLayoutFolder(QStringList &fileList); 513 503 514 UISoftKeyboardKey *m_pKeyUnderMouse; 504 515 UISoftKeyboardKey *m_pKeyBeingEdited; … … 512 523 QVector<UISoftKeyboardKey*> m_pressedModifiers; 513 524 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts; 525 UISoftKeyboardPhysicalLayout m_numPadLayout; 514 526 QVector<UISoftKeyboardLayout> m_layouts; 515 527 UISoftKeyboardLayout *m_pCurrentKeyboardLayout; … … 1530 1542 QSize UISoftKeyboardWidget::minimumSizeHint() const 1531 1543 { 1532 return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height()); 1544 float fScale = 0.5f; 1545 return QSize(fScale * m_minimumSize.width(), fScale * m_minimumSize.height()); 1533 1546 } 1534 1547 1535 1548 QSize UISoftKeyboardWidget::sizeHint() const 1536 1549 { 1537 return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height()); 1550 float fScale = 0.5f; 1551 return QSize(fScale * m_minimumSize.width(), fScale * m_minimumSize.height()); 1538 1552 } 1539 1553 … … 1541 1555 { 1542 1556 Q_UNUSED(pEvent); 1543 1544 1557 m_fScaleFactorX = width() / (float) m_iInitialWidth; 1545 1558 m_fScaleFactorY = height() / (float) m_iInitialHeight; … … 1563 1576 return; 1564 1577 1565 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout-> m_rows;1578 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows(); 1566 1579 for (int i = 0; i < rows.size(); ++i) 1567 1580 { … … 1711 1724 xmlWriter.writeTextElement("physicallayoutid", pPhysicalLayout->m_uId.toString()); 1712 1725 1713 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout-> m_rows;1726 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows(); 1714 1727 for (int i = 0; i < rows.size(); ++i) 1715 1728 { … … 1748 1761 } 1749 1762 1763 float UISoftKeyboardWidget::layoutAspectRation() 1764 { 1765 if (m_iInitialWidth == 0) 1766 return 1.f; 1767 return m_iInitialHeight / (float) m_iInitialWidth; 1768 } 1769 1750 1770 void UISoftKeyboardWidget::deleteCurrentLayout() 1751 1771 { … … 1860 1880 1861 1881 UISoftKeyboardKey *pKey = 0; 1862 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout-> m_rows;1882 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows(); 1863 1883 for (int i = 0; i < rows.size(); ++i) 1864 1884 { … … 1968 1988 } 1969 1989 1970 bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName )1990 bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad /* = false */) 1971 1991 { 1972 1992 if (strLayoutFileName.isEmpty()) 1973 1993 return false; 1974 1994 UIPhysicalLayoutReader reader; 1975 m_physicalLayouts.append(UISoftKeyboardPhysicalLayout()); 1976 UISoftKeyboardPhysicalLayout &newPhysicalLayout = m_physicalLayouts.back(); 1977 1978 if (!reader.parseXMLFile(strLayoutFileName, newPhysicalLayout)) 1995 UISoftKeyboardPhysicalLayout *newPhysicalLayout = 0; 1996 if (!isNumPad) 1997 { 1998 m_physicalLayouts.append(UISoftKeyboardPhysicalLayout()); 1999 newPhysicalLayout = &(m_physicalLayouts.back()); 2000 } 2001 else 2002 newPhysicalLayout = &(m_numPadLayout); 2003 2004 if (!reader.parseXMLFile(strLayoutFileName, *newPhysicalLayout)) 1979 2005 { 1980 2006 m_physicalLayouts.removeLast(); … … 1982 2008 } 1983 2009 2010 if (isNumPad) 2011 return true; 2012 1984 2013 int iY = m_iTopMargin; 1985 2014 int iMaxWidth = 0; 1986 QVector<UISoftKeyboardRow> &rows = newPhysicalLayout.m_rows; 2015 const QVector<UISoftKeyboardRow> &numPadRows = m_numPadLayout.rows(); 2016 QVector<UISoftKeyboardRow> &rows = newPhysicalLayout->rows(); 1987 2017 for (int i = 0; i < rows.size(); ++i) 1988 2018 { 1989 2019 UISoftKeyboardRow &row = rows[i]; 2020 /* Start adding the numpad keys after the 0th row: */ 2021 if (i > 0) 2022 { 2023 int iNumPadRowIndex = i - 1; 2024 if (iNumPadRowIndex < numPadRows.size()) 2025 { 2026 for (int m = 0; m < numPadRows[iNumPadRowIndex].keys().size(); ++m) 2027 row.keys().append(numPadRows[iNumPadRowIndex].keys()[m]); 2028 } 2029 } 2030 1990 2031 int iX = m_iLeftMargin; 1991 2032 int iRowHeight = row.defaultHeight(); … … 2011 2052 int iInitialWidth = iMaxWidth + m_iRightMargin; 2012 2053 int iInitialHeight = iY + m_iBottomMargin; 2013 2014 setNewMinimumSize(QSize(iInitialWidth, iInitialHeight)); 2015 setInitialSize(iInitialWidth, iInitialHeight); 2054 m_iInitialWidth = qMax(m_iInitialWidth, iInitialWidth); 2055 m_iInitialHeight = qMax(m_iInitialHeight, iInitialHeight); 2016 2056 return true; 2017 2057 } … … 2059 2099 { 2060 2100 /* Load physical layouts from resources: */ 2101 loadPhysicalLayout(":/numpad.xml", true); 2061 2102 QStringList physicalLayoutNames; 2062 2103 physicalLayoutNames << ":/101_ansi.xml" << ":/102_iso.xml"; 2063 2104 foreach (const QString &strName, physicalLayoutNames) 2064 2105 loadPhysicalLayout(strName); 2106 2107 setNewMinimumSize(QSize(m_iInitialWidth, m_iInitialHeight)); 2108 setInitialSize(m_iInitialWidth, m_iInitialHeight); 2065 2109 2066 2110 /* Add keyboard layouts from resources: */ … … 2134 2178 2135 2179 /* Update the key captions: */ 2136 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout-> m_rows;2180 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows(); 2137 2181 for (int i = 0; i < rows.size(); ++i) 2138 2182 { … … 2212 2256 int iDefaultWidth = attributes.value("defaultWidth").toInt(); 2213 2257 int iDefaultHeight = attributes.value("defaultHeight").toInt(); 2214 QVector<UISoftKeyboardRow> &rows = physicalLayout.m_rows; 2258 QVector<UISoftKeyboardRow> &rows = physicalLayout.rows(); 2259 int iRowCount = 0; 2215 2260 while (m_xmlReader.readNextStartElement()) 2216 2261 { 2217 2262 if (m_xmlReader.name() == "row") 2263 { 2218 2264 parseRow(iDefaultWidth, iDefaultHeight, rows); 2265 ++iRowCount; 2266 } 2219 2267 else if (m_xmlReader.name() == "space") 2220 2268 parseRowSpace(rows); … … 2766 2814 void UISoftKeyboard::loadSettings() 2767 2815 { 2816 float fKeyboardAspectRatio = 1.0f; 2817 if (m_pKeyboardWidget) 2818 fKeyboardAspectRatio = m_pKeyboardWidget->layoutAspectRation(); 2819 2768 2820 const QRect desktopRect = gpDesktop->availableGeometry(this); 2769 2821 int iDefaultWidth = desktopRect.width() / 2; 2770 int iDefaultHeight = desktopRect.height() * 3 / 4;2822 int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio;//desktopRect.height() * 3 / 4; 2771 2823 QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight); 2772 2824 -
trunk/src/VBox/Frontends/VirtualBox/xml/101_ansi.xml
r79121 r79314 146 146 <key> 147 147 <width>110</width> 148 149 148 <position>15</position> 150 149 <scancode>0x0e</scancode> … … 168 167 <scancode>0x49</scancode> 169 168 </key> 170 </row> 171 <row> 172 <key> 173 <width>75</width> 174 169 <space> 170 <width>25</width> 171 </space> 172 </row> 173 <row> 174 <key> 175 <width>75</width> 175 176 <position>16</position> 176 177 <scancode>0x0f</scancode> … … 247 248 <scancodeprefix>0xe0</scancodeprefix> 248 249 </key> 250 <space> 251 <width>25</width> 252 </space> 249 253 </row> 250 254 <row> … … 306 310 <scancode>0x1c</scancode> 307 311 </key> 312 <space> 313 <width>220</width> 314 </space> 308 315 </row> 309 316 <row> … … 371 378 <scancode>0x48</scancode> 372 379 </key> 380 <space> 381 <width>80</width> 382 </space> 373 383 </row> 374 384 <row> … … 448 458 <scancode>0x4d</scancode> 449 459 </key> 450 451 452 </row>453 460 <space> 461 <width>25</width> 462 </space> 463 </row> 454 464 </physicallayout> -
trunk/src/VBox/Frontends/VirtualBox/xml/102_iso.xml
r79121 r79314 164 164 <scancode>0x49</scancode> 165 165 </key> 166 <space> 167 <width>25</width> 168 </space> 166 169 </row> 167 170 <row> … … 223 226 <width>85</width> 224 227 <height>105</height> 225 226 228 <position>43</position> 227 229 <scancode>0x1c</scancode> … … 250 252 <scancodeprefix>0xe0</scancodeprefix> 251 253 </key> 254 <space> 255 <width>25</width> 256 </space> 252 257 </row> 253 258 <row> … … 307 312 <scancode>0xff</scancode> 308 313 </key> 314 <space> 315 <width>285</width> 316 </space> 309 317 </row> 310 318 <row> … … 376 384 <scancode>0x48</scancode> 377 385 </key> 386 <space> 387 <width>80</width> 388 </space> 378 389 </row> 379 390 <row> … … 453 464 <scancode>0x4d</scancode> 454 465 </key> 466 <space> 467 <width>25</width> 468 </space> 455 469 </row> 456 470 </physicallayout>
Note:
See TracChangeset
for help on using the changeset viewer.