- Timestamp:
- Aug 24, 2007 3:08:48 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r4324 r4354 341 341 return USBDeviceStates [aState]; 342 342 } 343 344 QStringList COMPortNames() const; 345 QString toCOMPortName (ulong aIRQ, ulong aIOBase) const; 346 bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const; 343 347 344 348 QPixmap snapshotIcon (bool online) const … … 557 561 QStringVector USBDeviceStates; 558 562 563 QString mUserDefinedCOMPortName; 564 559 565 mutable bool detailReportTemplatesReady; 560 566 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r4307 r4354 323 323 devicesMenu->insertSeparator(); 324 324 325 devicesMenu->insertItem (VBoxGlobal::iconSet ("nw_16px.png", "nw_disabled_16px.png"), 326 QString::null, devicesNetworkMenu, devicesNetworkMenuId); 327 devicesMenu->insertSeparator(); 328 325 329 devicesMenu->insertItem (VBoxGlobal::iconSet ("usb_16px.png", "usb_disabled_16px.png"), 326 330 QString::null, devicesUSBMenu, devicesUSBMenuId); … … 330 334 devicesSFMenuSeparatorId = devicesMenu->insertSeparator(); 331 335 devicesSFDialogAction->addTo (devicesSFMenu); 332 333 devicesMenu->insertItem (VBoxGlobal::iconSet ("nw_16px.png", "nw_disabled_16px.png"),334 QString::null, devicesNetworkMenu, devicesNetworkMenuId);335 devicesMenu->insertSeparator();336 336 337 337 devicesSwitchVrdpAction->addTo (devicesMenu); … … 2859 2859 machine_state = state; 2860 2860 2861 updateAppearanceOf (Caption | FloppyStuff | DVDStuff | 2861 updateAppearanceOf (Caption | FloppyStuff | DVDStuff | NetworkStuff | 2862 2862 USBStuff | VRDPStuff | PauseAction | 2863 2863 DisableMouseIntegrAction); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r4324 r4354 823 823 list += deviceTypes [i]; 824 824 return list; 825 } 826 827 static const struct PortConfig 828 { 829 const char *name; 830 const ulong IRQ; 831 const ulong IOBase; 832 } 833 kKnownPorts[] = 834 { 835 { "COM1", 4, 0x3F8 }, 836 { "COM2", 3, 0x2F8 }, 837 { "COM3", 4, 0x3E8 }, 838 { "COM4", 3, 0x2E8 }, 839 /* must not contain an element with IRQ=0 and IOBase=0 used to cause 840 * toCOMPortName() to return the "User-defined" string for these values. */ 841 }; 842 843 /** 844 * Returns the list of the standard COM port names (i.e. "COMx"). 845 */ 846 QStringList VBoxGlobal::COMPortNames() const 847 { 848 QStringList list; 849 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i) 850 list << kKnownPorts [i].name; 851 852 return list; 853 } 854 855 /** 856 * Returns the name of the standard COM port corresponding to the given 857 * parameters, or "User-defined" (which is also returned when both 858 * @a aIRQ and @a aIOBase are 0). 859 */ 860 QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const 861 { 862 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i) 863 if (kKnownPorts [i].IRQ == aIRQ && 864 kKnownPorts [i].IOBase == aIOBase) 865 return kKnownPorts [i].name; 866 867 return mUserDefinedCOMPortName; 868 } 869 870 /** 871 * Returns port parameters corresponding to the given standard COM name. 872 * Returns @c true on success, or @c false if the given port name is not one 873 * of the standard names (i.e. "COMx"). 874 */ 875 bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ, 876 ulong &aIOBase) const 877 { 878 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i) 879 if (strcmp (kKnownPorts [i].name, aName.utf8().data()) == 0) 880 { 881 aIRQ = kKnownPorts [i].IRQ; 882 aIOBase = kKnownPorts [i].IOBase; 883 return true; 884 } 885 886 return false; 825 887 } 826 888 … … 1305 1367 item); /* items */ 1306 1368 } 1369 /* serial ports */ 1370 { 1371 item = QString::null; 1372 ulong count = vbox.GetSystemProperties().GetSerialPortCount(); 1373 int rows = 2; /* including section header and footer */ 1374 for (ulong slot = 0; slot < count; slot ++) 1375 { 1376 CSerialPort port = m.GetSerialPort (slot); 1377 if (port.GetEnabled()) 1378 { 1379 CEnums::PortMode mode = port.GetHostMode(); 1380 QString data = 1381 toCOMPortName (port.GetIRQ(), port.GetIOBase()) + ", "; 1382 if (mode == CEnums::HostPipePort || 1383 mode == CEnums::HostDevicePort) 1384 data += QString ("%1 (<nobr>%1</nobr>)") 1385 .arg (vboxGlobal().toString (mode)) 1386 .arg (QDir::convertSeparators (port.GetPath())); 1387 else 1388 data += toString (mode); 1389 1390 item += QString (sSectionItemTpl) 1391 .arg (tr ("Port %1", "details report (serial ports)") 1392 .arg (port.GetSlot())) 1393 .arg (data); 1394 ++ rows; 1395 } 1396 } 1397 if (item.isNull()) 1398 { 1399 item = QString (sSectionItemTpl) 1400 .arg (tr ("Disabled", "details report (serial ports)"), ""); 1401 ++ rows; 1402 } 1403 1404 detailsReport += sectionTpl 1405 .arg (rows) /* rows */ 1406 .arg ("machine_16px.png", /* icon */ 1407 "#serialPorts", /* link */ 1408 tr ("Serial Ports", "details report"), /* title */ 1409 item); /* items */ 1410 } 1307 1411 /* USB */ 1308 1412 { … … 1334 1438 .arg ("usb_16px.png", /* icon */ 1335 1439 "#usb", /* link */ 1336 tr ("USB Controller", "details report"), /* title */ 1337 item); /* items */ 1338 } 1339 } 1340 /* VRDP */ 1341 { 1342 CVRDPServer srv = m.GetVRDPServer(); 1343 if (!srv.isNull()) 1344 { 1345 /* the VRDP server may be unavailable (i.e. in VirtualBox OSE) */ 1346 1347 if (srv.GetEnabled()) 1348 item = QString (sSectionItemTpl) 1349 .arg (tr ("VRDP Server Port", "details report (VRDP)"), 1350 tr ("%1", "details report (VRDP)") 1351 .arg (srv.GetPort())); 1352 else 1353 item = QString (sSectionItemTpl) 1354 .arg (tr ("Disabled", "details report (VRDP)"), ""); 1355 1356 detailsReport += sectionTpl 1357 .arg (2 + 1) /* rows */ 1358 .arg ("vrdp_16px.png", /* icon */ 1359 "#vrdp", /* link */ 1360 tr ("Remote Display", "details report"), /* title */ 1440 tr ("USB", "details report"), /* title */ 1361 1441 item); /* items */ 1362 1442 } … … 1382 1462 tr ("Shared Folders", "details report"), /* title */ 1383 1463 item); /* items */ 1464 } 1465 /* VRDP */ 1466 { 1467 CVRDPServer srv = m.GetVRDPServer(); 1468 if (!srv.isNull()) 1469 { 1470 /* the VRDP server may be unavailable (i.e. in VirtualBox OSE) */ 1471 1472 if (srv.GetEnabled()) 1473 item = QString (sSectionItemTpl) 1474 .arg (tr ("VRDP Server Port", "details report (VRDP)"), 1475 tr ("%1", "details report (VRDP)") 1476 .arg (srv.GetPort())); 1477 else 1478 item = QString (sSectionItemTpl) 1479 .arg (tr ("Disabled", "details report (VRDP)"), ""); 1480 1481 detailsReport += sectionTpl 1482 .arg (2 + 1) /* rows */ 1483 .arg ("vrdp_16px.png", /* icon */ 1484 "#vrdp", /* link */ 1485 tr ("Remote Display", "details report"), /* title */ 1486 item); /* items */ 1487 } 1384 1488 } 1385 1489 } … … 1925 2029 tr ("Captured", "USBDeviceState"); 1926 2030 2031 mUserDefinedCOMPortName = tr ("User-defined", "serial port"); 2032 1927 2033 detailReportTemplatesReady = false; 1928 2034 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSerialPortSettings.ui.h
r4324 r4354 27 27 28 28 29 static const struct PortConfig30 {31 const char *name;32 const ulong IRQ;33 const ulong IOBase;34 }35 kKnownPorts[] =36 {37 { "COM1", 4, 0x3F8 },38 { "COM2", 3, 0x2F8 },39 { "COM3", 4, 0x3E8 },40 { "COM4", 3, 0x2E8 },41 /* must not contain an element with IRQ=0 and IOBase=0 used to cause42 * portNumbers2Name() to return the "User-defined" string. */43 };44 45 static const PortConfig *findByPortNumbers (ulong aIRQ, ulong aIOBase)46 {47 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i)48 if (kKnownPorts [i].IRQ == aIRQ &&49 kKnownPorts [i].IOBase == aIOBase)50 return &kKnownPorts [i];51 return NULL;52 }53 54 static const PortConfig *findByPortName (const char *aName)55 {56 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i)57 if (strcmp (kKnownPorts [i].name, aName) == 0)58 return &kKnownPorts [i];59 return NULL;60 }61 62 static QString portNumbers2Name (ulong aIRQ, ulong aIOBase)63 {64 const PortConfig *config = findByPortNumbers (aIRQ, aIOBase);65 if (config)66 return config->name;67 68 return VBoxVMSerialPortSettings::tr ("User-defined");69 }70 71 72 29 void VBoxVMSerialPortSettings::init() 73 30 { … … 91 48 /* set initial values */ 92 49 93 for (size_t i = 0; i < ELEMENTS (kKnownPorts); ++ i) 94 mPortNumCombo->insertItem (kKnownPorts [i].name); 95 mPortNumCombo->insertItem (portNumbers2Name (0, 0)); 50 mPortNumCombo->insertStringList (vboxGlobal().COMPortNames()); 51 mPortNumCombo->insertItem (vboxGlobal().toCOMPortName (0, 0)); 96 52 97 53 mHostModeCombo->insertItem (vboxGlobal().toString (CEnums::DisconnectedPort)); … … 108 64 ulong IRQ = mPort.GetIRQ(); 109 65 ulong IOBase = mPort.GetIOBase(); 110 mPortNumCombo->setCurrentText ( portNumbers2Name (IRQ, IOBase));66 mPortNumCombo->setCurrentText (vboxGlobal().toCOMPortName (IRQ, IOBase)); 111 67 mIRQLine->setText (QString::number (IRQ)); 112 68 mIOPortLine->setText ("0x" + QString::number (IOBase, 16).upper()); … … 134 90 bool VBoxVMSerialPortSettings::isUserDefined() 135 91 { 136 return findByPortName (mPortNumCombo->currentText().utf8().data()) == NULL; 92 ulong a, b; 93 return !vboxGlobal().toCOMPortNumbers (mPortNumCombo->currentText(), a, b); 137 94 } 138 95 … … 148 105 void VBoxVMSerialPortSettings::mPortNumCombo_activated (const QString &aText) 149 106 { 150 const PortConfig *config = findByPortName (aText.utf8().data()); 151 mIRQLine->setEnabled (config == NULL); 152 mIOPortLine->setEnabled (config == NULL); 153 if (config != NULL) 107 ulong IRQ, IOBase; 108 bool std = vboxGlobal().toCOMPortNumbers (aText, IRQ, IOBase); 109 110 mIRQLine->setEnabled (!std); 111 mIOPortLine->setEnabled (!std); 112 if (std) 154 113 { 155 mIRQLine->setText (QString::number ( config->IRQ));156 mIOPortLine->setText ("0x" + QString::number ( config->IOBase, 16).upper());114 mIRQLine->setText (QString::number (IRQ)); 115 mIOPortLine->setText ("0x" + QString::number (IOBase, 16).upper()); 157 116 } 158 117 } -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui
r4324 r4354 213 213 </property> 214 214 <property name="text"> 215 <string> 6</string>215 <string>7</string> 216 216 </property> 217 217 <property name="text"> … … 233 233 </property> 234 234 <property name="text"> 235 <string> 7</string>235 <string>9</string> 236 236 </property> 237 237 <property name="text"> … … 273 273 </property> 274 274 <property name="text"> 275 <string> 9</string>275 <string>6</string> 276 276 </property> 277 277 <property name="text"> … … 279 279 </property> 280 280 <property name="pixmap"> 281 <pixmap> </pixmap>281 <pixmap>machine_16px.png</pixmap> 282 282 </property> 283 283 <property name="pixmap"> … … 2247 2247 </property> 2248 2248 <attribute name="id"> 2249 <number> 6</number>2249 <number>7</number> 2250 2250 </attribute> 2251 2251 <vbox> … … 2488 2488 </property> 2489 2489 <attribute name="id"> 2490 <number> 7</number>2490 <number>9</number> 2491 2491 </attribute> 2492 2492 <vbox> … … 2710 2710 </property> 2711 2711 <attribute name="id"> 2712 <number> 9</number>2712 <number>6</number> 2713 2713 </attribute> 2714 2714 <vbox>
Note:
See TracChangeset
for help on using the changeset viewer.