VirtualBox

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


Ignore:
Timestamp:
Oct 20, 2020 7:25:40 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Adding a menu to help browser dialog

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

Legend:

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

    r86622 r86634  
    5454#include "CSystemProperties.h"
    5555
     56enum HelpBrowserTabs
     57{
     58    HelpBrowserTabs_TOC = 0,
     59    HelpBrowserTabs_Index,
     60    HelpBrowserTabs_Bookmarks,
     61    HelpBrowserTabs_Max
     62};
     63
    5664class UIHelpBrowserViewer : public QTextBrowser
    5765{
     
    112120    , m_pSplitter(0)
    113121    , m_pMenu(0)
     122    , m_pContentWidget(0)
     123    , m_pIndexWidget(0)
     124    , m_pBookmarksWidget(0)
     125    , m_pShowHideContentsWidgetAction(0)
    114126{
    115127    prepare();
     
    139151    prepareActions();
    140152    prepareWidgets();
    141     prepareMenuAndMenuActions();
     153    prepareMenu();
    142154    retranslateUi();
    143155}
     
    145157void UIHelpBrowserWidget::prepareActions()
    146158{
    147 
     159    m_pShowHideContentsWidgetAction = new QAction(this);
     160    m_pShowHideContentsWidgetAction->setData(HelpBrowserTabs_TOC);
    148161}
    149162
     
    159172#ifdef RT_OS_LINUX
    160173    m_pHelpEngine = new QHelpEngine(m_strHelpFilePath, this);
    161 
     174    m_pBookmarksWidget = new QWidget(this);
    162175    m_pTabWidget = new QITabWidget;
    163     AssertReturnVoid(m_pTabWidget);
    164     AssertReturnVoid(m_pHelpEngine->contentWidget() && m_pHelpEngine->indexWidget());
     176    AssertReturnVoid(m_pTabWidget && m_pHelpEngine && m_pBookmarksWidget);
     177
     178    m_pContentWidget = m_pHelpEngine->contentWidget();
     179    m_pIndexWidget = m_pHelpEngine->indexWidget();
     180
     181    AssertReturnVoid(m_pContentWidget && m_pIndexWidget);
    165182    m_pSplitter->addWidget(m_pTabWidget);
    166     m_pTabWidget->addTab(m_pHelpEngine->contentWidget(), tr("Contents"));
    167     m_pTabWidget->addTab(m_pHelpEngine->indexWidget(), tr("Index"));
     183    m_pTabWidget->insertTab(HelpBrowserTabs_TOC, m_pContentWidget, QString());
     184    m_pTabWidget->insertTab(HelpBrowserTabs_Index, m_pIndexWidget, QString());
     185    m_pTabWidget->insertTab(HelpBrowserTabs_Bookmarks, m_pBookmarksWidget, QString());
    168186
    169187    m_pContentViewer = new UIHelpBrowserViewer(m_pHelpEngine);
     
    178196            this, &UIHelpBrowserWidget::sltHandleHelpEngineSetupFinished);
    179197
    180     connect(m_pHelpEngine->contentWidget(), &QHelpContentWidget::linkActivated,
     198    connect(m_pContentWidget, &QHelpContentWidget::linkActivated,
    181199            m_pContentViewer, &UIHelpBrowserViewer::setSource);
    182     connect(m_pHelpEngine->contentWidget(), &QHelpContentWidget::clicked,
     200    connect(m_pContentWidget, &QHelpContentWidget::clicked,
    183201            this, &UIHelpBrowserWidget::sltHandleContentWidgetItemClicked);
    184202
    185203
    186     connect(m_pHelpEngine->indexWidget(), &QHelpIndexWidget::linkActivated,
     204    connect(m_pIndexWidget, &QHelpIndexWidget::linkActivated,
    187205            m_pContentViewer, &UIHelpBrowserViewer::setSource);
    188206
     
    218236}
    219237
    220 void UIHelpBrowserWidget::prepareMenuAndMenuActions()
     238void UIHelpBrowserWidget::prepareMenu()
    221239{
    222240    m_pMenu = new QMenu(tr("View"), this);
     
    251269        m_pToolBar->updateLayout();
    252270#endif
     271    if (m_pTabWidget)
     272    {
     273        m_pTabWidget->setTabText(HelpBrowserTabs_TOC, tr("Contents"));
     274        m_pTabWidget->setTabText(HelpBrowserTabs_Index, tr("Index"));
     275        m_pTabWidget->setTabText(HelpBrowserTabs_Bookmarks, tr("Bookmarks"));
     276    }
     277    if (m_pShowHideContentsWidgetAction)
     278        m_pShowHideContentsWidgetAction->setText("Show/Hide Contents");
    253279}
    254280
     
    289315{
    290316#ifdef RT_OS_LINUX
    291     AssertReturnVoid(m_pContentViewer && m_pHelpEngine && m_pHelpEngine->contentWidget());
     317    AssertReturnVoid(m_pContentViewer && m_pHelpEngine && m_pContentWidget);
    292318    QHelpContentModel *pContentModel =
    293         qobject_cast<QHelpContentModel*>(m_pHelpEngine->contentWidget()->model());
     319        qobject_cast<QHelpContentModel*>(m_pContentWidget->model());
    294320    if (!pContentModel)
    295321        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserWidget.h

    r86622 r86634  
    3737
    3838/* Forward declarations: */
     39class QHBoxLayout;
    3940class QHelpEngine;
     41class QHelpContentWidget;
     42class QHelpIndexWidget;
    4043class QPlainTextEdit;
    41 class UIHelpBrowserViewer;
    42 class QHBoxLayout;
     44class QSplitter;
    4345class QITabWidget;
    4446class QIToolBar;
    4547class UIActionPool;
    4648class UIDialogPanel;
    47 class QSplitter;
     49class UIHelpBrowserViewer;
    4850
    49 /** QWidget extension providing GUI for VirtualBox LogViewer. It
    50  *  encapsulates log pages, toolbar, a tab widget and manages
    51  *  interaction between these classes. */
    5251class SHARED_LIBRARY_STUFF UIHelpBrowserWidget  : public QIWithRetranslateUI<QWidget>
    5352{
     
    6059public:
    6160
    62     /** Constructs the VM Log-Viewer by passing @a pParent to QWidget base-class constructor.
    63       * @param  enmEmbedding  Brings the type of widget embedding.
    64       * @param  fShowToolbar  Brings whether we should create/show toolbar.*/
    6561    UIHelpBrowserWidget(EmbedTo enmEmbedding, const QString &strHelpFilePath,
    6662                        bool fShowToolbar = true, QWidget *pParent = 0);
    67     /** Destructs the VM Log-Viewer. */
    6863    ~UIHelpBrowserWidget();
    6964
    70     /** Returns the menu. */
    7165    QMenu *menu() const;
    7266
    7367#ifdef VBOX_WS_MAC
    74     /** Returns the toolbar. */
    7568    QIToolBar *toolbar() const { return m_pToolBar; }
    7669#endif
     
    9386    void prepareWidgets();
    9487    void prepareToolBar();
    95     void prepareMenuAndMenuActions();
     88    void prepareMenu();
    9689    void loadOptions();
    9790
     
    135128    QSplitter           *m_pSplitter;
    136129    QMenu               *m_pMenu;
     130    QHelpContentWidget  *m_pContentWidget;
     131    QHelpIndexWidget    *m_pIndexWidget;
     132    QWidget             *m_pBookmarksWidget;
     133    QAction             *m_pShowHideContentsWidgetAction;
    137134};
    138135
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