VirtualBox

Changeset 81944 in vbox


Ignore:
Timestamp:
Nov 18, 2019 3:38:57 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref: 6143. Making the corner radius a bit less magic numberish.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r81881 r81944  
    154154        return QPointF();
    155155    /* Normalize the vector and add it to starting point: */
    156     vectorP0P1 = (fDistance /length) * vectorP0P1 + p0;
     156    vectorP0P1 = (fDistance / length) * vectorP0P1 + p0;
    157157    return vectorP0P1;
    158158}
     
    189189
    190190public:
     191    UISoftKeyboardPhysicalLayout();
    191192
    192193    void setName(const QString &strName);
     
    205206    void updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState);
    206207    void reset();
     208
     209    void setDefaultKeyWidth(int iDefaultKeyWidth);
     210    int defaultKeyWidth() const;
    207211
    208212    /** Returns the sum totalHeight() of all rows(). */
     
    216220    QString  m_strName;
    217221    QVector<UISoftKeyboardRow>    m_rows;
     222    int m_iDefaultKeyWidth;
    218223    /** Scroll, Num, and Caps Lock keys' states are updated thru some API events. Thus we keep their pointers in a containter. */
    219224    QMap<int, UISoftKeyboardKey*> m_lockKeys;
     
    446451    const QPainterPath &painterPath() const;
    447452
     453
     454    void setCornerRadius(float fCornerRadius);
     455
    448456    QPolygonF polygonInGlobal() const;
    449457
     
    494502      * and has precedence over the captions defined in keyboard layout files. */
    495503    QString m_strStaticCaption;
    496     bool m_fIsOSMenuKey;
     504    bool    m_fIsOSMenuKey;
     505    double  m_fCornerRadius;
    497506};
    498507
     
    539548    QString baseCaption(int iKeyPosition) const;
    540549    QString shiftCaption(int iKeyPosition) const;
     550
    541551    QString altGrCaption(int iKeyPosition) const;
    542552    QString shiftAltGrCaption(int iKeyPosition) const;
     
    545555    bool editedButNotSaved() const;
    546556
    547     void setUid(const QUuid &uid);
     557    void  setUid(const QUuid &uid);
    548558    QUuid uid() const;
    549559
    550560    void drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter);
    551 
    552 
    553561
    554562private:
     
    893901*********************************************************************************************************************************/
    894902
     903UISoftKeyboardPhysicalLayout::UISoftKeyboardPhysicalLayout()
     904    :m_iDefaultKeyWidth(50)
     905{
     906}
     907
    895908void UISoftKeyboardPhysicalLayout::setName(const QString &strName)
    896909{
     
    943956    updateLockKeyState(fNumLockState, m_lockKeys.value(iNumLockPosition, 0));
    944957    updateLockKeyState(fScrollLockState, m_lockKeys.value(iScrollLockPosition, 0));
     958}
     959
     960void UISoftKeyboardPhysicalLayout::setDefaultKeyWidth(int iDefaultKeyWidth)
     961{
     962    m_iDefaultKeyWidth = iDefaultKeyWidth;
     963}
     964
     965int UISoftKeyboardPhysicalLayout::defaultKeyWidth() const
     966{
     967    return m_iDefaultKeyWidth;
    945968}
    946969
     
    15541577    , m_enmKeyboardRegion(KeyboardRegion_Main)
    15551578    , m_fIsOSMenuKey(false)
     1579    , m_fCornerRadius(5.)
    15561580{
    15571581}
     
    17341758    if (m_points.size() < 3)
    17351759        return;
    1736     qreal fRadius = 5;
    1737     m_painterPath = QPainterPath(pointInBetween(fRadius, m_points[0], m_points[1]));
     1760
     1761    m_painterPath = QPainterPath(pointInBetween(m_fCornerRadius, m_points[0], m_points[1]));
    17381762    for (int i = 0; i < m_points.size(); ++i)
    17391763    {
    1740         QPointF p0 = pointInBetween(fRadius, m_points[(i+1)%m_points.size()], m_points[i]);
    1741         QPointF p1 = pointInBetween(fRadius, m_points[(i+1)%m_points.size()], m_points[(i+2)%m_points.size()]);
     1764        QPointF p0 = pointInBetween(m_fCornerRadius, m_points[(i+1)%m_points.size()], m_points[i]);
     1765        QPointF p1 = pointInBetween(m_fCornerRadius, m_points[(i+1)%m_points.size()], m_points[(i+2)%m_points.size()]);
    17421766        m_painterPath.lineTo(p0);
    17431767        m_painterPath.quadTo(m_points[(i+1)%m_points.size()], p1);
    17441768    }
     1769}
     1770
     1771void UISoftKeyboardKey::setCornerRadius(float fCornerRadius)
     1772{
     1773    m_fCornerRadius = fCornerRadius;
    17451774}
    17461775
     
    22492278    int unitSize = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
    22502279    float fLedRadius =  0.8 * unitSize;
    2251     float fLedMargin =  0.6 * unitSize;
     2280    float fLedMargin =  5;//0.6 * unitSize;
    22522281
    22532282    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(currentLayout.physicalLayoutUuid());
     
    29682997
    29692998            key.setKeyGeometry(QRect(iX, iY, key.width(), key.height()));
     2999            key.setCornerRadius(0.1 * newPhysicalLayout->defaultKeyWidth());
    29703000            key.setPoints(UIPhysicalLayoutReader::computeKeyVertices(key));
    29713001            key.setParentWidget(this);
     
    32293259    int iDefaultHeight = attributes.value("defaultHeight").toInt();
    32303260    QVector<UISoftKeyboardRow> &rows = physicalLayout.rows();
     3261    physicalLayout.setDefaultKeyWidth(iDefaultWidth);
    32313262
    32323263    while (m_xmlReader.readNextStartElement())
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette