VirtualBox

Changeset 89276 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 25, 2021 3:49:20 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10003: HiDPI support for UIWizard watermark.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp

    r87001 r89276  
    2020#include <QLayout>
    2121#include <QStyle>
     22#include <QWindow>
    2223
    2324/* GUI includes: */
     
    497498void UIWizard::assignWatermarkHelper()
    498499{
    499     /* Calculate metric and ratio: */
    500     const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
    501     const double dRatio = (double)iIconMetric / 32;
    502500    /* Load pixmap to icon first: */
    503501    QIcon icon = UIIconPool::iconSet(m_strWatermarkName);
    504     QSize size = icon.availableSizes().value(0, QSize(145, 290));
    505     size *= dRatio;
    506     /* Create initial watermark: */
    507     QPixmap pixWaterMark(icon.pixmap(size));
     502    /* Create initial watermark pixmap.
     503     * For HiDPI support parent-widget's device pixel ratio is to be taken into account: */
     504    QPixmap pixWaterMark(  parentWidget()
     505                         ? icon.pixmap(parentWidget()->windowHandle(), QSize(145, 290))
     506                         : icon.pixmap(QSize(145, 290)));
    508507    /* Convert watermark to image which
    509508     * allows to manage pixel data directly: */
     
    540539    /* Convert processed image to pixmap and assign it to wizard's watermark. */
    541540    QPixmap pixWatermarkNew = QPixmap::fromImage(imgWatermarkNew);
     541    /* For HiDPI support parent-widget's device pixel ratio is to be taken into account: */
     542    const double dRatio = parentWidget()->windowHandle()->devicePixelRatio();
     543    pixWatermarkNew.setDevicePixelRatio(dRatio);
     544    /* Assign watermark finally: */
    542545    setPixmap(QWizard::WatermarkPixmap, pixWatermarkNew);
    543546}
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