VirtualBox

Changeset 86881 in vbox


Ignore:
Timestamp:
Nov 13, 2020 11:47:47 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Some context menu fixes.

File:
1 edited

Legend:

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

    r86879 r86881  
    8282static int iFontPointSizeChangeStep = 2;
    8383
     84
     85/*********************************************************************************************************************************
     86*   UIContextMenuNavigationAction definition.                                                                                    *
     87*********************************************************************************************************************************/
     88class UIContextMenuNavigationAction : public QWidgetAction
     89{
     90
     91    Q_OBJECT;
     92
     93signals:
     94
     95    void sigGoBackward();
     96    void sigGoForward();
     97    void sigGoHome();
     98    void sigAddBookmark();
     99
     100public:
     101
     102    UIContextMenuNavigationAction(QObject *pParent = 0);
     103    void setBackwardAvailable(bool fAvailable);
     104    void setForwardAvailable(bool fAvailable);
     105
     106protected:
     107
     108
     109private slots:
     110
     111
     112private:
     113
     114    void prepare();
     115    QIToolButton *m_pBackwardButton;
     116    QIToolButton *m_pForwardButton;
     117    QIToolButton *m_pHomeButton;
     118    QIToolButton *m_pAddBookmarkButton;
     119};
     120
    84121/*********************************************************************************************************************************
    85122*   UIFontScaleWidget definition.                                                                                         *
     
    229266    void sigCloseFindInPageWidget();
    230267    void sigFontPointSizeChanged(int iFontPointSize);
     268    void sigGoBackward();
     269    void sigGoForward();
     270    void sigGoHome();
     271    void sigAddBookmark();
    231272
    232273public:
     
    397438    bool m_fSwitchToNewTab;
    398439};
     440
     441
     442/*********************************************************************************************************************************
     443*   UIContextMenuNavigationAction implementation.                                                                                *
     444*********************************************************************************************************************************/
     445UIContextMenuNavigationAction::UIContextMenuNavigationAction(QObject *pParent /* = 0 */)
     446    :QWidgetAction(pParent)
     447    , m_pBackwardButton(0)
     448    , m_pForwardButton(0)
     449    , m_pHomeButton(0)
     450    , m_pAddBookmarkButton(0)
     451{
     452    prepare();
     453}
     454
     455void UIContextMenuNavigationAction::setBackwardAvailable(bool fAvailable)
     456{
     457    if (m_pBackwardButton)
     458        m_pBackwardButton->setEnabled(fAvailable);
     459}
     460
     461void UIContextMenuNavigationAction::setForwardAvailable(bool fAvailable)
     462{
     463    if (m_pForwardButton)
     464        m_pForwardButton->setEnabled(fAvailable);
     465}
     466
     467void UIContextMenuNavigationAction::prepare()
     468{
     469    QWidget *pWidget = new QWidget;
     470    setDefaultWidget(pWidget);
     471    QHBoxLayout *pMainLayout = new QHBoxLayout(pWidget);
     472    AssertReturnVoid(pMainLayout);
     473
     474    m_pBackwardButton = new QIToolButton;
     475    m_pForwardButton = new QIToolButton;
     476    m_pHomeButton = new QIToolButton;
     477    m_pAddBookmarkButton = new QIToolButton;
     478
     479    AssertReturnVoid(m_pBackwardButton &&
     480                     m_pForwardButton &&
     481                     m_pHomeButton);
     482    m_pForwardButton->setEnabled(false);
     483    m_pBackwardButton->setEnabled(false);
     484    m_pHomeButton->setIcon(UIIconPool::iconSet(":/help_browser_home_32px.png"));
     485    m_pForwardButton->setIcon(UIIconPool::iconSet(":/help_browser_forward_32px.png", ":/help_browser_forward_disabled_32px.png"));
     486    m_pBackwardButton->setIcon(UIIconPool::iconSet(":/help_browser_backward_32px.png", ":/help_browser_backward_disabled_32px.png"));
     487    m_pAddBookmarkButton->setIcon(UIIconPool::iconSet(":/help_browser_add_bookmark.png"));
     488
     489    pMainLayout->addWidget(m_pBackwardButton);
     490    pMainLayout->addWidget(m_pForwardButton);
     491    pMainLayout->addWidget(m_pHomeButton);
     492    pMainLayout->addWidget(m_pAddBookmarkButton);
     493    pMainLayout->setContentsMargins(0, 0, 0, 0);
     494    //pMainLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
     495
     496    connect(m_pBackwardButton, &QIToolButton::pressed,
     497            this, &UIContextMenuNavigationAction::sigGoBackward);
     498    connect(m_pForwardButton, &QIToolButton::pressed,
     499            this, &UIContextMenuNavigationAction::sigGoForward);
     500    connect(m_pHomeButton, &QIToolButton::pressed,
     501            this, &UIContextMenuNavigationAction::sigGoHome);
     502    connect(m_pAddBookmarkButton, &QIToolButton::pressed,
     503            this, &UIContextMenuNavigationAction::sigAddBookmark);
     504}
    399505
    400506
     
    808914    connect(m_pContentViewer, &UIHelpBrowserViewer::sigFontPointSizeChanged,
    809915            this, &UIHelpBrowserTab::sigFontPointSizeChanged);
     916    connect(m_pContentViewer, &UIHelpBrowserViewer::sigGoBackward,
     917            this, &UIHelpBrowserTab::sltHandleBackwardAction);
     918    connect(m_pContentViewer, &UIHelpBrowserViewer::sigGoForward,
     919            this, &UIHelpBrowserTab::sltHandleForwardAction);
     920    connect(m_pContentViewer, &UIHelpBrowserViewer::sigGoHome,
     921            this, &UIHelpBrowserTab::sltHandleHomeAction);
     922    connect(m_pContentViewer, &UIHelpBrowserViewer::sigAddBookmark,
     923            this, &UIHelpBrowserTab::sltHandleAddBookmarkAction);
    810924
    811925    m_pContentViewer->setSource(initialUrl, m_strPageNotFoundText);
     
    10461160{
    10471161    QMenu pMenu;
     1162
     1163    UIContextMenuNavigationAction *pNavigationActions = new UIContextMenuNavigationAction;
     1164    pNavigationActions->setBackwardAvailable(isBackwardAvailable());
     1165    pNavigationActions->setForwardAvailable(isForwardAvailable());
     1166
     1167    connect(pNavigationActions, &UIContextMenuNavigationAction::sigGoBackward,
     1168            this, &UIHelpBrowserViewer::sigGoBackward);
     1169    connect(pNavigationActions, &UIContextMenuNavigationAction::sigGoForward,
     1170            this, &UIHelpBrowserViewer::sigGoForward);
     1171    connect(pNavigationActions, &UIContextMenuNavigationAction::sigGoHome,
     1172            this, &UIHelpBrowserViewer::sigGoHome);
     1173    connect(pNavigationActions, &UIContextMenuNavigationAction::sigAddBookmark,
     1174            this, &UIHelpBrowserViewer::sigAddBookmark);
     1175
    10481176    QAction *pOpenLinkAction = new QAction(UIHelpBrowserWidget::tr("Open Link"));
    10491177    connect(pOpenLinkAction, &QAction::triggered,
     
    10541182            this, &UIHelpBrowserViewer::sltHandleOpenLinkInNewTab);
    10551183
     1184    pMenu.addAction(pNavigationActions);
    10561185    pMenu.addAction(pOpenLinkAction);
    10571186    pMenu.addAction(pOpenInNewTabAction);
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