VirtualBox

Changeset 69712 in vbox for trunk


Ignore:
Timestamp:
Nov 16, 2017 12:14:46 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8694: Selector UI: HiDPI support fix for graphics-button used in chooser/details: Do not blindly expect that there will be pixmap of required size, check actual one (s.a. r119004).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp

    r69641 r69712  
    8787{
    8888    /* Prepare variables: */
    89     int iMargin = data(GraphicsButton_Margin).toInt();
    90     QIcon icon = data(GraphicsButton_Icon).value<QIcon>();
    91     QSize iconSize = data(GraphicsButton_IconSize).toSize();
     89    const int iMargin = data(GraphicsButton_Margin).toInt();
     90    const QIcon icon = data(GraphicsButton_Icon).value<QIcon>();
     91    const QSize expectedIconSize = data(GraphicsButton_IconSize).toSize();
     92    const QPixmap pixmap = icon.pixmap(expectedIconSize);
     93    const QSize actualIconSize = pixmap.size() / pixmap.devicePixelRatio();
     94    QPoint position = QPoint(iMargin, iMargin);
     95    if (actualIconSize != expectedIconSize)
     96    {
     97        const int iDx = (expectedIconSize.width() - actualIconSize.width()) / 2;
     98        const int iDy = (expectedIconSize.height() - actualIconSize.height()) / 2;
     99        position += QPoint(iDx, iDy);
     100    }
    92101
    93102    /* Just draw the pixmap: */
    94     pPainter->drawPixmap(QRect(QPoint(iMargin, iMargin), iconSize), icon.pixmap(iconSize));
     103    pPainter->drawPixmap(position, pixmap);
    95104}
    96105
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