VirtualBox

Changeset 85909 in vbox for trunk


Ignore:
Timestamp:
Aug 27, 2020 7:54:18 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9812: VM settings: Prepare cascade cleanup for Serial page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp

    r85750 r85909  
    131131private:
    132132
    133     /* Prepares widgets: */
     133    /** Prepares all. */
     134    void prepare();
     135    /** Prepares widgets. */
    134136    void prepareWidgets();
    135 
    136     /* Helper: Prepare stuff: */
    137     void prepareValidation();
     137    /** Prepares connections. */
     138    void prepareConnections();
    138139
    139140    /** Populates combo-boxes. */
     
    150151    /** @name Widgets
    151152     * @{ */
    152        QLineEdit *m_pLineEditIRQ;
    153        QLineEdit *m_pLineEditIOPort;
    154        QLineEdit *m_pLineEditPath;
    155        QComboBox *m_ComboBoxNumber;
    156        QComboBox *m_pComboBoxMode;
    157        QCheckBox *m_pCheckBoxSerial;
    158        QCheckBox *m_pComboBoxPipe;
    159        QLabel *m_pLabelNumber;
    160        QLabel *m_pLabelIRQ;
    161        QLabel *m_pLabelIOPort;
    162        QLabel *m_pLabelMode;
    163        QLabel *m_pLabelPath;
     153        /** Holds the port check-box instance. */
     154        QCheckBox *m_pCheckBoxPort;
     155        /** Holds the port settings widget instance. */
     156        QWidget   *m_pWidgetPortSettings;
     157        /** Holds the number label instance. */
     158        QLabel    *m_pLabelNumber;
     159        /** Holds the number combo instance. */
     160        QComboBox *m_pComboNumber;
     161        /** Holds the IRQ label instance. */
     162        QLabel    *m_pLabelIRQ;
     163        /** Holds the IRQ editor instance. */
     164        QLineEdit *m_pLineEditIRQ;
     165        /** Holds the IO port label instance. */
     166        QLabel    *m_pLabelIOPort;
     167        /** Holds the IO port editor instance. */
     168        QLineEdit *m_pLineEditIOPort;
     169        /** Holds the mode label instance. */
     170        QLabel    *m_pLabelMode;
     171        /** Holds the mode combo instance. */
     172        QComboBox *m_pComboMode;
     173        /** Holds the pipe check-box instance. */
     174        QCheckBox *m_pCheckBoxPipe;
     175        /** Holds the path label instance. */
     176        QLabel    *m_pLabelPath;
     177        /** Holds the path editor instance. */
     178        QLineEdit *m_pEditorPath;
    164179    /** @} */
    165180
     
    177192    , m_iSlot(-1)
    178193    , m_enmPortMode(KPortMode_Max)
     194    , m_pCheckBoxPort(0)
     195    , m_pWidgetPortSettings(0)
     196    , m_pLabelNumber(0)
     197    , m_pComboNumber(0)
     198    , m_pLabelIRQ(0)
    179199    , m_pLineEditIRQ(0)
     200    , m_pLabelIOPort(0)
    180201    , m_pLineEditIOPort(0)
    181     , m_pLineEditPath(0)
    182     , m_ComboBoxNumber(0)
    183     , m_pComboBoxMode(0)
    184     , m_pCheckBoxSerial(0)
    185     , m_pComboBoxPipe(0)
    186     , m_pLabelNumber(0)
    187     , m_pLabelIRQ(0)
    188     , m_pLabelIOPort(0)
    189202    , m_pLabelMode(0)
     203    , m_pComboMode(0)
     204    , m_pCheckBoxPipe(0)
    190205    , m_pLabelPath(0)
    191 {
    192     prepareWidgets();
    193 
    194     /* Setup validation: */
    195     m_pLineEditIRQ->setValidator(new QIULongValidator(0, 255, this));
    196     m_pLineEditIOPort->setValidator(new QIULongValidator(0, 0xFFFF, this));
    197     m_pLineEditPath->setValidator(new QRegExpValidator(QRegExp(".+"), this));
    198 
    199     /* Setup constraints: */
    200     m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().width("8888"));
    201     m_pLineEditIOPort->setFixedWidth(m_pLineEditIOPort->fontMetrics().width("8888888"));
    202 
    203     /* Set initial values: */
    204     /* Note: If you change one of the following don't forget retranslateUi. */
    205     m_ComboBoxNumber->insertItem(0, uiCommon().toCOMPortName(0, 0));
    206     m_ComboBoxNumber->insertItems(0, uiCommon().COMPortNames());
    207 
    208     /* Setup connections: */
    209     connect(m_pCheckBoxSerial, &QCheckBox::toggled,
    210             this, &UIMachineSettingsSerial::sltGbSerialToggled);
    211     connect(m_ComboBoxNumber, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::activated),
    212             this, &UIMachineSettingsSerial::sltCbNumberActivated);
    213     connect(m_pComboBoxMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
    214             this, &UIMachineSettingsSerial::sltHandlePortModeChange);
    215 
    216     /* Prepare validation: */
    217     prepareValidation();
    218 
    219     /* Apply language settings: */
    220     retranslateUi();
    221 }
    222 
    223 void UIMachineSettingsSerial::prepareWidgets()
    224 {
    225     if (objectName().isEmpty())
    226         setObjectName(QStringLiteral("UIMachineSettingsSerial"));
    227     resize(357, 179);
    228     QGridLayout *pMainLayout = new QGridLayout(this);
    229     pMainLayout->setObjectName(QStringLiteral("pMainLayout"));
    230     m_pCheckBoxSerial = new QCheckBox();
    231     m_pCheckBoxSerial->setObjectName(QStringLiteral("m_pCheckBoxSerial"));
    232     m_pCheckBoxSerial->setChecked(true);
    233 
    234     pMainLayout->addWidget(m_pCheckBoxSerial, 0, 0, 1, 2);
    235 
    236     QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    237     pMainLayout->addItem(pSpacerItem, 1, 0, 1, 1);
    238 
    239     QWidget *pWidgetSerialChild = new QWidget();
    240     pWidgetSerialChild->setObjectName(QStringLiteral("pWidgetSerialChild"));
    241     QGridLayout *pGridLayout1 = new QGridLayout(pWidgetSerialChild);
    242     pGridLayout1->setObjectName(QStringLiteral("pGridLayout1"));
    243     pGridLayout1->setContentsMargins(0, 0, 0, 0);
    244     m_pLabelNumber = new QLabel(pWidgetSerialChild);
    245     m_pLabelNumber->setObjectName(QStringLiteral("m_pLabelNumber"));
    246     m_pLabelNumber->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    247     pGridLayout1->addWidget(m_pLabelNumber, 0, 0, 1, 1);
    248 
    249     m_ComboBoxNumber = new QComboBox(pWidgetSerialChild);
    250     m_ComboBoxNumber->setObjectName(QStringLiteral("m_ComboBoxNumber"));
    251     pGridLayout1->addWidget(m_ComboBoxNumber, 0, 1, 1, 1);
    252 
    253     m_pLabelIRQ = new QLabel(pWidgetSerialChild);
    254     m_pLabelIRQ->setObjectName(QStringLiteral("m_pLabelIRQ"));
    255     pGridLayout1->addWidget(m_pLabelIRQ, 0, 2, 1, 1);
    256 
    257     m_pLineEditIRQ = new QLineEdit(pWidgetSerialChild);
    258     m_pLineEditIRQ->setObjectName(QStringLiteral("m_pLineEditIRQ"));
    259     pGridLayout1->addWidget(m_pLineEditIRQ, 0, 3, 1, 1);
    260 
    261     m_pLabelIOPort = new QLabel(pWidgetSerialChild);
    262     m_pLabelIOPort->setObjectName(QStringLiteral("m_pLabelIOPort"));
    263     pGridLayout1->addWidget(m_pLabelIOPort, 0, 4, 1, 1);
    264 
    265     m_pLineEditIOPort = new QLineEdit(pWidgetSerialChild);
    266     m_pLineEditIOPort->setObjectName(QStringLiteral("m_pLineEditIOPort"));
    267     pGridLayout1->addWidget(m_pLineEditIOPort, 0, 5, 1, 1);
    268 
    269     QSpacerItem *pSpacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    270     pGridLayout1->addItem(pSpacerItem1, 0, 6, 1, 1);
    271 
    272     m_pLabelMode = new QLabel(pWidgetSerialChild);
    273     m_pLabelMode->setObjectName(QStringLiteral("m_pLabelMode"));
    274     m_pLabelMode->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    275     pGridLayout1->addWidget(m_pLabelMode, 1, 0, 1, 1);
    276 
    277     m_pComboBoxMode = new QComboBox(pWidgetSerialChild);
    278     m_pComboBoxMode->setObjectName(QStringLiteral("m_pComboBoxMode"));
    279     pGridLayout1->addWidget(m_pComboBoxMode, 1, 1, 1, 1);
    280 
    281     QSpacerItem *pSpacerItem2 = new QSpacerItem(131, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    282     pGridLayout1->addItem(pSpacerItem2, 1, 2, 1, 4);
    283 
    284     m_pComboBoxPipe = new QCheckBox(pWidgetSerialChild);
    285     m_pComboBoxPipe->setObjectName(QStringLiteral("m_pComboBoxPipe"));
    286     pGridLayout1->addWidget(m_pComboBoxPipe, 2, 1, 1, 5);
    287 
    288     m_pLabelPath = new QLabel(pWidgetSerialChild);
    289     m_pLabelPath->setObjectName(QStringLiteral("m_pLabelPath"));
    290     m_pLabelPath->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    291     pGridLayout1->addWidget(m_pLabelPath, 3, 0, 1, 1);
    292 
    293     m_pLineEditPath = new QLineEdit(pWidgetSerialChild);
    294     m_pLineEditPath->setObjectName(QStringLiteral("m_pLineEditPath"));
    295     pGridLayout1->addWidget(m_pLineEditPath, 3, 1, 1, 6);
    296 
    297     pMainLayout->addWidget(pWidgetSerialChild, 1, 1, 1, 1);
    298     QSpacerItem *pSpacerItem3 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    299     pMainLayout->addItem(pSpacerItem3, 2, 0, 1, 2);
    300 
    301     m_pLabelNumber->setBuddy(m_ComboBoxNumber);
    302     m_pLabelIRQ->setBuddy(m_pLineEditIRQ);
    303     m_pLabelIOPort->setBuddy(m_pLineEditIOPort);
    304     m_pLabelMode->setBuddy(m_pComboBoxMode);
    305     m_pLabelPath->setBuddy(m_pLineEditPath);
    306 
    307     QObject::connect(m_pCheckBoxSerial, &QCheckBox::toggled, pWidgetSerialChild, &QLineEdit::setEnabled);
     206    , m_pEditorPath(0)
     207{
     208    prepare();
    308209}
    309210
     
    312213    /* Polish port page: */
    313214    ulong uIRQ, uIOBase;
    314     const bool fStd = uiCommon().toCOMPortNumbers(m_ComboBoxNumber->currentText(), uIRQ, uIOBase);
    315     const KPortMode enmMode = m_pComboBoxMode->currentData().value<KPortMode>();
    316     m_pCheckBoxSerial->setEnabled(m_pParent->isMachineOffline());
     215    const bool fStd = uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), uIRQ, uIOBase);
     216    const KPortMode enmMode = m_pComboMode->currentData().value<KPortMode>();
     217    m_pCheckBoxPort->setEnabled(m_pParent->isMachineOffline());
    317218    m_pLabelNumber->setEnabled(m_pParent->isMachineOffline());
    318     m_ComboBoxNumber->setEnabled(m_pParent->isMachineOffline());
     219    m_pComboNumber->setEnabled(m_pParent->isMachineOffline());
    319220    m_pLabelIRQ->setEnabled(m_pParent->isMachineOffline());
    320221    m_pLineEditIRQ->setEnabled(!fStd && m_pParent->isMachineOffline());
     
    322223    m_pLineEditIOPort->setEnabled(!fStd && m_pParent->isMachineOffline());
    323224    m_pLabelMode->setEnabled(m_pParent->isMachineOffline());
    324     m_pComboBoxMode->setEnabled(m_pParent->isMachineOffline());
    325     m_pComboBoxPipe->setEnabled(   (enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP)
     225    m_pComboMode->setEnabled(m_pParent->isMachineOffline());
     226    m_pCheckBoxPipe->setEnabled(   (enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP)
    326227                        && m_pParent->isMachineOffline());
    327228    m_pLabelPath->setEnabled(   enmMode != KPortMode_Disconnected
    328229                        && m_pParent->isMachineOffline());
    329     m_pLineEditPath->setEnabled(   enmMode != KPortMode_Disconnected
     230    m_pEditorPath->setEnabled(   enmMode != KPortMode_Disconnected
    330231                        && m_pParent->isMachineOffline());
    331232}
     
    337238
    338239    /* Load port data: */
    339     m_pCheckBoxSerial->setChecked(portData.m_fPortEnabled);
    340     m_ComboBoxNumber->setCurrentIndex(m_ComboBoxNumber->findText(uiCommon().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase)));
     240    m_pCheckBoxPort->setChecked(portData.m_fPortEnabled);
     241    m_pComboNumber->setCurrentIndex(m_pComboNumber->findText(uiCommon().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase)));
    341242    m_pLineEditIRQ->setText(QString::number(portData.m_uIRQ));
    342243    m_pLineEditIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper());
    343244    m_enmPortMode = portData.m_hostMode;
    344     m_pComboBoxPipe->setChecked(!portData.m_fServer);
    345     m_pLineEditPath->setText(portData.m_strPath);
     245    m_pCheckBoxPipe->setChecked(!portData.m_fServer);
     246    m_pEditorPath->setText(portData.m_strPath);
    346247
    347248    /* Repopulate combo-boxes content: */
    348249    populateComboboxes();
    349250    /* Ensure everything is up-to-date */
    350     sltGbSerialToggled(m_pCheckBoxSerial->isChecked());
     251    sltGbSerialToggled(m_pCheckBoxPort->isChecked());
    351252}
    352253
     
    354255{
    355256    /* Save port data: */
    356     portData.m_fPortEnabled = m_pCheckBoxSerial->isChecked();
     257    portData.m_fPortEnabled = m_pCheckBoxPort->isChecked();
    357258    portData.m_uIRQ = m_pLineEditIRQ->text().toULong(NULL, 0);
    358259    portData.m_uIOBase = m_pLineEditIOPort->text().toULong(NULL, 0);
    359     portData.m_fServer = !m_pComboBoxPipe->isChecked();
    360     portData.m_hostMode = m_pComboBoxMode->currentData().value<KPortMode>();
    361     portData.m_strPath = QDir::toNativeSeparators(m_pLineEditPath->text());
     260    portData.m_fServer = !m_pCheckBoxPipe->isChecked();
     261    portData.m_hostMode = m_pComboMode->currentData().value<KPortMode>();
     262    portData.m_strPath = QDir::toNativeSeparators(m_pEditorPath->text());
    362263}
    363264
    364265QWidget *UIMachineSettingsSerial::setOrderAfter(QWidget *pAfter)
    365266{
    366     setTabOrder(pAfter, m_pCheckBoxSerial);
    367     setTabOrder(m_pCheckBoxSerial, m_ComboBoxNumber);
    368     setTabOrder(m_ComboBoxNumber, m_pLineEditIRQ);
     267    setTabOrder(pAfter, m_pCheckBoxPort);
     268    setTabOrder(m_pCheckBoxPort, m_pComboNumber);
     269    setTabOrder(m_pComboNumber, m_pLineEditIRQ);
    369270    setTabOrder(m_pLineEditIRQ, m_pLineEditIOPort);
    370     setTabOrder(m_pLineEditIOPort, m_pComboBoxMode);
    371     setTabOrder(m_pComboBoxMode, m_pComboBoxPipe);
    372     setTabOrder(m_pComboBoxPipe, m_pLineEditPath);
    373     return m_pLineEditPath;
     271    setTabOrder(m_pLineEditIOPort, m_pComboMode);
     272    setTabOrder(m_pComboMode, m_pCheckBoxPipe);
     273    setTabOrder(m_pCheckBoxPipe, m_pEditorPath);
     274    return m_pEditorPath;
    374275}
    375276
     
    382283{
    383284    ulong a, b;
    384     return !uiCommon().toCOMPortNumbers(m_ComboBoxNumber->currentText(), a, b);
     285    return !uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), a, b);
    385286}
    386287
    387288void UIMachineSettingsSerial::retranslateUi()
    388289{
    389     m_pCheckBoxSerial->setWhatsThis(tr("When checked, enables the given serial port of the virtual machine."));
    390     m_pCheckBoxSerial->setText(tr("&Enable Serial Port"));
     290    m_pCheckBoxPort->setWhatsThis(tr("When checked, enables the given serial port of the virtual machine."));
     291    m_pCheckBoxPort->setText(tr("&Enable Serial Port"));
    391292    m_pLabelNumber->setText(tr("Port &Number:"));
    392     m_ComboBoxNumber->setWhatsThis(tr("Selects the serial port number. You can choose one of the standard serial ports or "
     293    m_pComboNumber->setWhatsThis(tr("Selects the serial port number. You can choose one of the standard serial ports or "
    393294                                      "select <b>User-defined</b> and specify port parameters manually."));
    394295    m_pLabelIRQ->setText(tr("&IRQ:"));
     
    400301                                       "range from <tt>0</tt> to <tt>0xFFFF</tt>."));
    401302    m_pLabelMode->setText(tr("Port &Mode:"));
    402     m_pComboBoxMode->setWhatsThis(tr("Selects the working mode of this serial port. If you select <b>Disconnected</b>, the guest "
     303    m_pComboMode->setWhatsThis(tr("Selects the working mode of this serial port. If you select <b>Disconnected</b>, the guest "
    403304                                     "OS will detect the serial port but will not be able to operate it."));
    404     m_pComboBoxPipe->setWhatsThis(tr("When checked, the virtual machine will assume that the pipe or socket specified in the "
     305    m_pCheckBoxPipe->setWhatsThis(tr("When checked, the virtual machine will assume that the pipe or socket specified in the "
    405306                                     "<b>Path/Address</b> field exists and try to use it. Otherwise, the pipe or socket will be "
    406307                                     "created by the virtual machine when it starts."));
    407     m_pComboBoxPipe->setText(tr("&Connect to existing pipe/socket"));
     308    m_pCheckBoxPipe->setText(tr("&Connect to existing pipe/socket"));
    408309    m_pLabelPath->setText(tr("&Path/Address:"));
    409     m_pLineEditPath->setWhatsThis(tr("<p>In <b>Host Pipe</b> mode: Holds the path to the serial port's pipe on the host. "
     310    m_pEditorPath->setWhatsThis(tr("<p>In <b>Host Pipe</b> mode: Holds the path to the serial port's pipe on the host. "
    410311                                     "Examples: \"\\\\.\\pipe\\myvbox\" or \"/tmp/myvbox\", for Windows and UNIX-like systems "
    411312                                     "respectively.</p><p>In <b>Host Device</b> mode: Holds the host serial device name. "
     
    414315                                     "the TCP \"port\" when in server mode, or \"hostname:port\" when in client mode."));
    415316
    416     m_ComboBoxNumber->setItemText(m_ComboBoxNumber->count() - 1, uiCommon().toCOMPortName(0, 0));
     317    m_pComboNumber->setItemText(m_pComboNumber->count() - 1, uiCommon().toCOMPortName(0, 0));
    417318
    418319    /* Translate combo-boxes content: */
     
    422323void UIMachineSettingsSerial::sltGbSerialToggled(bool fOn)
    423324{
     325    /* Update availability: */
     326    m_pWidgetPortSettings->setEnabled(m_pCheckBoxPort->isChecked());
     327
    424328    if (fOn)
    425329    {
    426         sltCbNumberActivated(m_ComboBoxNumber->currentText());
    427         sltHandlePortModeChange(m_pComboBoxMode->currentIndex());
     330        sltCbNumberActivated(m_pComboNumber->currentText());
     331        sltHandlePortModeChange(m_pComboMode->currentIndex());
    428332    }
    429333
     
    451355void UIMachineSettingsSerial::sltHandlePortModeChange(int iIndex)
    452356{
    453     const KPortMode enmMode = m_pComboBoxMode->itemData(iIndex).value<KPortMode>();
    454     m_pComboBoxPipe->setEnabled(enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP);
    455     m_pLineEditPath->setEnabled(enmMode != KPortMode_Disconnected);
     357    const KPortMode enmMode = m_pComboMode->itemData(iIndex).value<KPortMode>();
     358    m_pCheckBoxPipe->setEnabled(enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP);
     359    m_pEditorPath->setEnabled(enmMode != KPortMode_Disconnected);
    456360    m_pLabelPath->setEnabled(enmMode != KPortMode_Disconnected);
    457361
     
    460364}
    461365
    462 void UIMachineSettingsSerial::prepareValidation()
    463 {
    464     /* Prepare validation: */
     366void UIMachineSettingsSerial::prepare()
     367{
     368    /* Prepare everything: */
     369    prepareWidgets();
     370    prepareConnections();
     371
     372    /* Apply language settings: */
     373    retranslateUi();
     374}
     375
     376void UIMachineSettingsSerial::prepareWidgets()
     377{
     378    /* Prepare main layout: */
     379    QGridLayout *pMainLayout = new QGridLayout(this);
     380    if (pMainLayout)
     381    {
     382        pMainLayout->setRowStretch(2, 1);
     383
     384        /* Prepare port check-box: */
     385        m_pCheckBoxPort = new QCheckBox(this);
     386        if (m_pCheckBoxPort)
     387            pMainLayout->addWidget(m_pCheckBoxPort, 0, 0, 1, 2);
     388
     389        /* Prepare 20-px shifting spacer: */
     390        QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
     391        if (pSpacerItem)
     392            pMainLayout->addItem(pSpacerItem, 1, 0);
     393
     394        /* Prepare adapter settings widget: */
     395        m_pWidgetPortSettings = new QWidget(this);
     396        if (m_pWidgetPortSettings)
     397        {
     398            /* Prepare adapter settings widget layout: */
     399            QGridLayout *pLayoutPortSettings = new QGridLayout(m_pWidgetPortSettings);
     400            if (pLayoutPortSettings)
     401            {
     402                pLayoutPortSettings->setContentsMargins(0, 0, 0, 0);
     403                pLayoutPortSettings->setColumnStretch(6, 1);
     404
     405                /* Prepare number label: */
     406                m_pLabelNumber = new QLabel(m_pWidgetPortSettings);
     407                if (m_pLabelNumber)
     408                {
     409                    m_pLabelNumber->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     410                    pLayoutPortSettings->addWidget(m_pLabelNumber, 0, 0);
     411                }
     412                /* Prepare number combo: */
     413                m_pComboNumber = new QComboBox(m_pWidgetPortSettings);
     414                if (m_pComboNumber)
     415                {
     416                    m_pLabelNumber->setBuddy(m_pComboNumber);
     417                    m_pComboNumber->insertItem(0, uiCommon().toCOMPortName(0, 0));
     418                    m_pComboNumber->insertItems(0, uiCommon().COMPortNames());
     419                    pLayoutPortSettings->addWidget(m_pComboNumber, 0, 1);
     420                }
     421                /* Prepare IRQ label: */
     422                m_pLabelIRQ = new QLabel(m_pWidgetPortSettings);
     423                if (m_pLabelIRQ)
     424                    pLayoutPortSettings->addWidget(m_pLabelIRQ, 0, 2);
     425                /* Prepare IRQ label: */
     426                m_pLineEditIRQ = new QLineEdit(m_pWidgetPortSettings);
     427                if (m_pLineEditIRQ)
     428                {
     429                    m_pLabelIRQ->setBuddy(m_pLineEditIRQ);
     430                    m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().width("8888"));
     431                    m_pLineEditIRQ->setValidator(new QIULongValidator(0, 255, this));
     432                    pLayoutPortSettings->addWidget(m_pLineEditIRQ, 0, 3);
     433                }
     434                /* Prepare IO port label: */
     435                m_pLabelIOPort = new QLabel(m_pWidgetPortSettings);
     436                if (m_pLabelIOPort)
     437                    pLayoutPortSettings->addWidget(m_pLabelIOPort, 0, 4);
     438                /* Prepare IO port label: */
     439                m_pLineEditIOPort = new QLineEdit(m_pWidgetPortSettings);
     440                if (m_pLineEditIOPort)
     441                {
     442                    m_pLabelIOPort->setBuddy(m_pLineEditIOPort);
     443                    m_pLineEditIOPort->setFixedWidth(m_pLineEditIOPort->fontMetrics().width("8888888"));
     444                    m_pLineEditIOPort->setValidator(new QIULongValidator(0, 0xFFFF, this));
     445                    pLayoutPortSettings->addWidget(m_pLineEditIOPort, 0, 5);
     446                }
     447
     448                /* Prepare mode label: */
     449                m_pLabelMode = new QLabel(m_pWidgetPortSettings);
     450                if (m_pLabelMode)
     451                {
     452                    m_pLabelMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     453                    pLayoutPortSettings->addWidget(m_pLabelMode, 1, 0);
     454                }
     455                /* Prepare mode combo: */
     456                m_pComboMode = new QComboBox(m_pWidgetPortSettings);
     457                if (m_pComboMode)
     458                {
     459                    m_pLabelMode->setBuddy(m_pComboMode);
     460                    pLayoutPortSettings->addWidget(m_pComboMode, 1, 1);
     461                }
     462
     463                /* Prepare pipe check-box: */
     464                m_pCheckBoxPipe = new QCheckBox(m_pWidgetPortSettings);
     465                if (m_pCheckBoxPipe)
     466                    pLayoutPortSettings->addWidget(m_pCheckBoxPipe, 2, 1, 1, 5);
     467
     468                /* Prepare path label: */
     469                m_pLabelPath = new QLabel(m_pWidgetPortSettings);
     470                if (m_pLabelPath)
     471                {
     472                    m_pLabelPath->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     473                    pLayoutPortSettings->addWidget(m_pLabelPath, 3, 0);
     474                }
     475                /* Prepare path editor: */
     476                m_pEditorPath = new QLineEdit(m_pWidgetPortSettings);
     477                if (m_pEditorPath)
     478                {
     479                    m_pLabelPath->setBuddy(m_pEditorPath);
     480                    m_pEditorPath->setValidator(new QRegExpValidator(QRegExp(".+"), this));
     481                    pLayoutPortSettings->addWidget(m_pEditorPath, 3, 1, 1, 6);
     482                }
     483            }
     484
     485            pMainLayout->addWidget(m_pWidgetPortSettings, 1, 1);
     486        }
     487    }
     488}
     489
     490void UIMachineSettingsSerial::prepareConnections()
     491{
     492    connect(m_pCheckBoxPort, &QCheckBox::toggled, this, &UIMachineSettingsSerial::sltGbSerialToggled);
     493    connect(m_pComboNumber, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::activated),
     494            this, &UIMachineSettingsSerial::sltCbNumberActivated);
    465495    connect(m_pLineEditIRQ, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate);
    466496    connect(m_pLineEditIOPort, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate);
    467     connect(m_pLineEditPath, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate);
     497    connect(m_pComboMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
     498            this, &UIMachineSettingsSerial::sltHandlePortModeChange);
     499    connect(m_pEditorPath, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate);
    468500}
    469501
     
    473505    {
    474506        /* Clear the port mode combo-box: */
    475         m_pComboBoxMode->clear();
     507        m_pComboMode->clear();
    476508
    477509        /* Load currently supported port moded: */
     
    486518        foreach (const KPortMode &enmMode, supportedModes)
    487519        {
    488             m_pComboBoxMode->insertItem(iPortModeIndex, gpConverter->toString(enmMode));
    489             m_pComboBoxMode->setItemData(iPortModeIndex, QVariant::fromValue(enmMode));
    490             m_pComboBoxMode->setItemData(iPortModeIndex, m_pComboBoxMode->itemText(iPortModeIndex), Qt::ToolTipRole);
     520            m_pComboMode->insertItem(iPortModeIndex, gpConverter->toString(enmMode));
     521            m_pComboMode->setItemData(iPortModeIndex, QVariant::fromValue(enmMode));
     522            m_pComboMode->setItemData(iPortModeIndex, m_pComboMode->itemText(iPortModeIndex), Qt::ToolTipRole);
    491523            ++iPortModeIndex;
    492524        }
    493525
    494526        /* Choose requested port mode: */
    495         const int iIndex = m_pComboBoxMode->findData(m_enmPortMode);
    496         m_pComboBoxMode->setCurrentIndex(iIndex != -1 ? iIndex : 0);
     527        const int iIndex = m_pComboMode->findData(m_enmPortMode);
     528        m_pComboMode->setCurrentIndex(iIndex != -1 ? iIndex : 0);
    497529    }
    498530}
     
    646678        QWidget *pTab = m_pTabWidget->widget(iIndex);
    647679        UIMachineSettingsSerial *pPage = static_cast<UIMachineSettingsSerial*>(pTab);
    648         if (!pPage->m_pCheckBoxSerial->isChecked())
     680        if (!pPage->m_pCheckBoxPort->isChecked())
    649681            continue;
    650682
     
    676708        ports << pair;
    677709
    678         const KPortMode enmMode = pPage->m_pComboBoxMode->currentData().value<KPortMode>();
     710        const KPortMode enmMode = pPage->m_pComboMode->currentData().value<KPortMode>();
    679711        if (enmMode != KPortMode_Disconnected)
    680712        {
    681             const QString strPath(pPage->m_pLineEditPath->text());
     713            const QString strPath(pPage->m_pEditorPath->text());
    682714
    683715            if (strPath.isEmpty())
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