VirtualBox

Changeset 92289 in vbox for trunk/src


Ignore:
Timestamp:
Nov 9, 2021 12:48:18 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148135
Message:

FE/Qt: bugref:10141. Splitting Viso creator widget and dialog into different classes.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium/viso
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r92270 r92289  
    3939#endif
    4040
    41 UIVisoCreatorDialog::UIVisoCreatorDialog(QWidget *pParent /* =0 */, const QString& strMachineName /* = QString() */)
    42     : QIWithRetranslateUI<QIMainDialog>(pParent)
     41/*********************************************************************************************************************************
     42*   UIVisoCreatorWidget implementation.                                                                                        *
     43*********************************************************************************************************************************/
     44
     45UIVisoCreatorWidget::UIVisoCreatorWidget(QWidget *pParent /* =0 */, const QString& strMachineName /* = QString() */)
     46    : QIWithRetranslateUI<QWidget>(pParent)
    4347    , m_pActionConfiguration(0)
    4448    , m_pActionOptions(0)
     
    5155    , m_pHostBrowser(0)
    5256    , m_pVisoBrowser(0)
    53     , m_pButtonBox(0)
    5457    , m_pToolBar(0)
    5558    , m_pVerticalToolBar(0)
    56     , m_pCentralWidget(0)
    5759    , m_pMainMenu(0)
    5860    , m_strMachineName(strMachineName)
     
    6971}
    7072
    71 QStringList UIVisoCreatorDialog::entryList() const
     73QStringList UIVisoCreatorWidget::entryList() const
    7274{
    7375    if (!m_pVisoBrowser)
     
    7678}
    7779
    78 const QString &UIVisoCreatorDialog::visoName() const
     80const QString &UIVisoCreatorWidget::visoName() const
    7981{
    8082    return m_visoOptions.m_strVisoName;
    8183}
    8284
    83 const QStringList &UIVisoCreatorDialog::customOptions() const
     85const QStringList &UIVisoCreatorWidget::customOptions() const
    8486{
    8587    return m_visoOptions.m_customOptions;
    8688}
    8789
    88 QString UIVisoCreatorDialog::currentPath() const
     90QString UIVisoCreatorWidget::currentPath() const
    8991{
    9092    if (!m_pHostBrowser)
     
    9395}
    9496
    95 void UIVisoCreatorDialog::setCurrentPath(const QString &strPath)
     97void UIVisoCreatorWidget::setCurrentPath(const QString &strPath)
    9698{
    9799    if (!m_pHostBrowser)
     
    100102}
    101103
    102 void UIVisoCreatorDialog::retranslateUi()
    103 {
    104     if (!m_strMachineName.isEmpty())
    105         setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("VISO Creator")));
    106     else
    107         setWindowTitle(QString("%1").arg(tr("VISO Creator")));
     104void UIVisoCreatorWidget::retranslateUi()
     105{
    108106    if (m_pActionConfiguration)
    109107    {
     
    144142    if (m_pRenameAction)
    145143        m_pRenameAction->setToolTip(QApplication::translate("UIVisoCreator", "Rename the selected object"));
    146     if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Ok))
    147     {
    148         m_pButtonBox->button(QDialogButtonBox::Ok)->setText(QApplication::translate("UIVisoCreator", "C&reate"));
    149         m_pButtonBox->button(QDialogButtonBox::Ok)->setToolTip(QApplication::translate("UIVisoCreator", "Creates VISO file with the selected content"));
    150     }
    151     if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Help))
    152         m_pButtonBox->button(QDialogButtonBox::Help)->setToolTip(QApplication::translate("UIVisoCreator", "Opens the help browser and navigates to the related section"));
    153 }
    154 
    155 void UIVisoCreatorDialog::sltHandleAddObjectsToViso(QStringList pathList)
     144}
     145
     146void UIVisoCreatorWidget::sltHandleAddObjectsToViso(QStringList pathList)
    156147{
    157148    if (m_pVisoBrowser)
     
    159150}
    160151
    161 void UIVisoCreatorDialog::sltPanelActionToggled(bool fChecked)
     152void UIVisoCreatorWidget::sltPanelActionToggled(bool fChecked)
    162153{
    163154    QAction *pSenderAction = qobject_cast<QAction*>(sender());
     
    180171}
    181172
    182 void UIVisoCreatorDialog::sltHandleVisoNameChanged(const QString &strVisoName)
     173void UIVisoCreatorWidget::sltHandleVisoNameChanged(const QString &strVisoName)
    183174{
    184175    if (m_visoOptions.m_strVisoName == strVisoName)
     
    189180}
    190181
    191 void UIVisoCreatorDialog::sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions)
     182void UIVisoCreatorWidget::sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions)
    192183{
    193184    if (m_visoOptions.m_customOptions == customVisoOptions)
     
    196187}
    197188
    198 void UIVisoCreatorDialog::sltHandleShowHiddenObjectsChange(bool fShow)
     189void UIVisoCreatorWidget::sltHandleShowHiddenObjectsChange(bool fShow)
    199190{
    200191    if (m_browserOptions.m_fShowHiddenObjects == fShow)
     
    204195}
    205196
    206 void UIVisoCreatorDialog::sltHandleHidePanel(UIDialogPanel *pPanel)
     197void UIVisoCreatorWidget::sltHandleHidePanel(UIDialogPanel *pPanel)
    207198{
    208199    hidePanel(pPanel);
    209200}
    210201
    211 void UIVisoCreatorDialog::sltHandleBrowserTreeViewVisibilityChanged(bool fVisible)
     202void UIVisoCreatorWidget::sltHandleBrowserTreeViewVisibilityChanged(bool fVisible)
    212203{
    213204    Q_UNUSED(fVisible);
     
    215206}
    216207
    217 void UIVisoCreatorDialog::sltHandleHostBrowserTableSelectionChanged(bool fIsSelectionEmpty)
     208void UIVisoCreatorWidget::sltHandleHostBrowserTableSelectionChanged(bool fIsSelectionEmpty)
    218209{
    219210    if (m_pAddAction)
     
    221212}
    222213
    223 void UIVisoCreatorDialog::sltHandleContentBrowserTableSelectionChanged(bool fIsSelectionEmpty)
     214void UIVisoCreatorWidget::sltHandleContentBrowserTableSelectionChanged(bool fIsSelectionEmpty)
    224215{
    225216    if (m_pRemoveAction)
     
    227218}
    228219
    229 void UIVisoCreatorDialog::sltHandleShowContextMenu(const QWidget *pContextMenuRequester, const QPoint &point)
     220void UIVisoCreatorWidget::sltHandleShowContextMenu(const QWidget *pContextMenuRequester, const QPoint &point)
    230221{
    231222    if (!pContextMenuRequester)
     
    248239}
    249240
    250 void UIVisoCreatorDialog::prepareWidgets()
    251 {
    252     m_pCentralWidget = new QWidget;
    253     if (!m_pCentralWidget)
    254         return;
    255     setCentralWidget(m_pCentralWidget);
    256 
    257     m_pMainLayout = new QGridLayout;
    258     m_pCentralWidget->setLayout(m_pMainLayout);
    259     if (!m_pMainLayout || !menuBar())
     241void UIVisoCreatorWidget::prepareWidgets()
     242{
     243    m_pMainLayout = new QGridLayout(this);
     244    if (!m_pMainLayout)
    260245        return;
    261246
     
    272257#endif
    273258
    274     m_pMainMenu = menuBar()->addMenu(tr("VISO"));
    275     if (m_pActionConfiguration)
    276         m_pMainMenu->addAction(m_pActionConfiguration);
    277     if (m_pActionOptions)
    278         m_pMainMenu->addAction(m_pActionOptions);
    279 
    280     m_pToolBar = new QIToolBar;
    281     if (m_pToolBar)
    282     {
    283         /* Configure toolbar: */
    284         const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize));
    285         m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
    286         m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    287         m_pMainLayout->addWidget(m_pToolBar, 0, 0, 1, 5);
    288     }
     259    // m_pMainMenu = menuBar()->addMenu(tr("VISO"));
     260
     261    // if (m_pActionConfiguration)
     262    //     m_pMainMenu->addAction(m_pActionConfiguration);
     263    // if (m_pActionOptions)
     264    //     m_pMainMenu->addAction(m_pActionOptions);
     265
     266    // m_pToolBar = new QIToolBar;
     267    // if (m_pToolBar)
     268    // {
     269    //     /* Configure toolbar: */
     270    //     const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize));
     271    //     m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
     272    //     m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     273    //     m_pMainLayout->addWidget(m_pToolBar, 0, 0, 1, 5);
     274    // }
    289275
    290276    m_pHostBrowser = new UIVisoHostBrowser;
    291277    if (m_pHostBrowser)
    292278    {
    293         m_pMainLayout->addWidget(m_pHostBrowser, 1, 0, 1, 2);
     279        m_pMainLayout->addWidget(m_pHostBrowser, 0, 0, 1, 2);
    294280        m_pMainLayout->setColumnStretch(m_pMainLayout->indexOf(m_pHostBrowser), 2);
    295281    }
     
    298284    if (m_pVerticalToolBar)
    299285    {
    300         m_pMainLayout->addWidget(m_pVerticalToolBar, 1, 2, 1, 1);
     286        m_pMainLayout->addWidget(m_pVerticalToolBar, 0, 2, 1, 1);
    301287        m_pMainLayout->setColumnStretch(m_pMainLayout->indexOf(m_pVerticalToolBar), 1);
    302288    }
     
    305291    if (m_pVisoBrowser)
    306292    {
    307         m_pMainLayout->addWidget(m_pVisoBrowser, 1, 3, 1, 2);
     293        m_pMainLayout->addWidget(m_pVisoBrowser, 0, 3, 1, 2);
    308294        m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName);
    309295        m_pMainLayout->setColumnStretch(m_pMainLayout->indexOf(m_pVisoBrowser), 2);
     
    313299    if (m_pConfigurationPanel)
    314300    {
    315         m_pMainLayout->addWidget(m_pConfigurationPanel, 2, 0, 1, 5);
     301        m_pMainLayout->addWidget(m_pConfigurationPanel, 1, 0, 1, 5);
    316302        m_pConfigurationPanel->hide();
    317303        m_pConfigurationPanel->setVisoName(m_visoOptions.m_strVisoName);
     
    323309    {
    324310        m_pCreatorOptionsPanel->setShowHiddenbjects(m_browserOptions.m_fShowHiddenObjects);
    325         m_pMainLayout->addWidget(m_pCreatorOptionsPanel, 3, 0, 1, 5);
     311        m_pMainLayout->addWidget(m_pCreatorOptionsPanel, 2, 0, 1, 5);
    326312        m_pCreatorOptionsPanel->hide();
    327313    }
    328 
    329     m_pButtonBox = new QIDialogButtonBox;
    330     if (m_pButtonBox)
    331     {
    332         m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    333         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    334         m_pMainLayout->addWidget(m_pButtonBox, 4, 0, 1, 5);
    335 
    336         connect(m_pButtonBox->button(QIDialogButtonBox::Help), &QPushButton::pressed,
    337                 &(msgCenter()), &UIMessageCenter::sltHandleHelpRequest);
    338         m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
    339 
    340         uiCommon().setHelpKeyword(m_pButtonBox->button(QIDialogButtonBox::Help), "viso");
    341     }
    342 }
    343 
    344 void UIVisoCreatorDialog::prepareConnections()
     314}
     315
     316void UIVisoCreatorWidget::prepareConnections()
    345317{
    346318    if (m_pHostBrowser)
    347319    {
    348320        connect(m_pHostBrowser, &UIVisoHostBrowser::sigAddObjectsToViso,
    349                 this, &UIVisoCreatorDialog::sltHandleAddObjectsToViso);
     321                this, &UIVisoCreatorWidget::sltHandleAddObjectsToViso);
    350322        connect(m_pHostBrowser, &UIVisoHostBrowser::sigTreeViewVisibilityChanged,
    351                 this, &UIVisoCreatorDialog::sltHandleBrowserTreeViewVisibilityChanged);
     323                this, &UIVisoCreatorWidget::sltHandleBrowserTreeViewVisibilityChanged);
    352324        connect(m_pHostBrowser, &UIVisoHostBrowser::sigTableSelectionChanged,
    353                 this, &UIVisoCreatorDialog::sltHandleHostBrowserTableSelectionChanged);
     325                this, &UIVisoCreatorWidget::sltHandleHostBrowserTableSelectionChanged);
    354326        connect(m_pHostBrowser, &UIVisoHostBrowser::sigCreateFileTableViewContextMenu,
    355                 this, &UIVisoCreatorDialog::sltHandleShowContextMenu);
     327                this, &UIVisoCreatorWidget::sltHandleShowContextMenu);
    356328    }
    357329
     
    359331    {
    360332        connect(m_pVisoBrowser, &UIVisoContentBrowser::sigTableSelectionChanged,
    361                 this, &UIVisoCreatorDialog::sltHandleContentBrowserTableSelectionChanged);
     333                this, &UIVisoCreatorWidget::sltHandleContentBrowserTableSelectionChanged);
    362334        connect(m_pVisoBrowser, &UIVisoContentBrowser::sigCreateFileTableViewContextMenu,
    363                 this, &UIVisoCreatorDialog::sltHandleShowContextMenu);
    364     }
    365 
    366     if (m_pButtonBox)
    367     {
    368         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorDialog::close);
    369         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorDialog::accept);
     335                this, &UIVisoCreatorWidget::sltHandleShowContextMenu);
    370336    }
    371337
    372338    if (m_pActionConfiguration)
    373         connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreatorDialog::sltPanelActionToggled);
     339        connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreatorWidget::sltPanelActionToggled);
    374340    if (m_pActionOptions)
    375         connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreatorDialog::sltPanelActionToggled);
     341        connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreatorWidget::sltPanelActionToggled);
    376342
    377343    if (m_pConfigurationPanel)
    378344    {
    379345        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigVisoNameChanged,
    380                 this, &UIVisoCreatorDialog::sltHandleVisoNameChanged);
     346                this, &UIVisoCreatorWidget::sltHandleVisoNameChanged);
    381347        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigCustomVisoOptionsChanged,
    382                 this, &UIVisoCreatorDialog::sltHandleCustomVisoOptionsChanged);
     348                this, &UIVisoCreatorWidget::sltHandleCustomVisoOptionsChanged);
    383349        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigHidePanel,
    384                 this, &UIVisoCreatorDialog::sltHandleHidePanel);
     350                this, &UIVisoCreatorWidget::sltHandleHidePanel);
    385351        m_panelActionMap.insert(m_pConfigurationPanel, m_pActionConfiguration);
    386352    }
     
    389355    {
    390356        connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigShowHiddenObjects,
    391                 this, &UIVisoCreatorDialog::sltHandleShowHiddenObjectsChange);
     357                this, &UIVisoCreatorWidget::sltHandleShowHiddenObjectsChange);
    392358        connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigHidePanel,
    393                 this, &UIVisoCreatorDialog::sltHandleHidePanel);
     359                this, &UIVisoCreatorWidget::sltHandleHidePanel);
    394360        m_panelActionMap.insert(m_pCreatorOptionsPanel, m_pActionOptions);
    395361    }
     
    413379}
    414380
    415 void UIVisoCreatorDialog::prepareActions()
     381void UIVisoCreatorWidget::prepareActions()
    416382{
    417383    m_pActionConfiguration = new QAction(this);
     
    479445}
    480446
    481 void UIVisoCreatorDialog::populateMenuMainToolbar()
     447void UIVisoCreatorWidget::populateMenuMainToolbar()
    482448{
    483449    if (!m_pMainMenu || !m_pToolBar)
     
    496462}
    497463
    498 void UIVisoCreatorDialog::hidePanel(UIDialogPanel* panel)
     464void UIVisoCreatorWidget::hidePanel(UIDialogPanel* panel)
    499465{
    500466    if (panel && panel->isVisible())
     
    510476}
    511477
    512 void UIVisoCreatorDialog::showPanel(UIDialogPanel* panel)
     478void UIVisoCreatorWidget::showPanel(UIDialogPanel* panel)
    513479{
    514480    if (panel && panel->isHidden())
     
    525491}
    526492
    527 void UIVisoCreatorDialog::manageEscapeShortCut()
    528 {
    529     /* Take the escape key from m_pButtonBox and from the panels in case treeview(s) in
    530        host and/or content browser is open. We use the escape key to close those first: */
    531     if ((m_pHostBrowser && m_pHostBrowser->isTreeViewVisible()) ||
    532         (m_pVisoBrowser && m_pVisoBrowser->isTreeViewVisible()))
    533     {
    534         if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
    535             m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence());
    536         for (int i = 0; i < m_visiblePanelsList.size(); ++i)
    537             m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
    538         return;
    539     }
    540 
    541     /* if there are no visible panels then assign esc. key to cancel button of the button box: */
    542     if (m_visiblePanelsList.isEmpty())
    543     {
    544         if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
    545             m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
    546         return;
    547     }
    548     if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
    549         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence());
     493void UIVisoCreatorWidget::manageEscapeShortCut()
     494{
     495    // /* Take the escape key from m_pButtonBox and from the panels in case treeview(s) in
     496    //    host and/or content browser is open. We use the escape key to close those first: */
     497    // if ((m_pHostBrowser && m_pHostBrowser->isTreeViewVisible()) ||
     498    //     (m_pVisoBrowser && m_pVisoBrowser->isTreeViewVisible()))
     499    // {
     500    //     if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
     501    //         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence());
     502    //     for (int i = 0; i < m_visiblePanelsList.size(); ++i)
     503    //         m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
     504    //     return;
     505    // }
     506
     507    // /* if there are no visible panels then assign esc. key to cancel button of the button box: */
     508    // if (m_visiblePanelsList.isEmpty())
     509    // {
     510    //     if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
     511    //         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
     512    //     return;
     513    // }
     514    // if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
     515    //     m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence());
    550516
    551517    /* Just loop thru the visible panel list and set the esc key to the
    552518       panel which made visible latest */
    553     for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)
    554         m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
    555     m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
    556 }
    557 
    558 void UIVisoCreatorDialog::prepareVerticalToolBar()
     519    // for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)
     520    //     m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
     521    // m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
     522}
     523
     524void UIVisoCreatorWidget::prepareVerticalToolBar()
    559525{
    560526    m_pVerticalToolBar = new QIToolBar;
     
    580546    m_pVerticalToolBar->addWidget(bottomSpacerWidget);
    581547}
     548
     549/*********************************************************************************************************************************
     550*   UIVisoCreatorDialog implementation.                                                                                        *
     551*********************************************************************************************************************************/
     552UIVisoCreatorDialog::UIVisoCreatorDialog(QWidget *pParent /* = 0 */, const QString& strMachineName /* = QString() */)
     553    : QIWithRetranslateUI<QIMainDialog>(pParent)
     554    , m_strMachineName(strMachineName)
     555    , m_pVisoCreatorWidget(0)
     556    , m_pButtonBox(0)
     557{
     558    prepareWidgets();
     559    prepareConnections();
     560}
     561
     562QStringList  UIVisoCreatorDialog::entryList() const
     563{
     564    if (m_pVisoCreatorWidget)
     565        return m_pVisoCreatorWidget->entryList();
     566    return QStringList();
     567}
     568
     569QString UIVisoCreatorDialog::visoName() const
     570{
     571    if (m_pVisoCreatorWidget)
     572        return m_pVisoCreatorWidget->visoName();
     573    return QString();
     574}
     575
     576QStringList UIVisoCreatorDialog::customOptions() const
     577{
     578    if (m_pVisoCreatorWidget)
     579        return m_pVisoCreatorWidget->customOptions();
     580    return QStringList();
     581}
     582
     583QString UIVisoCreatorDialog::currentPath() const
     584{
     585    if (m_pVisoCreatorWidget)
     586        return m_pVisoCreatorWidget->currentPath();
     587    return QString();
     588}
     589
     590void    UIVisoCreatorDialog::setCurrentPath(const QString &strPath)
     591{
     592    if (m_pVisoCreatorWidget)
     593        m_pVisoCreatorWidget->setCurrentPath(strPath);
     594}
     595
     596void UIVisoCreatorDialog::prepareWidgets()
     597{
     598    QWidget *pCentralWidget = new QWidget;
     599    setCentralWidget(pCentralWidget);
     600    QVBoxLayout *pMainLayout = new QVBoxLayout;
     601    pCentralWidget->setLayout(pMainLayout);
     602
     603
     604    m_pVisoCreatorWidget = new UIVisoCreatorWidget(this, m_strMachineName);
     605    if (m_pVisoCreatorWidget)
     606    {
     607        pMainLayout->addWidget(m_pVisoCreatorWidget);
     608    }
     609
     610    m_pButtonBox = new QIDialogButtonBox;
     611    if (m_pButtonBox)
     612    {
     613        m_pButtonBox->setStandardButtons(QDialogButtonBox::Help | QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     614        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
     615        pMainLayout->addWidget(m_pButtonBox);
     616
     617        connect(m_pButtonBox->button(QIDialogButtonBox::Help), &QPushButton::pressed,
     618                &(msgCenter()), &UIMessageCenter::sltHandleHelpRequest);
     619        m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents);
     620
     621        uiCommon().setHelpKeyword(m_pButtonBox->button(QIDialogButtonBox::Help), "viso");
     622    }
     623    retranslateUi();
     624}
     625
     626void UIVisoCreatorDialog::prepareConnections()
     627{
     628    if (m_pButtonBox)
     629    {
     630        connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorDialog::close);
     631        connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorDialog::accept);
     632    }
     633}
     634
     635void UIVisoCreatorDialog::retranslateUi()
     636{
     637    if (!m_strMachineName.isEmpty())
     638        setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("VISO Creator")));
     639    else
     640        setWindowTitle(QString("%1").arg(tr("VISO Creator")));
     641    if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Ok))
     642    {
     643        m_pButtonBox->button(QDialogButtonBox::Ok)->setText(QApplication::translate("UIVisoCreator", "C&reate"));
     644        m_pButtonBox->button(QDialogButtonBox::Ok)->setToolTip(QApplication::translate("UIVisoCreator", "Creates VISO file with the selected content"));
     645    }
     646    if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Help))
     647        m_pButtonBox->button(QDialogButtonBox::Help)->setToolTip(QApplication::translate("UIVisoCreator", "Opens the help browser and navigates to the related section"));
     648}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r92270 r92289  
    4343  * for VISO file system. It has the main menu, main toolbar, and a vertical toolbar and corresponding
    4444  * actions. */
    45 class UIVisoCreatorDialog : public QIWithRetranslateUI<QIMainDialog>
     45class UIVisoCreatorWidget : public QIWithRetranslateUI<QWidget>
    4646{
    4747    Q_OBJECT;
     
    4949public:
    5050
    51     UIVisoCreatorDialog(QWidget *pParent = 0, const QString& strMachineName = QString());
     51    UIVisoCreatorWidget(QWidget *pParent = 0, const QString& strMachineName = QString());
    5252    /** Returns the content of the .viso file. Each element of the list corresponds to a line in the .viso file. */
    5353    QStringList       entryList() const;
     
    138138    UIVisoHostBrowser    *m_pHostBrowser;
    139139    UIVisoContentBrowser *m_pVisoBrowser;
    140     QIDialogButtonBox    *m_pButtonBox;
     140
    141141    QIToolBar            *m_pToolBar;
    142142    QIToolBar            *m_pVerticalToolBar;
    143143    VisoOptions           m_visoOptions;
    144144    BrowserOptions        m_browserOptions;
    145     QWidget              *m_pCentralWidget;
    146145    QMenu                *m_pMainMenu;
    147146    QString               m_strMachineName;
     
    152151};
    153152
     153
     154class UIVisoCreatorDialog : public QIWithRetranslateUI<QIMainDialog>
     155{
     156    Q_OBJECT;
     157
     158public:
     159
     160    UIVisoCreatorDialog(QWidget *pParent = 0, const QString& strMachineName = QString());
     161
     162    QStringList  entryList() const;
     163    QString visoName() const;
     164    QStringList customOptions() const;
     165    QString currentPath() const;
     166    void    setCurrentPath(const QString &strPath);
     167
     168private:
     169    void prepareWidgets();
     170    void prepareConnections();
     171    virtual void retranslateUi() final override;
     172
     173    QString m_strMachineName;
     174    UIVisoCreatorWidget *m_pVisoCreatorWidget;
     175    QIDialogButtonBox    *m_pButtonBox;
     176};
    154177#endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreator_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette