Changeset 4324 in vbox for trunk/src/VBox/Frontends/VirtualBox/ui
- Timestamp:
- Aug 23, 2007 7:01:31 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 23856
- Location:
- trunk/src/VBox/Frontends/VirtualBox/ui
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMNetworkSettings.ui.h
r4071 r4324 26 26 *****************************************************************************/ 27 27 28 /**29 * VBoxVMNetworkSettings class to use as network interface setup page.30 */31 28 void VBoxVMNetworkSettings::init() 32 29 { -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r4294 r4324 270 270 <item> 271 271 <property name="text"> 272 <string> Serial Port </string>272 <string> Serial Ports </string> 273 273 </property> 274 274 <property name="text"> … … 276 276 </property> 277 277 <property name="text"> 278 <string>#serial </string>278 <string>#serialPorts</string> 279 279 </property> 280 280 <property name="pixmap"> 281 <pixmap> refresh_16px.png</pixmap>281 <pixmap></pixmap> 282 282 </property> 283 283 <property name="pixmap"> … … 2712 2712 <number>9</number> 2713 2713 </attribute> 2714 <vbox> 2715 <property name="name"> 2716 <cstring>unnamed</cstring> 2717 </property> 2718 <property name="margin"> 2719 <number>0</number> 2720 </property> 2721 <widget class="QTabWidget"> 2722 <property name="name"> 2723 <cstring>tbwSerialPorts</cstring> 2724 </property> 2725 <property name="sizePolicy"> 2726 <sizepolicy> 2727 <hsizetype>1</hsizetype> 2728 <vsizetype>1</vsizetype> 2729 <horstretch>0</horstretch> 2730 <verstretch>0</verstretch> 2731 </sizepolicy> 2732 </property> 2733 </widget> 2734 </vbox> 2714 2735 </widget> 2715 2736 </widget> … … 3055 3076 <include location="local" impldecl="in declaration">VBoxGlobal.h</include> 3056 3077 <include location="local" impldecl="in implementation">VBoxVMNetworkSettings.h</include> 3078 <include location="local" impldecl="in implementation">VBoxVMSerialPortSettings.h</include> 3057 3079 <include location="local" impldecl="in implementation">VBoxUSBFilterSettings.h</include> 3058 3080 <include location="local" impldecl="in implementation">VBoxSharedFoldersSettings.h</include> … … 3066 3088 <forward>class VBoxUSBMenu</forward> 3067 3089 <forward>class VBoxSharedFoldersSettings</forward> 3068 <forward>class VBoxVMSerialPortSettings</forward>3069 3090 <forward>class QIRichLabel</forward> 3070 3091 <forward>class BootItemsList</forward> … … 3092 3113 <variable access="private">bool mUSBFilterListModified;</variable> 3093 3114 <variable access="private">VBoxSharedFoldersSettings *mSharedFolders;</variable> 3094 <variable access="private">VBoxVMSerialPortSettings *mSerialPorts;</variable>3095 3115 <variable access="private">QString warningString;</variable> 3096 3116 <variable access="private">VBoxMediaComboBox *cbHDA;</variable> … … 3116 3136 <slot>showImageManagerISOFloppy()</slot> 3117 3137 <slot>showVDImageManager( QUuid *id, VBoxMediaComboBox *le, QLabel *tx = NULL )</slot> 3118 <slot>addNetworkAdapter( const CNetworkAdapter & adapter )</slot> 3138 <slot>addNetworkAdapter( const CNetworkAdapter & )</slot> 3139 <slot>addSerialPort( const CSerialPort & )</slot> 3119 3140 <slot>slRAM_valueChanged( int val )</slot> 3120 3141 <slot>leRAM_textChanged( const QString & text )</slot> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r4300 r4324 470 470 471 471 472 class VBoxVMSerialPortSettings : public QWidget473 {474 Q_OBJECT475 476 public: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 537 private 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 564 private:565 566 struct PortConfig567 {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) const576 {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 ("Create Pipe &Automatically"), 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 715 472 void VBoxVMSettingsDlg::init() 716 473 { … … 957 714 QToolTip::add (pbHostRemove, tr ("Remove")); 958 715 716 /* Serial Port Page */ 717 959 718 /* USB Page */ 960 719 … … 1021 780 mSharedFolders->setDialogType (VBoxSharedFoldersSettings::MachineType); 1022 781 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);1029 782 1030 783 /* … … 1549 1302 Q_UNUSED (wval); 1550 1303 1304 /* reset the warning text; interested parties will set it during 1305 * validation */ 1306 setWarning (QString::null); 1307 1551 1308 /* detect the overall validity */ 1552 1309 bool newValid = true; … … 1567 1324 valid = newValid; 1568 1325 buttonOk->setEnabled (valid); 1569 if (valid) 1570 setWarning(0); 1571 warningLabel->setHidden(valid); 1572 warningPixmap->setHidden(valid); 1573 } 1574 } 1575 1576 1577 void VBoxVMSettingsDlg::revalidate( QIWidgetValidator *wval ) 1326 warningLabel->setHidden (valid); 1327 warningPixmap->setHidden (valid); 1328 } 1329 } 1330 1331 1332 void VBoxVMSettingsDlg::revalidate (QIWidgetValidator *wval) 1578 1333 { 1579 1334 /* do individual validations for pages */ … … 1581 1336 bool valid = wval->isOtherValid(); 1582 1337 1338 QString warningText; 1339 QString pageTitle = ::path (listView->currentItem()); 1340 1583 1341 if (pg == pageHDD) 1584 1342 { … … 1593 1351 { 1594 1352 valid = false; 1595 setWarning (tr ("Primary Master hard disk is not selected."));1353 warningText = tr ("Primary Master hard disk is not selected"); 1596 1354 } 1597 1355 else uuids << uuidHDA; … … 1603 1361 { 1604 1362 valid = false; 1605 setWarning (tr ("Primary Slave hard disk is not selected."));1363 warningText = tr ("Primary Slave hard disk is not selected"); 1606 1364 } 1607 1365 else … … 1616 1374 uuids << uuidHDB; 1617 1375 else 1618 setWarning (tr ("Primary Slave hard disk is already attached "1619 "to a different slot."));1376 warningText = tr ("Primary Slave hard disk is already attached " 1377 "to a different slot"); 1620 1378 } 1621 1379 } … … 1626 1384 { 1627 1385 valid = false; 1628 setWarning (tr ("Secondary Slave hard disk is not selected."));1386 warningText = tr ("Secondary Slave hard disk is not selected"); 1629 1387 } 1630 1388 else … … 1639 1397 uuids << uuidHDB; 1640 1398 else 1641 setWarning (tr ("Secondary Slave hard disk is already attached "1642 "to a different slot."));1399 warningText = tr ("Secondary Slave hard disk is already attached " 1400 "to a different slot"); 1643 1401 } 1644 1402 } … … 1667 1425 1668 1426 if (!valid) 1669 setWarning (tr ("CD/DVD image file is not selected."));1427 warningText = tr ("CD/DVD image file is not selected"); 1670 1428 } 1671 1429 else if (pg == pageFloppy) … … 1684 1442 1685 1443 if (!valid) 1686 setWarning (tr ("Floppy image file is not selected."));1444 warningText = tr ("Floppy image file is not selected"); 1687 1445 } 1688 1446 else if (pg == pageNetwork) 1689 1447 { 1448 QWidget *tab = NULL; 1449 for (int index = 0; index < tbwNetwork->count(); ++ index) 1450 { 1451 QWidget *tab = tbwNetwork->page (index); 1452 VBoxVMNetworkSettings *page = 1453 static_cast <VBoxVMNetworkSettings *> (tab); 1454 valid = page->isPageValid (mInterfaceList); 1455 if (!valid) break; 1456 } 1457 if (!valid) 1458 { 1459 Assert (tab); 1460 warningText = tr ("Incorrect host network interface is selected"); 1461 pageTitle += ": " + tbwNetwork->tabLabel (tab); 1462 } 1463 } 1464 else if (pg == pageSerial) 1465 { 1466 QValueList <QString> ports; 1467 QValueList <QString> paths; 1468 1690 1469 int index = 0; 1691 for (; index < tbwNetwork->count(); ++index) 1692 { 1693 QWidget *tab = tbwNetwork->page (index); 1694 VBoxVMNetworkSettings *set = static_cast<VBoxVMNetworkSettings*> (tab); 1695 valid = set->isPageValid (mInterfaceList); 1696 if (!valid) break; 1697 } 1698 if (!valid) 1699 setWarning (tr ("Incorrect host network interface is selected " 1700 "for Adapter %1.").arg (index)); 1470 for (; index < tbwSerialPorts->count(); ++ index) 1471 { 1472 QWidget *tab = tbwSerialPorts->page (index); 1473 VBoxVMSerialPortSettings *page = 1474 static_cast <VBoxVMSerialPortSettings *> (tab); 1475 1476 /* skip disabled ports */ 1477 if (!page->mSerialPortBox->isChecked()) 1478 continue; 1479 /* check the predefined port number unicity */ 1480 if (!page->isUserDefined()) 1481 { 1482 QString port = page->mPortNumCombo->currentText(); 1483 valid = !ports.contains (port); 1484 if (!valid) 1485 { 1486 warningText = tr ("Duplicate port number is selected "); 1487 pageTitle += ": " + tbwSerialPorts->tabLabel (tab); 1488 break; 1489 } 1490 ports << port; 1491 } 1492 /* check the port path unicity */ 1493 CEnums::PortMode mode = 1494 vboxGlobal().toPortMode (page->mHostModeCombo->currentText()); 1495 if (mode != CEnums::DisconnectedPort) 1496 { 1497 QString path = page->mPortPathLine->text(); 1498 valid = !paths.contains (path); 1499 if (!valid) 1500 { 1501 warningText = tr ("Duplicate port path is entered "); 1502 pageTitle += ": " + tbwSerialPorts->tabLabel (tab); 1503 break; 1504 } 1505 paths << path; 1506 } 1507 } 1701 1508 } 1702 1509 else if (pg == pageVRDP) … … 1707 1514 (leVRDPPort->text().isEmpty() || leVRDPTimeout->text().isEmpty())); 1708 1515 if (!valid && leVRDPPort->text().isEmpty()) 1709 setWarning (tr ("VRDP Port is not set."));1516 warningText = tr ("VRDP Port is not set "); 1710 1517 if (!valid && leVRDPTimeout->text().isEmpty()) 1711 setWarning (tr ("VRDP Timeout is not set."));1518 warningText = tr ("VRDP Timeout is not set "); 1712 1519 } 1713 1520 else 1714 1521 valid = true; 1715 1522 } 1523 1524 if (!valid) 1525 setWarning (tr ("%1 on the <b>%2</b> page.") 1526 .arg (warningText, pageTitle)); 1716 1527 1717 1528 wval->setOtherValid (valid); … … 1980 1791 } 1981 1792 1793 /* serial ports */ 1794 { 1795 ulong count = vbox.GetSystemProperties().GetSerialPortCount(); 1796 for (ulong slot = 0; slot < count; ++ slot) 1797 { 1798 CSerialPort port = machine.GetSerialPort (slot); 1799 addSerialPort (port); 1800 } 1801 } 1802 1982 1803 /* USB */ 1983 1804 { … … 2049 1870 { 2050 1871 mSharedFolders->getFromMachine (machine); 2051 }2052 2053 /* serial ports */2054 {2055 mSerialPorts->getFromMachine (machine);2056 1872 } 2057 1873 … … 2254 2070 } 2255 2071 2072 /* serial ports */ 2073 { 2074 for (int index = 0; index < tbwSerialPorts->count(); index++) 2075 { 2076 VBoxVMSerialPortSettings *page = 2077 (VBoxVMSerialPortSettings *) tbwSerialPorts->page (index); 2078 Assert (page); 2079 page->putBackToPort(); 2080 } 2081 } 2082 2256 2083 /* usb */ 2257 2084 { … … 2316 2143 } 2317 2144 2318 /* serial ports */2319 {2320 mSerialPorts->putBackToMachine();2321 }2322 2323 2145 return COMResult(); 2324 2146 } … … 2400 2222 2401 2223 #endif 2224 } 2225 2226 void VBoxVMSettingsDlg::addSerialPort (const CSerialPort &aPort) 2227 { 2228 VBoxVMSerialPortSettings *page = new VBoxVMSerialPortSettings(); 2229 page->getFromPort (aPort); 2230 tbwSerialPorts->addTab (page, QString (tr ("Port %1", "serial ports")) 2231 .arg (aPort.GetSlot())); 2232 2233 /* fix the tab order so that main dialog's buttons are always the last */ 2234 setTabOrder (page->mPortPathLine, buttonHelp); 2235 setTabOrder (buttonHelp, buttonOk); 2236 setTabOrder (buttonOk, buttonCancel); 2237 2238 /* setup validation */ 2239 QIWidgetValidator *wval = new QIWidgetValidator (pageSerial, this); 2240 connect (page->mSerialPortBox, SIGNAL (toggled (bool)), 2241 wval, SLOT (revalidate())); 2242 connect (page->mIRQLine, SIGNAL (textChanged (const QString &)), 2243 wval, SLOT (revalidate())); 2244 connect (page->mIOPortLine, SIGNAL (textChanged (const QString &)), 2245 wval, SLOT (revalidate())); 2246 connect (page->mHostModeCombo, SIGNAL (activated (const QString &)), 2247 wval, SLOT (revalidate())); 2248 connect (wval, SIGNAL (validityChanged (const QIWidgetValidator *)), 2249 this, SLOT (enableOk (const QIWidgetValidator *))); 2250 connect (wval, SIGNAL (isValidRequested (QIWidgetValidator *)), 2251 this, SLOT (revalidate (QIWidgetValidator *))); 2252 2253 wval->revalidate(); 2402 2254 } 2403 2255
Note:
See TracChangeset
for help on using the changeset viewer.