VirtualBox

Changeset 95251 in vbox


Ignore:
Timestamp:
Jun 12, 2022 5:01:37 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. A better handling of the zoom operation.

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

Legend:

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

    r95069 r95251  
    7474static const int iBookmarkUrlDataType = 6;
    7575
     76static int iZoomPercentageStep = 20;
     77const QPair<int, int> zoomPercentageMinMax = QPair<int, int>(20, 300);
    7678
    7779/*********************************************************************************************************************************
     
    196198    void sigLinkHighlighted(const QString &strLink);
    197199#endif
    198     void sigZoomPercentageChanged(int iPercentage);
    199200    void sigFindInPageWidgetVisibilityChanged(bool fVisible);
    200201    void sigHistoryChanged(bool fBackwardAvailable, bool fForwardAvailable);
    201202    void sigMouseOverImage(const QString &strImageName);
     203    void sigZoomRequest(UIHelpViewer::ZoomOperation enmZoomOperation);
    202204
    203205public:
     
    211213    void setToolBarVisible(bool fVisible);
    212214    void print(QPrinter &printer);
    213     void zoom(UIHelpViewer::ZoomOperation enmZoomOperation);
    214     int zoomPercentage() const;
    215215    void setZoomPercentage(int iZoomPercentage);
    216216    void setHelpFileList(const QList<QUrl> &helpFileList);
     
    302302    void printCurrent(QPrinter &printer);
    303303    void switchToTab(int iIndex);
    304     /** Returns the zoom percentage of 0th tab. */
    305304    int zoomPercentage() const;
    306     /** Sets the zoom percentage of all tabs. */
    307305    void setZoomPercentage(int iZoomPercentage);
    308306    void setHelpFileList(const QList<QUrl> &helpFileList);
     
    318316    void sltCloseCurrentTab();
    319317    void sltCloseOtherTabs();
    320     void sltZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation);
    321318    void sltHomeAction();
    322319    void sltAddBookmarkAction();
     
    324321    void sltBackwardAction();
    325322    void sltReloadPageAction();
     323    void sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation);
    326324
    327325private slots:
     
    356354    QStringList m_tabTitleList;
    357355    QList<QUrl> m_helpFileList;
     356    /** As percentage. */
     357    int m_iZoomPercentage;
    358358};
    359359
     
    624624}
    625625
    626 void UIHelpBrowserTab::zoom(UIHelpViewer::ZoomOperation enmZoomOperation)
    627 {
    628     if (m_pContentViewer)
    629         m_pContentViewer->zoom(enmZoomOperation);
    630 }
    631 
    632626void UIHelpBrowserTab::setZoomPercentage(int iZoomPercentage)
    633627{
     
    672666    if (m_pContentViewer)
    673667        return m_pContentViewer->sltSelectPreviousMatch();
    674 }
    675 
    676 int UIHelpBrowserTab::zoomPercentage() const
    677 {
    678     if (m_pContentViewer)
    679         return m_pContentViewer->zoomPercentage();
    680     return 100;
    681668}
    682669
     
    723710            this, &UIHelpBrowserTab::sigLinkHighlighted);
    724711#endif
    725     connect(m_pContentViewer, &UIHelpViewer::sigZoomPercentageChanged,
    726             this, &UIHelpBrowserTab::sigZoomPercentageChanged);
    727712    connect(m_pContentViewer, &UIHelpViewer::copyAvailable,
    728713            this, &UIHelpBrowserTab::sigCopyAvailableChanged);
     
    731716    connect(m_pContentViewer, &UIHelpViewer::sigMouseOverImage,
    732717            this, &UIHelpBrowserTab::sigMouseOverImage);
     718    connect(m_pContentViewer, &UIHelpViewer::sigZoomRequest,
     719            this, &UIHelpBrowserTab::sigZoomRequest);
    733720
    734721    m_pContentViewer->setSource(initialUrl);
     
    929916    , m_fSwitchToNewTab(true)
    930917    , m_fToolBarVisible(true)
     918    , m_iZoomPercentage(100)
    931919{
    932920    Q_UNUSED(m_fSwitchToNewTab);
     
    956944    connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark,
    957945            this, &UIHelpBrowserTabManager::sigAddBookmark);
    958     connect(pTabWidget, &UIHelpBrowserTab::sigZoomPercentageChanged,
    959             this, &UIHelpBrowserTabManager::sigZoomPercentageChanged);
    960946    connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted,
    961947            this, &UIHelpBrowserTabManager::sigLinkHighlighted);
     
    968954   connect(pTabWidget, &UIHelpBrowserTab::sigMouseOverImage,
    969955            this, &UIHelpBrowserTabManager::sigMouseOverImage);
     956   connect(pTabWidget, &UIHelpBrowserTab::sigZoomRequest,
     957            this, &UIHelpBrowserTabManager::sltHandleZoomRequest);
    970958
    971959   pTabWidget->setZoomPercentage(zoomPercentage());
    972     pTabWidget->setHelpFileList(m_helpFileList);
    973     setFocusProxy(pTabWidget);
    974     if (!fBackground)
    975         setCurrentIndex(index);
     960   pTabWidget->setHelpFileList(m_helpFileList);
     961   setFocusProxy(pTabWidget);
     962   if (!fBackground)
     963       setCurrentIndex(index);
    976964}
    977965
     
    11101098int UIHelpBrowserTabManager::zoomPercentage() const
    11111099{
    1112     UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(0));
    1113     if (pTab)
    1114         return pTab->zoomPercentage();
    1115     return 100;
    1116 }
    1117 
    1118 void UIHelpBrowserTabManager::setZoomPercentage(int iZoomPercentage)
    1119 {
    1120     for (int i = 0; i < count(); ++i)
    1121     {
    1122         UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
    1123         if (pTab)
    1124             pTab->setZoomPercentage(iZoomPercentage);
    1125     }
     1100    return m_iZoomPercentage;
    11261101}
    11271102
     
    12561231}
    12571232
    1258 void UIHelpBrowserTabManager::sltZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation)
    1259 {
    1260     for (int i = 0; i < count(); ++i)
    1261     {
    1262         UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
    1263         if (pTab)
    1264             pTab->zoom(enmZoomOperation);
    1265     }
    1266 }
    1267 
    12681233void UIHelpBrowserTabManager::sltShowTabBarContextMenu(const QPoint &pos)
    12691234{
     
    13081273    if (pTab)
    13091274        pTab->sltBackwardAction();
     1275}
     1276
     1277void UIHelpBrowserTabManager::sltHandleZoomRequest(UIHelpViewer::ZoomOperation enmOperation)
     1278{
     1279    int iZoomPercentage = m_iZoomPercentage;
     1280    switch (enmOperation)
     1281    {
     1282        case UIHelpViewer::ZoomOperation_In:
     1283            iZoomPercentage += iZoomPercentageStep;
     1284            break;
     1285        case UIHelpViewer::ZoomOperation_Out:
     1286            iZoomPercentage -= iZoomPercentageStep;
     1287            break;
     1288        case UIHelpViewer::ZoomOperation_Reset:
     1289        default:
     1290            iZoomPercentage = 100;
     1291            break;
     1292    }
     1293    setZoomPercentage(iZoomPercentage);
     1294}
     1295
     1296void UIHelpBrowserTabManager::setZoomPercentage(int iZoomPercentage)
     1297{
     1298
     1299    if (iZoomPercentage > zoomPercentageMinMax.second ||
     1300        iZoomPercentage < zoomPercentageMinMax.first)
     1301        return;
     1302
     1303    m_iZoomPercentage = iZoomPercentage;
     1304
     1305    for (int i = 0; i < count(); ++i)
     1306    {
     1307        UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
     1308        if (pTab)
     1309            pTab->setZoomPercentage(m_iZoomPercentage);
     1310    }
     1311    emit sigZoomPercentageChanged(m_iZoomPercentage);
    13101312}
    13111313
     
    22242226        return;
    22252227    UIHelpViewer::ZoomOperation enmOperation = (UIHelpViewer::ZoomOperation)(iZoomOperation);
    2226     m_pTabManager->sltZoomOperation(enmOperation);
     2228    m_pTabManager->sltHandleZoomRequest(enmOperation);
    22272229}
    22282230
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp

    r95076 r95251  
    5555#ifdef VBOX_WITH_QHELP_VIEWER
    5656
    57 static int iZoomPercentageStep = 20;
    58 const QPair<int, int> UIHelpViewer::zoomPercentageMinMax = QPair<int, int>(20, 300);
    59 
    60 
    6157/*********************************************************************************************************************************
    6258*   UIContextMenuNavigationAction definition.                                                                                    *
     
    402398    , m_iSelectedMatchIndex(0)
    403399    , m_iSearchTermLength(0)
    404     , m_iZoomPercentage(100)
    405400    , m_fOverlayMode(false)
    406401    , m_fCursorChanged(false)
    407402    , m_pOverlayLabel(0)
     403    , m_iZoomPercentage(100)
    408404{
    409405    m_iInitialFontPointSize = font().pointSize();
     
    546542}
    547543
    548 void UIHelpViewer::zoom(ZoomOperation enmZoomOperation)
    549 {
     544void UIHelpViewer::setZoomPercentage(int iZoomPercentage)
     545{
     546    m_iZoomPercentage = iZoomPercentage;
    550547    clearOverlay();
    551     int iPrevZoom = m_iZoomPercentage;
    552     switch (enmZoomOperation)
    553     {
    554         case ZoomOperation_In:
    555             iPrevZoom += iZoomPercentageStep;
    556             break;
    557         case ZoomOperation_Out:
    558             iPrevZoom -= iZoomPercentageStep;
    559             break;
    560         case ZoomOperation_Reset:
    561         default:
    562             iPrevZoom = 100;
    563             break;
    564     }
    565     setZoomPercentage(iPrevZoom);
    566 }
    567 
    568 void UIHelpViewer::setZoomPercentage(int iZoomPercentage)
    569 {
    570     if (iZoomPercentage > zoomPercentageMinMax.second ||
    571         iZoomPercentage < zoomPercentageMinMax.first ||
    572         m_iZoomPercentage == iZoomPercentage)
    573         return;
    574 
    575     m_iZoomPercentage = iZoomPercentage;
    576548    scaleFont();
    577549    scaleImages();
    578     emit sigZoomPercentageChanged(m_iZoomPercentage);
    579550}
    580551
     
    590561{
    591562    return textCursor().hasSelection();
    592 }
    593 
    594 int UIHelpViewer::zoomPercentage() const
    595 {
    596     return m_iZoomPercentage;
    597563}
    598564
     
    690656    {
    691657        if (pEvent->angleDelta().y() > 0)
    692             zoom(ZoomOperation_In);
     658            emit sigZoomRequest(ZoomOperation_In);
    693659        else if (pEvent->angleDelta().y() < 0)
    694             zoom(ZoomOperation_Out);
     660            emit sigZoomRequest(ZoomOperation_Out);
    695661    }
    696662}
     
    804770        {
    805771            case Qt::Key_Equal:
    806                 zoom(ZoomOperation_In);
     772                emit sigZoomRequest(ZoomOperation_In);
    807773                break;
    808774            case Qt::Key_Minus:
    809                 zoom(ZoomOperation_Out);
     775                emit sigZoomRequest(ZoomOperation_Out);
    810776                break;
    811777            case Qt::Key_0:
    812                 zoom(ZoomOperation_Reset);
     778                emit sigZoomRequest(ZoomOperation_Reset);
    813779                break;
    814780            default:
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h

    r94064 r95251  
    4646    Q_OBJECT;
    4747
    48 signals:
    49 
    50     void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
    51     void sigFindInPageWidgetToogle(bool fVisible);
    52     void sigFontPointSizeChanged(int iFontPointSize);
    53     void sigGoBackward();
    54     void sigGoForward();
    55     void sigGoHome();
    56     void sigAddBookmark();
    57     void sigZoomPercentageChanged(int iPercentage);
    58     void sigMouseOverImage(const QString &strImageName);
    59 
    6048public:
    6149
     
    6856    };
    6957
     58signals:
     59
     60    void sigOpenLinkInNewTab(const QUrl &url, bool fBackground);
     61    void sigFindInPageWidgetToogle(bool fVisible);
     62    void sigFontPointSizeChanged(int iFontPointSize);
     63    void sigGoBackward();
     64    void sigGoForward();
     65    void sigGoHome();
     66    void sigAddBookmark();
     67    void sigMouseOverImage(const QString &strImageName);
     68    void sigZoomRequest(ZoomOperation enmZoomOperation);
     69
     70public:
     71
    7072    UIHelpViewer(const QHelpEngine *pHelpEngine, QWidget *pParent = 0);
    7173    virtual QVariant loadResource(int type, const QUrl &name) RT_OVERRIDE;
     
    7678    void setFont(const QFont &);
    7779    bool isFindInPageWidgetVisible() const;
    78     void zoom(ZoomOperation enmZoomOperation);
    79     int zoomPercentage() const;
    8080    void setZoomPercentage(int iZoomPercentage);
    8181    void setHelpFileList(const QList<QUrl> &helpFileList);
     
    155155    /** A container to store the original image sizes/positions in the document. key is image name value is DocumentImage. */
    156156    QHash<QString, DocumentImage> m_imageMap;
    157     /** As percentage. */
    158     int m_iZoomPercentage;
    159157    /** Used to change th document cursor back from m_handCursor. */
    160158    QCursor m_defaultCursor;
     
    167165    QLabel *m_pOverlayLabel;
    168166    QGraphicsBlurEffect *m_pOverlayBlurEffect;
     167    int m_iZoomPercentage;
    169168};
    170169
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