Changeset 86963 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 24, 2020 9:43:55 AM (4 years ago)
- 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 3445 3445 if (!m_pHelpBrowserDialog) 3446 3446 { 3447 UIHelpBrowserDialogFactory dialogFactory(strHelpFilePath); 3448 dialogFactory.prepare(m_pHelpBrowserDialog); 3447 m_pHelpBrowserDialog = new UIHelpBrowserDialog(0 /* parent */, 0 /* Center Widget */, strHelpFilePath); 3449 3448 AssertReturnVoid(m_pHelpBrowserDialog); 3450 connect(m_pHelpBrowserDialog, &QIManagerDialog::sigClose, 3451 this, &UIMessageCenter::sltCloseHelpBrowser); 3449 connect(m_pHelpBrowserDialog, &QMainWindow::destroyed, this, &UIMessageCenter::sltHelpBrowserClosed); 3452 3450 } 3453 3451 … … 3457 3455 } 3458 3456 3459 void UIMessageCenter::sltCloseHelpBrowser() 3460 { 3461 QIManagerDialog* pDialog = qobject_cast<QIManagerDialog*>(sender()); 3462 if (m_pHelpBrowserDialog != pDialog || !pDialog) 3463 return; 3464 3457 void UIMessageCenter::sltHelpBrowserClosed() 3458 { 3465 3459 m_pHelpBrowserDialog = 0; 3466 pDialog->close();3467 UIHelpBrowserDialogFactory().cleanup(pDialog);3468 3460 } 3469 3461 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r86928 r86963 34 34 35 35 /* Forward declarations: */ 36 class QIManagerDialog;36 class UIHelpBrowserDialog; 37 37 class UIMedium; 38 38 struct StorageSlot; … … 553 553 void sltResetSuppressedMessages(); 554 554 void sltShowUserManual(const QString &strLocation); 555 void slt CloseHelpBrowser();555 void sltHelpBrowserClosed(); 556 556 void sltHandleDialogHelpButtonPress(); 557 557 … … 611 611 612 612 /** Holds UIHelpBrowserDialog instance. */ 613 QIManagerDialog *m_pHelpBrowserDialog;613 UIHelpBrowserDialog *m_pHelpBrowserDialog; 614 614 615 615 /** Holds the singleton message-center instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/helpbrowser/UIHelpBrowserDialog.cpp
r86915 r86963 23 23 #include <QKeyEvent> 24 24 #include <QLabel> 25 #include <QMenuBar> 25 26 #include <QPlainTextEdit> 26 27 #include <QPushButton> … … 41 42 42 43 /********************************************************************************************************************************* 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 /*********************************************************************************************************************************63 44 * Class UIHelpBrowserDialog implementation. * 64 45 *********************************************************************************************************************************/ 65 46 66 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *p CenterWidget, const QString &strHelpFilePath)67 : QIWithRetranslateUI<QI ManagerDialog>(pCenterWidget)47 UIHelpBrowserDialog::UIHelpBrowserDialog(QWidget *pParent, QWidget *pCenterWidget, const QString &strHelpFilePath) 48 : QIWithRetranslateUI<QIWithRestorableGeometry<QMainWindow> >(pParent) 68 49 , m_strHelpFilePath(strHelpFilePath) 69 50 , m_pWidget(0) 51 , m_pCenterWidget(pCenterWidget) 70 52 { 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 60 UIHelpBrowserDialog::~UIHelpBrowserDialog() 61 { 62 saveSettings(); 71 63 } 72 64 … … 84 76 { 85 77 #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")); 88 79 #endif 89 80 } 90 81 91 void UIHelpBrowserDialog::configure()92 {93 /* Apply window icons: */94 setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));95 }96 82 97 void UIHelpBrowserDialog:: configureCentralWidget()83 void UIHelpBrowserDialog::prepareCentralWidget() 98 84 { 99 85 #if defined(RT_OS_LINUX) && defined(VBOX_WITH_DOCS_QHELP) && (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) 100 86 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); 106 88 #ifdef VBOX_WS_MAC 107 89 setWidgetToolbar(m_pWidget->toolbar()); 108 90 #endif 109 connect(m_pWidget, &UIHelpBrowserWidget::sigSetCloseButtonShortCut, 110 this, &UIHelpBrowserDialog::sltSetCloseButtonShortCut); 91 setCentralWidget((m_pWidget)); 111 92 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); 115 96 #endif 116 }117 118 void UIHelpBrowserDialog::finalize()119 {120 /* Apply language settings: */121 retranslateUi();122 97 } 123 98 … … 130 105 131 106 /* Load geometry from extradata: */ 132 const QRect geo = gEDataManager->helpBrowserDialogGeometry(this, centerWidget(), defaultGeo);107 const QRect geo = gEDataManager->helpBrowserDialogGeometry(this, m_pCenterWidget, defaultGeo); 133 108 LogRel2(("GUI: UIHelpBrowserDialog: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n", 134 109 geo.x(), geo.y(), geo.width(), geo.height())); … … 148 123 return gEDataManager->helpBrowserDialogShouldBeMaximized(); 149 124 } 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 40 40 class UIHelpBrowserWidget; 41 41 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> 42 class SHARED_LIBRARY_STUFF UIHelpBrowserDialog : public QIWithRetranslateUI<QIWithRestorableGeometry<QMainWindow> > 64 43 { 65 44 Q_OBJECT; … … 67 46 public: 68 47 69 UIHelpBrowserDialog(QWidget *pCenterWidget, const QString &strHelpFilePath); 48 UIHelpBrowserDialog(QWidget *pParent, QWidget *pCenterWidget, const QString &strHelpFilePath); 49 ~UIHelpBrowserDialog(); 70 50 /** A passthru function for QHelpIndexWidget::showHelpForKeyword. */ 71 51 void showHelpForKeyword(const QString &strKeyword); … … 73 53 protected: 74 54 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 */; 80 57 81 58 /** @name Prepare/cleanup cascade. 82 59 * @{ */ 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 */; 90 62 virtual void loadSettings() /* override */; 91 92 /** Saves dialog setting into extradata. */93 63 virtual void saveSettings() /* override */; 94 64 /** @} */ 95 65 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 */; 101 68 102 69 private slots: 103 104 /** Must be handles soemthing related to close @a shortcut. */105 void sltSetCloseButtonShortCut(QKeySequence shortcut);106 70 107 71 private: … … 109 73 QString m_strHelpFilePath; 110 74 UIHelpBrowserWidget *m_pWidget; 75 QWidget *m_pCenterWidget; 111 76 }; 112 77
Note:
See TracChangeset
for help on using the changeset viewer.