VirtualBox

Changeset 76944 in vbox


Ignore:
Timestamp:
Jan 23, 2019 7:39:42 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9080: Convert options and configuration dialogs to panels.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited
2 copied
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r76820 r76944  
    832832        src/medium/viso/UIVisoContentBrowser.h \
    833833        src/medium/viso/UIVisoCreator.h \
    834         src/medium/viso/UIVisoConfigurationDialog.h \
    835         src/medium/viso/UIVisoCreatorOptionsDialog.h \
     834        src/medium/viso/UIVisoCreatorPanel.h \
     835        src/medium/viso/UIVisoConfigurationPanel.h \
     836        src/medium/viso/UIVisoCreatorOptionsPanel.h \
    836837        src/medium/viso/UIVisoHostBrowser.h \
    837838        src/settings/UISettingsDialog.h \
     
    12971298        src/medium/viso/UIVisoContentBrowser.cpp \
    12981299        src/medium/viso/UIVisoCreator.cpp \
    1299         src/medium/viso/UIVisoConfigurationDialog.cpp \
    1300         src/medium/viso/UIVisoCreatorOptionsDialog.cpp \
     1300        src/medium/viso/UIVisoCreatorPanel.cpp \
     1301        src/medium/viso/UIVisoConfigurationPanel.cpp \
     1302        src/medium/viso/UIVisoCreatorOptionsPanel.cpp \
    13011303        src/medium/viso/UIVisoHostBrowser.cpp \
    13021304        src/objects/UIRichTextString.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.cpp

    r76943 r76944  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVisoConfigurationDialog class implementation.
     3 * VBox Qt GUI - UIVisoConfigurationPanel class implementation.
    44 */
    55
     
    2626
    2727/* GUI includes: */
     28#include <QComboBox>
    2829#include "QIDialogButtonBox.h"
     30#include "UIIconPool.h"
    2931#include "QILabel.h"
    3032#include "QILineEdit.h"
    31 #include "UIVisoConfigurationDialog.h"
    32 #include "UIVisoCreator.h"
     33#include "QIToolButton.h"
     34#include "UIVisoConfigurationPanel.h"
    3335
    34 UIVisoConfigurationDialog::UIVisoConfigurationDialog(const VisoOptions &visoOptions,
    35                                                      QWidget *pParent /* =0 */)
    36     : QIDialog(pParent)
    37     , m_pMainLayout(0)
    38     , m_pButtonBox(0)
     36UIVisoConfigurationPanel::UIVisoConfigurationPanel(QWidget *pParent /* =0 */)
     37    : UIVisoCreatorPanel(pParent)
     38    , m_pVisoNameLabel(0)
     39    , m_pCustomOptionsLabel(0)
    3940    , m_pVisoNameLineEdit(0)
    40     , m_pCustomOptionsTextEdit(0)
    41     , m_visoOptions(visoOptions)
     41    , m_pCustomOptionsComboBox(0)
     42    , m_pDeleteButton(0)
    4243{
    4344    prepareObjects();
     
    4546}
    4647
    47 UIVisoConfigurationDialog::~UIVisoConfigurationDialog()
     48UIVisoConfigurationPanel::~UIVisoConfigurationPanel()
    4849{
    4950}
    5051
    51 const VisoOptions &UIVisoConfigurationDialog::visoOptions() const
     52QString UIVisoConfigurationPanel::panelName() const
    5253{
    53     return m_visoOptions;
     54    return "ConfigurationPanel";
    5455}
    5556
    56 void UIVisoConfigurationDialog::accept()
     57void UIVisoConfigurationPanel::setVisoName(const QString& strVisoName)
    5758{
    5859    if (m_pVisoNameLineEdit)
    59         m_visoOptions.m_strVisoName = m_pVisoNameLineEdit->text();
    60 
    61     if (m_pCustomOptionsTextEdit)
    62     {
    63         QTextDocument *pDocument = m_pCustomOptionsTextEdit->document();
    64         if (pDocument)
    65         {
    66             for(QTextBlock block = pDocument->begin(); block != pDocument->end()/*.isValid()*/; block = block.next())
    67                     m_visoOptions.m_customOptions << block.text();
    68         }
    69     }
    70 
    71     QIDialog::accept();
     60        m_pVisoNameLineEdit->setText(strVisoName);
    7261}
    7362
    74 void UIVisoConfigurationDialog::prepareObjects()
     63void UIVisoConfigurationPanel::setVisoCustomOptions(const QStringList& visoCustomOptions)
    7564{
    76     m_pMainLayout = new QGridLayout;
     65    if (!m_pCustomOptionsComboBox)
     66        return;
     67    m_pCustomOptionsComboBox->clear();
     68    foreach (const QString &strOption, visoCustomOptions)
     69    {
     70        m_pCustomOptionsComboBox->addItem(strOption);
     71    }
     72}
    7773
    78     if (!m_pMainLayout)
     74void UIVisoConfigurationPanel::prepareObjects()
     75{
     76    if (!mainLayout())
    7977        return;
    8078
    8179    /* Name edit and and label: */
    82     QILabel *pVisoNameLabel = new QILabel(UIVisoCreator::tr("VISO Name:"));
     80    m_pVisoNameLabel = new QILabel(QApplication::translate("UIVisoCreator", "VISO Name:"));
    8381    m_pVisoNameLineEdit = new QILineEdit;
    84     if (pVisoNameLabel && m_pVisoNameLineEdit)
     82    if (m_pVisoNameLabel && m_pVisoNameLineEdit)
    8583    {
    86         m_pVisoNameLineEdit->setText(m_visoOptions.m_strVisoName);
    87         pVisoNameLabel->setBuddy(m_pVisoNameLineEdit);
    88         m_pMainLayout->addWidget(pVisoNameLabel, 0, 0, 1, 1);
    89         m_pMainLayout->addWidget(m_pVisoNameLineEdit, 0, 1, 1, 1);
     84        m_pVisoNameLabel->setBuddy(m_pVisoNameLineEdit);
     85        mainLayout()->addWidget(m_pVisoNameLabel, 0, Qt::AlignLeft);
     86        mainLayout()->addWidget(m_pVisoNameLineEdit, 0, Qt::AlignLeft);
    9087    }
    9188
     89    addVerticalSeparator();
     90
     91
    9292    /* Cutom Viso options stuff: */
    93     QILabel *pCustomOptionsLabel = new QILabel(UIVisoCreator::tr("Custom VISO options:"));
    94     m_pCustomOptionsTextEdit = new QTextEdit;
    95     if (pCustomOptionsLabel && m_pCustomOptionsTextEdit)
     93    m_pCustomOptionsLabel = new QILabel(QApplication::translate("UIVisoCreator", "Custom VISO options:"));
     94    m_pCustomOptionsComboBox = new QComboBox;
     95    m_pDeleteButton = new QIToolButton;
     96
     97    if (m_pCustomOptionsLabel && m_pCustomOptionsComboBox && m_pDeleteButton)
    9698    {
    97         m_pCustomOptionsTextEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    98         pCustomOptionsLabel->setBuddy(m_pCustomOptionsTextEdit);
    99         m_pMainLayout->addWidget(pCustomOptionsLabel, 1, 0, 1, 1, Qt::AlignTop);
    100         m_pMainLayout->addWidget(m_pCustomOptionsTextEdit, 1, 1, 1, 1);
    101         foreach (const QString &strLine, m_visoOptions.m_customOptions)
    102             m_pCustomOptionsTextEdit->append(strLine);
     99        m_pDeleteButton->setIcon(UIIconPool::iconSet(":/log_viewer_delete_current_bookmark_16px.png"));
     100
     101        m_pCustomOptionsComboBox->setEditable(true);
     102        m_pCustomOptionsLabel->setBuddy(m_pCustomOptionsComboBox);
     103
     104        mainLayout()->addWidget(m_pCustomOptionsLabel, 0, Qt::AlignLeft);
     105        mainLayout()->addWidget(m_pCustomOptionsComboBox, Qt::AlignLeft);
     106        mainLayout()->addWidget(m_pDeleteButton, 0, Qt::AlignLeft);
    103107    }
    104 
    105     m_pButtonBox = new QIDialogButtonBox;
    106     if (m_pButtonBox)
    107     {
    108         m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    109         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    110         m_pMainLayout->addWidget(m_pButtonBox, 2, 0, 1, 2);
    111     }
    112     setLayout(m_pMainLayout);
     108    retranslateUi();
    113109}
    114110
    115 void UIVisoConfigurationDialog::prepareConnections()
     111void UIVisoConfigurationPanel::prepareConnections()
    116112{
    117     if (m_pButtonBox)
     113    if (m_pVisoNameLineEdit)
     114        connect(m_pVisoNameLineEdit, &QILineEdit::editingFinished, this, &UIVisoConfigurationPanel::sltHandleVisoNameChanged);
     115    if (m_pDeleteButton)
     116        connect(m_pDeleteButton, &QIToolButton::clicked, this, &UIVisoConfigurationPanel::sltHandleDeleteCurrentCustomOption);
     117}
     118
     119bool UIVisoConfigurationPanel::eventFilter(QObject *pObject, QEvent *pEvent)
     120{
     121    /* Depending on event-type: */
     122    switch (pEvent->type())
    118123    {
    119         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoConfigurationDialog::close);
    120         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoConfigurationDialog::accept);
     124        /* Process key press only: */
     125    case QEvent::KeyPress:
     126        {
     127            /* Cast to corresponding key press event: */
     128            QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
     129
     130             if (pKeyEvent->key() == Qt::Key_Return && m_pCustomOptionsComboBox && m_pCustomOptionsComboBox->hasFocus())
     131                 addCustomVisoOption();
     132            return true;
     133            break;
     134        }
     135    default:
     136        break;
    121137    }
     138    /* Call to base-class: */
     139    return UIVisoCreatorPanel::eventFilter(pObject, pEvent);
    122140}
     141
     142void UIVisoConfigurationPanel::retranslateUi()
     143{
     144    if (m_pVisoNameLabel)
     145        m_pVisoNameLabel->setText(QApplication::translate("UIVisoCreator", "VISO Name:"));
     146    if (m_pCustomOptionsLabel)
     147        m_pCustomOptionsLabel->setText(QApplication::translate("UIVisoCreator", "Custom VISO options:"));
     148    if (m_pDeleteButton)
     149        m_pDeleteButton->setToolTip(QApplication::translate("UIVisoCreator", "Remove current option."));
     150}
     151
     152void UIVisoConfigurationPanel::addCustomVisoOption()
     153{
     154    if (!m_pCustomOptionsComboBox)
     155        return;
     156    if (m_pCustomOptionsComboBox->currentText().isEmpty())
     157        return;
     158
     159    emitCustomVisoOptions();
     160    m_pCustomOptionsComboBox->clearEditText();
     161}
     162
     163void UIVisoConfigurationPanel::emitCustomVisoOptions()
     164{
     165    if (!m_pCustomOptionsComboBox)
     166        return;
     167    QStringList customVisoOptions;
     168    for (int i = 0; i < m_pCustomOptionsComboBox->count(); ++i)
     169        customVisoOptions << m_pCustomOptionsComboBox->itemText(i);
     170
     171    if (!customVisoOptions.isEmpty())
     172        emit sigCustomVisoOptionsChanged(customVisoOptions);
     173}
     174
     175void UIVisoConfigurationPanel::sltHandleVisoNameChanged()
     176{
     177    if (m_pVisoNameLineEdit)
     178        emit sigVisoNameChanged(m_pVisoNameLineEdit->text());
     179}
     180
     181void UIVisoConfigurationPanel::sltHandleDeleteCurrentCustomOption()
     182{
     183    if (!m_pCustomOptionsComboBox)
     184        return;
     185    if (m_pCustomOptionsComboBox->currentText().isEmpty())
     186        return;
     187    m_pCustomOptionsComboBox->removeItem(m_pCustomOptionsComboBox->currentIndex());
     188    emitCustomVisoOptions();
     189}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoConfigurationPanel.h

    r76943 r76944  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVisoConfigurationDialog class declaration.
     3 * VBox Qt GUI - UIVisoConfigurationPanel class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationDialog_h
    19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationDialog_h
     18#ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h
     19#define FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2323
    2424/* GUI includes: */
    25 #include "QIDialog.h"
    26 #include "QIWithRetranslateUI.h"
     25#include "UIVisoCreatorPanel.h"
    2726#include "UIVisoCreatorDefs.h"
    2827
     
    3029class QGridLayout;
    3130class QTextEdit;
    32 class QIDialogButtonBox;
     31class QComboBox;
     32class QILabel;
    3333class QILineEdit;
    3434class QITabWidget;
     35class QIToolButton;
     36class UIVisoCreator;
    3537
    36 class UIVisoConfigurationDialog : public QIDialog
     38class UIVisoConfigurationPanel : public UIVisoCreatorPanel
    3739{
    3840    Q_OBJECT;
    3941
    4042public:
    41     UIVisoConfigurationDialog(const VisoOptions &visoOptions,
    42                               QWidget *pParent = 0);
    43     ~UIVisoConfigurationDialog();
    44     const VisoOptions &visoOptions() const;
     43    UIVisoConfigurationPanel(QWidget *pParent = 0);
     44    ~UIVisoConfigurationPanel();
     45    virtual QString panelName() const /* override */;
     46    void setVisoName(const QString& strVisoName);
     47    void setVisoCustomOptions(const QStringList& visoCustomOptions);
    4548
    46 public slots:
     49signals:
    4750
    48     void accept() /* override */;
     51    void sigVisoNameChanged(const QString &strVisoName);
     52    void sigCustomVisoOptionsChanged(const QStringList &customVisoOptions);
    4953
     54
     55protected:
     56
     57    bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
     58    void retranslateUi() /* override */;
     59
     60private slots:
     61
     62    void sltHandleVisoNameChanged();
     63    void sltHandleDeleteCurrentCustomOption();
    5064
    5165private:
     
    5367    void prepareObjects();
    5468    void prepareConnections();
     69    void addCustomVisoOption();
     70    void emitCustomVisoOptions();
    5571
    56     QGridLayout          *m_pMainLayout;
    57     QIDialogButtonBox    *m_pButtonBox;
    58     QILineEdit           *m_pVisoNameLineEdit;
    59     QTextEdit           *m_pCustomOptionsTextEdit;
    60     VisoOptions          m_visoOptions;
     72    QILabel      *m_pVisoNameLabel;
     73    QILabel      *m_pCustomOptionsLabel;
     74    QILineEdit   *m_pVisoNameLineEdit;
     75    QComboBox    *m_pCustomOptionsComboBox;
     76    QIToolButton *m_pDeleteButton;
    6177
    6278    friend class UIVisoCreator;
    6379};
    6480
    65 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationDialog_h */
     81#endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoConfigurationPanel_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r76844 r76944  
    2929#include "UIVisoHostBrowser.h"
    3030#include "UIVisoCreator.h"
    31 #include "UIVisoConfigurationDialog.h"
    32 #include "UIVisoCreatorOptionsDialog.h"
     31#include "UIVisoConfigurationPanel.h"
     32#include "UIVisoCreatorOptionsPanel.h"
    3333#include "UIVisoContentBrowser.h"
    3434
     
    4949    , m_pVisoContentBrowserMenu(0)
    5050    , m_strMachineName(strMachineName)
     51    , m_pCreatorOptionsPanel(0)
     52    , m_pConfigurationPanel(0)
    5153{
    5254    prepareActions();
    5355    prepareObjects();
    5456    prepareConnections();
     57    manageEscapeShortCut();
    5558}
    5659
     
    105108}
    106109
    107 void UIVisoCreator::sltHandleOptionsAction()
    108 {
    109     UIVisoCreatorOptionsDialog *pDialog = new UIVisoCreatorOptionsDialog(m_browserOptions, this);
    110 
    111     if(!pDialog)
    112         return;
    113     if (pDialog->execute(true, false))
    114     {
    115         /** Check if any of the options has been modified: */
    116         checkBrowserOptions(pDialog->browserOptions());
    117     }
    118     delete pDialog;
    119 }
    120 
    121 void UIVisoCreator::sltHandleConfigurationAction()
    122 {
    123     UIVisoConfigurationDialog *pDialog = new UIVisoConfigurationDialog(m_visoOptions, this);
    124 
    125     if(!pDialog)
    126         return;
    127     if (pDialog->execute(true, false))
    128     {
    129         /** Check if any of the options has been modified: */
    130         checkVisoOptions(pDialog->visoOptions());
    131     }
    132     delete pDialog;
     110// void UIVisoCreator::sltHandleOptionsAction()
     111// {
     112//     // UIVisoCreatorOptionsDialog *pDialog = new UIVisoCreatorOptionsDialog(this, m_browserOptions, this);
     113
     114//     // if(!pDialog)
     115//     //     return;
     116//     // if (pDialog->execute(true, false))
     117//     // {
     118//     //     /** Check if any of the options has been modified: */
     119//     //     checkBrowserOptions(pDialog->browserOptions());
     120//     // }
     121//     // delete pDialog;
     122// }
     123
     124// void UIVisoCreator::sltHandleConfigurationAction()
     125// {
     126//     // UIVisoConfigurationDialog *pDialog = new UIVisoConfigurationDialog(m_visoOptions, this);
     127
     128//     // if(!pDialog)
     129//     //     return;
     130//     // if (pDialog->execute(true, false))
     131//     // {
     132//     //     /** Check if any of the options has been modified: */
     133//     //     checkVisoOptions(pDialog->visoOptions());
     134//     // }
     135//     // delete pDialog;
     136// }
     137
     138void UIVisoCreator::sltPanelActionToggled(bool fChecked)
     139{
     140    QAction *pSenderAction = qobject_cast<QAction*>(sender());
     141    if (!pSenderAction)
     142        return;
     143    UIVisoCreatorPanel* pPanel = 0;
     144    /* Look for the sender() within the m_panelActionMap's values: */
     145    for (QMap<UIVisoCreatorPanel*, QAction*>::const_iterator iterator = m_panelActionMap.begin();
     146        iterator != m_panelActionMap.end(); ++iterator)
     147    {
     148        if (iterator.value() == pSenderAction)
     149            pPanel = iterator.key();
     150    }
     151    if (!pPanel)
     152        return;
     153    if (fChecked)
     154        showPanel(pPanel);
     155    else
     156        hidePanel(pPanel);
     157}
     158
     159void UIVisoCreator::sltHandleVisoNameChanged(const QString &strVisoName)
     160{
     161    if (m_visoOptions.m_strVisoName == strVisoName)
     162        return;
     163    m_visoOptions.m_strVisoName = strVisoName;
     164    if(m_pVisoBrowser)
     165        m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName);
     166}
     167
     168void UIVisoCreator::sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions)
     169{
     170    if (m_visoOptions.m_customOptions == customVisoOptions)
     171        return;
     172    m_visoOptions.m_customOptions = customVisoOptions;
     173}
     174
     175void UIVisoCreator::sltHandleShowHiddenObjectsChange(bool fShow)
     176{
     177    if (m_browserOptions.m_fShowHiddenObjects == fShow)
     178        return;
     179    m_browserOptions.m_fShowHiddenObjects = fShow;
     180    m_pHostBrowser->showHideHiddenObjects(fShow);
     181}
     182
     183void UIVisoCreator::sltHandleHidePanel(UIVisoCreatorPanel *pPanel)
     184{
     185    hidePanel(pPanel);
    133186}
    134187
     
    144197    if (!m_pMainLayout || !menuBar())
    145198        return;
     199
     200    /* Configure layout: */
     201    m_pMainLayout->setContentsMargins(1, 1, 1, 1);
     202#ifdef VBOX_WS_MAC
     203    m_pMainLayout->setSpacing(10);
     204#else
     205    m_pMainLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);
     206#endif
    146207
    147208    m_pMainMenu = menuBar()->addMenu(tr("VISO"));
     
    184245                this, &UIVisoCreator::sltHandleAddObjectsToViso);
    185246    }
     247
    186248    m_pVisoBrowser = new UIVisoContentBrowser(0 /* parent */, m_pVisoContentBrowserMenu);
    187249    if (m_pVisoBrowser)
     
    190252        m_pVisoBrowser->setVisoName(m_visoOptions.m_strVisoName);
    191253    }
     254
     255    m_pConfigurationPanel = new UIVisoConfigurationPanel(this);
     256    if (m_pConfigurationPanel)
     257    {
     258        m_pVerticalSplitter->addWidget(m_pConfigurationPanel);
     259        m_panelActionMap.insert(m_pConfigurationPanel, m_pActionConfiguration);
     260        m_pConfigurationPanel->hide();
     261        m_pConfigurationPanel->setVisoName(m_visoOptions.m_strVisoName);
     262        m_pConfigurationPanel->setVisoCustomOptions(m_visoOptions.m_customOptions);
     263        installEventFilter(m_pConfigurationPanel);
     264    }
     265
     266    m_pCreatorOptionsPanel = new UIVisoCreatorOptionsPanel(this);
     267    if (m_pCreatorOptionsPanel)
     268    {
     269        m_pCreatorOptionsPanel->setShowHiddenbjects(m_browserOptions.m_fShowHiddenObjects);
     270        m_pMainLayout->addWidget(m_pCreatorOptionsPanel);
     271        m_panelActionMap.insert(m_pCreatorOptionsPanel, m_pActionOptions);
     272        m_pCreatorOptionsPanel->hide();
     273    }
     274
    192275    m_pButtonBox = new QIDialogButtonBox;
    193276    if (m_pButtonBox)
     
    196279        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    197280        m_pMainLayout->addWidget(m_pButtonBox);
     281
    198282    }
    199283    retranslateUi();
     
    207291        connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreator::accept);
    208292    }
     293
    209294    if (m_pActionConfiguration)
    210         connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreator::sltHandleConfigurationAction);
     295        connect(m_pActionConfiguration, &QAction::triggered, this, &UIVisoCreator::sltPanelActionToggled);
    211296    if (m_pActionOptions)
    212         connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreator::sltHandleOptionsAction);
     297        connect(m_pActionOptions, &QAction::triggered, this, &UIVisoCreator::sltPanelActionToggled);
     298
     299    if (m_pConfigurationPanel)
     300    {
     301        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigVisoNameChanged,
     302                this, &UIVisoCreator::sltHandleVisoNameChanged);
     303        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigCustomVisoOptionsChanged,
     304                this, &UIVisoCreator::sltHandleCustomVisoOptionsChanged);
     305        connect(m_pConfigurationPanel, &UIVisoConfigurationPanel::sigHidePanel,
     306                this, &UIVisoCreator::sltHandleHidePanel);
     307    }
     308    if (m_pCreatorOptionsPanel)
     309    {
     310        connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigShowHiddenObjects,
     311                this, &UIVisoCreator::sltHandleShowHiddenObjectsChange);
     312        connect(m_pCreatorOptionsPanel, &UIVisoCreatorOptionsPanel::sigHidePanel,
     313                this, &UIVisoCreator::sltHandleHidePanel);
     314    }
    213315}
    214316
     
    218320    if (m_pActionConfiguration)
    219321    {
     322        m_pActionConfiguration->setCheckable(true);
    220323        m_pActionConfiguration->setIcon(UIIconPool::iconSetFull(":/file_manager_options_32px.png",
    221324                                                          ":/%file_manager_options_16px.png",
     
    227330    if (m_pActionOptions)
    228331    {
     332        m_pActionOptions->setCheckable(true);
     333
    229334        m_pActionOptions->setIcon(UIIconPool::iconSetFull(":/file_manager_options_32px.png",
    230335                                                          ":/%file_manager_options_16px.png",
     
    234339}
    235340
    236 void UIVisoCreator::checkBrowserOptions(const BrowserOptions &browserOptions)
    237 {
    238     if (browserOptions == m_browserOptions)
    239         return;
    240     if (browserOptions.m_bShowHiddenObjects != m_browserOptions.m_bShowHiddenObjects)
    241     {
    242         if (m_pHostBrowser)
    243             m_pHostBrowser->showHideHiddenObjects(browserOptions.m_bShowHiddenObjects);
    244         if(m_pVisoBrowser)
    245             m_pVisoBrowser->showHideHiddenObjects(browserOptions.m_bShowHiddenObjects);
    246     }
    247     m_browserOptions = browserOptions;
    248 }
    249 
    250 void UIVisoCreator::checkVisoOptions(const VisoOptions &visoOptions)
    251 {
    252     if (visoOptions == m_visoOptions)
    253         return;
    254     if (visoOptions.m_strVisoName != m_visoOptions.m_strVisoName)
    255     {
    256         if(m_pVisoBrowser)
    257             m_pVisoBrowser->setVisoName(visoOptions.m_strVisoName);
    258     }
    259     m_visoOptions = visoOptions;
    260 }
     341
     342void UIVisoCreator::hidePanel(UIVisoCreatorPanel* panel)
     343{
     344    if (panel && panel->isVisible())
     345        panel->setVisible(false);
     346    QMap<UIVisoCreatorPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
     347    if (iterator != m_panelActionMap.end())
     348    {
     349        if (iterator.value() && iterator.value()->isChecked())
     350            iterator.value()->setChecked(false);
     351    }
     352    m_visiblePanelsList.removeAll(panel);
     353    manageEscapeShortCut();
     354}
     355
     356void UIVisoCreator::showPanel(UIVisoCreatorPanel* panel)
     357{
     358    if (panel && panel->isHidden())
     359        panel->setVisible(true);
     360    QMap<UIVisoCreatorPanel*, QAction*>::iterator iterator = m_panelActionMap.find(panel);
     361    if (iterator != m_panelActionMap.end())
     362    {
     363        if (!iterator.value()->isChecked())
     364            iterator.value()->setChecked(true);
     365    }
     366    if (!m_visiblePanelsList.contains(panel))
     367        m_visiblePanelsList.push_back(panel);
     368    manageEscapeShortCut();
     369}
     370
     371
     372
     373void UIVisoCreator::manageEscapeShortCut()
     374{
     375    /* if there are no visible panels then assign esc. key to cancel button of the button box: */
     376    if (m_visiblePanelsList.isEmpty())
     377    {
     378        if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
     379            m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
     380        return;
     381    }
     382    if (m_pButtonBox && m_pButtonBox->button(QDialogButtonBox::Cancel))
     383        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence());
     384
     385    /* Just loop thru the visible panel list and set the esc key to the
     386       panel which made visible latest */
     387    for (int i = 0; i < m_visiblePanelsList.size() - 1; ++i)
     388    {
     389        m_visiblePanelsList[i]->setCloseButtonShortCut(QKeySequence());
     390    }
     391    m_visiblePanelsList.back()->setCloseButtonShortCut(QKeySequence(Qt::Key_Escape));
     392}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r76913 r76944  
    4545class UIVisoHostBrowser;
    4646class UIVisoContentBrowser;
     47class UIVisoCreatorOptionsPanel;
     48class UIVisoCreatorPanel;
     49class UIVisoConfigurationPanel;
    4750
    4851class UIVisoCreator : public QIWithRetranslateUI<QIMainDialog>
     
    7073
    7174    void sltHandleAddObjectsToViso(QStringList pathList);
    72     void sltHandleOptionsAction();
    73     void sltHandleConfigurationAction();
     75    void sltPanelActionToggled(bool fChecked);
     76    void sltHandleVisoNameChanged(const QString& strVisoName);
     77    void sltHandleCustomVisoOptionsChanged(const QStringList &customVisoOptions);
     78    void sltHandleShowHiddenObjectsChange(bool fShow);
     79    void sltHandleHidePanel(UIVisoCreatorPanel *pPanel);
    7480
    75  private:
     81private:
    7682
    7783    void prepareObjects();
     
    8187    void setTableRootIndex(QModelIndex index = QModelIndex() );
    8288    void setTreeCurrentIndex(QModelIndex index = QModelIndex() );
    83     void checkBrowserOptions(const BrowserOptions &browserOptions);
    84     void checkVisoOptions(const VisoOptions &visoOptions);
     89    void hidePanel(UIVisoCreatorPanel *panel);
     90    void showPanel(UIVisoCreatorPanel *panel);
     91    /** Makes sure escape key is assigned to only a single widget. This is done by checking
     92        several things in the following order:
     93        - when there are no more panels visible assign it to the parent dialog
     94        - grab it from the dialog as soon as a panel becomes visible again
     95        - assign it to the most recently "unhidden" panel */
     96    void manageEscapeShortCut();
    8597
    8698    QVBoxLayout          *m_pMainLayout;
     
    99111    QMenu                *m_pVisoContentBrowserMenu;
    100112    QString               m_strMachineName;
     113    UIVisoCreatorOptionsPanel *m_pCreatorOptionsPanel;
     114    UIVisoConfigurationPanel  *m_pConfigurationPanel;
     115    QMap<UIVisoCreatorPanel*, QAction*> m_panelActionMap;
     116    QList<UIVisoCreatorPanel*>          m_visiblePanelsList;
    101117};
    102118
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorDefs.h

    r76768 r76944  
    4040{
    4141    BrowserOptions()
    42         :m_bShowHiddenObjects(true){}
     42        :m_fShowHiddenObjects(true){}
    4343    bool operator==(const BrowserOptions &otherOptions) const
    4444    {
    45         return m_bShowHiddenObjects == otherOptions.m_bShowHiddenObjects;
     45        return m_fShowHiddenObjects == otherOptions.m_fShowHiddenObjects;
    4646    }
    47     bool m_bShowHiddenObjects;
     47    bool m_fShowHiddenObjects;
    4848};
    4949
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsPanel.cpp

    r76943 r76944  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVisoCreatorOptionsDialog class implementation.
     3 * VBox Qt GUI - UIVisoCreatorOptionsPanel class implementation.
    44 */
    55
     
    2525
    2626/* GUI includes: */
    27 #include "QIDialogButtonBox.h"
    2827#include "QILabel.h"
    2928#include "QILineEdit.h"
    3029#include "QITabWidget.h"
    3130#include "UIVisoCreator.h"
    32 #include "UIVisoCreatorOptionsDialog.h"
     31#include "UIVisoCreatorOptionsPanel.h"
    3332
    34 UIVisoCreatorOptionsDialog::UIVisoCreatorOptionsDialog(const BrowserOptions &browserOptions, QWidget *pParent /* =0 */)
    35     : QIDialog(pParent)
    36     , m_pMainLayout(0)
    37     , m_pButtonBox(0)
    38     , m_browserOptions(browserOptions)
     33UIVisoCreatorOptionsPanel::UIVisoCreatorOptionsPanel(QWidget *pParent /* =0 */)
     34    : UIVisoCreatorPanel(pParent)
     35    , m_pShowHiddenObjectsCheckBox(0)
     36    , m_pShowHiddenObjectsLabel(0)
    3937{
    4038    prepareObjects();
     
    4240}
    4341
    44 UIVisoCreatorOptionsDialog::~UIVisoCreatorOptionsDialog()
     42UIVisoCreatorOptionsPanel::~UIVisoCreatorOptionsPanel()
    4543{
    4644}
    4745
    48 const BrowserOptions &UIVisoCreatorOptionsDialog::browserOptions() const
     46QString UIVisoCreatorOptionsPanel::panelName() const
    4947{
    50     return m_browserOptions;
     48    return "OptionsPanel";
    5149}
    5250
    53 void UIVisoCreatorOptionsDialog::sltHandlShowHiddenObjectsChange(int iState)
     51void UIVisoCreatorOptionsPanel::setShowHiddenbjects(bool fShow)
     52{
     53    if (m_pShowHiddenObjectsCheckBox)
     54        m_pShowHiddenObjectsCheckBox->setChecked(fShow);
     55}
     56
     57void UIVisoCreatorOptionsPanel::retranslateUi()
     58{
     59    if (m_pShowHiddenObjectsLabel)
     60        m_pShowHiddenObjectsLabel->setText(UIVisoCreator::tr("Show Hidden Objects"));
     61}
     62
     63void UIVisoCreatorOptionsPanel::sltHandlShowHiddenObjectsChange(int iState)
    5464{
    5565    if (iState == static_cast<int>(Qt::Checked))
    56         m_browserOptions.m_bShowHiddenObjects = true;
     66        sigShowHiddenObjects(true);
    5767    else
    58         m_browserOptions.m_bShowHiddenObjects = false;
     68        sigShowHiddenObjects(false);
    5969}
    6070
    61 void UIVisoCreatorOptionsDialog::prepareObjects()
     71void UIVisoCreatorOptionsPanel::prepareObjects()
    6272{
    63     m_pMainLayout = new QGridLayout;
    64     if (!m_pMainLayout)
     73    if (!mainLayout())
    6574        return;
    6675
    67     QCheckBox *pShowHiddenObjectsCheckBox = new QCheckBox;
    68     pShowHiddenObjectsCheckBox->setChecked(m_browserOptions.m_bShowHiddenObjects);
    69     QILabel *pShowHiddenObjectsLabel = new QILabel(UIVisoCreator::tr("Show Hidden Objects"));
    70     pShowHiddenObjectsLabel->setBuddy(pShowHiddenObjectsCheckBox);
    71     m_pMainLayout->addWidget(pShowHiddenObjectsLabel, 0, 0);
    72     m_pMainLayout->addWidget(pShowHiddenObjectsCheckBox, 0, 1);
    73     connect(pShowHiddenObjectsCheckBox, &QCheckBox::stateChanged,
    74             this, &UIVisoCreatorOptionsDialog::sltHandlShowHiddenObjectsChange);
    75 
    76     m_pButtonBox = new QIDialogButtonBox;
    77     if (m_pButtonBox)
    78     {
    79         m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    80         m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
    81         m_pMainLayout->addWidget(m_pButtonBox, 1, 0, 1, 2);
    82     }
    83     setLayout(m_pMainLayout);
     76    m_pShowHiddenObjectsCheckBox = new QCheckBox;
     77    m_pShowHiddenObjectsLabel = new QILabel(UIVisoCreator::tr("Show Hidden Objects"));
     78    m_pShowHiddenObjectsLabel->setBuddy(m_pShowHiddenObjectsCheckBox);
     79    mainLayout()->addWidget(m_pShowHiddenObjectsCheckBox, 0, Qt::AlignLeft);
     80    mainLayout()->addWidget(m_pShowHiddenObjectsLabel, 0, Qt::AlignLeft);
     81    mainLayout()->addStretch(6);
     82    connect(m_pShowHiddenObjectsCheckBox, &QCheckBox::stateChanged,
     83            this, &UIVisoCreatorOptionsPanel::sltHandlShowHiddenObjectsChange);
    8484}
    8585
    86 void UIVisoCreatorOptionsDialog::prepareConnections()
     86void UIVisoCreatorOptionsPanel::prepareConnections()
    8787{
    88     if (m_pButtonBox)
    89     {
    90         connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIVisoCreatorOptionsDialog::close);
    91         connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIVisoCreatorOptionsDialog::accept);
    92     }
    9388}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorOptionsPanel.h

    r76943 r76944  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVisoCreatorOptionsDialog class declaration.
     3 * VBox Qt GUI - UIVisoCreatorOptionsPanel class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsDialog_h
    19 #define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsDialog_h
     18#ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h
     19#define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
    2222#endif
    2323
     24/* Forward declarations: */
     25class QCheckBox;
     26class QILabel;
     27
    2428/* GUI includes: */
    25 #include "QIDialog.h"
     29#include "UIVisoCreatorPanel.h"
    2630#include "QIWithRetranslateUI.h"
    2731#include "UIVisoCreatorDefs.h"
    2832
    29 /* Forward declarations: */
    30 class QGridLayout;
    31 class QIDialogButtonBox;
    3233
    33 class UIVisoCreatorOptionsDialog : public QIDialog
     34class UIVisoCreatorOptionsPanel : public UIVisoCreatorPanel
    3435{
    3536    Q_OBJECT;
     
    3738public:
    3839
    39     UIVisoCreatorOptionsDialog(const BrowserOptions &browserOptions,
    40                                QWidget *pParent = 0);
    41     ~UIVisoCreatorOptionsDialog();
    42     const BrowserOptions &browserOptions() const;
     40    UIVisoCreatorOptionsPanel(QWidget *pParent = 0);
     41    ~UIVisoCreatorOptionsPanel();
     42    virtual QString panelName() const /* override */;
     43    void setShowHiddenbjects(bool fShow);
     44
     45signals:
     46
     47    void sigShowHiddenObjects(bool fShow);
     48
     49protected:
     50
     51    void retranslateUi() /* override */;
     52
    4353
    4454private slots:
     
    5060    void prepareObjects();
    5161    void prepareConnections();
    52     QGridLayout          *m_pMainLayout;
    53     QIDialogButtonBox    *m_pButtonBox;
    54     BrowserOptions       m_browserOptions;
     62
     63    QCheckBox *m_pShowHiddenObjectsCheckBox;
     64    QILabel *m_pShowHiddenObjectsLabel;
     65
    5566    friend class UIVisoCreator;
    5667};
    5768
    58 #endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsDialog_h */
     69#endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorOptionsPanel_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorPanel.cpp

    r76910 r76944  
    2727#include "QIToolButton.h"
    2828#include "UIIconPool.h"
    29 #include "UIFileManager.h"
    30 #include "UIFileManagerPanel.h"
     29#include "UIVisoCreatorPanel.h"
    3130#ifdef VBOX_WS_MAC
    3231# include "VBoxUtils-darwin.h"
     
    3433
    3534
    36 UIFileManagerPanel::UIFileManagerPanel(UIFileManager *pManagerWidget, QWidget *pParent)
     35UIVisoCreatorPanel::UIVisoCreatorPanel(QWidget *pParent)
    3736    : QIWithRetranslateUI<QWidget>(pParent)
    3837    , m_pMainLayout(0)
    3938    , m_pCloseButton(0)
    40     , m_pFileManager(pManagerWidget)
    4139{
    4240    prepare();
    4341}
    4442
    45 void UIFileManagerPanel::setCloseButtonShortCut(QKeySequence shortCut)
     43void UIVisoCreatorPanel::setCloseButtonShortCut(QKeySequence shortCut)
    4644{
    4745    if (!m_pCloseButton)
     
    5048}
    5149
    52 QHBoxLayout* UIFileManagerPanel::mainLayout()
     50QHBoxLayout* UIVisoCreatorPanel::mainLayout()
    5351{
    5452    return m_pMainLayout;
    5553}
    5654
    57 void UIFileManagerPanel::prepare()
     55void UIVisoCreatorPanel::prepare()
    5856{
    5957    prepareWidgets();
     
    6260}
    6361
    64 void UIFileManagerPanel::prepareWidgets()
     62void UIVisoCreatorPanel::prepareWidgets()
    6563{
    6664    m_pMainLayout = new QHBoxLayout(this);
     
    8583}
    8684
    87 void UIFileManagerPanel::prepareConnections()
     85void UIVisoCreatorPanel::prepareConnections()
    8886{
    8987    if (m_pCloseButton)
    90         connect(m_pCloseButton, &QIToolButton::clicked, this, &UIFileManagerPanel::hide);
     88        connect(m_pCloseButton, &QIToolButton::clicked, this, &UIVisoCreatorPanel::hide);
    9189}
    9290
    93 void UIFileManagerPanel::retranslateUi()
     91void UIVisoCreatorPanel::retranslateUi()
    9492{
    9593    if (m_pCloseButton)
    96         m_pCloseButton->setToolTip(UIFileManager::tr("Close the pane"));
     94        m_pCloseButton->setToolTip(QApplication::translate("UIVisoCreator", "Close the pane"));
    9795}
    9896
    99 bool UIFileManagerPanel::eventFilter(QObject *pObject, QEvent *pEvent)
     97bool UIVisoCreatorPanel::eventFilter(QObject *pObject, QEvent *pEvent)
    10098{
    10199    Q_UNUSED(pObject);
     
    105103}
    106104
    107 void UIFileManagerPanel::showEvent(QShowEvent *pEvent)
     105void UIVisoCreatorPanel::showEvent(QShowEvent *pEvent)
    108106{
    109107    QWidget::showEvent(pEvent);
    110108}
    111109
    112 void UIFileManagerPanel::hideEvent(QHideEvent *pEvent)
     110void UIVisoCreatorPanel::hideEvent(QHideEvent *pEvent)
    113111{
    114112    /* Get focused widget: */
     
    118116    if (pFocus && pFocus->parent() == this)
    119117        focusNextPrevChild(true);
    120     if (m_pFileManager)
    121         m_pFileManager->hidePanel(this);
     118    emit sigHidePanel(this);
    122119
    123120    QWidget::hideEvent(pEvent);
    124121}
     122
     123void UIVisoCreatorPanel::addVerticalSeparator()
     124{
     125    QFrame *pSeparator = new QFrame();
     126    pSeparator->setFrameShape(QFrame::VLine);
     127    pSeparator->setFrameShadow(QFrame::Sunken);
     128    mainLayout()->addWidget(pSeparator);
     129}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreatorPanel.h

    r76910 r76944  
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_guestctrl_UIFileManagerPanel_h
    19 #define FEQT_INCLUDED_SRC_guestctrl_UIFileManagerPanel_h
     18#ifndef FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h
     19#define FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    3333class QTextDocument;
    3434class QIToolButton;
    35 class UIFileManager;
     35
    3636
    3737/** QWidget extension acting as the base class for UIVMLogViewerXXXPanel widgets. */
    38 class UIFileManagerPanel : public QIWithRetranslateUI<QWidget>
     38class UIVisoCreatorPanel : public QIWithRetranslateUI<QWidget>
    3939{
    4040    Q_OBJECT;
     
    4242public:
    4343
    44     UIFileManagerPanel(UIFileManager *pManagerWidget, QWidget *pParent);
     44    UIVisoCreatorPanel(QWidget *pParent);
    4545    void setCloseButtonShortCut(QKeySequence shortCut);
    4646    virtual QString panelName() const = 0;
     47
     48signals:
     49
     50    void sigHidePanel(UIVisoCreatorPanel *pPanel);
    4751
    4852protected:
     
    6468    /** Handles the Qt hide @a pEvent. */
    6569    void hideEvent(QHideEvent *pEvent);
     70    void addVerticalSeparator();
    6671
    6772private:
     
    7075    QHBoxLayout   *m_pMainLayout;
    7176    QIToolButton  *m_pCloseButton;
    72     UIFileManager *m_pFileManager;
    7377};
    7478
    75 #endif /* !FEQT_INCLUDED_SRC_guestctrl_UIFileManagerPanel_h */
     79#endif /* !FEQT_INCLUDED_SRC_medium_viso_UIVisoCreatorPanel_h */
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