VirtualBox

Changeset 72715 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 28, 2018 10:21:28 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123249
Message:

FE/Qt: bugref:8694: Adjust icons when moving GUI between screen with different DPI: UITabBar.

File:
1 edited

Legend:

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

    r69260 r72715  
    104104protected:
    105105
     106    /** Handles any Qt @a pEvent. */
     107    virtual bool event(QEvent *pEvent) /* override */;
     108
    106109    /** Handles translation event. */
    107110    virtual void retranslateUi() /* override */;
     
    130133    /** Prepares all. */
    131134    void prepare();
     135    /** Update pixmap. */
     136    void updatePixmap();
    132137
    133138    /** Holds the item ID. */
     
    212217    /* And call for repaint: */
    213218    update();
     219}
     220
     221bool UITabBarItem::event(QEvent *pEvent)
     222{
     223    /* Handle know event types: */
     224    switch (pEvent->type())
     225    {
     226        case QEvent::Show:
     227        case QEvent::ScreenChangeInternal:
     228        {
     229            /* Update pixmap: */
     230            updatePixmap();
     231            break;
     232        }
     233        default:
     234            break;
     235    }
     236
     237    /* Call to base-class: */
     238    return QIWithRetranslateUI<QWidget>::event(pEvent);
    214239}
    215240
     
    552577    pDrag->setMimeData(pMimeData);
    553578    const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    554     pDrag->setPixmap(m_pAction->icon().pixmap(iMetric, iMetric));
     579    pDrag->setPixmap(m_pAction->icon().pixmap(window()->windowHandle(), QSize(iMetric, iMetric)));
    555580    pDrag->exec();
    556581}
     
    593618    /* Create main layout: */
    594619    m_pLayout = new QHBoxLayout(this);
    595     AssertPtrReturnVoid(m_pLayout);
     620    if (m_pLayout)
    596621    {
    597622        /* Invent pixel metric: */
     
    619644        /* Create icon label: */
    620645        m_pLabelIcon = new QLabel;
    621         AssertPtrReturnVoid(m_pLabelIcon);
     646        if (m_pLabelIcon)
    622647        {
    623648            /* Configure label: */
    624649            m_pLabelIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    625             m_pLabelIcon->setPixmap(m_pAction->icon().pixmap(iMetric));
    626650        }
    627651
    628652        /* Create name label: */
    629653        m_pLabelName = new QLabel;
    630         AssertPtrReturnVoid(m_pLabelName);
     654        if (m_pLabelName)
    631655        {
    632656            /* Configure label: */
     
    636660        /* Create close button: */
    637661        m_pButtonClose = new QToolButton;
    638         AssertPtrReturnVoid(m_pButtonClose);
     662        if (m_pButtonClose)
    639663        {
    640664            /* Configure button: */
     
    653677        /* Create stacked-layout: */
    654678        m_pLayoutStacked = new QStackedLayout(m_pLayout);
     679        if (m_pLayoutStacked)
    655680        {
    656681            m_pLayoutStacked->setAlignment(Qt::AlignCenter);
     
    676701    }
    677702
     703    /* Update pixmap: */
     704    updatePixmap();
     705
    678706    /* Apply language settings: */
    679707    retranslateUi();
     708}
     709
     710void UITabBarItem::updatePixmap()
     711{
     712    /* Configure label icon: */
     713    const int iMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
     714    m_pLabelIcon->setPixmap(m_pAction->icon().pixmap(window()->windowHandle(), QSize(iMetric, iMetric)));
    680715}
    681716
Note: See TracChangeset for help on using the changeset viewer.

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