VirtualBox

Ignore:
Timestamp:
Nov 24, 2020 9:43:55 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9831. Deriving the help dialog directly from QMainWindow

File:
1 edited

Legend:

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

    r86915 r86963  
    2323#include <QKeyEvent>
    2424#include <QLabel>
     25#include <QMenuBar>
    2526#include <QPlainTextEdit>
    2627#include <QPushButton>
     
    4142
    4243/*********************************************************************************************************************************
    43 *   Class UIHelpBrowserDialogFactory implementation.                                                                             *
    44 *********************************************************************************************************************************/
    45 
    46 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory(const QString &strHelpFilePath)
    47     : m_strHelpFilePath(strHelpFilePath)
    48 {
    49 }
    50 
    51 UIHelpBrowserDialogFactory::UIHelpBrowserDialogFactory()
    52     : m_strHelpFilePath(QString())
    53 {
    54 }
    55 
    56 void UIHelpBrowserDialogFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)
    57 {
    58     pDialog = new UIHelpBrowserDialog(pCenterWidget, m_strHelpFilePath);
    59 }
    60 
    61 
    62 /*********************************************************************************************************************************
    6344*   Class UIHelpBrowserDialog implementation.                                                                                    *
    6445*********************************************************************************************************************************/
    6546
    66 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath)
    67     : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget)
     47UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pParent, QWidget *pCenterWidget, const QString &strHelpFilePath)
     48    : QIWithRetranslateUI<QIWithRestorableGeometry<QMainWindow> >(pParent)
    6849    , m_strHelpFilePath(strHelpFilePath)
    6950    , m_pWidget(0)
     51    , m_pCenterWidget(pCenterWidget)
    7052{
     53    setAttribute(Qt::WA_DeleteOnClose);
     54    setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));
     55    prepareCentralWidget();
     56    loadSettings();
     57    retranslateUi();
     58}
     59
     60UIHelpBrowserDialog::~UIHelpBrowserDialog()
     61{
     62    saveSettings();
    7163}
    7264
     
    8476{
    8577#if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
    86     setWindowTitle(UIHelpBrowserWidget::tr("User Manual"));
    87     button(ButtonType_Close)->setText(UIHelpBrowserWidget::tr("Close"));
     78    setWindowTitle(UIHelpBrowserWidget::tr("Oracle VM VirtualBox User Manual"));
    8879#endif
    8980}
    9081
    91 void UIHelpBrowserDialog::configure()
    92 {
    93     /* Apply window icons: */
    94     setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));
    95 }
    9682
    97 void UIHelpBrowserDialog::configureCentralWidget()
     83void UIHelpBrowserDialog::prepareCentralWidget()
    9884{
    9985#if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
    10086    m_pWidget = new UIHelpBrowserWidget(EmbedTo_Dialog, m_strHelpFilePath);
    101     if (m_pWidget)
    102     {
    103         /* Configure widget: */
    104         setWidget(m_pWidget);
    105         setWidgetMenus(m_pWidget->menus());
     87    AssertPtrReturnVoid(m_pWidget);
    10688#ifdef VBOX_WS_MAC
    107         setWidgetToolbar(m_pWidget->toolbar());
     89    setWidgetToolbar(m_pWidget->toolbar());
    10890#endif
    109         connect(m_pWidget, &UIHelpBrowserWidget::sigSetCloseButtonShortCut,
    110                 this, &UIHelpBrowserDialog::sltSetCloseButtonShortCut);
     91    setCentralWidget((m_pWidget));
    11192
    112         /* Add into layout: */
    113         centralWidget()->layout()->addWidget(m_pWidget);
    114     }
     93    const QList<QMenu*> menuList = m_pWidget->menus();
     94    foreach (QMenu *pMenu, menuList)
     95        menuBar()->addMenu(pMenu);
    11596#endif
    116 }
    117 
    118 void UIHelpBrowserDialog::finalize()
    119 {
    120     /* Apply language settings: */
    121     retranslateUi();
    12297}
    12398
     
    130105
    131106    /* Load geometry from extradata: */
    132     const QRect geo = gEDataManager->helpBrowserDialogGeometry(this, centerWidget(), defaultGeo);
     107    const QRect geo = gEDataManager->helpBrowserDialogGeometry(this, m_pCenterWidget, defaultGeo);
    133108    LogRel2(("GUI: UIHelpBrowserDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n",
    134109             geo.x(), geo.y(), geo.width(), geo.height()));
     
    148123    return gEDataManager->helpBrowserDialogShouldBeMaximized();
    149124}
    150 
    151 void UIHelpBrowserDialog::sltSetCloseButtonShortCut(QKeySequence shortcut)
    152 {
    153     if (button(ButtonType_Close))
    154         button(ButtonType_Close)->setShortcut(shortcut);
    155 }
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