VirtualBox

Changeset 86807 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 4, 2020 2:22:52 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Adding a context menu to the search results widget

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

Legend:

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

    r86806 r86807  
    739739    connect(m_pHelpEngine, &QHelpEngine::setupFinished,
    740740            this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished);
    741     // if (m_pContentWidget->selectionModel())
    742     //     connect(m_pContentWidget->selectionModel(), &QItemSelectionModel::selectionChanged,
    743     //             this, &UIHelpBrowserWidget::sltHandleContentWidgetSelectionChanged);
    744741    connect(m_pContentWidget, &QHelpContentWidget::clicked,
    745742            this, &UIHelpBrowserWidget::sltHandleContentWidgetItemClicked);
     
    747744            this, &UIHelpBrowserWidget::sltHandleContentsCreated);
    748745    connect(m_pContentWidget, &QHelpContentWidget::customContextMenuRequested,
    749             this, &UIHelpBrowserWidget::sltOpenLinksContextMenu);
     746            this, &UIHelpBrowserWidget::sltShowLinksContextMenu);
    750747
    751748    if (QFile(m_strHelpFilePath).exists() && m_pHelpEngine)
     
    766763    m_pSearchResultWidget = m_pSearchEngine->resultWidget();
    767764    AssertReturnVoid(m_pSearchQueryWidget && m_pSearchResultWidget);
     765    m_pSearchResultWidget->setContextMenuPolicy(Qt::CustomContextMenu);
    768766
    769767    QVBoxLayout *pSearchLayout = new QVBoxLayout(m_pSearchContainerWidget);
     
    774772    connect(m_pSearchQueryWidget, &QHelpSearchQueryWidget::search,
    775773            this, &UIHelpBrowserWidget::sltHandleSearchStart);
    776     // connect(m_pSearchResultWidget, &QHelpSearchResultWidget::requestShowLink,
    777     //         m_pContentViewer, &UIHelpBrowserViewer::setSource);
     774    connect(m_pSearchResultWidget, &QHelpSearchResultWidget::requestShowLink,
     775            this, &UIHelpBrowserWidget::sltOpenLinkWithUrl);
     776    connect(m_pSearchResultWidget, &QHelpContentWidget::customContextMenuRequested,
     777            this, &UIHelpBrowserWidget::sltShowLinksContextMenu);
    778778
    779779    // connect(searchEngine, &QHelpSearchEngine::searchingStarted,
     
    993993}
    994994
    995 void UIHelpBrowserWidget::sltHandleContentWidgetSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
    996 {
    997     Q_UNUSED(deselected);
    998     QModelIndexList selectedItemIndices = selected.indexes();
    999     if (selectedItemIndices.isEmpty())
    1000         return;
    1001     sltHandleContentWidgetItemClicked(selectedItemIndices[0]);
    1002 }
    1003 
    1004995void UIHelpBrowserWidget::sltHandleHelpBrowserViewerSourceChange(const QUrl &source)
    1005996{
     
    10521043}
    10531044
    1054 void UIHelpBrowserWidget::sltOpenLinksContextMenu(const QPoint &pos)
     1045void UIHelpBrowserWidget::sltShowLinksContextMenu(const QPoint &pos)
    10551046{
    10561047    QWidget *pSender = qobject_cast<QWidget*>(sender());
     
    10591050
    10601051    QUrl url;
    1061 
    10621052    if (pSender == m_pContentWidget)
    10631053        url = contentWidgetUrl(m_pContentWidget->currentIndex());
     1054    else if (pSender == m_pSearchResultWidget)
     1055    {
     1056        QTextBrowser* browser = m_pSearchResultWidget->findChild<QTextBrowser*>();
     1057        if (!browser)
     1058            return;
     1059        if (!browser->rect().contains(pos, true))
     1060            return;
     1061        QPoint browserPos = browser->mapFromGlobal(m_pSearchResultWidget->mapToGlobal(pos));
     1062        printf("pos %d %d\n", pos.x(), pos.y());
     1063        url = browser->anchorAt(browserPos);
     1064    }
    10641065
    10651066    if (!url.isValid())
     
    10991100}
    11001101
     1102void UIHelpBrowserWidget::sltOpenLinkWithUrl(const QUrl &url)
     1103{
     1104    if (m_pTabManager && url.isValid())
     1105        m_pTabManager->setSource(url, false);
     1106}
    11011107#include "UIHelpBrowserWidget.moc"
    11021108
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r86806 r86807  
    8686    void sltHandleHelpEngineSetupFinished();
    8787    void sltHandleContentWidgetItemClicked(const QModelIndex &index);
    88     void sltHandleContentWidgetSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
    8988    void sltHandleSideBarVisibility(bool togggled);
    9089    void sltHandleToolBarVisibility(bool togggled);
     
    9594    void sltHandleSearchStart();
    9695    void sltHandleHelpBrowserViewerSourceChange(const QUrl &source);
    97     void sltOpenLinksContextMenu(const QPoint &pos);
     96    void sltOpenLinkWithUrl(const QUrl &url);
     97    void sltShowLinksContextMenu(const QPoint &pos);
    9898    void sltOpenLinkInNewTab();
    9999    void sltOpenLink();
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