VirtualBox

Changeset 86794 in vbox


Ignore:
Timestamp:
Nov 3, 2020 12:22:16 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Fixing content widget connections

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

Legend:

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

    r86791 r86794  
    8383    virtual QVariant loadResource(int type, const QUrl &name) /* override */;
    8484    void emitHistoryChangedSignal();
     85    void setSource(const QUrl &url, const QString &strError);
    8586
    8687public slots:
     
    152153{
    153154    Q_OBJECT;
     155
     156signals:
     157
     158    void sigSourceChanged(const QUrl &url);
    154159
    155160public:
     
    210215    {
    211216        m_pContentViewer->blockSignals(true);
    212         m_pContentViewer->setSource(url);
     217        m_pContentViewer->setSource(url, m_strPageNotFoundText);
    213218        m_pContentViewer->blockSignals(false);
    214219        /* emit historyChanged signal explicitly since we have blocked the signals: */
     
    242247        this, &UIHelpBrowserTab::sltAnchorClicked);
    243248
    244     m_pContentViewer->setSource(initialUrl);
     249    m_pContentViewer->setSource(initialUrl, m_strPageNotFoundText);
    245250}
    246251
     
    311316    if (!m_pContentViewer)
    312317        return;
    313     if (m_homeUrl.isValid())
    314         m_pContentViewer->setSource(m_homeUrl);
     318    m_pContentViewer->setSource(m_homeUrl, m_strPageNotFoundText);
    315319}
    316320
     
    406410}
    407411
     412void UIHelpBrowserViewer::setSource(const QUrl &url, const QString &strError)
     413{
     414    if (!url.isValid())
     415        setText(strError.arg(url.toString()));
     416    else
     417        QTextBrowser::setSource(url);
     418}
     419
    408420
    409421/*********************************************************************************************************************************
     
    425437    clearAndDeleteTabs();
    426438    /* Add a single tab with m_homeUrl: */
    427     if (m_savedUrlList.isEmpty())
    428     {
    429         addTab(new  UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, QUrl()), QString());
    430     }
    431     else
    432     {
    433         addTab(new  UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, m_savedUrlList[0]), QString());
    434 
    435     }
     439    QUrl initialUrl;
     440    if (!m_savedUrlList.isEmpty())
     441        initialUrl = m_savedUrlList[0];
     442    UIHelpBrowserTab *pTabWidget = new  UIHelpBrowserTab(m_pHelpEngine, m_homeUrl, initialUrl);
     443    addTab(pTabWidget, QString());
     444    connect(pTabWidget, &UIHelpBrowserTab::sigSourceChanged,
     445            this, &UIHelpBrowserTabManager::sigSourceChanged);
    436446}
    437447
     
    600610    m_pSplitter->setChildrenCollapsible(false);
    601611
     612    connect(m_pTabManager, &UIHelpBrowserTabManager::sigSourceChanged,
     613            this, &UIHelpBrowserWidget::sltHandleHelpBrowserViewerSourceChange);
    602614    connect(m_pHelpEngine, &QHelpEngine::setupFinished,
    603615            this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished);
    604     // connect(m_pContentWidget, &QHelpContentWidget::linkActivated,
    605     //         m_pContentViewer, &UIHelpBrowserViewer::setSource);
    606616    connect(m_pContentWidget, &QHelpContentWidget::clicked,
    607617            this, &UIHelpBrowserWidget::sltHandleContentWidgetItemClicked);
    608     // connect(m_pIndexWidget, &QHelpIndexWidget::linkActivated,
    609     //         m_pContentViewer, &UIHelpBrowserViewer::setSource);
    610618    connect(m_pContentModel, &QHelpContentModel::contentsCreated,
    611619            this, &UIHelpBrowserWidget::sltHandleContentsCreated);
     620
    612621
    613622    if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine)
     
    826835}
    827836
    828 void UIHelpBrowserWidget::show404Error(const QUrl & /*url*/)
    829 {
    830 //     QList<QUrl> files = m_pHelpEngine->files(m_pHelpEngine->namespaceName(m_strHelpFilePath), QStringList());
    831 //     int iIndex = -1;
    832 //     for (int i = 0; i < files.size(); ++i)
    833 //     {
    834 //         if (files[i].toString().contains("index.html", Qt::CaseInsensitive))
    835 //         {
    836 //             iIndex = i;
    837 //             break;
    838 //         }
    839 //     }
    840 //     if (iIndex == -1)
    841 //     {
    842 //         /* If index html/htm could not be found try to find a html file at least: */
    843 //         for (int i = 0; i < files.size(); ++i)
    844 //         {
    845 //             if (files[i].toString().contains(".html", Qt::CaseInsensitive) ||
    846 //                 files[i].toString().contains(".htm", Qt::CaseInsensitive))
    847 //             {
    848 //                 iIndex = i;
    849 //                 break;
    850 //             }
    851 //         }
    852 //     }
    853 //     if (iIndex != -1 && files.size() > iIndex)
    854 //         return files[iIndex];
    855 //     return QUrl();
    856 // #else
    857 //     return QUrl();
    858 }
    859 
    860837void UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished()
    861838{
    862839    AssertReturnVoid(m_pTabManager && m_pHelpEngine);
    863840    m_pTabManager->initilizeTabs();
    864     /* Search for the index of the index.htnl: */
    865     // QUrl url = findIndexHtml();
    866     // if (url.isValid())
    867     //     m_pContentViewer->setSource(url);
    868     // else
    869     //     show404Error(url);
    870 }
    871 
     841}
    872842
    873843void UIHelpBrowserWidget::sltHandleContentWidgetItemClicked(const QModelIndex & index)
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r86791 r86794  
    107107    void cleanup();
    108108    QUrl findIndexHtml() const;
    109     void show404Error(const QUrl &url);
    110109    /** @name Event handling stuff.
    111110     * @{ */
    112111    /** Handles translation event. */
    113     virtual void retranslateUi() /* override */;
     112       virtual void retranslateUi() /* override */;
    114113
    115     /** Handles Qt show @a pEvent. */
    116     virtual void showEvent(QShowEvent *pEvent) /* override */;
    117     /** Handles Qt key-press @a pEvent. */
    118     virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;
     114       /** Handles Qt show @a pEvent. */
     115       virtual void showEvent(QShowEvent *pEvent) /* override */;
     116       /** Handles Qt key-press @a pEvent. */
     117       virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;
    119118    /** @} */
    120119
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