VirtualBox

Changeset 72710 in vbox


Ignore:
Timestamp:
Jun 27, 2018 6:30:08 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123240
Message:

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

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r72692 r72710  
    3535# include "UIGraphicsTextPane.h"
    3636# include "UIActionPool.h"
     37# include "UIConverter.h"
    3738# include "UIIconPool.h"
    38 # include "UIConverter.h"
     39# include "UISelectorWindow.h"
    3940# include "VBoxGlobal.h"
    4041
     
    131132}
    132133
     134void UIGDetailsElement::sltHandleWindowRemapped()
     135{
     136    /* Update icon: */
     137    updateIcon();
     138}
     139
    133140void UIGDetailsElement::sltToggleButtonClicked()
    134141{
     
    197204    /* Update current machine mount-target: */
    198205    vboxGlobal().updateMachineStorage(machine(), target);
     206}
     207
     208void UIGDetailsElement::showEvent(QShowEvent *pEvent)
     209{
     210    /* Call to base-class: */
     211    UIGDetailsItem::showEvent(pEvent);
     212
     213    /* Update icon: */
     214    updateIcon();
    199215}
    200216
     
    242258}
    243259
    244 void UIGDetailsElement::setIcon(const QIcon &icon)
    245 {
     260void UIGDetailsElement::updateIcon()
     261{
     262    /* Prepare whole icon first of all: */
     263    const QIcon icon = gpConverter->toIcon(elementType());
     264
    246265    /* Cache icon: */
    247266    if (icon.isNull())
     
    253272    else
    254273    {
    255         /* Determine default the icon size: */
    256         const QStyle *pStyle = QApplication::style();
    257         const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize);
     274        /* Determine default icon size: */
     275        const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    258276        m_pixmapSize = QSize(iIconMetric, iIconMetric);
    259         /* Acquire the icon of the corresponding size: */
    260         m_pixmap = icon.pixmap(m_pixmapSize);
     277        /* Acquire the icon of corresponding size (taking top-level widget DPI into account): */
     278        m_pixmap = icon.pixmap(gpSelectorWindow->windowHandle(), m_pixmapSize);
    261279    }
    262280
     
    412430    m_textFont = font();
    413431
     432    /* Update icon: */
     433    updateIcon();
     434
    414435    /* Create highlight machine: */
    415436    m_pHighlightMachine = new QStateMachine(this);
     
    444465    m_pHighlightMachine->start();
    445466
    446     connect(this, SIGNAL(sigToggleElement(DetailsElementType, bool)), model(), SLOT(sltToggleElements(DetailsElementType, bool)));
     467    /* Configure connections: */
     468    connect(gpSelectorWindow, &UISelectorWindow::sigWindowRemapped,
     469            this, &UIGDetailsElement::sltHandleWindowRemapped);
     470    connect(this, SIGNAL(sigToggleElement(DetailsElementType, bool)),
     471            model(), SLOT(sltToggleElements(DetailsElementType, bool)));
    447472    connect(this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
    448473            model(), SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)));
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r69639 r72710  
    9393protected slots:
    9494
     95    /** Handles top-level window remaps. */
     96    void sltHandleWindowRemapped();
     97
    9598    /* Handlers: Toggle stuff: */
    9699    void sltToggleButtonClicked();
     
    117120    };
    118121
     122    /** Handles show @a pEvent. */
     123    virtual void showEvent(QShowEvent *pEvent) /* override */;
     124
    119125    /** This event handler is delivered after the widget has been resized. */
    120126    void resizeEvent(QGraphicsSceneResizeEvent *pEvent);
     
    131137
    132138    /* API: Icon stuff: */
    133     void setIcon(const QIcon &icon);
     139    void updateIcon();
    134140
    135141    /* API: Name stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r72223 r72710  
    6666    , m_pTask(0)
    6767{
    68     /* Assign corresponding icon: */
    69     setIcon(gpConverter->toIcon(elementType()));
    70 
    7168    /* Listen for the global thread-pool: */
    7269    connect(vboxGlobal().threadPool(), SIGNAL(sigTaskComplete(UITask*)),
     
    124121    : UIGDetailsElement(pParent, DetailsElementType_Preview, fOpened)
    125122{
    126     /* Assign corresponding icon: */
    127     setIcon(gpConverter->toIcon(elementType()));
    128 
    129123    /* Create preview: */
    130124    m_pPreview = new UIGMachinePreview(this);
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