VirtualBox

Changeset 88418 in vbox for trunk


Ignore:
Timestamp:
Apr 8, 2021 2:05:51 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Resizing images along side with font.

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

Legend:

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

    r88415 r88418  
    389389        m_pFindInPageWidget->clearSearchField();
    390390    }
     391    scaleImages();
    391392}
    392393
     
    463464    m_iZoomPercentage = iZoomPercentage;
    464465    scaleFont();
     466    scaleImages();
    465467    emit sigZoomPercentageChanged(m_iZoomPercentage);
    466468}
     
    730732void UIHelpViewer::iterateDocumentImages()
    731733{
    732     m_imageSizesMap.clear();
     734    m_imageMap.clear();
    733735    QTextCursor cursor = textCursor();
    734736    cursor.movePosition(QTextCursor::Start);
     
    738740        if (cursor.charFormat().isImageFormat())
    739741        {
     742            DocumentImage image;
    740743           QTextImageFormat imageFormat = cursor.charFormat().toImageFormat();
    741            m_imageSizesMap[imageFormat.name()] = imageFormat.width();
     744           image.m_fInitialWidth = imageFormat.width();
     745           image.m_iPosition = cursor.position();
     746           m_imageMap[imageFormat.name()] = image;
    742747        }
    743748    }
     
    751756}
    752757
     758void UIHelpViewer::scaleImages()
     759{
     760    for (QMap<QString, DocumentImage>::iterator iterator = m_imageMap.begin();
     761         iterator != m_imageMap.end(); ++iterator)
     762    {
     763        QTextCursor cursor = textCursor();
     764        cursor.movePosition(QTextCursor::Start);
     765        cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, (*iterator).m_iPosition - 1);
     766        if (cursor.isNull())
     767            continue;
     768        QTextCharFormat format = cursor.charFormat();
     769        if (!format.isImageFormat())
     770            continue;
     771        QTextImageFormat imageFormat = format.toImageFormat();
     772        imageFormat.setWidth((*iterator).m_fInitialWidth * m_iZoomPercentage / 100.);
     773        cursor.deleteChar();
     774        cursor.insertImage(imageFormat);
     775    }
     776}
     777
     778
    753779#include "UIHelpViewer.moc"
    754780
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h

    r88411 r88418  
    9595private:
    9696
     97    struct DocumentImage
     98    {
     99        qreal m_fInitialWidth;
     100        int m_iPosition;
     101    };
     102
    97103    void retranslateUi();
    98104    bool isRectInside(const QRect &rect, int iMargin) const;
     
    103109    void iterateDocumentImages();
    104110    void scaleFont();
     111    void scaleImages();
    105112    const QHelpEngine* m_pHelpEngine;
    106113    UIFindInPageWidget *m_pFindInPageWidget;
     
    113120    int m_iSearchTermLength;
    114121    int m_iInitialFontPointSize;
    115     /** A container to store the original image sizes in the document. key is image name value is the width. */
    116     QMap<QString, qreal> m_imageSizesMap;
     122    /** A container to store the original image sizes/positions in the document. key is image name value is DocumentImage. */
     123    QMap<QString, DocumentImage> m_imageMap;
    117124    /** As percentage. */
    118125    int m_iZoomPercentage;
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