VirtualBox

Changeset 90872 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 25, 2021 11:28:56 AM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Moving overlay label management from paintevent to a separate function.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp

    r90870 r90872  
    708708        painter.fillRect(fillRect, Qt::white);
    709709        painter.drawPixmap(imageRect, newPixmap, newPixmap.rect());
    710     }
    711     if (m_pOverlayLabel)
    712     {
    713         if (m_fOverlayMode && !m_pOverlayLabel->isVisible())
    714         {
    715             /* Scale the image to 1:1 as long as it fits into avaible space (minus some margins and scrollbar sizes): */
    716             int vWidth = 0;
    717             if (verticalScrollBar() && verticalScrollBar()->isVisible())
    718                 vWidth = verticalScrollBar()->width();
    719             int hMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) +
    720                 qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) + vWidth;
    721 
    722             int hHeight = 0;
    723             if (horizontalScrollBar() && horizontalScrollBar()->isVisible())
    724                 hHeight = horizontalScrollBar()->height();
    725             int vMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) +
    726                 qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) + hHeight;
    727 
    728             QSize size(qMin(width() - hMargin, m_overlayPixmap.width()),
    729                        qMin(height() - vMargin, m_overlayPixmap.height()));
    730             m_pOverlayLabel->setPixmap(m_overlayPixmap.scaled(size,  Qt::KeepAspectRatio, Qt::SmoothTransformation));
    731             m_pOverlayLabel->show();
    732 
    733             /* Center the label: */
    734             int x = 0.5 * (width() - vWidth - m_pOverlayLabel->width());
    735             int y = 0.5 * (height() - hHeight - m_pOverlayLabel->height());
    736             m_pOverlayLabel->move(x, y);
    737         }
    738         if (!m_fOverlayMode && m_pOverlayLabel->isVisible())
    739             m_pOverlayLabel->hide();
    740710    }
    741711}
     
    1000970void UIHelpViewer::clearOverlay()
    1001971{
     972    AssertReturnVoid(m_pOverlayLabel);
    1002973    setImageOverCursor(cursor().pos());
    1003974
     
    1008979    if (m_pOverlayBlurEffect)
    1009980        m_pOverlayBlurEffect->setEnabled(false);
     981    m_pOverlayLabel->hide();
     982}
     983
     984void UIHelpViewer::enableOverlay()
     985{
     986    AssertReturnVoid(m_pOverlayLabel);
     987    m_fOverlayMode = true;
     988    if (m_pOverlayBlurEffect)
     989        m_pOverlayBlurEffect->setEnabled(true);
     990    viewport()->setCursor(m_defaultCursor);
     991    m_fCursorChanged = false;
     992    toggleFindInPageWidget(false);
     993
     994    /* Scale the image to 1:1 as long as it fits into avaible space (minus some margins and scrollbar sizes): */
     995    int vWidth = 0;
     996    if (verticalScrollBar() && verticalScrollBar()->isVisible())
     997        vWidth = verticalScrollBar()->width();
     998    int hMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) +
     999        qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) + vWidth;
     1000
     1001    int hHeight = 0;
     1002    if (horizontalScrollBar() && horizontalScrollBar()->isVisible())
     1003        hHeight = horizontalScrollBar()->height();
     1004    int vMargin = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) +
     1005        qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) + hHeight;
     1006
     1007    QSize size(qMin(width() - hMargin, m_overlayPixmap.width()),
     1008               qMin(height() - vMargin, m_overlayPixmap.height()));
     1009    m_pOverlayLabel->setPixmap(m_overlayPixmap.scaled(size,  Qt::KeepAspectRatio, Qt::SmoothTransformation));
     1010    m_pOverlayLabel->show();
     1011
     1012    /* Center the label: */
     1013    int x = 0.5 * (width() - vWidth - m_pOverlayLabel->width());
     1014    int y = 0.5 * (height() - hHeight - m_pOverlayLabel->height());
     1015    m_pOverlayLabel->move(x, y);
    10101016}
    10111017
     
    10391045        m_overlayPixmap.loadFromData(fileData,"PNG");
    10401046        if (!m_overlayPixmap.isNull())
    1041         {
    1042             m_fOverlayMode = true;
    1043             if (m_pOverlayBlurEffect)
    1044                 m_pOverlayBlurEffect->setEnabled(true);
    1045             viewport()->setCursor(m_defaultCursor);
    1046             m_fCursorChanged = false;
    1047             toggleFindInPageWidget(false);
    1048         }
     1047            enableOverlay();
    10491048    }
    10501049}
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h

    r90870 r90872  
    129129    void loadImageAtPosition(const QPoint &globalPosition);
    130130    void clearOverlay();
     131    void enableOverlay();
    131132    void setImageOverCursor(QPoint globalPosition);
    132133
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