VirtualBox

Ignore:
Timestamp:
Jan 30, 2024 12:29:34 PM (13 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161368
Message:

FE/Qt: HiDPI support for various label icons in QILineEdit, UIToolBox and UIWizardNewVM.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp

    r102613 r103121  
    3434#include <QMenu>
    3535#include <QStyleOptionFrame>
    36 #include <QWindow>
    3736
    3837/* GUI includes: */
    3938#include "QILineEdit.h"
     39#include "UIDesktopWidgetWatchdog.h"
    4040#include "UIIconPool.h"
    4141
     
    242242void UIMarkableLineEdit::mark(bool fError, const QString &strErrorMessage /* = QString() */)
    243243{
     244    AssertPtrReturnVoid(m_pIconLabel);
    244245    m_pIconLabel->setVisible(true);
    245     AssertReturnVoid(m_pIconLabel);
     246    const QIcon icon = fError ? UIIconPool::iconSet(":/status_error_16px.png") : UIIconPool::iconSet(":/status_check_16px.png");
    246247    const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    247     const qreal fDevicePixelRatio = window() && window()->windowHandle() ? window()->windowHandle()->devicePixelRatio() : 1;
    248     if (fError)
    249         m_pIconLabel->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio));
    250     else
    251         m_pIconLabel->setPixmap(UIIconPool::iconSet(":/status_check_16px.png").pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio));
     248    const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel);
     249    m_pIconLabel->setPixmap(icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio));
    252250    m_pIconLabel->setToolTip(strErrorMessage);
    253251}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBox.cpp

    r101560 r103121  
    3232#include <QStyle>
    3333#include <QVBoxLayout>
    34 #include <QWindow>
    3534
    3635/* GUI includes: */
     
    3837#include "QIToolButton.h"
    3938#include "UICommon.h"
     39#include "UIDesktopWidgetWatchdog.h"
    4040#include "UIIconPool.h"
    4141#include "UIToolBox.h"
     
    296296        return;
    297297    }
    298     const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    299     const qreal fDevicePixelRatio = window() && window()->windowHandle() ? window()->windowHandle()->devicePixelRatio() : 1;
    300     m_pIconLabel->setPixmap(icon.pixmap(QSize(iMetric, iMetric), fDevicePixelRatio));
     298    const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     299    const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pIconLabel);
     300    m_pIconLabel->setPixmap(icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio));
    301301    m_pIconLabel->setToolTip(strToolTip);
    302302}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r101382 r103121  
    2929#include <QCheckBox>
    3030#include <QDir>
     31#include <QStyle>
    3132#include <QRegularExpression>
    3233#include <QVBoxLayout>
     
    3536#include "QIRichTextLabel.h"
    3637#include "UICommon.h"
     38#include "UIDesktopWidgetWatchdog.h"
     39#include "UIIconPool.h"
    3740#include "UINameAndSystemEditor.h"
    3841#include "UINotificationCenter.h"
     
    567570    }
    568571
    569     m_pInfoLabel->setText(QString("<img src=\":/session_info_16px.png\" style=\"vertical-align:top\"> %1").arg(strMessage));
     572    const QIcon icon = UIIconPool::iconSet(":/session_info_16px.png");
     573    const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     574    const qreal fDevicePixelRatio = gpDesktop->devicePixelRatio(m_pInfoLabel);
     575    m_pInfoLabel->registerPixmap(icon.pixmap(QSize(iIconMetric, iIconMetric), fDevicePixelRatio), "wizard://info");
     576    m_pInfoLabel->setText(QString("<img src='wizard://info' style=\"vertical-align:top\"> %1").arg(strMessage));
    570577}
    571578
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