Changeset 81208 in vbox
- Timestamp:
- Oct 10, 2019 11:16:51 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r81171 r81208 107 107 }; 108 108 109 struct KeyCaptions 110 { 109 struct UIKeyCaptions 110 { 111 UIKeyCaptions(const QString &strBase, const QString &strShift, 112 const QString &strAltGr, const QString &strShiftAltGr) 113 : m_strBase(strBase) 114 , m_strShift(strShift) 115 , m_strAltGr(strAltGr) 116 , m_strShiftAltGr(strShiftAltGr) 117 { 118 m_strBase.replace("\\n", "\n"); 119 m_strShift.replace("\\n", "\n"); 120 m_strAltGr.replace("\\n", "\n"); 121 m_strShiftAltGr.replace("\\n", "\n"); 122 } 123 UIKeyCaptions(){} 124 bool operator==(const UIKeyCaptions &other) const 125 { 126 return (m_strBase == other.m_strBase && 127 m_strShift == other.m_strShift && 128 m_strAltGr == other.m_strAltGr && 129 m_strShiftAltGr == other.m_strShiftAltGr); 130 } 111 131 QString m_strBase; 112 132 QString m_strShift; … … 175 195 176 196 void sigLayoutEdited(); 177 void sig KeyCaptionsEdited(UISoftKeyboardKey* pKey);197 void sigUIKeyCaptionsEdited(UISoftKeyboardKey* pKey); 178 198 void sigGoBackButton(); 179 199 … … 192 212 private slots: 193 213 194 void sltKeyBaseCaptionChange(const QString &strCaption); 195 void sltKeyShiftCaptionChange(const QString &strCaption); 196 void sltKeyAltGrCaptionChange(const QString &strCaption); 197 void sltKeyShiftAltGrCaptionChange(const QString &strCaption); 214 void sltCaptionsUpdate(); 198 215 void sltPhysicalLayoutChanged(); 199 216 void sltLayoutNameChanged(const QString &strCaption); … … 327 344 /** UISoftKeyboardKey is a place holder for a keyboard key. Graphical key represantations are drawn according to this class. 328 345 * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey does not have 329 * caption field(s). */ 346 * caption field(s). Captions are kept by UISoftKeyboardLayout since same keys may (and usually do) have different captions in 347 * different layouts. */ 330 348 class UISoftKeyboardKey 331 349 { … … 450 468 bool isFromResources() const; 451 469 452 void update KeyCaptions(int iKeyPosition,KeyCaptions &newCaptions);470 void updateUIKeyCaptions(int iKeyPosition, UIKeyCaptions &newCaptions); 453 471 454 472 void setEditable(bool fEditable); … … 458 476 const QUuid &physicalLayoutUuid() const; 459 477 460 void setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap); 461 QMap<int, KeyCaptions> &keyCapMap(); 462 const QMap<int, KeyCaptions> &keyCapMap() const; 478 void setKeyCapMap(const QMap<int, UIKeyCaptions> &keyCaptionsMap); 479 void addOrUpdateUIKeyCaptions(int iKeyPosition, const UIKeyCaptions &keyCaptions); 480 UIKeyCaptions keyCaptions(int iKeyPosition); 481 463 482 bool operator==(const UISoftKeyboardLayout &otherLayout); 464 483 465 const QString baseCaption(int iKeyPosition) const; 466 void setBaseCaption(int iKeyPosition, const QString &strBaseCaption); 467 468 const QString shiftCaption(int iKeyPosition) const; 469 void setShiftCaption(int iKeyPosition, const QString &strShiftCaption); 470 471 const QString altGrCaption(int iKeyPosition) const; 472 void setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption); 473 474 const QString shiftAltGrCaption(int iKeyPosition) const; 475 void setShiftAltGrCaption(int iKeyPosition, const QString &strAltGrCaption); 476 477 const KeyCaptions keyCaptions(int iKeyPosition) const; 484 QString baseCaption(int iKeyPosition) const; 485 QString shiftCaption(int iKeyPosition) const; 486 QString altGrCaption(int iKeyPosition) const; 487 QString shiftAltGrCaption(int iKeyPosition) const; 478 488 479 489 void setUid(const QUuid &uid); … … 485 495 private: 486 496 487 QMap<int, KeyCaptions> m_keyCapMap;488 QMap<int, QPicture> m_pictureMap;489 497 QMap<int, UIKeyCaptions> m_keyCaptionsMap; 498 /** Caching the font sizes we used for font rendering since it is not a very cheap process to compute these. */ 499 QMap<int, int> m_keyCaptionsFontSizeMap; 490 500 /** The UUID of the physical layout used by this layout. */ 491 501 QUuid m_physicalLayoutUuid; … … 693 703 private: 694 704 695 void parseKey( QMap<int, KeyCaptions> &keyCapMap);705 void parseKey(UISoftKeyboardLayout &layout); 696 706 QXmlStreamReader m_xmlReader; 697 707 /** Map key is the key position and the value is the captions of the key. */ … … 897 907 if (m_pKey) 898 908 { 899 KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position()); 900 if (captions.m_strBase != m_pBaseCaptionEdit->text()) 901 m_pLayout->setBaseCaption(m_pKey->position(), m_pBaseCaptionEdit->text()); 902 if (captions.m_strShift != m_pShiftCaptionEdit->text()) 903 m_pLayout->setShiftCaption(m_pKey->position(), m_pShiftCaptionEdit->text()); 904 if (captions.m_strAltGr != m_pAltGrCaptionEdit->text()) 905 m_pLayout->setAltGrCaption(m_pKey->position(), m_pAltGrCaptionEdit->text()); 906 if (captions.m_strShiftAltGr != m_pShiftAltGrCaptionEdit->text()) 907 m_pLayout->setShiftAltGrCaption(m_pKey->position(), m_pShiftAltGrCaptionEdit->text()); 909 UIKeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position()); 910 if (captions.m_strBase != m_pBaseCaptionEdit->text() || 911 captions.m_strShift != m_pShiftCaptionEdit->text() || 912 captions.m_strAltGr != m_pAltGrCaptionEdit->text() || 913 captions.m_strShiftAltGr != m_pShiftAltGrCaptionEdit->text()) 914 m_pLayout->addOrUpdateUIKeyCaptions(m_pKey->position(), 915 UIKeyCaptions(m_pBaseCaptionEdit->text(), 916 m_pShiftCaptionEdit->text(), 917 m_pAltGrCaptionEdit->text(), 918 m_pShiftAltGrCaptionEdit->text())); 908 919 } 909 920 m_pKey = pKey; … … 919 930 if (m_pPositionEdit) 920 931 m_pPositionEdit->setText(QString::number(m_pKey->position())); 921 KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position());932 UIKeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position()); 922 933 if (m_pBaseCaptionEdit) 923 934 m_pBaseCaptionEdit->setText(captions.m_strBase); … … 1005 1016 } 1006 1017 1007 void UIKeyboardLayoutEditor::slt KeyBaseCaptionChange(const QString &strCaption)1018 void UIKeyboardLayoutEditor::sltCaptionsUpdate() 1008 1019 { 1009 1020 if (!m_pKey || !m_pLayout) 1010 1021 return; 1011 if (m_pLayout->baseCaption(m_pKey->position()) == strCaption) 1012 return; 1013 m_pLayout->setBaseCaption(m_pKey->position(), strCaption); 1014 emit sigKeyCaptionsEdited(m_pKey); 1015 } 1016 1017 void UIKeyboardLayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption) 1018 { 1019 if (!m_pKey || !m_pLayout) 1020 return; 1021 if (m_pLayout->shiftCaption(m_pKey->position()) == strCaption) 1022 return; 1023 m_pLayout->setShiftCaption(m_pKey->position(), strCaption); 1024 emit sigKeyCaptionsEdited(m_pKey); 1025 } 1026 1027 void UIKeyboardLayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption) 1028 { 1029 if (!m_pKey || !m_pLayout) 1030 return; 1031 if (m_pLayout->altGrCaption(m_pKey->position()) == strCaption) 1032 return; 1033 m_pLayout->setAltGrCaption(m_pKey->position(), strCaption); 1034 emit sigKeyCaptionsEdited(m_pKey); 1035 } 1036 1037 void UIKeyboardLayoutEditor::sltKeyShiftAltGrCaptionChange(const QString &strCaption) 1038 { 1039 if (!m_pKey || !m_pLayout) 1040 return; 1041 if (m_pLayout->shiftAltGrCaption(m_pKey->position()) == strCaption) 1042 return; 1043 m_pLayout->setShiftAltGrCaption(m_pKey->position(), strCaption); 1044 emit sigKeyCaptionsEdited(m_pKey); 1022 m_pLayout->addOrUpdateUIKeyCaptions(m_pKey->position(), 1023 UIKeyCaptions(m_pBaseCaptionEdit->text(), 1024 m_pShiftCaptionEdit->text(), 1025 m_pAltGrCaptionEdit->text(), 1026 m_pShiftAltGrCaptionEdit->text())); 1027 emit sigUIKeyCaptionsEdited(m_pKey); 1045 1028 } 1046 1029 … … 1166 1149 pCaptionEditorLayout->addWidget(m_pBaseCaptionLabel, 0, 0); 1167 1150 pCaptionEditorLayout->addWidget(m_pBaseCaptionEdit, 0, 1); 1168 connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::slt KeyBaseCaptionChange);1151 connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate); 1169 1152 1170 1153 m_pShiftCaptionLabel = new QLabel; … … 1173 1156 pCaptionEditorLayout->addWidget(m_pShiftCaptionLabel, 1, 0); 1174 1157 pCaptionEditorLayout->addWidget(m_pShiftCaptionEdit, 1, 1); 1175 connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::slt KeyShiftCaptionChange);1158 connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate); 1176 1159 1177 1160 m_pAltGrCaptionLabel = new QLabel; … … 1180 1163 pCaptionEditorLayout->addWidget(m_pAltGrCaptionLabel, 2, 0); 1181 1164 pCaptionEditorLayout->addWidget(m_pAltGrCaptionEdit, 2, 1); 1182 connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::slt KeyAltGrCaptionChange);1165 connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate); 1183 1166 1184 1167 m_pShiftAltGrCaptionLabel = new QLabel; … … 1187 1170 pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionLabel, 3, 0); 1188 1171 pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionEdit, 3, 1); 1189 connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::slt KeyShiftAltGrCaptionChange);1172 connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate); 1190 1173 1191 1174 … … 1685 1668 } 1686 1669 1687 void UISoftKeyboardLayout::update KeyCaptions(int iKeyPosition,KeyCaptions &newCaptions)1688 { 1689 if (!m_keyCap Map.contains(iKeyPosition))1690 return; 1691 m_keyCap Map[iKeyPosition] = newCaptions;1670 void UISoftKeyboardLayout::updateUIKeyCaptions(int iKeyPosition, UIKeyCaptions &newCaptions) 1671 { 1672 if (!m_keyCaptionsMap.contains(iKeyPosition)) 1673 return; 1674 m_keyCaptionsMap[iKeyPosition] = newCaptions; 1692 1675 } 1693 1676 … … 1764 1747 } 1765 1748 1766 void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap) 1767 { 1768 m_keyCapMap = keyCapMap; 1769 } 1770 1771 QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() 1772 { 1773 return m_keyCapMap; 1774 } 1775 1776 const QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() const 1777 { 1778 return m_keyCapMap; 1749 void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, UIKeyCaptions> &keyCaptionsMap) 1750 { 1751 m_keyCaptionsMap = keyCaptionsMap; 1752 } 1753 1754 void UISoftKeyboardLayout::addOrUpdateUIKeyCaptions(int iKeyPosition, const UIKeyCaptions &keyCaptions) 1755 { 1756 if (m_keyCaptionsMap[iKeyPosition] == keyCaptions) 1757 return; 1758 m_keyCaptionsMap[iKeyPosition] = keyCaptions; 1759 /* Updating the captions invalidates the cached font size. We set it to 0, thereby forcing its recomputaion: */ 1760 m_keyCaptionsFontSizeMap[iKeyPosition] = 0; 1761 } 1762 1763 UIKeyCaptions UISoftKeyboardLayout::keyCaptions(int iKeyPosition) 1764 { 1765 return m_keyCaptionsMap[iKeyPosition]; 1779 1766 } 1780 1767 … … 1796 1783 } 1797 1784 1798 const QString UISoftKeyboardLayout::baseCaption(int iKeyPosition) const 1799 { 1800 return m_keyCapMap.value(iKeyPosition, KeyCaptions()).m_strBase; 1801 } 1802 1803 void UISoftKeyboardLayout::setBaseCaption(int iKeyPosition, const QString &strBaseCaption) 1804 { 1805 m_keyCapMap[iKeyPosition].m_strBase = strBaseCaption; 1806 m_keyCapMap[iKeyPosition].m_strBase.replace("\\n", "\n"); 1807 } 1808 1809 const QString UISoftKeyboardLayout::shiftCaption(int iKeyPosition) const 1810 { 1811 if (!m_keyCapMap.contains(iKeyPosition)) 1785 QString UISoftKeyboardLayout::baseCaption(int iKeyPosition) const 1786 { 1787 return m_keyCaptionsMap.value(iKeyPosition, UIKeyCaptions()).m_strBase; 1788 } 1789 1790 QString UISoftKeyboardLayout::shiftCaption(int iKeyPosition) const 1791 { 1792 if (!m_keyCaptionsMap.contains(iKeyPosition)) 1812 1793 return QString(); 1813 return m_keyCapMap[iKeyPosition].m_strShift; 1814 } 1815 1816 void UISoftKeyboardLayout::setShiftCaption(int iKeyPosition, const QString &strShiftCaption) 1817 { 1818 m_keyCapMap[iKeyPosition].m_strShift = strShiftCaption; 1819 m_keyCapMap[iKeyPosition].m_strShift.replace("\\n", "\n"); 1820 } 1821 1822 const QString UISoftKeyboardLayout::altGrCaption(int iKeyPosition) const 1823 { 1824 if (!m_keyCapMap.contains(iKeyPosition)) 1794 return m_keyCaptionsMap[iKeyPosition].m_strShift; 1795 } 1796 1797 QString UISoftKeyboardLayout::altGrCaption(int iKeyPosition) const 1798 { 1799 if (!m_keyCaptionsMap.contains(iKeyPosition)) 1825 1800 return QString(); 1826 return m_keyCapMap[iKeyPosition].m_strAltGr; 1827 } 1828 1829 void UISoftKeyboardLayout::setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption) 1830 { 1831 m_keyCapMap[iKeyPosition].m_strAltGr = strAltGrCaption; 1832 m_keyCapMap[iKeyPosition].m_strAltGr.replace("\\n", "\n"); 1833 } 1834 1835 const QString UISoftKeyboardLayout::shiftAltGrCaption(int iKeyPosition) const 1836 { 1837 if (!m_keyCapMap.contains(iKeyPosition)) 1801 return m_keyCaptionsMap[iKeyPosition].m_strAltGr; 1802 } 1803 1804 QString UISoftKeyboardLayout::shiftAltGrCaption(int iKeyPosition) const 1805 { 1806 if (!m_keyCaptionsMap.contains(iKeyPosition)) 1838 1807 return QString(); 1839 return m_keyCapMap[iKeyPosition].m_strShiftAltGr; 1840 } 1841 1842 void UISoftKeyboardLayout::setShiftAltGrCaption(int iKeyPosition, const QString &strShiftAltGrCaption) 1843 { 1844 m_keyCapMap[iKeyPosition].m_strShiftAltGr = strShiftAltGrCaption; 1845 m_keyCapMap[iKeyPosition].m_strShiftAltGr.replace("\\n", "\n"); 1846 } 1847 1848 const KeyCaptions UISoftKeyboardLayout::keyCaptions(int iKeyPosition) const 1849 { 1850 if (!m_keyCapMap.contains(iKeyPosition)) 1851 return KeyCaptions(); 1852 return m_keyCapMap[iKeyPosition]; 1808 return m_keyCaptionsMap[iKeyPosition].m_strShiftAltGr; 1853 1809 } 1854 1810 … … 1865 1821 void UISoftKeyboardLayout::drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter) 1866 1822 { 1867 int iKeyPosition = key.position(); 1868 const QRect &keyGeometry = key.keyGeometry(); 1869 QFont painterFont(painter.font()); 1870 int iFontSize = 30; 1871 1872 const QString &strBaseCaption = baseCaption(iKeyPosition); 1873 const QString &strShiftCaption = shiftCaption(iKeyPosition); 1874 1875 const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition); 1876 const QString &strAltGrCaption = altGrCaption(iKeyPosition); 1877 1878 const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption; 1879 const QString &strBottomleftString = !strShiftCaption.isEmpty() ? strBaseCaption : QString(); 1880 1881 do 1882 { 1883 painterFont.setPixelSize(iFontSize); 1884 painterFont.setBold(true); 1885 painter.setFont(painterFont); 1886 QFontMetrics fontMetrics = painter.fontMetrics(); 1887 int iMargin = 0.25 * fontMetrics.width('X'); 1888 1889 int iTopWidth = 0; 1890 1891 QStringList strList; 1892 strList << strTopleftString.split("\n", QString::SkipEmptyParts) 1893 << strShiftAltGrCaption.split("\n", QString::SkipEmptyParts); 1894 foreach (const QString &strPart, strList) 1895 iTopWidth = qMax(iTopWidth, fontMetrics.width(strPart)); 1896 strList.clear(); 1897 strList << strBottomleftString.split("\n", QString::SkipEmptyParts) 1898 << strAltGrCaption.split("\n", QString::SkipEmptyParts); 1899 1900 int iBottomWidth = 0; 1901 foreach (const QString &strPart, strList) 1902 iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart)); 1903 int iTextWidth = 2 * iMargin + qMax(iTopWidth, iBottomWidth); 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(); 1910 1911 if (iTextWidth >= keyGeometry.width() || iTextHeight >= keyGeometry.height()) 1912 --iFontSize; 1913 else 1914 break; 1915 1916 }while(iFontSize > 1); 1917 1918 1919 QFontMetrics fontMetrics = painter.fontMetrics(); 1920 int iMargin = 0.25 * fontMetrics.width('X'); 1921 #if 0 1922 painter.drawText(iMargin, iMargin + fontMetrics.height(), QString::number(iKeyPosition)); 1923 #else 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); 1933 1934 painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString); 1935 painter.drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, strBottomleftString); 1936 painter.drawText(textRect, Qt::AlignRight | Qt::AlignTop, strShiftAltGrCaption); 1937 painter.drawText(textRect, Qt::AlignRight | Qt::AlignBottom, strAltGrCaption); 1938 1939 #endif 1823 int iKeyPosition = key.position(); 1824 const QRect &keyGeometry = key.keyGeometry(); 1825 QFont painterFont(painter.font()); 1826 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); 1832 1833 const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption; 1834 const QString &strBottomleftString = !strShiftCaption.isEmpty() ? strBaseCaption : QString(); 1835 1836 int iFontSize = 30; 1837 if (!m_keyCaptionsFontSizeMap.contains(iKeyPosition) || m_keyCaptionsFontSizeMap.value(iKeyPosition) == 0) 1838 { 1839 do 1840 { 1841 painterFont.setPixelSize(iFontSize); 1842 painterFont.setBold(true); 1843 painter.setFont(painterFont); 1844 QFontMetrics fontMetrics = painter.fontMetrics(); 1845 int iMargin = 0.25 * fontMetrics.width('X'); 1846 1847 int iTopWidth = 0; 1848 /* Some captions are multi line using \n as separator: */ 1849 QStringList strList; 1850 strList << strTopleftString.split("\n", QString::SkipEmptyParts) 1851 << strShiftAltGrCaption.split("\n", QString::SkipEmptyParts); 1852 foreach (const QString &strPart, strList) 1853 iTopWidth = qMax(iTopWidth, fontMetrics.width(strPart)); 1854 strList.clear(); 1855 strList << strBottomleftString.split("\n", QString::SkipEmptyParts) 1856 << strAltGrCaption.split("\n", QString::SkipEmptyParts); 1857 1858 int iBottomWidth = 0; 1859 foreach (const QString &strPart, strList) 1860 iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart)); 1861 int iTextWidth = 2 * iMargin + qMax(iTopWidth, iBottomWidth); 1862 int iTextHeight = 0; 1863 1864 if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys) 1865 iTextHeight = 2 * iMargin + fontMetrics.height(); 1866 else 1867 iTextHeight = 2 * iMargin + 2 * fontMetrics.height(); 1868 1869 if (iTextWidth >= keyGeometry.width() || iTextHeight >= keyGeometry.height()) 1870 --iFontSize; 1871 else 1872 break; 1873 1874 }while(iFontSize > 1); 1875 m_keyCaptionsFontSizeMap[iKeyPosition] = iFontSize; 1876 } 1877 else 1878 { 1879 iFontSize = m_keyCaptionsFontSizeMap[iKeyPosition]; 1880 painterFont.setPixelSize(iFontSize); 1881 painterFont.setBold(true); 1882 painter.setFont(painterFont); 1883 } 1884 1885 QFontMetrics fontMetrics = painter.fontMetrics(); 1886 int iMargin = 0.25 * fontMetrics.width('X'); 1887 QRect textRect; 1888 if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys) 1889 textRect = QRect(2 * iMargin, iMargin, 1890 keyGeometry.width() - 2 * iMargin, 1891 keyGeometry.height() - 2 * iMargin); 1892 else 1893 textRect = QRect(iMargin, iMargin, 1894 keyGeometry.width() - 2 * iMargin, 1895 keyGeometry.height() - 2 * iMargin); 1896 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); 1940 1901 } 1941 1902 … … 3213 3174 { 3214 3175 if (m_xmlReader.name() == "key") 3215 parseKey(layout .keyCapMap());3176 parseKey(layout); 3216 3177 else if (m_xmlReader.name() == "name") 3217 3178 layout.setName(m_xmlReader.readElementText()); … … 3228 3189 } 3229 3190 3230 void UIKeyboardLayoutReader::parseKey( QMap<int, KeyCaptions> &keyCapMap)3231 { 3232 KeyCaptions keyCaptions;3191 void UIKeyboardLayoutReader::parseKey(UISoftKeyboardLayout &layout) 3192 { 3193 UIKeyCaptions keyCaptions; 3233 3194 int iKeyPosition = 0; 3234 3195 while (m_xmlReader.readNextStartElement()) … … 3259 3220 m_xmlReader.skipCurrentElement(); 3260 3221 } 3261 keyCapMap.insert(iKeyPosition, keyCaptions);3222 layout.addOrUpdateUIKeyCaptions(iKeyPosition, keyCaptions); 3262 3223 } 3263 3224 … … 3787 3748 connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector); 3788 3749 connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited); 3789 connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sig KeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);3750 connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigUIKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited); 3790 3751 3791 3752 connect(m_pStatusBarWidget, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel, this, &UISoftKeyboard::sltShowHideSidePanel);
Note:
See TracChangeset
for help on using the changeset viewer.