VirtualBox

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


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

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r86939 r86963  
    34453445    if (!m_pHelpBrowserDialog)
    34463446    {
    3447         UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath);
    3448         dialogFactory.prepare(m_pHelpBrowserDialog);
     3447        m_pHelpBrowserDialog = new UIHelpBrowserDialog(0 /* parent */, 0 /* Center Widget */, strHelpFilePath);
    34493448        AssertReturnVoid(m_pHelpBrowserDialog);
    3450         connect(m_pHelpBrowserDialog, &QIManagerDialog::sigClose,
    3451                 this, &UIMessageCenter::sltCloseHelpBrowser);
     3449        connect(m_pHelpBrowserDialog, &QMainWindow::destroyed, this, &UIMessageCenter::sltHelpBrowserClosed);
    34523450    }
    34533451
     
    34573455}
    34583456
    3459 void UIMessageCenter::sltCloseHelpBrowser()
    3460 {
    3461     QIManagerDialog* pDialog = qobject_cast<QIManagerDialog*>(sender());
    3462     if (m_pHelpBrowserDialog != pDialog || !pDialog)
    3463         return;
    3464 
     3457void UIMessageCenter::sltHelpBrowserClosed()
     3458{
    34653459    m_pHelpBrowserDialog = 0;
    3466     pDialog->close();
    3467     UIHelpBrowserDialogFactory().cleanup(pDialog);
    34683460}
    34693461
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r86928 r86963  
    3434
    3535/* Forward declarations: */
    36 class QIManagerDialog;
     36class UIHelpBrowserDialog;
    3737class UIMedium;
    3838struct StorageSlot;
     
    553553    void sltResetSuppressedMessages();
    554554    void sltShowUserManual(const QString &strLocation);
    555     void sltCloseHelpBrowser();
     555    void sltHelpBrowserClosed();
    556556    void sltHandleDialogHelpButtonPress();
    557557
     
    611611
    612612    /** Holds UIHelpBrowserDialog instance. */
    613     QIManagerDialog *m_pHelpBrowserDialog;
     613    UIHelpBrowserDialog *m_pHelpBrowserDialog;
    614614
    615615    /** Holds the singleton message-center instance. */
  • 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 }
  • trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.h

    r86913 r86963  
    4040class UIHelpBrowserWidget;
    4141
    42 /** QIManagerDialogFactory extension used as a factory for Log Viewer dialog. */
    43 class SHARED_LIBRARY_STUFF UIHelpBrowserDialogFactory : public QIManagerDialogFactory
    44 {
    45 
    46 public:
    47 
    48     /** @param strHelpFilePath: the full path of the qHelp archive file. */
    49     UIHelpBrowserDialogFactory(const QString &strHelpFilePath);
    50     UIHelpBrowserDialogFactory();
    51 
    52 protected:
    53 
    54     /** Creates derived @a pDialog instance.
    55       * @param  pCenterWidget  Brings the widget to center wrt. pCenterWidget. */
    56     virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) /* override */;
    57 
    58 private:
    59 
    60     QString m_strHelpFilePath;
    61 };
    62 
    63 class SHARED_LIBRARY_STUFF UIHelpBrowserDialog : public QIWithRetranslateUI<QIManagerDialog>
     42class SHARED_LIBRARY_STUFF UIHelpBrowserDialog : public QIWithRetranslateUI<QIWithRestorableGeometry<QMainWindow> >
    6443{
    6544    Q_OBJECT;
     
    6746public:
    6847
    69     UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath);
     48    UIHelpBrowserDialog(QWidget *pParent, QWidget *pCenterWidget, const QString &strHelpFilePath);
     49    ~UIHelpBrowserDialog();
    7050    /** A passthru function for QHelpIndexWidget::showHelpForKeyword. */
    7151    void showHelpForKeyword(const QString &strKeyword);
     
    7353protected:
    7454
    75     /** @name Event-handling stuff.
    76       * @{ */
    77         /** Handles translation event. */
    78         virtual void retranslateUi() /* override */;
    79     /** @} */
     55    /** Handles translation event. */
     56    virtual void retranslateUi() /* override */;
    8057
    8158    /** @name Prepare/cleanup cascade.
    8259     * @{ */
    83         /** Configures all. */
    84         virtual void configure() /* override */;
    85         /** Configures central-widget. */
    86         virtual void configureCentralWidget() /* override */;
    87         /** Perform final preparations. */
    88         virtual void finalize() /* override */;
    89         /** Loads dialog setting from extradata. */
     60
     61        virtual void prepareCentralWidget() /* override */;
    9062        virtual void loadSettings() /* override */;
    91 
    92         /** Saves dialog setting into extradata. */
    9363        virtual void saveSettings() /* override */;
    9464    /** @} */
    9565
    96     /** @name Functions related to geometry restoration.
    97      * @{ */
    98         /** Returns whether the window should be maximized when geometry being restored. */
    99         virtual bool shouldBeMaximized() const /* override */;
    100     /** @} */
     66    /** Returns whether the window should be maximized when geometry being restored. */
     67    virtual bool shouldBeMaximized() const /* override */;
    10168
    10269private slots:
    103 
    104     /** Must be handles soemthing related to close @a shortcut. */
    105     void sltSetCloseButtonShortCut(QKeySequence shortcut);
    10670
    10771private:
     
    10973    QString m_strHelpFilePath;
    11074    UIHelpBrowserWidget *m_pWidget;
     75    QWidget *m_pCenterWidget;
    11176};
    11277
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