VirtualBox

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


Ignore:
Timestamp:
May 31, 2021 5:20:54 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Adding the navigation menu

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

Legend:

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

    r89390 r89409  
    214214
    215215    void sltFindInPageAction(bool fToggled);
    216 
    217 private slots:
    218 
    219216    void sltHomeAction();
    220217    void sltForwardAction();
    221218    void sltBackwardAction();
     219    void sltAddBookmarkAction();
     220    void sltReloadPageAction();
     221
     222private slots:
     223
    222224    void sltHistoryChanged();
    223225    void sltAddressBarIndexChanged(int index);
    224     void sltAddBookmarkAction();
    225226    void sltAnchorClicked(const QUrl &link);
    226227    void sltFindInPageWidgetVisibilityChanged(bool  fVisible);
    227     void sltReloadPageAction();
    228228
    229229private:
     
    303303    void sltCloseOtherTabs();
    304304    void sltZoomOperation(UIHelpViewer::ZoomOperation enmZoomOperation);
     305    void sltHomeAction();
     306    void sltAddBookmarkAction();
     307    void sltForwardAction();
     308    void sltBackwardAction();
     309    void sltReloadPageAction();
    305310
    306311private slots:
    307312
    308     void slttabTitleChange(const QString &strTitle);
     313    void sltTabTitleChange(const QString &strTitle);
    309314    void sltOpenLinkInNewTab(const QUrl &url, bool fBackground);
    310315    void sltTabClose(int iTabIndex);
     
    549554    , m_pAddBookmarkAction(0)
    550555    , m_pFindInPageAction(0)
     556    , m_pReloadPageAction(0)
    551557    , m_pMainLayout(0)
    552558    , m_pToolBar(0)
     
    768774{
    769775    setActionTextAndToolTip(m_pHomeAction, tr("Home"), tr("Return to Start Page"));
    770     setActionTextAndToolTip(m_pBackwardAction, tr("Backward"), tr("Navigate to Previous Page"));
    771     setActionTextAndToolTip(m_pForwardAction, tr("Forward"), tr("Navigate to Next Page"));
    772     setActionTextAndToolTip(m_pAddBookmarkAction, tr("Bookmark"), tr("Add a New Bookmark"));
     776    setActionTextAndToolTip(m_pBackwardAction, tr("Backward"), tr("Go Back to Previous Page"));
     777    setActionTextAndToolTip(m_pForwardAction, tr("Forward"), tr("Go Froward to Next Page"));
     778    setActionTextAndToolTip(m_pAddBookmarkAction, tr("Add Bookmark"), tr("Add a New Bookmark"));
     779    setActionTextAndToolTip(m_pReloadPageAction, tr("Reload"), tr("Reload the Current Page"));
    773780    setActionTextAndToolTip(m_pFindInPageAction, tr("Find in Page"), tr("Find a String in the Current Page"));
    774781}
     
    906913            this, &UIHelpBrowserTabManager::sigSourceChanged);
    907914    connect(pTabWidget, &UIHelpBrowserTab::sigTitleUpdate,
    908             this, &UIHelpBrowserTabManager::slttabTitleChange);
     915            this, &UIHelpBrowserTabManager::sltTabTitleChange);
    909916    connect(pTabWidget, &UIHelpBrowserTab::sigOpenLinkInNewTab,
    910917            this, &UIHelpBrowserTabManager::sltOpenLinkInNewTab);
     
    11271134}
    11281135
    1129 void UIHelpBrowserTabManager::slttabTitleChange(const QString &strTitle)
     1136void UIHelpBrowserTabManager::sltTabTitleChange(const QString &strTitle)
    11301137{
    11311138    for (int i = 0; i < count(); ++i)
     
    12311238
    12321239    menu.exec(tabBar()->mapToGlobal(pos));
     1240}
     1241
     1242void UIHelpBrowserTabManager::sltHomeAction()
     1243{
     1244    UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
     1245    if (pTab)
     1246        pTab->sltHomeAction();
     1247}
     1248
     1249void UIHelpBrowserTabManager::sltAddBookmarkAction()
     1250{
     1251    UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
     1252    if (pTab)
     1253        pTab->sltAddBookmarkAction();
     1254}
     1255
     1256void UIHelpBrowserTabManager::sltForwardAction()
     1257{
     1258    UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
     1259    if (pTab)
     1260        pTab->sltForwardAction();
     1261}
     1262
     1263void UIHelpBrowserTabManager::sltBackwardAction()
     1264{
     1265    UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
     1266    if (pTab)
     1267        pTab->sltBackwardAction();
     1268}
     1269
     1270void UIHelpBrowserTabManager::sltReloadPageAction()
     1271{
     1272    UIHelpBrowserTab *pTab = qobject_cast<UIHelpBrowserTab*>(currentWidget());
     1273    if (pTab)
     1274        pTab->sltReloadPageAction();
    12331275}
    12341276
     
    12771319    , m_pViewMenu(0)
    12781320    , m_pTabsMenu(0)
     1321    , m_pNavigationMenu(0)
    12791322    , m_pContentWidget(0)
    12801323    , m_pIndexWidget(0)
     
    12941337    , m_pFindNextInPageAction(0)
    12951338    , m_pFindPreviousInPageAction(0)
     1339    , m_pBackwardAction(0)
     1340    , m_pForwardAction(0)
     1341    , m_pHomeAction(0)
     1342    , m_pReloadPageAction(0)
     1343    , m_pAddBookmarkAction(0)
    12961344    , m_pZoomMenuAction(0)
    12971345    , m_fModelContentCreated(false)
     
    13141362        << m_pFileMenu
    13151363        << m_pEditMenu
     1364        << m_pNavigationMenu
    13161365        << m_pViewMenu
    13171366        << m_pTabsMenu;
     
    13521401    prepareMenu();
    13531402    prepareWidgets();
     1403    prepareConnections();
    13541404    prepareSearchWidgets();
    13551405    loadBookmarks();
     
    14111461    m_pQuitAction->setShortcut(QString("Ctrl+Q"));
    14121462
     1463    m_pBackwardAction = new QAction(this);
     1464    connect(m_pBackwardAction, &QAction::triggered,
     1465            this, &UIHelpBrowserWidget::sigGoBackward);
     1466
     1467    m_pForwardAction = new QAction(this);
     1468    connect(m_pForwardAction, &QAction::triggered,
     1469            this, &UIHelpBrowserWidget::sigGoForward);
     1470
     1471    m_pHomeAction = new QAction(this);
     1472    connect(m_pHomeAction, &QAction::triggered,
     1473            this, &UIHelpBrowserWidget::sigGoHome);
     1474
     1475    m_pReloadPageAction = new QAction(this);
     1476    connect(m_pReloadPageAction, &QAction::triggered,
     1477            this, &UIHelpBrowserWidget::sigReloadPage);
     1478
     1479    m_pAddBookmarkAction = new QAction(this);
     1480    connect(m_pAddBookmarkAction, &QAction::triggered,
     1481            this, &UIHelpBrowserWidget::sigAddBookmark);
     1482
    14131483    m_pZoomMenuAction = new UIZoomMenuAction(this);
    14141484    connect(m_pZoomMenuAction, &UIZoomMenuAction::sigZoomChanged,
    14151485            this, &UIHelpBrowserWidget::sltZoomActions);
     1486}
     1487
     1488void UIHelpBrowserWidget::prepareConnections()
     1489{
     1490    if (m_pTabManager)
     1491    {
     1492        connect(m_pHomeAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltHomeAction);
     1493        connect(m_pAddBookmarkAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltAddBookmarkAction);
     1494        connect(m_pForwardAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltForwardAction);
     1495        connect(m_pBackwardAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltBackwardAction);
     1496        connect(m_pReloadPageAction, &QAction::triggered, m_pTabManager, &UIHelpBrowserTabManager::sltReloadPageAction);
     1497    }
    14161498}
    14171499
     
    15561638    m_pFileMenu = new QMenu(tr("&File"), this);
    15571639    m_pEditMenu = new QMenu(tr("&Edit"), this);
     1640    m_pNavigationMenu = new QMenu(tr("&Navigation"), this);
    15581641    m_pViewMenu = new QMenu(tr("&View"), this);
    15591642    m_pTabsMenu = new QMenu(tr("&Tabs"), this);
    15601643
    1561     AssertReturnVoid(m_pFileMenu && m_pViewMenu && m_pTabsMenu);
    1562 
    1563     if (m_pPrintAction)
    1564         m_pFileMenu->addAction(m_pPrintAction);
    1565     if (m_pQuitAction)
    1566         m_pFileMenu->addAction(m_pQuitAction);
    1567 
    1568     if (m_pCopySelectedTextAction)
    1569         m_pEditMenu->addAction(m_pCopySelectedTextAction);
    1570     if(m_pFindInPageAction)
    1571         m_pEditMenu->addAction(m_pFindInPageAction);
    1572     if(m_pFindNextInPageAction)
    1573         m_pEditMenu->addAction(m_pFindNextInPageAction);
    1574     if(m_pFindPreviousInPageAction)
    1575         m_pEditMenu->addAction(m_pFindPreviousInPageAction);
    1576 
    1577     if (m_pZoomMenuAction)
    1578         m_pViewMenu->addAction(m_pZoomMenuAction);
    1579     if (m_pShowHideSideBarAction)
    1580         m_pViewMenu->addAction(m_pShowHideSideBarAction);
    1581     if (m_pShowHideToolBarAction)
    1582         m_pViewMenu->addAction(m_pShowHideToolBarAction);
    1583     if (m_pShowHideStatusBarAction)
    1584         m_pViewMenu->addAction(m_pShowHideStatusBarAction);
     1644    AssertReturnVoid(m_pFileMenu && m_pViewMenu &&
     1645                     m_pTabsMenu && m_pNavigationMenu);
     1646
     1647    addActionToMenu(m_pFileMenu, m_pPrintAction);
     1648    addActionToMenu(m_pFileMenu, m_pQuitAction);
     1649
     1650    addActionToMenu(m_pEditMenu, m_pCopySelectedTextAction);
     1651    addActionToMenu(m_pEditMenu, m_pFindInPageAction);
     1652    addActionToMenu(m_pEditMenu, m_pFindNextInPageAction);
     1653    addActionToMenu(m_pEditMenu, m_pFindPreviousInPageAction);
     1654
     1655    addActionToMenu(m_pViewMenu, m_pZoomMenuAction);
     1656    addActionToMenu(m_pViewMenu, m_pShowHideSideBarAction);
     1657    addActionToMenu(m_pViewMenu, m_pShowHideToolBarAction);
     1658    addActionToMenu(m_pViewMenu, m_pShowHideStatusBarAction);
     1659
     1660    addActionToMenu(m_pNavigationMenu, m_pBackwardAction);
     1661    addActionToMenu(m_pNavigationMenu, m_pForwardAction);
     1662    addActionToMenu(m_pNavigationMenu, m_pHomeAction);
     1663    addActionToMenu(m_pNavigationMenu, m_pReloadPageAction);
     1664    addActionToMenu(m_pNavigationMenu, m_pAddBookmarkAction);
    15851665}
    15861666
     
    17191799    if (m_pFindPreviousInPageAction)
    17201800        m_pFindPreviousInPageAction->setText(tr("&Find Previous"));
     1801
     1802    if (m_pBackwardAction)
     1803        m_pBackwardAction->setText(tr("Go Backward"));
     1804    if (m_pForwardAction)
     1805        m_pForwardAction->setText(tr("Go Forward"));
     1806    if (m_pHomeAction)
     1807        m_pHomeAction->setText(tr("Go to Start Page"));
     1808    if (m_pReloadPageAction)
     1809        m_pReloadPageAction->setText(tr("Reload Page"));
     1810    if (m_pAddBookmarkAction)
     1811        m_pAddBookmarkAction->setText(tr("Add Bookmark"));
    17211812}
    17221813
     
    20902181}
    20912182
     2183void UIHelpBrowserWidget::addActionToMenu(QMenu *pMenu, QAction *pAction)
     2184{
     2185    if (!pMenu || !pAction)
     2186        return;
     2187    pMenu->addAction(pAction);
     2188}
    20922189
    20932190#include "UIHelpBrowserWidget.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r89318 r89409  
    5959    void sigStatusBarVisible(bool fToggled);
    6060    void sigZoomPercentageChanged(int iPercentage);
     61    void sigGoBackward();
     62    void sigGoForward();
     63    void sigGoHome();
     64    void sigReloadPage();
     65    void sigAddBookmark();
    6166
    6267public:
     
    114119    void prepareToolBar();
    115120    void prepareMenu();
     121    void prepareConnections();
     122
    116123    void loadOptions();
    117124    QStringList loadSavedUrlList();
     
    139146    /* Looks for Url for the keyword using QHelpEngine API and shows it in a new tab whne successful. */
    140147    void findAndShowUrlForKeyword(const QString &strKeyword);
     148    void addActionToMenu(QMenu *pMenu, QAction *pAction);
    141149
    142150    /** Holds the widget's embedding type. */
     
    163171    QMenu               *m_pViewMenu;
    164172    QMenu               *m_pTabsMenu;
     173    QMenu               *m_pNavigationMenu;
    165174    QHelpContentWidget  *m_pContentWidget;
    166175    QHelpIndexWidget    *m_pIndexWidget;
     
    171180    UIHelpBrowserTabManager  *m_pTabManager;
    172181    UIBookmarksListContainer *m_pBookmarksWidget;
    173     QWidget             *m_pSearchContainerWidget;
    174     QAction             *m_pPrintAction;
    175     QAction             *m_pQuitAction;
    176     QAction             *m_pShowHideSideBarAction;
    177     QAction             *m_pShowHideToolBarAction;
    178     QAction             *m_pShowHideStatusBarAction;
    179     QAction             *m_pCopySelectedTextAction;
    180     QAction             *m_pFindInPageAction;
    181     QAction             *m_pFindNextInPageAction;
    182     QAction             *m_pFindPreviousInPageAction;
     182    QWidget *m_pSearchContainerWidget;
     183    QAction *m_pPrintAction;
     184    QAction *m_pQuitAction;
     185    QAction *m_pShowHideSideBarAction;
     186    QAction *m_pShowHideToolBarAction;
     187    QAction *m_pShowHideStatusBarAction;
     188    QAction *m_pCopySelectedTextAction;
     189    QAction *m_pFindInPageAction;
     190    QAction *m_pFindNextInPageAction;
     191    QAction *m_pFindPreviousInPageAction;
     192    QAction *m_pBackwardAction;
     193    QAction *m_pForwardAction;
     194    QAction *m_pHomeAction;
     195    QAction *m_pReloadPageAction;
     196    QAction *m_pAddBookmarkAction;
     197
    183198    UIZoomMenuAction    *m_pZoomMenuAction;
    184199
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.cpp

    r89390 r89409  
    7070    void sigGoForward();
    7171    void sigGoHome();
     72    void sigReloadPage();
    7273    void sigAddBookmark();
    7374
     
    8485    QIToolButton *m_pForwardButton;
    8586    QIToolButton *m_pHomeButton;
     87    QIToolButton *m_pReloadPageButton;
    8688    QIToolButton *m_pAddBookmarkButton;
    8789};
     
    135137    , m_pForwardButton(0)
    136138    , m_pHomeButton(0)
     139    , m_pReloadPageButton(0)
    137140    , m_pAddBookmarkButton(0)
    138141{
     
    162165    m_pForwardButton = new QIToolButton;
    163166    m_pHomeButton = new QIToolButton;
     167    m_pReloadPageButton = new QIToolButton;
    164168    m_pAddBookmarkButton = new QIToolButton;
    165169
    166170    AssertReturnVoid(m_pBackwardButton &&
    167171                     m_pForwardButton &&
    168                      m_pHomeButton);
     172                     m_pHomeButton &&
     173                     m_pReloadPageButton);
     174
    169175    m_pForwardButton->setEnabled(false);
    170176    m_pBackwardButton->setEnabled(false);
    171177    m_pHomeButton->setIcon(UIIconPool::iconSet(":/help_browser_home_32px.png"));
     178    m_pReloadPageButton->setIcon(UIIconPool::iconSet(":/help_browser_reload_32px.png"));
    172179    m_pForwardButton->setIcon(UIIconPool::iconSet(":/help_browser_forward_32px.png", ":/help_browser_forward_disabled_32px.png"));
    173180    m_pBackwardButton->setIcon(UIIconPool::iconSet(":/help_browser_backward_32px.png", ":/help_browser_backward_disabled_32px.png"));
     
    177184    pMainLayout->addWidget(m_pForwardButton);
    178185    pMainLayout->addWidget(m_pHomeButton);
     186    pMainLayout->addWidget(m_pReloadPageButton);
    179187    pMainLayout->addWidget(m_pAddBookmarkButton);
    180188    pMainLayout->setContentsMargins(0, 0, 0, 0);
     
    186194    connect(m_pHomeButton, &QIToolButton::pressed,
    187195            this, &UIContextMenuNavigationAction::sigGoHome);
     196    connect(m_pReloadPageButton, &QIToolButton::pressed,
     197            this, &UIContextMenuNavigationAction::sigReloadPage);
    188198    connect(m_pAddBookmarkButton, &QIToolButton::pressed,
     199            this, &UIContextMenuNavigationAction::sigAddBookmark);
     200    connect(m_pReloadPageButton, &QIToolButton::pressed,
    189201            this, &UIContextMenuNavigationAction::sigAddBookmark);
    190202}
     
    545557    connect(pNavigationActions, &UIContextMenuNavigationAction::sigGoHome,
    546558            this, &UIHelpViewer::sigGoHome);
     559    connect(pNavigationActions, &UIContextMenuNavigationAction::sigReloadPage,
     560            this, &UIHelpViewer::reload);
    547561    connect(pNavigationActions, &UIContextMenuNavigationAction::sigAddBookmark,
    548562            this, &UIHelpViewer::sigAddBookmark);
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpViewer.h

    r89390 r89409  
    7676    static const QPair<int, int> zoomPercentageMinMax;
    7777    void toggleFindInPageWidget(bool fVisible);
    78     void reload();
    7978
    8079public slots:
     
    8281    void sltSelectPreviousMatch();
    8382    void sltSelectNextMatch();
     83    virtual void reload() /* overload */;
    8484
    8585protected:
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