VirtualBox

Changeset 101658 in vbox for trunk/src


Ignore:
Timestamp:
Oct 30, 2023 1:38:39 PM (16 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159747
Message:

FE/Qt: bugref:6143. Drawing soft keyboard's multimedia keys resolution aware.

File:
1 edited

Legend:

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

    r101563 r101658  
    402402  * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey usually does not have
    403403  * caption field(s). Captions are kept by UISoftKeyboardLayout since same keys may (and usually do) have different captions in
    404   * different layouts. So called static captions are exections. They are defined in physical layout files and kept as member of
     404  * different layouts. So called static captions are exceptions. They are defined in physical layout files and kept as member of
    405405  * UISoftKeyboardKey. When a static caption exits captions (if any) from the keyboard layout files are ignored. */
    406406class UISoftKeyboardKey
     
    449449
    450450    void setImageByName(const QString &strCaption);
    451     const QImage &image() const;
     451    QPixmap image() const;
    452452
    453453    void setParentWidget(UISoftKeyboardWidget* pParent);
     
    517517    bool    m_fIsOSMenuKey;
    518518    double  m_fCornerRadius;
    519     QImage  m_image;
     519    QIcon   m_icon;
    520520};
    521521
     
    17331733    if (strImageFileName.isEmpty())
    17341734        return;
    1735     m_image = QImage(QString(":/%1").arg(strImageFileName));
    1736 }
    1737 
    1738 const QImage &UISoftKeyboardKey::image() const
    1739 {
    1740     return m_image;
     1735    m_icon = UIIconPool::iconSet(QString(":/%1").arg(strImageFileName));
     1736}
     1737
     1738QPixmap UISoftKeyboardKey::image() const
     1739{
     1740    QPixmap pixmap;
     1741
     1742    /* Check whether we have valid icon: */
     1743    if (!m_icon.isNull())
     1744    {
     1745        /* Determine desired icon size: */
     1746        const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
     1747        const QSize iconSize = QSize(iIconMetric, iIconMetric);
     1748        /* Get pixmap of requested size (take into account the DPI of the main shown window, if possible): */
     1749        const qreal fDevicePixelRatio = windowManager().mainWindowShown() && windowManager().mainWindowShown()->windowHandle()
     1750                                      ? windowManager().mainWindowShown()->windowHandle()->devicePixelRatio() : 1;
     1751        pixmap = m_icon.pixmap(iconSize, fDevicePixelRatio);
     1752    }
     1753
     1754    return pixmap;
    17411755}
    17421756
     
    21852199    int iMargin = 0.1 * qMax(keyGeometry.width(), keyGeometry.height());
    21862200    int size = qMin(keyGeometry.width() - 2 * iMargin, keyGeometry.height() - 2 * iMargin);
    2187     painter.drawImage(QRect(0.5 * (keyGeometry.width() - size), 0.5 * (keyGeometry.height() - size),
     2201    painter.drawPixmap(QRect(0.5 * (keyGeometry.width() - size), 0.5 * (keyGeometry.height() - size),
    21882202                            size, size), key.image());
    21892203}
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