VirtualBox

Changeset 4294 in vbox


Ignore:
Timestamp:
Aug 22, 2007 5:27:24 PM (17 years ago)
Author:
vboxsync
Message:

GUI Settings for Serial Port implemented:

VM Serial Port Settings implemented as one settings-page per each port (unified with tab-widget) /* network adapter like settings */.
Each page has:

  1. Combo-box with 4 predefined port configuration (I/O Base & IRQ). Each advanced-configuration (predefined with using of VBoxManage) are also added into this combo-box.
  2. Combo-box with 3 predefined host mode types (Disconnected, Host Pipe, Host Device).
  3. Check-box to define if port (in Host Pipe mode) is used as server port (disabled in other host mode types).
  4. Line-edit to enter the Pipe-Name or Device-Path (in Host Pipe and Host Device modes).
Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r4201 r4294  
    226226    }
    227227
     228    QString toString (CEnums::SerialHostMode t) const
     229    {
     230        AssertMsg (!serialHostModeTypes [t].isNull(), ("No text for %d", t));
     231        return serialHostModeTypes [t];
     232    }
     233
    228234    QString toString (CEnums::USBDeviceFilterAction t) const
    229235    {
     
    252258        AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.latin1()));
    253259        return CEnums::VRDPAuthType (it - vrdpAuthTypes.begin());
     260    }
     261
     262    CEnums::SerialHostMode toSerialHostMode (const QString &s) const
     263    {
     264        QStringVector::const_iterator it =
     265            qFind (serialHostModeTypes.begin(), serialHostModeTypes.end(), s);
     266        AssertMsg (it != serialHostModeTypes.end(), ("No value for {%s}", s.latin1()));
     267        return CEnums::SerialHostMode (it - serialHostModeTypes.begin());
    254268    }
    255269
     
    535549    QStringVector diskStorageTypes;
    536550    QStringVector vrdpAuthTypes;
     551    QStringVector serialHostModeTypes;
    537552    QStringVector usbFilterActionTypes;
    538553    QStringVector diskControllerDevices;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r4201 r4294  
    576576    , diskStorageTypes (CEnums::HardDiskStorageType_COUNT)
    577577    , vrdpAuthTypes (CEnums::VRDPAuthType_COUNT)
     578    , serialHostModeTypes (CEnums::SerialHostMode_COUNT)
    578579    , usbFilterActionTypes (CEnums::USBDeviceFilterAction_COUNT)
    579580    , diskControllerDevices (3)
     
    18621863        tr ("Guest", "VRDPAuthType");
    18631864
     1865    serialHostModeTypes [CEnums::Disconnected] =
     1866        tr ("Disconnected", "SerialHostMode");
     1867    serialHostModeTypes [CEnums::HostPipe] =
     1868        tr ("Host Pipe", "SerialHostMode");
     1869    serialHostModeTypes [CEnums::HostDevice] =
     1870        tr ("Host Device", "SerialHostMode");
     1871
    18641872    usbFilterActionTypes [CEnums::USBDeviceFilterIgnore] =
    18651873        tr ("Ignore", "USBFilterActionType");
     
    30693077 *  @a aClassName (if it is not NULL) and among children of @a aParent. If @a
    30703078 *  aParent is NULL, all top-level widgets are searched. If @a aRecursive is
    3071  *  true, child widgets are recursively searched as well. 
     3079 *  true, child widgets are recursively searched as well.
    30723080 */
    30733081/* static */
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r4071 r4294  
    268268            </property>
    269269        </item>
     270        <item>
     271            <property name="text">
     272                <string> Serial Port </string>
     273            </property>
     274            <property name="text">
     275                <string>9</string>
     276            </property>
     277            <property name="text">
     278                <string>#serial</string>
     279            </property>
     280            <property name="pixmap">
     281                <pixmap>refresh_16px.png</pixmap>
     282            </property>
     283            <property name="pixmap">
     284                <pixmap></pixmap>
     285            </property>
     286            <property name="pixmap">
     287                <pixmap></pixmap>
     288            </property>
     289        </item>
    270290            <property name="name">
    271291                <cstring>listView</cstring>
     
    26832703                <attribute name="id">
    26842704                    <number>8</number>
     2705                </attribute>
     2706            </widget>
     2707            <widget class="QWidget">
     2708                <property name="name">
     2709                    <cstring>pageSerial</cstring>
     2710                </property>
     2711                <attribute name="id">
     2712                    <number>9</number>
    26852713                </attribute>
    26862714            </widget>
     
    30383066    <forward>class VBoxUSBMenu</forward>
    30393067    <forward>class VBoxSharedFoldersSettings</forward>
     3068    <forward>class VBoxVMSerialPortSettings</forward>
    30403069    <forward>class QIRichLabel</forward>
    30413070    <forward>class BootItemsList</forward>
     
    30623091    <variable access="private">QWidgetStack *wstUSBFilters;</variable>
    30633092    <variable access="private">bool mUSBFilterListModified;</variable>
    3064     <variable access="private">VBoxSharedFoldersSettings* mSharedFolders;</variable>
     3093    <variable access="private">VBoxSharedFoldersSettings *mSharedFolders;</variable>
     3094    <variable access="private">VBoxVMSerialPortSettings *mSerialPorts;</variable>
    30653095    <variable access="private">QString warningString;</variable>
    30663096    <variable access="private">VBoxMediaComboBox *cbHDA;</variable>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r4166 r4294  
    469469};
    470470
     471
     472class VBoxVMSerialPortSettings : public QWidget
     473{
     474    Q_OBJECT
     475
     476public:
     477
     478    VBoxVMSerialPortSettings (QWidget *aParent)
     479        : QWidget (aParent, "VBoxVMSerialPortSettings")
     480        , mTabWidget (0)
     481    {
     482        /* Basic initialization */
     483        mTabWidget = new QTabWidget (this, "mTabWidget");
     484        mTabWidget->setMargin (11);
     485        mTabWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
     486        QVBoxLayout *mainLayout = new QVBoxLayout (this);
     487        mainLayout->addWidget (mTabWidget);
     488        mainLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Preferred,
     489                                                    QSizePolicy::Expanding));
     490
     491        /* Create a list of known COM interfaces configurations */
     492        mConfigList << PortConfig (0x3f8, 4, 1);
     493        mConfigList << PortConfig (0x2f8, 3, 2);
     494        mConfigList << PortConfig (0x3e8, 4, 3);
     495        mConfigList << PortConfig (0x2e8, 3, 4);
     496    }
     497
     498    void getFromMachine (const CMachine &aMachine)
     499    {
     500        mMachine = aMachine;
     501
     502        ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetSerialPortCount();
     503        for (ulong slot = 0; slot < count; ++ slot)
     504        {
     505            CSerialPort port = mMachine.GetSerialPort (slot);
     506            addPage (port, slot);
     507        }
     508
     509        /* Revalidate all pages */
     510        portConfigUpdate();
     511    }
     512
     513    void putBackToMachine()
     514    {
     515        for (int slot = 0; slot < mTabWidget->count(); ++ slot)
     516        {
     517            CSerialPort port = mMachine.GetSerialPort (slot);
     518
     519            port.SetEnabled (static_cast<QGroupBox*> (mTabWidget->page (slot))->isChecked());
     520
     521            PortConfig config = parsePortConfig (mPortList.at (slot)->currentText());
     522            port.SetIOBase (config.io);
     523            port.SetIRQ (config.irq);
     524
     525            port.SetHostMode (vboxGlobal().toSerialHostMode (mModeList.at (slot)->currentText()));
     526
     527            QCheckBox *chbIsServer = mIsServerList.at (slot);
     528            port.SetServer (chbIsServer->isEnabled() ?
     529                            chbIsServer->isChecked() : false);
     530
     531            QLineEdit *lePath = mPathList.at (slot);
     532            port.SetPath (lePath->isEnabled() ?
     533                          lePath->text() : QString::null);
     534        }
     535    }
     536
     537private slots:
     538
     539    void portConfigUpdate()
     540    {
     541        for (int index = 0; index < mTabWidget->count(); ++ index)
     542        {
     543            QComboBox *cbPortConfig = mPortList.at (index);
     544            QString oldText = cbPortConfig->currentText();
     545            QStringList newList = portConfigList (index);
     546            cbPortConfig->clear();
     547            cbPortConfig->insertStringList (newList);
     548            cbPortConfig->setCurrentText (oldText);
     549        }
     550    }
     551
     552    void hostModeUpdate (int aIndex = -1)
     553    {
     554        if (aIndex == -1)
     555            aIndex = mTabWidget->currentPageIndex();
     556        QCheckBox *chbIsServer = mIsServerList.at (aIndex);
     557        QLineEdit *lePath = mPathList.at (aIndex);
     558        CEnums::SerialHostMode mode = vboxGlobal().toSerialHostMode (
     559            mModeList.at (aIndex)->currentText());
     560        chbIsServer->setEnabled (mode == CEnums::HostPipe);
     561        lePath->setEnabled (mode != CEnums::Disconnected);
     562    }
     563
     564private:
     565
     566    struct PortConfig
     567    {
     568        PortConfig ()
     569            : io (0), irq (0), number (0) {}
     570        PortConfig (ulong aIO, ulong aIRQ, ulong aNumber)
     571            : io (aIO), irq (aIRQ), number (aNumber) {}
     572
     573        bool isNull() { return !io && !irq; }
     574
     575        bool operator== (const PortConfig &aCfg) const
     576        {
     577            return io  == aCfg.io && irq == aCfg.irq;
     578        }
     579
     580        static QString format()
     581        {
     582            return QString ("I/O Port = 0x%1, IRQ = %2");
     583        }
     584        QString toString()
     585        {
     586            QString info = format().arg (QString::number (io, 16)).arg (irq);
     587            if (number)
     588                info += QString (" (COM%1)").arg (number);
     589            return info;
     590        }
     591
     592        ulong io;
     593        ulong irq;
     594        ulong number;
     595    };
     596    typedef QValueList<PortConfig> PortConfigs;
     597
     598    void addPage (const CSerialPort &aPort, ulong aSlot)
     599    {
     600        /* Create Serial Port page */
     601        QGroupBox *gBox = new QGroupBox (tr ("&Enable Serial Port"));
     602        gBox->setColumnLayout (0, Qt::Vertical);
     603        gBox->layout()->setMargin (11);
     604        gBox->layout()->setSpacing (6);
     605        gBox->setCheckable (true);
     606
     607        QLabel *lbPort = new QLabel (tr ("Serial Port &Number"), gBox);
     608        QComboBox *cbPort = new QComboBox (gBox);
     609        lbPort->setBuddy (cbPort);
     610        connect (cbPort, SIGNAL (activated (int)),
     611                 this , SLOT (portConfigUpdate()));
     612
     613        QLabel *lbType = new QLabel (tr ("Serial Port Host &Mode"), gBox);
     614        QComboBox *cbMode = new QComboBox (gBox);
     615        lbType->setBuddy (cbMode);
     616        cbMode->insertItem (vboxGlobal().toString (CEnums::Disconnected));
     617        cbMode->insertItem (vboxGlobal().toString (CEnums::HostPipe));
     618        cbMode->insertItem (vboxGlobal().toString (CEnums::HostDevice));
     619        connect (cbMode, SIGNAL (activated (int)),
     620                 this , SLOT (hostModeUpdate()));
     621
     622        QCheckBox *chbIsServer = new QCheckBox (tr ("Act As &Server"), gBox);
     623
     624        QLabel *lbPath = new QLabel (tr ("Serial Port &Path"), gBox);
     625        QLineEdit *lePath = new QLineEdit (gBox);
     626        lbPath->setBuddy (lePath);
     627
     628        QGridLayout *pageLayout = new QGridLayout (gBox->layout());
     629        pageLayout->setAlignment (Qt::AlignTop);
     630        pageLayout->addWidget (lbPort, 0, 0);
     631        pageLayout->addMultiCellWidget (cbPort, 0, 0, 1, 2);
     632        pageLayout->addWidget (lbType, 1, 0);
     633        pageLayout->addWidget (cbMode, 1, 1);
     634        pageLayout->addWidget (chbIsServer, 1, 2);
     635        pageLayout->addWidget (lbPath, 2, 0);
     636        pageLayout->addMultiCellWidget (lePath, 2, 2, 1, 2);
     637
     638        /* Load machine information */
     639        gBox->setChecked (aPort.GetEnabled());
     640
     641        PortConfig config (aPort.GetIOBase(), aPort.GetIRQ(), 0);
     642        if (!mConfigList.contains (config))
     643            mConfigList << config;
     644        cbPort->insertStringList (portConfigList (mTabWidget->count()));
     645        for (int id = 0; id < cbPort->count(); ++ id)
     646            if (parsePortConfig (cbPort->text (id)) == config)
     647                cbPort->setCurrentItem (id);
     648
     649        cbMode->setCurrentText (vboxGlobal().toString (aPort.GetHostMode()));
     650
     651        chbIsServer->setChecked (aPort.GetServer());
     652
     653        lePath->setText (aPort.GetPath());
     654
     655        /* Append newly createrd widget */
     656        mTabWidget->addTab (gBox, tr ("Port &%1").arg (aSlot));
     657        mPortList.append (cbPort);
     658        mModeList.append (cbMode);
     659        mIsServerList.append (chbIsServer);
     660        mPathList.append (lePath);
     661
     662        /* Revalidate page */
     663        hostModeUpdate (aSlot);
     664    }
     665
     666    QStringList portConfigList (int aIndex)
     667    {
     668        QStringList list;
     669        PortConfigs config = portConfigs (aIndex);
     670        for (ulong id = 0; id < config.count(); ++ id)
     671            list << config [id].toString();
     672        return list;
     673    }
     674
     675    PortConfigs portConfigs (int aIndex)
     676    {
     677        PortConfigs config (mConfigList);
     678        if (aIndex == mTabWidget->count())
     679            return config;
     680
     681        for (int index = 0; index < mTabWidget->count(); ++ index)
     682        {
     683            if (index != aIndex)
     684            {
     685                PortConfig used = parsePortConfig (mPortList.at (index)->currentText());
     686                Assert (!used.isNull());
     687                config.remove (used);
     688            }
     689        }
     690        return config;
     691    }
     692
     693    PortConfig parsePortConfig (const QString &aString)
     694    {
     695        QRegExp regExp (PortConfig::format().arg ("([0-9a-f]+)").arg ("(\\d+)"));
     696        if (regExp.search (aString) != -1)
     697            return PortConfig (regExp.cap (1).toULong(0, 16),
     698                               regExp.cap (2).toULong(), 0);
     699        Assert (0);
     700        return PortConfig();
     701    }
     702
     703    QTabWidget *mTabWidget;
     704    PortConfigs mConfigList;
     705
     706    QPtrList<QComboBox> mPortList;
     707    QPtrList<QComboBox> mModeList;
     708    QPtrList<QCheckBox> mIsServerList;
     709    QPtrList<QLineEdit> mPathList;
     710
     711    CMachine mMachine;
     712};
     713
     714
    471715void VBoxVMSettingsDlg::init()
    472716{
     
    7771021    mSharedFolders->setDialogType (VBoxSharedFoldersSettings::MachineType);
    7781022    pageFoldersLayout->addWidget (mSharedFolders);
     1023
     1024    /* Serial Port Page */
     1025
     1026    QVBoxLayout* pageSerialLayout = new QVBoxLayout (pageSerial, 0, 0);
     1027    mSerialPorts = new VBoxVMSerialPortSettings (pageSerial);
     1028    pageSerialLayout->addWidget (mSerialPorts);
    7791029
    7801030    /*
     
    18012051    }
    18022052
     2053    /* serial ports */
     2054    {
     2055        mSerialPorts->getFromMachine (machine);
     2056    }
     2057
    18032058    /* request for media shortcuts update */
    18042059    cbHDA->setBelongsTo (machine.GetId());
     
    20592314    {
    20602315        mSharedFolders->putBackToMachine();
     2316    }
     2317
     2318    /* serial ports */
     2319    {
     2320        mSerialPorts->putBackToMachine();
    20612321    }
    20622322
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