Changeset 4294 in vbox
- Timestamp:
- Aug 22, 2007 5:27:24 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r4201 r4294 226 226 } 227 227 228 QString toString (CEnums::SerialHostMode t) const 229 { 230 AssertMsg (!serialHostModeTypes [t].isNull(), ("No text for %d", t)); 231 return serialHostModeTypes [t]; 232 } 233 228 234 QString toString (CEnums::USBDeviceFilterAction t) const 229 235 { … … 252 258 AssertMsg (it != vrdpAuthTypes.end(), ("No value for {%s}", s.latin1())); 253 259 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()); 254 268 } 255 269 … … 535 549 QStringVector diskStorageTypes; 536 550 QStringVector vrdpAuthTypes; 551 QStringVector serialHostModeTypes; 537 552 QStringVector usbFilterActionTypes; 538 553 QStringVector diskControllerDevices; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r4201 r4294 576 576 , diskStorageTypes (CEnums::HardDiskStorageType_COUNT) 577 577 , vrdpAuthTypes (CEnums::VRDPAuthType_COUNT) 578 , serialHostModeTypes (CEnums::SerialHostMode_COUNT) 578 579 , usbFilterActionTypes (CEnums::USBDeviceFilterAction_COUNT) 579 580 , diskControllerDevices (3) … … 1862 1863 tr ("Guest", "VRDPAuthType"); 1863 1864 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 1864 1872 usbFilterActionTypes [CEnums::USBDeviceFilterIgnore] = 1865 1873 tr ("Ignore", "USBFilterActionType"); … … 3069 3077 * @a aClassName (if it is not NULL) and among children of @a aParent. If @a 3070 3078 * 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. 3072 3080 */ 3073 3081 /* static */ -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r4071 r4294 268 268 </property> 269 269 </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> 270 290 <property name="name"> 271 291 <cstring>listView</cstring> … … 2683 2703 <attribute name="id"> 2684 2704 <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> 2685 2713 </attribute> 2686 2714 </widget> … … 3038 3066 <forward>class VBoxUSBMenu</forward> 3039 3067 <forward>class VBoxSharedFoldersSettings</forward> 3068 <forward>class VBoxVMSerialPortSettings</forward> 3040 3069 <forward>class QIRichLabel</forward> 3041 3070 <forward>class BootItemsList</forward> … … 3062 3091 <variable access="private">QWidgetStack *wstUSBFilters;</variable> 3063 3092 <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> 3065 3095 <variable access="private">QString warningString;</variable> 3066 3096 <variable access="private">VBoxMediaComboBox *cbHDA;</variable> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h
r4166 r4294 469 469 }; 470 470 471 472 class VBoxVMSerialPortSettings : public QWidget 473 { 474 Q_OBJECT 475 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 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 471 715 void VBoxVMSettingsDlg::init() 472 716 { … … 777 1021 mSharedFolders->setDialogType (VBoxSharedFoldersSettings::MachineType); 778 1022 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); 779 1029 780 1030 /* … … 1801 2051 } 1802 2052 2053 /* serial ports */ 2054 { 2055 mSerialPorts->getFromMachine (machine); 2056 } 2057 1803 2058 /* request for media shortcuts update */ 1804 2059 cbHDA->setBelongsTo (machine.GetId()); … … 2059 2314 { 2060 2315 mSharedFolders->putBackToMachine(); 2316 } 2317 2318 /* serial ports */ 2319 { 2320 mSerialPorts->putBackToMachine(); 2061 2321 } 2062 2322
Note:
See TracChangeset
for help on using the changeset viewer.