Changeset 38431 in vbox
- Timestamp:
- Aug 12, 2011 11:04:16 AM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/nls/VirtualBox_ru.ts
r38412 r38431 2513 2513 <message> 2514 2514 <source>No supported devices connected to the host PC</source> 2515 <translation> </translation>2515 <translation>Нет поддерживаемых USB устройств, подсоединенных к хосту</translation> 2516 2516 </message> 2517 2517 </context> -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r38348 r38431 1322 1322 void UIMachineLogic::sltPrepareUSBMenu() 1323 1323 { 1324 /* Get the sender() menu: */1324 /* Get and check the sender menu object: */ 1325 1325 QMenu *pMenu = qobject_cast<QMenu*>(sender()); 1326 #ifdef RT_STRICT1327 1326 QMenu *pUSBDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->menu(); 1328 #endif1329 1327 AssertMsg(pMenu == pUSBDevicesMenu, ("This slot should only be called on hovering USB menu!\n")); 1328 Q_UNUSED(pUSBDevicesMenu); 1329 1330 /* Clear menu initially: */ 1330 1331 pMenu->clear(); 1331 1332 1332 /* Get HOST: */1333 /* Get current host: */ 1333 1334 CHost host = vboxGlobal().virtualBox().GetHost(); 1334 1335 1335 /* Get USB deviceslist: */1336 /* Get host USB device list: */ 1336 1337 CHostUSBDeviceVector devices = host.GetUSBDevices(); 1337 1338 1338 /* Fill USB device smenu: */1339 /* Fill USB device menu: */ 1339 1340 bool fIsUSBListEmpty = devices.size() == 0; 1341 /* If device list is empty: */ 1340 1342 if (fIsUSBListEmpty) 1341 1343 { 1342 /* Fill USB devices menu: */1344 /* Add only one - "empty" action: */ 1343 1345 QAction *pEmptyMenuAction = new QAction(pMenu); 1344 1346 pEmptyMenuAction->setEnabled(false); 1345 pEmptyMenuAction->setText(QApplication::translate("UIMachineLogic", "No USB Devices Connected")); 1347 pEmptyMenuAction->setText(tr("No USB Devices Connected")); 1348 pEmptyMenuAction->setToolTip(tr("No supported devices connected to the host PC")); 1346 1349 pEmptyMenuAction->setIcon(UIIconPool::iconSet(":/delete_16px.png", ":/delete_dis_16px.png")); 1347 pEmptyMenuAction->setToolTip(QApplication::translate("UIMachineLogic", "No supported devices connected to the host PC")); 1348 } 1350 pMenu->addAction(pEmptyMenuAction); 1351 } 1352 /* If device list is NOT empty: */ 1349 1353 else 1350 1354 { 1351 foreach (const CHostUSBDevice hostDevice, devices) 1352 { 1353 /* Get common USB device: */ 1355 /* Populate menu with host USB devices: */ 1356 for (int i = 0; i < devices.size(); ++i) 1357 { 1358 /* Get current host USB device: */ 1359 const CHostUSBDevice& hostDevice = devices[i]; 1360 /* Get USB device from current host USB device: */ 1354 1361 CUSBDevice device(hostDevice); 1355 1362 1356 1363 /* Create USB device action: */ 1357 QAction * attachUSBAction = new QAction(vboxGlobal().details(device), pMenu);1358 attachUSBAction->setCheckable(true);1359 connect( attachUSBAction, SIGNAL(triggered(bool)), this, SLOT(sltAttachUSBDevice()));1360 pMenu->addAction( attachUSBAction);1364 QAction *pAttachUSBAction = new QAction(vboxGlobal().details(device), pMenu); 1365 pAttachUSBAction->setCheckable(true); 1366 connect(pAttachUSBAction, SIGNAL(triggered(bool)), this, SLOT(sltAttachUSBDevice())); 1367 pMenu->addAction(pAttachUSBAction); 1361 1368 1362 1369 /* Check if that USB device was already attached to this session: */ 1363 1370 CConsole console = session().GetConsole(); 1364 1371 CUSBDevice attachedDevice = console.FindUSBDeviceById(device.GetId()); 1365 attachUSBAction->setChecked(!attachedDevice.isNull());1366 attachUSBAction->setEnabled(hostDevice.GetState() != KUSBDeviceState_Unavailable);1372 pAttachUSBAction->setChecked(!attachedDevice.isNull()); 1373 pAttachUSBAction->setEnabled(hostDevice.GetState() != KUSBDeviceState_Unavailable); 1367 1374 1368 1375 /* Set USB attach data: */ 1369 attachUSBAction->setData(QVariant::fromValue(USBTarget(!attachUSBAction->isChecked(), device.GetId())));1370 attachUSBAction->setToolTip(vboxGlobal().toolTip(device));1376 pAttachUSBAction->setData(QVariant::fromValue(USBTarget(!pAttachUSBAction->isChecked(), device.GetId()))); 1377 pAttachUSBAction->setToolTip(vboxGlobal().toolTip(device)); 1371 1378 } 1372 1379 } … … 1375 1382 void UIMachineLogic::sltAttachUSBDevice() 1376 1383 { 1377 /* Get sender action: */ 1378 QAction *action = qobject_cast<QAction*>(sender()); 1379 AssertMsg(action, ("This slot should only be called on selecting USB menu item!\n")); 1384 /* Get and check sender action object: */ 1385 QAction *pAction = qobject_cast<QAction*>(sender()); 1386 AssertMsg(pAction, ("This slot should only be called on selecting USB menu item!\n")); 1387 1388 /* Get operation target: */ 1389 USBTarget target = pAction->data().value<USBTarget>(); 1380 1390 1381 1391 /* Get current console: */ 1382 1392 CConsole console = session().GetConsole(); 1383 1393 1384 /* Get USB target: */1385 USBTarget target = action->data().value<USBTarget>();1386 CUSBDevice device = console.FindUSBDeviceById(target.id);1387 1388 1394 /* Attach USB device: */ 1389 1395 if (target.attach) 1390 1396 { 1397 /* Try to attach corresponding device: */ 1391 1398 console.AttachUSBDevice(target.id); 1399 /* Check if console is OK: */ 1392 1400 if (!console.isOk()) 1401 { 1402 /* Get current host: */ 1403 CHost host = vboxGlobal().virtualBox().GetHost(); 1404 /* Search the host for the corresponding USB device: */ 1405 CHostUSBDevice hostDevice = host.FindUSBDeviceById(target.id); 1406 /* Get USB device from host USB device: */ 1407 CUSBDevice device(hostDevice); 1408 /* Show a message about procedure failure: */ 1393 1409 msgCenter().cannotAttachUSBDevice(console, vboxGlobal().details(device)); 1394 } 1410 } 1411 } 1412 /* Detach USB device: */ 1395 1413 else 1396 1414 { 1415 /* Search the console for the corresponding USB device: */ 1416 CUSBDevice device = console.FindUSBDeviceById(target.id); 1417 /* Try to detach corresponding device: */ 1397 1418 console.DetachUSBDevice(target.id); 1419 /* Check if console is OK: */ 1398 1420 if (!console.isOk()) 1421 { 1422 /* Show a message about procedure failure: */ 1399 1423 msgCenter().cannotDetachUSBDevice(console, vboxGlobal().details(device)); 1424 } 1400 1425 } 1401 1426 }
Note:
See TracChangeset
for help on using the changeset viewer.