VirtualBox

Changeset 5837 in vbox


Ignore:
Timestamp:
Nov 26, 2007 4:49:18 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
26295
Message:

2481: “Create parallel port UI”: implemented.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r5570 r5837  
    88#
    99#  Copyright (C) 2006-2007 innotek GmbH
    10 # 
     10#
    1111#  This file is part of VirtualBox Open Source Edition (OSE), as
    1212#  available from http://www.virtualbox.org. This file is free software;
     
    2323        ui/VBoxVMNetworkSettings.ui \
    2424        ui/VBoxVMSerialPortSettings.ui \
     25        ui/VBoxVMParallelPortSettings.ui \
    2526        ui/VBoxUSBFilterSettings.ui \
    2627        ui/VBoxSharedFoldersSettings.ui \
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r5370 r5837  
    372372    QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
    373373    bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
     374
     375    QStringList LPTPortNames() const;
     376    QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
     377    bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
    374378
    375379    QPixmap snapshotIcon (bool online) const
     
    605609    QStringVector USBDeviceStates;
    606610
    607     QString mUserDefinedCOMPortName;
     611    QString mUserDefinedPortName;
    608612
    609613    mutable bool detailReportTemplatesReady;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r5370 r5837  
    957957}
    958958
    959 static const struct PortConfig
     959struct PortConfig
    960960{
    961961    const char *name;
    962962    const ulong IRQ;
    963963    const ulong IOBase;
    964 }
    965 kKnownPorts[] =
     964};
     965
     966static const PortConfig comKnownPorts[] =
    966967{
    967968    { "COM1", 4, 0x3F8 },
     
    973974};
    974975
     976static const PortConfig lptKnownPorts[] =
     977{
     978    { "LPT1", 7, 0x3BC },
     979    { "LPT2", 5, 0x378 },
     980    { "LPT3", 5, 0x278 },
     981    /* must not contain an element with IRQ=0 and IOBase=0 used to cause
     982     * toLPTPortName() to return the "User-defined" string for these values. */
     983};
     984
    975985/**
    976986 *  Returns the list of the standard COM port names (i.e. "COMx").
     
    979989{
    980990    QStringList list;
    981     for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i)
    982         list << kKnownPorts [i].name;
     991    for (size_t i = 0; i < ELEMENTS (comKnownPorts); ++ i)
     992        list << comKnownPorts [i].name;
     993
     994    return list;
     995}
     996
     997/**
     998 *  Returns the list of the standard LPT port names (i.e. "LPTx").
     999 */
     1000QStringList VBoxGlobal::LPTPortNames() const
     1001{
     1002    QStringList list;
     1003    for (size_t i = 0; i < ELEMENTS (lptKnownPorts); ++ i)
     1004        list << lptKnownPorts [i].name;
    9831005
    9841006    return list;
     
    9921014QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const
    9931015{
    994     for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i)
    995         if (kKnownPorts [i].IRQ == aIRQ &&
    996             kKnownPorts [i].IOBase == aIOBase)
    997             return kKnownPorts [i].name;
    998 
    999     return mUserDefinedCOMPortName;
     1016    for (size_t i = 0; i < ELEMENTS (comKnownPorts); ++ i)
     1017        if (comKnownPorts [i].IRQ == aIRQ &&
     1018            comKnownPorts [i].IOBase == aIOBase)
     1019            return comKnownPorts [i].name;
     1020
     1021    return mUserDefinedPortName;
     1022}
     1023
     1024/**
     1025 *  Returns the name of the standard LPT port corresponding to the given
     1026 *  parameters, or "User-defined" (which is also returned when both
     1027 *  @a aIRQ and @a aIOBase are 0).
     1028 */
     1029QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const
     1030{
     1031    for (size_t i = 0; i < ELEMENTS (lptKnownPorts); ++ i)
     1032        if (lptKnownPorts [i].IRQ == aIRQ &&
     1033            lptKnownPorts [i].IOBase == aIOBase)
     1034            return lptKnownPorts [i].name;
     1035
     1036    return mUserDefinedPortName;
    10001037}
    10011038
     
    10081045                                   ulong &aIOBase) const
    10091046{
    1010     for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i)
    1011         if (strcmp (kKnownPorts [i].name, aName.utf8().data()) == 0)
    1012         {
    1013             aIRQ = kKnownPorts [i].IRQ;
    1014             aIOBase = kKnownPorts [i].IOBase;
     1047    for (size_t i = 0; i < ELEMENTS (comKnownPorts); ++ i)
     1048        if (strcmp (comKnownPorts [i].name, aName.utf8().data()) == 0)
     1049        {
     1050            aIRQ = comKnownPorts [i].IRQ;
     1051            aIOBase = comKnownPorts [i].IOBase;
     1052            return true;
     1053        }
     1054
     1055    return false;
     1056}
     1057
     1058/**
     1059 *  Returns port parameters corresponding to the given standard LPT name.
     1060 *  Returns @c true on success, or @c false if the given port name is not one
     1061 *  of the standard names (i.e. "LPTx").
     1062 */
     1063bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ,
     1064                                   ulong &aIOBase) const
     1065{
     1066    for (size_t i = 0; i < ELEMENTS (lptKnownPorts); ++ i)
     1067        if (strcmp (lptKnownPorts [i].name, aName.utf8().data()) == 0)
     1068        {
     1069            aIRQ = lptKnownPorts [i].IRQ;
     1070            aIOBase = lptKnownPorts [i].IOBase;
    10151071            return true;
    10161072        }
     
    15141570                    if (mode == CEnums::HostPipePort ||
    15151571                        mode == CEnums::HostDevicePort)
    1516                         data += QString ("%1 (<nobr>%1</nobr>)")
     1572                        data += QString ("%1 (<nobr>%2</nobr>)")
    15171573                            .arg (vboxGlobal().toString (mode))
    15181574                            .arg (QDir::convertSeparators (port.GetPath()));
     
    15391595                      "#serialPorts", /* link */
    15401596                      tr ("Serial Ports", "details report"), /* title */
     1597                      item); /* items */
     1598        }
     1599        /* parallel ports */
     1600        {
     1601            item = QString::null;
     1602            ulong count = mVBox.GetSystemProperties().GetParallelPortCount();
     1603            int rows = 2; /* including section header and footer */
     1604            for (ulong slot = 0; slot < count; slot ++)
     1605            {
     1606                CParallelPort port = m.GetParallelPort (slot);
     1607                if (port.GetEnabled())
     1608                {
     1609                    QString data =
     1610                        toLPTPortName (port.GetIRQ(), port.GetIOBase()) +
     1611                        QString (" (<nobr>%1</nobr>)")
     1612                        .arg (QDir::convertSeparators (port.GetPath()));
     1613
     1614                    item += QString (sSectionItemTpl)
     1615                        .arg (tr ("Port %1", "details report (parallel ports)")
     1616                              .arg (port.GetSlot()))
     1617                        .arg (data);
     1618                    ++ rows;
     1619                }
     1620            }
     1621            if (item.isNull())
     1622            {
     1623                item = QString (sSectionItemTpl)
     1624                    .arg (tr ("Disabled", "details report (parallel ports)"), "");
     1625                ++ rows;
     1626            }
     1627
     1628            detailsReport += sectionTpl
     1629                .arg (rows) /* rows */
     1630                .arg ("serial_port_16px.png", /* icon */
     1631                      "#parallelPorts", /* link */
     1632                      tr ("Parallel Ports", "details report"), /* title */
    15411633                      item); /* items */
    15421634        }
     
    21212213        tr ("Captured", "USBDeviceState");
    21222214
    2123     mUserDefinedCOMPortName = tr ("User-defined", "serial port");
     2215    mUserDefinedPortName = tr ("User-defined", "serial port");
    21242216
    21252217    detailReportTemplatesReady = false;
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSerialPortSettings.ui

    r5194 r5837  
    66
    77     Copyright (C) 2006-2007 innotek GmbH
    8    
     8
    99     This file is part of VirtualBox Open Source Edition (OSE), as
    1010     available from http://www.virtualbox.org. This file is free software;
     
    230230    <include location="global" impldecl="in implementation">qvalidator.h</include>
    231231    <include location="local" impldecl="in implementation">VBoxGlobal.h</include>
    232     <include location="local" impldecl="in implementation">VBoxProblemReporter.h</include>
    233232    <include location="local" impldecl="in implementation">VBoxVMSerialPortSettings.ui.h</include>
    234233</includes>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSerialPortSettings.ui.h

    r5807 r5837  
    8383    mPort.SetIOBase (mIOPortLine->text().toULong (NULL, 0));
    8484
    85     CEnums::PortMode mode = vboxGlobal().toPortMode (mHostModeCombo->currentText());
    86     mPort.SetHostMode (mode);
     85    mPort.SetPath (QDir::convertSeparators (mPortPathLine->text()));
    8786
     87    mPort.SetHostMode (vboxGlobal().toPortMode (mHostModeCombo->currentText()));
    8888    mPort.SetServer (mServerCheck->isChecked());
    89     mPort.SetPath (QDir::convertSeparators (mPortPathLine->text()));
    9089}
    9190
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui

    r5795 r5837  
    213213            </property>
    214214            <property name="text">
    215                 <string>7</string>
     215                <string>8</string>
    216216            </property>
    217217            <property name="text">
     
    233233            </property>
    234234            <property name="text">
    235                 <string>9</string>
     235                <string>10</string>
    236236            </property>
    237237            <property name="text">
     
    253253            </property>
    254254            <property name="text">
    255                 <string>8</string>
     255                <string>9</string>
    256256            </property>
    257257            <property name="text">
     
    277277            <property name="text">
    278278                <string>#serialPorts</string>
     279            </property>
     280            <property name="pixmap">
     281                <pixmap>serial_port_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>
     290        <item>
     291            <property name="text">
     292                <string> Parallel Ports </string>
     293            </property>
     294            <property name="text">
     295                <string>7</string>
     296            </property>
     297            <property name="text">
     298                <string>#parallelPorts</string>
    279299            </property>
    280300            <property name="pixmap">
     
    22762296                </property>
    22772297                <attribute name="id">
    2278                     <number>7</number>
     2298                    <number>8</number>
    22792299                </attribute>
    22802300                <vbox>
     
    25362556                </property>
    25372557                <attribute name="id">
    2538                     <number>9</number>
     2558                    <number>10</number>
    25392559                </attribute>
    25402560                <vbox>
     
    27502770                </property>
    27512771                <attribute name="id">
    2752                     <number>8</number>
     2772                    <number>9</number>
    27532773                </attribute>
    27542774            </widget>
     
    27702790                        <property name="name">
    27712791                            <cstring>tbwSerialPorts</cstring>
     2792                        </property>
     2793                        <property name="sizePolicy">
     2794                            <sizepolicy>
     2795                                <hsizetype>1</hsizetype>
     2796                                <vsizetype>1</vsizetype>
     2797                                <horstretch>0</horstretch>
     2798                                <verstretch>0</verstretch>
     2799                            </sizepolicy>
     2800                        </property>
     2801                    </widget>
     2802                </vbox>
     2803            </widget>
     2804            <widget class="QWidget">
     2805                <property name="name">
     2806                    <cstring>pageParallel</cstring>
     2807                </property>
     2808                <attribute name="id">
     2809                    <number>7</number>
     2810                </attribute>
     2811                <vbox>
     2812                    <property name="name">
     2813                        <cstring>unnamed</cstring>
     2814                    </property>
     2815                    <property name="margin">
     2816                        <number>0</number>
     2817                    </property>
     2818                    <widget class="QTabWidget">
     2819                        <property name="name">
     2820                            <cstring>tbwParallelPorts</cstring>
    27722821                        </property>
    27732822                        <property name="sizePolicy">
     
    31213170    <include location="local" impldecl="in implementation">VBoxVMNetworkSettings.h</include>
    31223171    <include location="local" impldecl="in implementation">VBoxVMSerialPortSettings.h</include>
     3172    <include location="local" impldecl="in implementation">VBoxVMParallelPortSettings.h</include>
    31233173    <include location="local" impldecl="in implementation">VBoxUSBFilterSettings.h</include>
    31243174    <include location="local" impldecl="in implementation">VBoxSharedFoldersSettings.h</include>
     
    31833233    <slot>addNetworkAdapter( const CNetworkAdapter &amp; )</slot>
    31843234    <slot>addSerialPort( const CSerialPort &amp; )</slot>
     3235    <slot>addParallelPort( const CParallelPort &amp; )</slot>
    31853236    <slot>slRAM_valueChanged( int val )</slot>
    31863237    <slot>leRAM_textChanged( const QString &amp; text )</slot>
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r5807 r5837  
    15051505    else if (pg == pageSerial)
    15061506    {
     1507        valid = true;
    15071508        QValueList <QString> ports;
    15081509        QValueList <QString> paths;
     
    15411542                        tr ("Duplicate port path is entered ");
    15421543                    pageTitle += ": " + tbwSerialPorts->tabLabel (tab);
     1544                    break;
     1545                }
     1546                paths << path;
     1547            }
     1548        }
     1549    }
     1550    else if (pg == pageParallel)
     1551    {
     1552        valid = true;
     1553        QValueList <QString> ports;
     1554        QValueList <QString> paths;
     1555
     1556        int index = 0;
     1557        for (; index < tbwParallelPorts->count(); ++ index)
     1558        {
     1559            QWidget *tab = tbwParallelPorts->page (index);
     1560            VBoxVMParallelPortSettings *page =
     1561                static_cast <VBoxVMParallelPortSettings *> (tab);
     1562
     1563            /* check the predefined port number unicity */
     1564            if (page->mParallelPortBox->isChecked() && !page->isUserDefined())
     1565            {
     1566                QString port = page->mPortNumCombo->currentText();
     1567                valid = !ports.contains (port);
     1568                if (!valid)
     1569                {
     1570                    warningText = tr ("Duplicate port number is selected ");
     1571                    pageTitle += ": " + tbwParallelPorts->tabLabel (tab);
     1572                    break;
     1573                }
     1574                ports << port;
     1575            }
     1576            /* check the port path emptiness & unicity */
     1577            if (page->mParallelPortBox->isChecked())
     1578            {
     1579                QString path = page->mPortPathLine->text();
     1580                valid = !path.isEmpty() && !paths.contains (path);
     1581                if (!valid)
     1582                {
     1583                    warningText = path.isEmpty() ?
     1584                        tr ("Port path is not specified ") :
     1585                        tr ("Duplicate port path is entered ");
     1586                    pageTitle += ": " + tbwParallelPorts->tabLabel (tab);
    15431587                    break;
    15441588                }
     
    18301874    }
    18311875
     1876    /* parallel ports */
     1877    {
     1878        ulong count = vbox.GetSystemProperties().GetParallelPortCount();
     1879        for (ulong slot = 0; slot < count; ++ slot)
     1880        {
     1881            CParallelPort port = machine.GetParallelPort (slot);
     1882            addParallelPort (port);
     1883        }
     1884    }
     1885
    18321886    /* USB */
    18331887    {
     
    21152169            VBoxVMSerialPortSettings *page =
    21162170                (VBoxVMSerialPortSettings *) tbwSerialPorts->page (index);
     2171            Assert (page);
     2172            page->putBackToPort();
     2173        }
     2174    }
     2175
     2176    /* parallel ports */
     2177    {
     2178        for (int index = 0; index < tbwParallelPorts->count(); index++)
     2179        {
     2180            VBoxVMParallelPortSettings *page =
     2181                (VBoxVMParallelPortSettings *) tbwParallelPorts->page (index);
    21172182            Assert (page);
    21182183            page->putBackToPort();
     
    23062371}
    23072372
     2373void VBoxVMSettingsDlg::addParallelPort (const CParallelPort &aPort)
     2374{
     2375    VBoxVMParallelPortSettings *page = new VBoxVMParallelPortSettings();
     2376    page->getFromPort (aPort);
     2377    QString pageTitle = QString (tr ("Port %1", "parallel ports"))
     2378                                 .arg (aPort.GetSlot());
     2379    tbwParallelPorts->addTab (page, pageTitle);
     2380
     2381    /* fix the tab order so that main dialog's buttons are always the last */
     2382    setTabOrder (page->mPortPathLine, buttonHelp);
     2383    setTabOrder (buttonHelp, buttonOk);
     2384    setTabOrder (buttonOk, buttonCancel);
     2385
     2386    /* setup validation */
     2387    QIWidgetValidator *wval =
     2388        new QIWidgetValidator (QString ("%1: %2")
     2389                               .arg (pagePath (pageParallel), pageTitle),
     2390                               pageParallel, this);
     2391    connect (page->mParallelPortBox, SIGNAL (toggled (bool)),
     2392             wval, SLOT (revalidate()));
     2393    connect (page->mIRQLine, SIGNAL (textChanged (const QString &)),
     2394             wval, SLOT (revalidate()));
     2395    connect (page->mIOPortLine, SIGNAL (textChanged (const QString &)),
     2396             wval, SLOT (revalidate()));
     2397    connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)),
     2398             this, SLOT (enableOk (const QIWidgetValidator *)));
     2399    connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)),
     2400             this, SLOT (revalidate (QIWidgetValidator *)));
     2401
     2402    wval->revalidate();
     2403}
     2404
    23082405void VBoxVMSettingsDlg::slRAM_valueChanged( int val )
    23092406{
Note: See TracChangeset for help on using the changeset viewer.

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