VirtualBox

Changeset 79314 in vbox


Ignore:
Timestamp:
Jun 24, 2019 4:55:42 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131532
Message:

FE/Qt: bugref:6143. adding the numpad

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc

    r79248 r79314  
    66        <file alias="german.xml">xml/german.xml</file>
    77        <file alias="us.xml">xml/us.xml</file>
     8        <file alias="numpad.xml">xml/numpad.xml</file>       
    89    </qresource>
    910</RCC>
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79295 r79314  
    115115    QUuid    m_uId;
    116116
     117    const QVector<UISoftKeyboardRow> &rows() const
     118    {
     119        return m_rows;
     120    }
     121
     122    QVector<UISoftKeyboardRow> &rows()
     123    {
     124        return m_rows;
     125    }
     126
     127private:
     128
     129    QString  m_strName;
    117130    QVector<UISoftKeyboardRow>  m_rows;
    118 
    119 private:
    120 
    121     QString  m_strName;
    122131};
    123132
     
    466475    void saveCurentLayoutToFile();
    467476    void copyCurentLayout();
     477    float layoutAspectRation();
    468478
    469479protected:
     
    490500    void               handleKeyPress(UISoftKeyboardKey *pKey);
    491501    void               handleKeyRelease(UISoftKeyboardKey *pKey);
    492     bool               loadPhysicalLayout(const QString &strLayoutFileName);
     502    bool               loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false);
    493503    bool               loadKeyboardLayout(const QString &strLayoutName);
    494504    void               reset();
     
    501511    /** Looks under the default keyboard layout folder and add the file names to the fileList. */
    502512    void               lookAtDefaultLayoutFolder(QStringList &fileList);
     513
    503514    UISoftKeyboardKey *m_pKeyUnderMouse;
    504515    UISoftKeyboardKey *m_pKeyBeingEdited;
     
    512523    QVector<UISoftKeyboardKey*> m_pressedModifiers;
    513524    QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts;
     525    UISoftKeyboardPhysicalLayout          m_numPadLayout;
    514526    QVector<UISoftKeyboardLayout>         m_layouts;
    515527    UISoftKeyboardLayout *m_pCurrentKeyboardLayout;
     
    15301542QSize UISoftKeyboardWidget::minimumSizeHint() const
    15311543{
    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());
    15331546}
    15341547
    15351548QSize UISoftKeyboardWidget::sizeHint() const
    15361549{
    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());
    15381552}
    15391553
     
    15411555{
    15421556    Q_UNUSED(pEvent);
    1543 
    15441557    m_fScaleFactorX = width() / (float) m_iInitialWidth;
    15451558    m_fScaleFactorY = height() / (float) m_iInitialHeight;
     
    15631576        return;
    15641577
    1565     QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
     1578    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows();
    15661579    for (int i = 0; i < rows.size(); ++i)
    15671580    {
     
    17111724    xmlWriter.writeTextElement("physicallayoutid", pPhysicalLayout->m_uId.toString());
    17121725
    1713     QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
     1726    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows();
    17141727    for (int i = 0; i < rows.size(); ++i)
    17151728    {
     
    17481761}
    17491762
     1763float UISoftKeyboardWidget::layoutAspectRation()
     1764{
     1765    if (m_iInitialWidth == 0)
     1766        return 1.f;
     1767    return  m_iInitialHeight / (float) m_iInitialWidth;
     1768}
     1769
    17501770void UISoftKeyboardWidget::deleteCurrentLayout()
    17511771{
     
    18601880
    18611881    UISoftKeyboardKey *pKey = 0;
    1862     QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
     1882    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows();
    18631883    for (int i = 0; i < rows.size(); ++i)
    18641884    {
     
    19681988}
    19691989
    1970 bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName)
     1990bool UISoftKeyboardWidget::loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad /* = false */)
    19711991{
    19721992    if (strLayoutFileName.isEmpty())
    19731993        return false;
    19741994    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))
    19792005    {
    19802006        m_physicalLayouts.removeLast();
     
    19822008    }
    19832009
     2010    if (isNumPad)
     2011        return true;
     2012
    19842013    int iY = m_iTopMargin;
    19852014    int iMaxWidth = 0;
    1986     QVector<UISoftKeyboardRow> &rows = newPhysicalLayout.m_rows;
     2015    const QVector<UISoftKeyboardRow> &numPadRows = m_numPadLayout.rows();
     2016    QVector<UISoftKeyboardRow> &rows = newPhysicalLayout->rows();
    19872017    for (int i = 0; i < rows.size(); ++i)
    19882018    {
    19892019        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
    19902031        int iX = m_iLeftMargin;
    19912032        int iRowHeight = row.defaultHeight();
     
    20112052    int iInitialWidth = iMaxWidth + m_iRightMargin;
    20122053    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);
    20162056    return true;
    20172057}
     
    20592099{
    20602100    /* Load physical layouts from resources: */
     2101    loadPhysicalLayout(":/numpad.xml", true);
    20612102    QStringList physicalLayoutNames;
    20622103    physicalLayoutNames << ":/101_ansi.xml" << ":/102_iso.xml";
    20632104    foreach (const QString &strName, physicalLayoutNames)
    20642105        loadPhysicalLayout(strName);
     2106
     2107    setNewMinimumSize(QSize(m_iInitialWidth, m_iInitialHeight));
     2108    setInitialSize(m_iInitialWidth, m_iInitialHeight);
    20652109
    20662110    /* Add keyboard layouts from resources: */
     
    21342178
    21352179    /* Update the key captions: */
    2136     QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows;
     2180    QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows();
    21372181    for (int i = 0; i < rows.size(); ++i)
    21382182    {
     
    22122256    int iDefaultWidth = attributes.value("defaultWidth").toInt();
    22132257    int iDefaultHeight = attributes.value("defaultHeight").toInt();
    2214     QVector<UISoftKeyboardRow> &rows = physicalLayout.m_rows;
     2258    QVector<UISoftKeyboardRow> &rows = physicalLayout.rows();
     2259    int iRowCount = 0;
    22152260    while (m_xmlReader.readNextStartElement())
    22162261    {
    22172262        if (m_xmlReader.name() == "row")
     2263        {
    22182264            parseRow(iDefaultWidth, iDefaultHeight, rows);
     2265            ++iRowCount;
     2266        }
    22192267        else if (m_xmlReader.name() == "space")
    22202268            parseRowSpace(rows);
     
    27662814void UISoftKeyboard::loadSettings()
    27672815{
     2816    float fKeyboardAspectRatio = 1.0f;
     2817    if (m_pKeyboardWidget)
     2818        fKeyboardAspectRatio = m_pKeyboardWidget->layoutAspectRation();
     2819
    27682820    const QRect desktopRect = gpDesktop->availableGeometry(this);
    27692821    int iDefaultWidth = desktopRect.width() / 2;
    2770     int iDefaultHeight = desktopRect.height() * 3 / 4;
     2822    int iDefaultHeight = iDefaultWidth * fKeyboardAspectRatio;//desktopRect.height() * 3 / 4;
    27712823    QRect defaultGeometry(0, 0, iDefaultWidth, iDefaultHeight);
    27722824
  • trunk/src/VBox/Frontends/VirtualBox/xml/101_ansi.xml

    r79121 r79314  
    146146        <key>
    147147            <width>110</width>
    148 
    149148            <position>15</position>
    150149            <scancode>0x0e</scancode>
     
    168167            <scancode>0x49</scancode>
    169168        </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>
    175176            <position>16</position>
    176177            <scancode>0x0f</scancode>
     
    247248            <scancodeprefix>0xe0</scancodeprefix>
    248249        </key>
     250        <space>
     251            <width>25</width>
     252        </space>
    249253    </row>
    250254    <row>
     
    306310            <scancode>0x1c</scancode>
    307311        </key>
     312        <space>
     313            <width>220</width>
     314        </space>
    308315    </row>
    309316    <row>
     
    371378            <scancode>0x48</scancode>
    372379        </key>
     380        <space>
     381            <width>80</width>
     382        </space>
    373383    </row>
    374384    <row>
     
    448458            <scancode>0x4d</scancode>
    449459        </key>
    450 
    451 
    452     </row>
    453 
     460        <space>
     461            <width>25</width>
     462        </space>
     463    </row>
    454464</physicallayout>
  • trunk/src/VBox/Frontends/VirtualBox/xml/102_iso.xml

    r79121 r79314  
    164164            <scancode>0x49</scancode>
    165165        </key>
     166        <space>
     167            <width>25</width>
     168        </space>
    166169    </row>
    167170    <row>
     
    223226            <width>85</width>
    224227            <height>105</height>
    225 
    226228            <position>43</position>
    227229            <scancode>0x1c</scancode>
     
    250252            <scancodeprefix>0xe0</scancodeprefix>
    251253        </key>
     254        <space>
     255            <width>25</width>
     256        </space>
    252257    </row>
    253258    <row>
     
    307312            <scancode>0xff</scancode>
    308313        </key>
     314        <space>
     315            <width>285</width>
     316        </space>
    309317    </row>
    310318    <row>
     
    376384            <scancode>0x48</scancode>
    377385        </key>
     386        <space>
     387            <width>80</width>
     388        </space>
    378389    </row>
    379390    <row>
     
    453464            <scancode>0x4d</scancode>
    454465        </key>
     466        <space>
     467            <width>25</width>
     468        </space>
    455469    </row>
    456470</physicallayout>
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