VirtualBox

Changeset 88392 in vbox


Ignore:
Timestamp:
Apr 7, 2021 10:41:40 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Misc. fixes

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

Legend:

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

    r87697 r88392  
    262262    UIHelpBrowserTabManager(const QHelpEngine  *pHelpEngine, const QUrl &homeUrl,
    263263                            const QStringList &urlList, QWidget *pParent = 0);
    264     /* Return the list of urls of all open tabs as QStringList. */
     264    /* Returns the list of urls of all open tabs as QStringList. */
    265265    QStringList tabUrlList() const;
    266266    QStringList tabTitleList() const;
     
    273273    void setToolBarVisible(bool fVisible);
    274274    void printCurrent(QPrinter &printer);
    275     int initialFontPointSize() const;
     275    int  initialFontPointSize() const;
    276276    void setFontPointSize(int iPointSize);
    277     int fontPointSize() const;
     277    int  fontPointSize() const;
    278278    void setFontScaleWidgetVisible(bool fToggled);
    279279    void switchToTab(int iIndex);
     
    308308    /** Closes all tabs other than the one with index @param iTabIndex. */
    309309    void closeAllTabsBut(int iTabIndex);
     310    /* Returns the tab index with @Url if there is one. Returns -1 otherwise. */
     311    int  findTab(const QUrl &Url) const;
    310312    const QHelpEngine* m_pHelpEngine;
    311313    UIFontScaleWidget *m_pFontScaleWidget;
     
    838840void UIHelpBrowserTabManager::addNewTab(const QUrl &initialUrl, bool fBackground)
    839841{
    840    UIHelpBrowserTab *pTabWidget = new  UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl);
    841    AssertReturnVoid(pTabWidget);
    842    pTabWidget->setToolBarVisible(m_fToolBarVisible);
    843    int index = addTab(pTabWidget, pTabWidget->documentTitle());
    844    connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged,
    845            this, &UIHelpBrowserTabManager::sigSourceChanged);
    846    connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate,
    847            this, &UIHelpBrowserTabManager::sltHandletabTitleChange);
    848    connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab,
    849            this, &UIHelpBrowserTabManager::sltHandleOpenLinkInNewTab);
    850    connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark,
    851            this, &UIHelpBrowserTabManager::sigAddBookmark);
    852    connect(pTabWidget, &UIHelpBrowserTab::sigFontPointSizeChanged,
    853            this, &UIHelpBrowserTabManager::sltHandleFontSizeChange);
    854    connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted,
    855            this, &UIHelpBrowserTabManager::sigLinkHighlighted);
    856 
    857    if (!fBackground)
    858        setCurrentIndex(index);
    859 
    860    if (!m_pFontScaleWidget)
    861    {
    862        m_pFontScaleWidget = new UIFontScaleWidget(initialFontPointSize(), this);
    863        connect(m_pFontScaleWidget, &UIFontScaleWidget::sigFontPointSizeChanged,
    864                this, &UIHelpBrowserTabManager::sltHandleFontSizeChange);
    865    }
     842    /* If there is already a tab with a source which is equal to @initialUrl then make it current: */
     843    int iExistIndex = findTab(initialUrl);
     844    if (iExistIndex != -1)
     845    {
     846        setCurrentIndex(iExistIndex);
     847        return;
     848    }
     849
     850    UIHelpBrowserTab *pTabWidget = new  UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl);
     851    AssertReturnVoid(pTabWidget);
     852    pTabWidget->setToolBarVisible(m_fToolBarVisible);
     853    int index = addTab(pTabWidget, pTabWidget->documentTitle());
     854    connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged,
     855            this, &UIHelpBrowserTabManager::sigSourceChanged);
     856    connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate,
     857            this, &UIHelpBrowserTabManager::sltHandletabTitleChange);
     858    connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab,
     859            this, &UIHelpBrowserTabManager::sltHandleOpenLinkInNewTab);
     860    connect(pTabWidget, &UIHelpBrowserTab::sigAddBookmark,
     861            this, &UIHelpBrowserTabManager::sigAddBookmark);
     862    connect(pTabWidget, &UIHelpBrowserTab::sigFontPointSizeChanged,
     863            this, &UIHelpBrowserTabManager::sltHandleFontSizeChange);
     864    connect(pTabWidget, &UIHelpBrowserTab::sigLinkHighlighted,
     865            this, &UIHelpBrowserTabManager::sigLinkHighlighted);
     866
     867    if (!fBackground)
     868        setCurrentIndex(index);
     869
     870    if (!m_pFontScaleWidget)
     871    {
     872        m_pFontScaleWidget = new UIFontScaleWidget(initialFontPointSize(), this);
     873        connect(m_pFontScaleWidget, &UIFontScaleWidget::sigFontPointSizeChanged,
     874                this, &UIHelpBrowserTabManager::sltHandleFontSizeChange);
     875    }
    866876}
    867877
     
    893903    addTab(widgetList[iTabIndex], strTitle);
    894904    updateTabUrlTitleList();
     905}
     906
     907int  UIHelpBrowserTabManager::findTab(const QUrl &Url) const
     908{
     909    for (int i = 0; i < count(); ++i)
     910    {
     911        UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(widget(i));
     912        if (!pTab || !pTab->source().isValid())
     913            continue;
     914        if (pTab->source() == Url)
     915            return i;
     916    }
     917    return -1;
    895918}
    896919
     
    956979    return list;
    957980}
    958 
    959981
    960982void UIHelpBrowserTabManager::setToolBarVisible(bool fVisible)
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp

    r87659 r88392  
    3131#include <QHBoxLayout>
    3232#include <QScrollBar>
     33#include <QTextBlock>
    3334#include <QWidgetAction>
    3435#ifdef RT_OS_SOLARIS
     
    374375    QTextBrowser::setSource(url);
    375376    QTextDocument *pDocument = document();
     377    //iterateDocumentImages();
    376378    if (!pDocument || pDocument->isEmpty())
    377379    {
     
    525527    if (!strAnchor.isEmpty())
    526528    {
    527         QString strLink = source().resolved(strAnchor).toString();
    528         emit sigOpenLinkInNewTab(strLink, true);
     529        if (pEvent->modifiers() & Qt::ControlModifier)
     530        {
     531            QString strLink = source().resolved(strAnchor).toString();
     532            emit sigOpenLinkInNewTab(strLink, true);
     533            return;
     534        }
    529535    }
    530536    QIWithRetranslateUI<QTextBrowser>::mousePressEvent(pEvent);
     
    620626}
    621627
     628void UIHelpViewer::iterateDocumentImages()
     629{
     630    QTextCursor cursor = textCursor();
     631    cursor.movePosition(QTextCursor::Start);
     632    while (!cursor.atEnd())
     633    {
     634        cursor.movePosition(QTextCursor::NextCharacter);
     635        if (cursor.charFormat().isImageFormat())
     636        {
     637            QTextImageFormat imageFormat = cursor.charFormat().toImageFormat();
     638            printf("%s %lf\n", qPrintable(imageFormat.name()), imageFormat.width());
     639        }
     640    }
     641}
     642
    622643void UIHelpViewer::sltHandleOpenLinkInNewTab()
    623644{
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h

    r87656 r88392  
    8787    void highlightFinds(int iSearchTermLength);
    8888    void selectMatch(int iMatchIndex, int iSearchStringLength);
     89    void iterateDocumentImages();
    8990    const QHelpEngine* m_pHelpEngine;
    9091    UIFindInPageWidget *m_pFindInPageWidget;
     
    9798    int m_iSearchTermLength;
    9899    int m_iInitialFontPointSize;
     100    QMap<QString, qreal> m_imageSizesMap;
    99101};
    100102
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