VirtualBox

Ignore:
Timestamp:
Mar 1, 2022 1:10:19 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6899: VM settings: Reworking Audio page to increase page accessibility; Adjust editors, get rid of QIComboBox objects.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r93998 r94039  
    10811081    {
    10821082        /* Prepare editor: */
    1083         UIAudioHostDriverEditor *pEditor = new UIAudioHostDriverEditor(pPopup, true /* with label */);
     1083        UIAudioHostDriverEditor *pEditor = new UIAudioHostDriverEditor(pPopup);
    10841084        if (pEditor)
    10851085        {
     
    11131113    {
    11141114        /* Prepare editor: */
    1115         UIAudioControllerEditor *pEditor = new UIAudioControllerEditor(pPopup, true /* with label */);
     1115        UIAudioControllerEditor *pEditor = new UIAudioControllerEditor(pPopup);
    11161116        if (pEditor)
    11171117        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioControllerEditor.cpp

    r93115 r94039  
    1717
    1818/* Qt includes: */
     19#include <QComboBox>
    1920#include <QGridLayout>
    2021#include <QHBoxLayout>
     
    2223
    2324/* GUI includes: */
    24 #include "QIComboBox.h"
    2525#include "UICommon.h"
    2626#include "UIConverter.h"
     
    3131
    3232
    33 UIAudioControllerEditor::UIAudioControllerEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     33UIAudioControllerEditor::UIAudioControllerEditor(QWidget *pParent /* = 0 */)
    3434    : QIWithRetranslateUI<QWidget>(pParent)
    35     , m_fWithLabel(fWithLabel)
    3635    , m_enmValue(KAudioControllerType_Max)
    3736    , m_pLabel(0)
     
    6564}
    6665
     66int UIAudioControllerEditor::minimumLabelHorizontalHint() const
     67{
     68    return m_pLabel->minimumSizeHint().width();
     69}
     70
     71void UIAudioControllerEditor::setMinimumLayoutIndent(int iIndent)
     72{
     73    if (m_pLayout)
     74        m_pLayout->setColumnMinimumWidth(0, iIndent);
     75}
     76
    6777void UIAudioControllerEditor::retranslateUi()
    6878{
     
    7686            m_pCombo->setItemText(i, gpConverter->toString(enmType));
    7787        }
     88        m_pCombo->setToolTip(tr("Selects the type of the virtual sound card. Depending on this value, "
     89                                "VirtualBox will provide different audio hardware to the virtual machine."));
    7890    }
    7991}
     
    88100{
    89101    /* Create main layout: */
    90     QGridLayout *pMainLayout = new QGridLayout(this);
    91     if (pMainLayout)
     102    m_pLayout = new QGridLayout(this);
     103    if (m_pLayout)
    92104    {
    93         pMainLayout->setContentsMargins(0, 0, 0, 0);
    94         int iRow = 0;
     105        m_pLayout->setContentsMargins(0, 0, 0, 0);
    95106
    96107        /* Create label: */
    97         if (m_fWithLabel)
    98             m_pLabel = new QLabel(this);
     108        m_pLabel = new QLabel(this);
    99109        if (m_pLabel)
    100             pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
     110        {
     111            m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     112            m_pLayout->addWidget(m_pLabel, 0, 0);
     113        }
    101114
    102115        /* Create combo layout: */
     
    105118        {
    106119            /* Create combo: */
    107             m_pCombo = new QIComboBox(this);
     120            m_pCombo = new QComboBox(this);
    108121            if (m_pCombo)
    109122            {
    110                 setFocusProxy(m_pCombo->focusProxy());
    111123                /* This is necessary since contents is dynamical now: */
    112124                m_pCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    113125                if (m_pLabel)
    114                     m_pLabel->setBuddy(m_pCombo->focusProxy());
    115                 connect(m_pCombo, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
     126                    m_pLabel->setBuddy(m_pCombo);
     127                connect(m_pCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    116128                        this, &UIAudioControllerEditor::sltHandleCurrentIndexChanged);
    117129                pComboLayout->addWidget(m_pCombo);
     
    122134
    123135            /* Add combo-layout into main-layout: */
    124             pMainLayout->addLayout(pComboLayout, 0, iRow++, 1, 1);
     136            m_pLayout->addLayout(pComboLayout, 0, 1);
    125137        }
    126138    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioControllerEditor.h

    r93990 r94039  
    3333
    3434/* Forward declarations: */
     35class QComboBox;
     36class QGridLayout;
    3537class QLabel;
    36 class QIComboBox;
    3738
    3839/** QWidget subclass used as an audio controller editor. */
     
    4849public:
    4950
    50     /** Constructs audio controller editor passing @a pParent to the base-class.
    51       * @param  fWithLabel  Brings whether we should add label ourselves. */
    52     UIAudioControllerEditor(QWidget *pParent = 0, bool fWithLabel = false);
     51    /** Constructs audio controller editor passing @a pParent to the base-class. */
     52    UIAudioControllerEditor(QWidget *pParent = 0);
    5353
    5454    /** Defines editor @a enmValue. */
     
    5959    /** Returns the vector of supported values. */
    6060    QVector<KAudioControllerType> supportedValues() const { return m_supportedValues; }
     61
     62    /** Returns minimum layout hint. */
     63    int minimumLabelHorizontalHint() const;
     64    /** Defines minimum layout @a iIndent. */
     65    void setMinimumLayoutIndent(int iIndent);
    6166
    6267protected:
     
    7782    void populateCombo();
    7883
    79     /** Holds whether descriptive label should be created. */
    80     bool  m_fWithLabel;
    81 
    8284    /** Holds the value to be selected. */
    8385    KAudioControllerType  m_enmValue;
     
    8688    QVector<KAudioControllerType>  m_supportedValues;
    8789
     90    /** Holds the main layout instance. */
     91    QGridLayout *m_pLayout;
    8892    /** Holds the label instance. */
    89     QLabel     *m_pLabel;
     93    QLabel      *m_pLabel;
    9094    /** Holds the combo instance. */
    91     QIComboBox *m_pCombo;
     95    QComboBox  *m_pCombo;
    9296};
    9397
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioHostDriverEditor.cpp

    r93115 r94039  
    1717
    1818/* Qt includes: */
     19#include <QComboBox>
    1920#include <QGridLayout>
    2021#include <QHBoxLayout>
     
    2223
    2324/* GUI includes: */
    24 #include "QIComboBox.h"
    2525#include "UICommon.h"
    2626#include "UIConverter.h"
     
    3131
    3232
    33 UIAudioHostDriverEditor::UIAudioHostDriverEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     33UIAudioHostDriverEditor::UIAudioHostDriverEditor(QWidget *pParent /* = 0 */)
    3434    : QIWithRetranslateUI<QWidget>(pParent)
    35     , m_fWithLabel(fWithLabel)
    3635    , m_enmValue(KAudioDriverType_Max)
    3736    , m_pLabel(0)
     
    6564}
    6665
     66int UIAudioHostDriverEditor::minimumLabelHorizontalHint() const
     67{
     68    return m_pLabel->minimumSizeHint().width();
     69}
     70
     71void UIAudioHostDriverEditor::setMinimumLayoutIndent(int iIndent)
     72{
     73    if (m_pLayout)
     74        m_pLayout->setColumnMinimumWidth(0, iIndent);
     75}
     76
    6777void UIAudioHostDriverEditor::retranslateUi()
    6878{
     
    7686            m_pCombo->setItemText(i, gpConverter->toString(enmType));
    7787        }
     88        m_pCombo->setToolTip(tr("Selects the audio output driver. The <b>Null Audio Driver</b> makes the guest "
     89                                "see an audio card, however every access to it will be ignored."));
    7890    }
    7991}
     
    88100{
    89101    /* Create main layout: */
    90     QGridLayout *pMainLayout = new QGridLayout(this);
    91     if (pMainLayout)
     102    m_pLayout = new QGridLayout(this);
     103    if (m_pLayout)
    92104    {
    93         pMainLayout->setContentsMargins(0, 0, 0, 0);
    94         int iRow = 0;
     105        m_pLayout->setContentsMargins(0, 0, 0, 0);
    95106
    96107        /* Create label: */
    97         if (m_fWithLabel)
    98             m_pLabel = new QLabel(this);
     108        m_pLabel = new QLabel(this);
    99109        if (m_pLabel)
    100             pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
     110        {
     111            m_pLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     112            m_pLayout->addWidget(m_pLabel, 0, 0);
     113        }
    101114
    102115        /* Create combo layout: */
     
    105118        {
    106119            /* Create combo: */
    107             m_pCombo = new QIComboBox(this);
     120            m_pCombo = new QComboBox(this);
    108121            if (m_pCombo)
    109122            {
    110                 setFocusProxy(m_pCombo->focusProxy());
    111123                /* This is necessary since contents is dynamical now: */
    112124                m_pCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    113125                if (m_pLabel)
    114                     m_pLabel->setBuddy(m_pCombo->focusProxy());
    115                 connect(m_pCombo, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
     126                    m_pLabel->setBuddy(m_pCombo);
     127                connect(m_pCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    116128                        this, &UIAudioHostDriverEditor::sltHandleCurrentIndexChanged);
    117129                pComboLayout->addWidget(m_pCombo);
     
    122134
    123135            /* Add combo-layout into main-layout: */
    124             pMainLayout->addLayout(pComboLayout, 0, iRow++, 1, 1);
     136            m_pLayout->addLayout(pComboLayout, 0, 1);
    125137        }
    126138    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIAudioHostDriverEditor.h

    r93990 r94039  
    3333
    3434/* Forward declarations: */
     35class QComboBox;
     36class QGridLayout;
    3537class QLabel;
    36 class QIComboBox;
    3738
    3839/** QWidget subclass used as an audio host driver editor. */
     
    4849public:
    4950
    50     /** Constructs audio host driver editor passing @a pParent to the base-class.
    51       * @param  fWithLabel  Brings whether we should add label ourselves. */
    52     UIAudioHostDriverEditor(QWidget *pParent = 0, bool fWithLabel = false);
     51    /** Constructs audio host driver editor passing @a pParent to the base-class. */
     52    UIAudioHostDriverEditor(QWidget *pParent = 0);
    5353
    5454    /** Defines editor @a enmValue. */
     
    5959    /** Returns the vector of supported values. */
    6060    QVector<KAudioDriverType> supportedValues() const { return m_supportedValues; }
     61
     62    /** Returns minimum layout hint. */
     63    int minimumLabelHorizontalHint() const;
     64    /** Defines minimum layout @a iIndent. */
     65    void setMinimumLayoutIndent(int iIndent);
    6166
    6267protected:
     
    7782    void populateCombo();
    7883
    79     /** Holds whether descriptive label should be created. */
    80     bool  m_fWithLabel;
    81 
    8284    /** Holds the value to be selected. */
    8385    KAudioDriverType  m_enmValue;
     
    8688    QVector<KAudioDriverType>  m_supportedValues;
    8789
     90    /** Holds the main layout instance. */
     91    QGridLayout *m_pLayout;
    8892    /** Holds the label instance. */
    89     QLabel     *m_pLabel;
     93    QLabel      *m_pLabel;
    9094    /** Holds the combo instance. */
    91     QIComboBox *m_pCombo;
     95    QComboBox  *m_pCombo;
    9296};
    9397
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp

    r93829 r94039  
    7878    , m_pCheckBoxAudio(0)
    7979    , m_pWidgetAudioSettings(0)
    80     , m_pLabelAudioHostDriver(0)
     80    , m_pLayoutAudioSettings(0)
    8181    , m_pEditorAudioHostDriver(0)
    82     , m_pLabelAudioController(0)
    8382    , m_pEditorAudioController(0)
    8483    , m_pLabelAudioExtended(0)
     
    8685    , m_pCheckBoxAudioInput(0)
    8786{
    88     /* Prepare: */
    8987    prepare();
    9088}
     
    9290UIMachineSettingsAudio::~UIMachineSettingsAudio()
    9391{
    94     /* Cleanup: */
    9592    cleanup();
    9693}
     
    177174void UIMachineSettingsAudio::retranslateUi()
    178175{
     176    m_pCheckBoxAudio->setText(tr("Enable &Audio"));
    179177    m_pCheckBoxAudio->setToolTip(tr("When checked, a virtual PCI audio card will be plugged into the virtual machine "
    180178                                    "and will communicate with the host audio system using the specified driver."));
    181     m_pCheckBoxAudio->setText(tr("Enable &Audio"));
    182     m_pLabelAudioHostDriver->setText(tr("Host Audio &Driver:"));
    183     m_pEditorAudioHostDriver->setToolTip(tr("Selects the audio output driver. The <b>Null Audio Driver</b> makes the guest "
    184                                             "see an audio card, however every access to it will be ignored."));
    185     m_pLabelAudioController->setText(tr("Audio &Controller:"));
    186     m_pEditorAudioController->setToolTip(tr("Selects the type of the virtual sound card. Depending on this value, "
    187                                             "VirtualBox will provide different audio hardware to the virtual machine."));
    188179    m_pLabelAudioExtended->setText(tr("Extended Features:"));
     180    m_pCheckBoxAudioOutput->setText(tr("Enable Audio &Output"));
    189181    m_pCheckBoxAudioOutput->setToolTip(tr("When checked, output to the virtual audio device will reach the host. "
    190182                                          "Otherwise the guest is muted."));
    191     m_pCheckBoxAudioOutput->setText(tr("Enable Audio &Output"));
     183    m_pCheckBoxAudioInput->setText(tr("Enable Audio &Input"));
    192184    m_pCheckBoxAudioInput->setToolTip(tr("When checked, the guest will be able to capture audio input from the host. "
    193185                                         "Otherwise the guest will capture only silence."));
    194     m_pCheckBoxAudioInput->setText(tr("Enable Audio &Input"));
     186
     187    /* These editors have own labels, but we want them to be properly layouted according to each other: */
     188    int iMinimumLayoutHint = 0;
     189    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioHostDriver->minimumLabelHorizontalHint());
     190    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAudioController->minimumLabelHorizontalHint());
     191    iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pLabelAudioExtended->minimumSizeHint().width());
     192    m_pEditorAudioHostDriver->setMinimumLayoutIndent(iMinimumLayoutHint);
     193    m_pEditorAudioController->setMinimumLayoutIndent(iMinimumLayoutHint);
     194    m_pLayoutAudioSettings->setColumnMinimumWidth(0, iMinimumLayoutHint);
    195195}
    196196
     
    199199    /* Polish audio page availability: */
    200200    m_pCheckBoxAudio->setEnabled(isMachineOffline());
    201     m_pLabelAudioHostDriver->setEnabled(isMachineOffline() || isMachineSaved());
    202201    m_pEditorAudioHostDriver->setEnabled(isMachineOffline() || isMachineSaved());
    203     m_pLabelAudioController->setEnabled(isMachineOffline());
    204202    m_pEditorAudioController->setEnabled(isMachineOffline());
    205203    m_pLabelAudioExtended->setEnabled(isMachineInValidMode());
     
    246244        {
    247245            /* Prepare audio settings widget layout: */
    248             QGridLayout *pLayoutAudioSettings = new QGridLayout(m_pWidgetAudioSettings);
    249             if (pLayoutAudioSettings)
    250             {
    251                 pLayoutAudioSettings->setContentsMargins(0, 0, 0, 0);
    252                 pLayoutAudioSettings->setColumnStretch(1, 1);
    253 
    254                 /* Prepare audio host driver label: */
    255                 m_pLabelAudioHostDriver = new QLabel(m_pWidgetAudioSettings);
    256                 if (m_pLabelAudioHostDriver)
    257                 {
    258                     m_pLabelAudioHostDriver->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    259                     pLayoutAudioSettings->addWidget(m_pLabelAudioHostDriver, 0, 0);
    260                 }
     246            m_pLayoutAudioSettings = new QGridLayout(m_pWidgetAudioSettings);
     247            if (m_pLayoutAudioSettings)
     248            {
     249                m_pLayoutAudioSettings->setContentsMargins(0, 0, 0, 0);
     250                m_pLayoutAudioSettings->setColumnStretch(1, 1);
     251
    261252                /* Prepare audio host driver editor: */
    262253                m_pEditorAudioHostDriver = new UIAudioHostDriverEditor(m_pWidgetAudioSettings);
    263254                if (m_pEditorAudioHostDriver)
    264                 {
    265                     if (m_pLabelAudioHostDriver)
    266                         m_pLabelAudioHostDriver->setBuddy(m_pEditorAudioHostDriver->focusProxy());
    267                     pLayoutAudioSettings->addWidget(m_pEditorAudioHostDriver, 0, 1, 1, 2);
    268                 }
    269 
    270                 /* Prepare audio host controller label: */
    271                 m_pLabelAudioController = new QLabel(m_pWidgetAudioSettings);
    272                 if (m_pLabelAudioController)
    273                 {
    274                     m_pLabelAudioController->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    275                     pLayoutAudioSettings->addWidget(m_pLabelAudioController, 1, 0);
    276                 }
     255                    m_pLayoutAudioSettings->addWidget(m_pEditorAudioHostDriver, 0, 0, 1, 3);
     256
    277257                /* Prepare audio host controller editor: */
    278258                m_pEditorAudioController = new UIAudioControllerEditor(m_pWidgetAudioSettings);
    279259                if (m_pEditorAudioController)
    280                 {
    281                     if (m_pLabelAudioController)
    282                         m_pLabelAudioController->setBuddy(m_pEditorAudioController->focusProxy());
    283                     pLayoutAudioSettings->addWidget(m_pEditorAudioController, 1, 1, 1, 2);
    284                 }
     260                    m_pLayoutAudioSettings->addWidget(m_pEditorAudioController, 1, 0, 1, 3);
    285261
    286262                /* Prepare audio extended label: */
     
    289265                {
    290266                    m_pLabelAudioExtended->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    291                     pLayoutAudioSettings->addWidget(m_pLabelAudioExtended, 2, 0);
     267                    m_pLayoutAudioSettings->addWidget(m_pLabelAudioExtended, 2, 0);
    292268                }
    293269                /* Prepare audio output check-box: */
    294270                m_pCheckBoxAudioOutput = new QCheckBox(m_pWidgetAudioSettings);
    295271                if (m_pCheckBoxAudioOutput)
    296                     pLayoutAudioSettings->addWidget(m_pCheckBoxAudioOutput, 2, 1);
     272                    m_pLayoutAudioSettings->addWidget(m_pCheckBoxAudioOutput, 2, 1);
    297273                /* Prepare audio input check-box: */
    298274                m_pCheckBoxAudioInput = new QCheckBox(m_pWidgetAudioSettings);
    299275                if (m_pCheckBoxAudioInput)
    300                     pLayoutAudioSettings->addWidget(m_pCheckBoxAudioInput, 3, 1);
     276                    m_pLayoutAudioSettings->addWidget(m_pCheckBoxAudioInput, 3, 1);
    301277            }
    302278
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.h

    r93990 r94039  
    2727/* Forward declarations: */
    2828class QCheckBox;
     29class QGridLayout;
    2930class QLabel;
    3031class UIAudioControllerEditor;
     
    9394        /** Holds the audio settings widget instance. */
    9495        QWidget                 *m_pWidgetAudioSettings;
    95         /** Holds the audio host driver label instance. */
    96         QLabel                  *m_pLabelAudioHostDriver;
     96        /** Holds the audio settings layout instance. */
     97        QGridLayout             *m_pLayoutAudioSettings;
    9798        /** Holds the audio host driver editor instance. */
    9899        UIAudioHostDriverEditor *m_pEditorAudioHostDriver;
    99         /** Holds the audio host controller label instance. */
    100         QLabel                  *m_pLabelAudioController;
    101100        /** Holds the audio host controller instance instance. */
    102101        UIAudioControllerEditor *m_pEditorAudioController;
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