- Timestamp:
- Feb 24, 2010 5:31:02 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.cpp
r26714 r26758 35 35 * the state of some thing, as described by the state property. 36 36 */ 37 38 QIStateIndicator::QIStateIndicator(QWidget *pParent /* = 0 */) 39 : QFrame(pParent) 40 , mState(0) 41 , mSize(0, 0) 42 { 43 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 44 } 37 45 38 46 /** -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.h
r25177 r26758 34 34 public: 35 35 36 QIStateIndicator (QWidget *pParent = 0); 36 37 QIStateIndicator (int aState); 37 38 ~QIStateIndicator(); … … 43 44 QPixmap stateIcon (int aState) const; 44 45 void setStateIcon (int aState, const QPixmap &aPixmap); 46 47 virtual void updateAppearance() {} 45 48 46 49 public slots: -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
r26709 r26758 24 24 /* Local includes */ 25 25 #include "UIIndicatorsPool.h" 26 #include "VBoxGlobal.h" 26 27 #include "COMDefs.h" 27 28 class UIIndicatorHardDisks : public QIStateIndicator 29 { 30 Q_OBJECT; 31 32 public: 33 34 UIIndicatorHardDisks() : QIStateIndicator(KDeviceActivity_Idle) 28 #include "QIWithRetranslateUI.h" 29 30 class UIIndicatorHardDisks : public QIWithRetranslateUI<QIStateIndicator> 31 { 32 Q_OBJECT; 33 34 public: 35 36 UIIndicatorHardDisks(CSession &session) 37 : QIWithRetranslateUI<QIStateIndicator>() 38 , m_session(session) 35 39 { 36 40 setStateIcon(KDeviceActivity_Idle, QPixmap(":/hd_16px.png")); … … 38 42 setStateIcon(KDeviceActivity_Writing, QPixmap(":/hd_write_16px.png")); 39 43 setStateIcon(KDeviceActivity_Null, QPixmap(":/hd_disabled_16px.png")); 40 } 41 }; 42 43 class UIIndicatorOpticalDisks : public QIStateIndicator 44 { 45 Q_OBJECT; 46 47 public: 48 49 UIIndicatorOpticalDisks() : QIStateIndicator(KDeviceActivity_Idle) 44 45 retranslateUi(); 46 } 47 48 void retranslateUi() 49 { 50 updateAppearance(); 51 } 52 53 void updateAppearance() 54 { 55 const CMachine &machine = m_session.GetMachine(); 56 57 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity " 58 "of the virtual hard disks:</nobr>%1</p>", "HDD tooltip"); 59 60 QString strFullData; 61 bool bAttachmentsPresent = false; 62 63 CStorageControllerVector controllers = machine.GetStorageControllers(); 64 foreach (const CStorageController &controller, controllers) 65 { 66 QString strAttData; 67 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController(controller.GetName()); 68 foreach (const CMediumAttachment &attachment, attachments) 69 { 70 if (attachment.GetType() != KDeviceType_HardDisk) 71 continue; 72 strAttData += QString("<br> <nobr>%1: %2</nobr>") 73 .arg(vboxGlobal().toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 74 .arg(VBoxMedium(attachment.GetMedium(), VBoxDefs::MediumType_HardDisk).location()); 75 bAttachmentsPresent = true; 76 } 77 if (!strAttData.isNull()) 78 strFullData += QString("<br><nobr><b>%1</b></nobr>").arg(controller.GetName()) + strAttData; 79 } 80 81 if (!bAttachmentsPresent) 82 strFullData += tr("<br><nobr><b>No hard disks attached</b></nobr>", "HDD tooltip"); 83 84 setToolTip(strToolTip.arg(strFullData)); 85 setState(bAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 86 } 87 88 protected: 89 /* For compatibility reason we do it here, later this should be moved to 90 * QIStateIndicator. */ 91 CSession &m_session; 92 }; 93 94 class UIIndicatorOpticalDisks : public QIWithRetranslateUI<QIStateIndicator> 95 { 96 Q_OBJECT; 97 98 public: 99 100 UIIndicatorOpticalDisks(CSession &session) 101 : QIWithRetranslateUI<QIStateIndicator>() 102 , m_session(session) 50 103 { 51 104 setStateIcon(KDeviceActivity_Idle, QPixmap(":/cd_16px.png")); … … 53 106 setStateIcon(KDeviceActivity_Writing, QPixmap(":/cd_write_16px.png")); 54 107 setStateIcon(KDeviceActivity_Null, QPixmap(":/cd_disabled_16px.png")); 55 } 56 }; 57 58 class UIIndicatorFloppyDisks : public QIStateIndicator 59 { 60 Q_OBJECT; 61 62 public: 63 64 UIIndicatorFloppyDisks() : QIStateIndicator(KDeviceActivity_Idle) 108 109 retranslateUi(); 110 } 111 112 void retranslateUi() 113 { 114 updateAppearance(); 115 } 116 117 void updateAppearance() 118 { 119 const CMachine &machine = m_session.GetMachine(); 120 121 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity " 122 "of the CD/DVD devices:</nobr>%1</p>", "CD/DVD tooltip"); 123 124 QString strFullData; 125 bool bAttachmentsPresent = false; 126 127 CStorageControllerVector controllers = machine.GetStorageControllers(); 128 foreach (const CStorageController &controller, controllers) 129 { 130 QString strAttData; 131 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController(controller.GetName()); 132 foreach (const CMediumAttachment &attachment, attachments) 133 { 134 if (attachment.GetType() != KDeviceType_DVD) 135 continue; 136 VBoxMedium vboxMedium(attachment.GetMedium(), VBoxDefs::MediumType_DVD); 137 strAttData += QString("<br> <nobr>%1: %2</nobr>") 138 .arg(vboxGlobal().toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 139 .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location()); 140 if (!vboxMedium.isNull()) 141 bAttachmentsPresent = true; 142 } 143 if (!strAttData.isNull()) 144 strFullData += QString("<br><nobr><b>%1</b></nobr>").arg(controller.GetName()) + strAttData; 145 } 146 147 if (strFullData.isNull()) 148 strFullData = tr("<br><nobr><b>No CD/DVD devices attached</b></nobr>", "CD/DVD tooltip"); 149 150 setToolTip(strToolTip.arg(strFullData)); 151 setState(bAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 152 } 153 154 protected: 155 /* For compatibility reason we do it here, later this should be moved to 156 * QIStateIndicator. */ 157 CSession &m_session; 158 }; 159 160 class UIIndicatorFloppyDisks : public QIWithRetranslateUI<QIStateIndicator> 161 { 162 Q_OBJECT; 163 164 public: 165 166 UIIndicatorFloppyDisks(CSession &session) 167 : QIWithRetranslateUI<QIStateIndicator>() 168 , m_session(session) 65 169 { 66 170 setStateIcon(KDeviceActivity_Idle, QPixmap(":/fd_16px.png")); … … 68 172 setStateIcon(KDeviceActivity_Writing, QPixmap(":/fd_write_16px.png")); 69 173 setStateIcon(KDeviceActivity_Null, QPixmap(":/fd_disabled_16px.png")); 70 } 71 }; 72 73 class UIIndicatorNetworkAdapters : public QIStateIndicator 74 { 75 Q_OBJECT; 76 77 public: 78 79 UIIndicatorNetworkAdapters() : QIStateIndicator(KDeviceActivity_Idle) 174 175 retranslateUi(); 176 } 177 178 void retranslateUi() 179 { 180 updateAppearance(); 181 } 182 183 void updateAppearance() 184 { 185 const CMachine &machine = m_session.GetMachine(); 186 187 QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity " 188 "of the floppy devices:</nobr>%1</p>", "FD tooltip"); 189 QString data; 190 bool attachmentsPresent = false; 191 192 CStorageControllerVector controllers = machine.GetStorageControllers(); 193 foreach (const CStorageController &controller, controllers) 194 { 195 QString attData; 196 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName()); 197 foreach (const CMediumAttachment &attachment, attachments) 198 { 199 if (attachment.GetType() != KDeviceType_Floppy) 200 continue; 201 VBoxMedium vboxMedium (attachment.GetMedium(), VBoxDefs::MediumType_Floppy); 202 attData += QString ("<br> <nobr>%1: %2</nobr>") 203 .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 204 .arg (vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location()); 205 if (!vboxMedium.isNull()) 206 attachmentsPresent = true; 207 } 208 if (!attData.isNull()) 209 data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData; 210 } 211 212 if (data.isNull()) 213 data = tr ("<br><nobr><b>No floppy devices attached</b></nobr>", "FD tooltip"); 214 215 setToolTip (tip.arg (data)); 216 setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 217 } 218 219 protected: 220 /* For compatibility reason we do it here, later this should be moved to 221 * QIStateIndicator. */ 222 CSession &m_session; 223 }; 224 225 class UIIndicatorNetworkAdapters : public QIWithRetranslateUI<QIStateIndicator> 226 { 227 Q_OBJECT; 228 229 public: 230 231 UIIndicatorNetworkAdapters(CSession &session) 232 : QIWithRetranslateUI<QIStateIndicator>() 233 , m_session(session) 80 234 { 81 235 setStateIcon(KDeviceActivity_Idle, QPixmap(":/nw_16px.png")); … … 83 237 setStateIcon(KDeviceActivity_Writing, QPixmap(":/nw_write_16px.png")); 84 238 setStateIcon(KDeviceActivity_Null, QPixmap(":/nw_disabled_16px.png")); 85 } 86 }; 87 88 class UIIndicatorUSBDevices : public QIStateIndicator 89 { 90 Q_OBJECT; 91 92 public: 93 94 UIIndicatorUSBDevices() : QIStateIndicator(KDeviceActivity_Idle) 239 240 retranslateUi(); 241 } 242 243 void retranslateUi() 244 { 245 updateAppearance(); 246 } 247 248 void updateAppearance() 249 { 250 const CMachine &machine = m_session.GetMachine(); 251 252 ulong uMaxCount = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 253 ulong uCount = 0; 254 for (ulong uSlot = 0; uSlot < uMaxCount; ++ uSlot) 255 if (machine.GetNetworkAdapter(uSlot).GetEnabled()) 256 ++ uCount; 257 setState(uCount > 0 ? KDeviceActivity_Idle : KDeviceActivity_Null); 258 259 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of the " 260 "network interfaces:</nobr>%1</p>", "Network adapters tooltip"); 261 QString strFullData; 262 263 for (ulong uSlot = 0; uSlot < uMaxCount; ++ uSlot) 264 { 265 CNetworkAdapter adapter = machine.GetNetworkAdapter(uSlot); 266 if (adapter.GetEnabled()) 267 strFullData += tr("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", "Network adapters tooltip") 268 .arg(uSlot + 1) 269 .arg(vboxGlobal().toString(adapter.GetAttachmentType())) 270 .arg(adapter.GetCableConnected() ? 271 tr("connected", "Network adapters tooltip") : 272 tr("disconnected", "Network adapters tooltip")); 273 } 274 275 if (strFullData.isNull()) 276 strFullData = tr("<br><nobr><b>All network adapters are disabled</b></nobr>", "Network adapters tooltip"); 277 278 setToolTip(strToolTip.arg(strFullData)); 279 } 280 281 protected: 282 /* For compatibility reason we do it here, later this should be moved to 283 * QIStateIndicator. */ 284 CSession &m_session; 285 }; 286 287 class UIIndicatorUSBDevices : public QIWithRetranslateUI<QIStateIndicator> 288 { 289 Q_OBJECT; 290 291 public: 292 293 UIIndicatorUSBDevices(CSession &session) 294 : QIWithRetranslateUI<QIStateIndicator>() 295 , m_session(session) 95 296 { 96 297 setStateIcon(KDeviceActivity_Idle, QPixmap(":/usb_16px.png")); … … 98 299 setStateIcon(KDeviceActivity_Writing, QPixmap(":/usb_write_16px.png")); 99 300 setStateIcon(KDeviceActivity_Null, QPixmap(":/usb_disabled_16px.png")); 100 } 101 }; 102 103 class UIIndicatorSharedFolders : public QIStateIndicator 104 { 105 Q_OBJECT; 106 107 public: 108 109 UIIndicatorSharedFolders() : QIStateIndicator(KDeviceActivity_Idle) 301 302 retranslateUi(); 303 } 304 305 void retranslateUi() 306 { 307 updateAppearance(); 308 } 309 310 void updateAppearance() 311 { 312 const CMachine &machine = m_session.GetMachine(); 313 314 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of " 315 "the attached USB devices:</nobr>%1</p>", "USB device tooltip"); 316 QString strFullData; 317 318 CUSBController usbctl = machine.GetUSBController(); 319 if (!usbctl.isNull() && usbctl.GetEnabled()) 320 { 321 const CConsole &console = m_session.GetConsole(); 322 323 CUSBDeviceVector devsvec = console.GetUSBDevices(); 324 for (int i = 0; i < devsvec.size(); ++ i) 325 { 326 CUSBDevice usb = devsvec[i]; 327 strFullData += QString("<br><b><nobr>%1</nobr></b>").arg(vboxGlobal().details(usb)); 328 } 329 if (strFullData.isNull()) 330 strFullData = tr("<br><nobr><b>No USB devices attached</b></nobr>", "USB device tooltip"); 331 } 332 else 333 strFullData = tr("<br><nobr><b>USB Controller is disabled</b></nobr>", "USB device tooltip"); 334 335 setToolTip(strToolTip.arg(strFullData)); 336 } 337 338 protected: 339 /* For compatibility reason we do it here, later this should be moved to 340 * QIStateIndicator. */ 341 CSession &m_session; 342 }; 343 344 class UIIndicatorSharedFolders : public QIWithRetranslateUI<QIStateIndicator> 345 { 346 Q_OBJECT; 347 348 public: 349 350 UIIndicatorSharedFolders(CSession &session) 351 : QIWithRetranslateUI<QIStateIndicator>() 352 , m_session(session) 110 353 { 111 354 setStateIcon(KDeviceActivity_Idle, QPixmap(":/shared_folder_16px.png")); … … 113 356 setStateIcon(KDeviceActivity_Writing, QPixmap(":/shared_folder_write_16px.png")); 114 357 setStateIcon(KDeviceActivity_Null, QPixmap(":/shared_folder_disabled_16px.png")); 115 } 116 }; 117 118 class UIIndicatorVirtualization : public QIStateIndicator 119 { 120 Q_OBJECT; 121 122 public: 123 124 UIIndicatorVirtualization() : QIStateIndicator(0) 358 359 retranslateUi(); 360 } 361 362 void retranslateUi() 363 { 364 updateAppearance(); 365 } 366 367 void updateAppearance() 368 { 369 const CMachine &machine = m_session.GetMachine(); 370 const CConsole &console = m_session.GetConsole(); 371 372 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of " 373 "the machine's shared folders:</nobr>%1</p>", "Shared folders tooltip"); 374 375 QString strFullData; 376 QMap<QString, QString> sfs; 377 378 /* Permanent folders */ 379 CSharedFolderVector psfvec = machine.GetSharedFolders(); 380 381 for (int i = 0; i < psfvec.size(); ++ i) 382 { 383 CSharedFolder sf = psfvec[i]; 384 sfs.insert(sf.GetName(), sf.GetHostPath()); 385 } 386 387 /* Transient folders */ 388 CSharedFolderVector tsfvec = console.GetSharedFolders(); 389 390 for (int i = 0; i < tsfvec.size(); ++ i) 391 { 392 CSharedFolder sf = tsfvec[i]; 393 sfs.insert(sf.GetName(), sf.GetHostPath()); 394 } 395 396 for (QMap<QString, QString>::const_iterator it = sfs.constBegin(); it != sfs.constEnd(); ++ it) 397 { 398 /* Select slashes depending on the OS type */ 399 if (VBoxGlobal::isDOSType(console.GetGuest().GetOSTypeId())) 400 strFullData += QString("<br><nobr><b>\\\\vboxsvr\\%1 </b></nobr><nobr>%2</nobr>") 401 .arg(it.key(), it.value()); 402 else 403 strFullData += QString("<br><nobr><b>%1 </b></nobr><nobr>%2</nobr>") 404 .arg(it.key(), it.value()); 405 } 406 407 if (sfs.count() == 0) 408 strFullData = tr("<br><nobr><b>No shared folders</b></nobr>", "Shared folders tooltip"); 409 410 setToolTip(strToolTip.arg(strFullData)); 411 } 412 413 protected: 414 /* For compatibility reason we do it here, later this should be moved to 415 * QIStateIndicator. */ 416 CSession &m_session; 417 }; 418 419 class UIIndicatorVRDPDisks : public QIWithRetranslateUI<QIStateIndicator> 420 { 421 Q_OBJECT; 422 423 public: 424 425 UIIndicatorVRDPDisks(CSession &session) 426 : QIWithRetranslateUI<QIStateIndicator>() 427 , m_session(session) 428 { 429 setStateIcon(0, QPixmap (":/vrdp_disabled_16px.png")); 430 setStateIcon(1, QPixmap (":/vrdp_16px.png")); 431 432 retranslateUi(); 433 } 434 435 void retranslateUi() 436 { 437 updateAppearance(); 438 } 439 440 void updateAppearance() 441 { 442 CVRDPServer vrdpsrv = m_session.GetMachine().GetVRDPServer(); 443 if (!vrdpsrv.isNull()) 444 { 445 /* update menu&status icon state */ 446 bool fVRDPEnabled = vrdpsrv.GetEnabled(); 447 448 setState(fVRDPEnabled ? 1 : 0); 449 450 QString tip = tr("Indicates whether the Remote Display (VRDP Server) " 451 "is enabled (<img src=:/vrdp_16px.png/>) or not " 452 "(<img src=:/vrdp_disabled_16px.png/>)."); 453 if (vrdpsrv.GetEnabled()) 454 tip += tr ("<hr>The VRDP Server is listening on port %1").arg(vrdpsrv.GetPorts()); 455 setToolTip(tip); 456 } 457 } 458 459 protected: 460 /* For compatibility reason we do it here, later this should be moved to 461 * QIStateIndicator. */ 462 CSession &m_session; 463 }; 464 465 class UIIndicatorVirtualization : public QIWithRetranslateUI<QIStateIndicator> 466 { 467 Q_OBJECT; 468 469 public: 470 471 UIIndicatorVirtualization(CSession &session) 472 : QIWithRetranslateUI<QIStateIndicator>() 473 , m_session(session) 125 474 { 126 475 setStateIcon(0, QPixmap(":/vtx_amdv_disabled_16px.png")); 127 476 setStateIcon(1, QPixmap(":/vtx_amdv_16px.png")); 128 } 129 }; 130 131 class UIIndicatorMouse : public QIStateIndicator 132 { 133 Q_OBJECT; 134 135 public: 136 137 UIIndicatorMouse() : QIStateIndicator(0) 477 478 retranslateUi(); 479 } 480 481 void retranslateUi() 482 { 483 updateAppearance(); 484 } 485 486 void updateAppearance() 487 { 488 const CConsole &console = m_session.GetConsole(); 489 490 bool bVirtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 491 QString virtualization = bVirtEnabled ? 492 VBoxGlobal::tr("Enabled", "details report (VT-x/AMD-V)") : 493 VBoxGlobal::tr("Disabled", "details report (VT-x/AMD-V)"); 494 495 bool bNestEnabled = console.GetDebugger().GetHWVirtExNestedPagingEnabled(); 496 QString nestedPaging = bNestEnabled ? 497 VBoxGlobal::tr("Enabled", "nested paging") : 498 VBoxGlobal::tr("Disabled", "nested paging"); 499 500 QString tip(tr("Indicates the status of the hardware virtualization " 501 "features used by this virtual machine:" 502 "<br><nobr><b>%1:</b> %2</nobr>" 503 "<br><nobr><b>%3:</b> %4</nobr>", 504 "Virtualization Stuff LED") 505 .arg(VBoxGlobal::tr("VT-x/AMD-V", "details report"), virtualization) 506 .arg(VBoxGlobal::tr("Nested Paging"), nestedPaging)); 507 508 int cpuCount = console.GetMachine().GetCPUCount(); 509 if (cpuCount > 1) 510 tip += tr("<br><nobr><b>%1:</b> %2</nobr>", "Virtualization Stuff LED") 511 .arg(VBoxGlobal::tr("Processor(s)", "details report")).arg(cpuCount); 512 513 setToolTip(tip); 514 setState(bVirtEnabled); 515 } 516 517 protected: 518 /* For compatibility reason we do it here, later this should be moved to 519 * QIStateIndicator. */ 520 CSession &m_session; 521 }; 522 523 class UIIndicatorMouse : public QIWithRetranslateUI<QIStateIndicator> 524 { 525 Q_OBJECT; 526 527 public: 528 529 UIIndicatorMouse(CSession &session) 530 : QIWithRetranslateUI<QIStateIndicator>() 531 , m_session(session) 138 532 { 139 533 setStateIcon(0, QPixmap(":/mouse_disabled_16px.png")); … … 142 536 setStateIcon(3, QPixmap(":/mouse_can_seamless_16px.png")); 143 537 setStateIcon(4, QPixmap(":/mouse_can_seamless_uncaptured_16px.png")); 144 } 145 }; 146 147 class UIIndicatorHostkey : public QIStateIndicator 148 { 149 Q_OBJECT; 150 151 public: 152 153 UIIndicatorHostkey() : QIStateIndicator(0) 538 539 retranslateUi(); 540 } 541 542 void retranslateUi() 543 { 544 setToolTip(tr("Indicates whether the host mouse pointer is captured by the guest OS:<br>" 545 "<nobr><img src=:/mouse_disabled_16px.png/> pointer is not captured</nobr><br>" 546 "<nobr><img src=:/mouse_16px.png/> pointer is captured</nobr><br>" 547 "<nobr><img src=:/mouse_seamless_16px.png/> mouse integration (MI) is On</nobr><br>" 548 "<nobr><img src=:/mouse_can_seamless_16px.png/> MI is Off, pointer is captured</nobr><br>" 549 "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/> MI is Off, pointer is not captured</nobr><br>" 550 "Note that the mouse integration feature requires Guest Additions to be installed in the guest OS.")); 551 } 552 553 protected: 554 /* For compatibility reason we do it here, later this should be moved to 555 * QIStateIndicator. */ 556 CSession &m_session; 557 }; 558 559 class UIIndicatorHostkey : public QIWithRetranslateUI<QIStateIndicator> 560 { 561 Q_OBJECT; 562 563 public: 564 565 UIIndicatorHostkey(CSession &session) 566 : QIWithRetranslateUI<QIStateIndicator>() 567 , m_session(session) 154 568 { 155 569 setStateIcon(0, QPixmap(":/hostkey_16px.png")); … … 157 571 setStateIcon(2, QPixmap(":/hostkey_pressed_16px.png")); 158 572 setStateIcon(3, QPixmap(":/hostkey_captured_pressed_16px.png")); 159 } 160 }; 161 162 UIIndicatorsPool::UIIndicatorsPool(QObject *pParent) 573 574 retranslateUi(); 575 } 576 577 void retranslateUi() 578 { 579 setToolTip(tr("Indicates whether the keyboard is captured by the guest OS " 580 "(<img src=:/hostkey_captured_16px.png/>) or not (<img src=:/hostkey_16px.png/>).")); 581 } 582 583 protected: 584 /* For compatibility reason we do it here, later this should be moved to 585 * QIStateIndicator. */ 586 CSession &m_session; 587 }; 588 589 UIIndicatorsPool::UIIndicatorsPool(CSession &session, QObject *pParent) 163 590 : QObject(pParent) 591 , m_session(session) 164 592 , m_IndicatorsPool(UIIndicatorIndex_End, 0) 165 593 { … … 183 611 { 184 612 case UIIndicatorIndex_HardDisks: 185 m_IndicatorsPool[index] = new UIIndicatorHardDisks ;613 m_IndicatorsPool[index] = new UIIndicatorHardDisks(m_session); 186 614 break; 187 615 case UIIndicatorIndex_OpticalDisks: 188 m_IndicatorsPool[index] = new UIIndicatorOpticalDisks ;616 m_IndicatorsPool[index] = new UIIndicatorOpticalDisks(m_session); 189 617 break; 190 618 case UIIndicatorIndex_NetworkAdapters: 191 m_IndicatorsPool[index] = new UIIndicatorNetworkAdapters ;619 m_IndicatorsPool[index] = new UIIndicatorNetworkAdapters(m_session); 192 620 break; 193 621 case UIIndicatorIndex_USBDevices: 194 m_IndicatorsPool[index] = new UIIndicatorUSBDevices ;622 m_IndicatorsPool[index] = new UIIndicatorUSBDevices(m_session); 195 623 break; 196 624 case UIIndicatorIndex_SharedFolders: 197 m_IndicatorsPool[index] = new UIIndicatorSharedFolders ;625 m_IndicatorsPool[index] = new UIIndicatorSharedFolders(m_session); 198 626 break; 199 627 case UIIndicatorIndex_Virtualization: 200 m_IndicatorsPool[index] = new UIIndicatorVirtualization ;628 m_IndicatorsPool[index] = new UIIndicatorVirtualization(m_session); 201 629 break; 202 630 case UIIndicatorIndex_Mouse: 203 m_IndicatorsPool[index] = new UIIndicatorMouse ;631 m_IndicatorsPool[index] = new UIIndicatorMouse(m_session); 204 632 break; 205 633 case UIIndicatorIndex_Hostkey: 206 m_IndicatorsPool[index] = new UIIndicatorHostkey ;634 m_IndicatorsPool[index] = new UIIndicatorHostkey(m_session); 207 635 break; 208 636 default: -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h
r26709 r26758 27 27 #include "QIStateIndicator.h" 28 28 29 class CSession; 30 29 31 enum UIIndicatorIndex 30 32 { 31 33 UIIndicatorIndex_HardDisks, 32 34 UIIndicatorIndex_OpticalDisks, 35 UIIndicatorIndex_FloppyDisks, 33 36 UIIndicatorIndex_NetworkAdapters, 34 37 UIIndicatorIndex_USBDevices, 35 38 UIIndicatorIndex_SharedFolders, 39 UIIndicatorIndex_VRDP, 36 40 UIIndicatorIndex_Virtualization, 37 41 UIIndicatorIndex_Mouse, … … 46 50 public: 47 51 48 UIIndicatorsPool( QObject *pParent);52 UIIndicatorsPool(CSession &session, QObject *pParent); 49 53 ~UIIndicatorsPool(); 50 54 … … 53 57 private: 54 58 59 CSession &m_session; 55 60 QVector<QIStateIndicator*> m_IndicatorsPool; 56 61 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
r26730 r26758 47 47 : QIWithRetranslateUI<QIMainDialog>(0) 48 48 , UIMachineWindow(pMachineLogic) 49 , m_pIndicatorsPool(new UIIndicatorsPool( this))49 , m_pIndicatorsPool(new UIIndicatorsPool(pMachineLogic->uisession()->session(), this)) 50 50 , m_pIdleTimer(0) 51 51 { … … 296 296 /* Translate parent class: */ 297 297 UIMachineWindow::retranslateUi(); 298 299 #ifdef Q_WS_MAC 300 // TODO_NEW_CORE 301 // m_pDockSettingsMenu->setTitle(tr("Dock Icon")); 302 // m_pDockDisablePreview->setText(tr("Show Application Icon")); 303 // m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview")); 304 #endif /* Q_WS_MAC */ 305 306 m_pNameHostkey->setToolTip( 307 tr("Shows the currently assigned Host key.<br>" 308 "This key, when pressed alone, toggles the keyboard and mouse " 309 "capture state. It can also be used in combination with other keys " 310 "to quickly perform actions from the main menu.")); 311 m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey())); 298 312 } 299 313 … … 303 317 UIMachineWindow::updateAppearanceOf(iElement); 304 318 305 // TODO: Move most of this update code into indicators-pool!306 307 319 /* Update that machine window: */ 308 CMachine machine = session().GetMachine();309 CConsole console = session().GetConsole();310 311 320 if (iElement & UIVisualElement_HDStuff) 312 { 313 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity " 314 "of the virtual hard disks:</nobr>%1</p>", "HDD tooltip"); 315 316 QString strFullData; 317 bool bAttachmentsPresent = false; 318 319 CStorageControllerVector controllers = machine.GetStorageControllers(); 320 foreach (const CStorageController &controller, controllers) 321 { 322 QString strAttData; 323 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController(controller.GetName()); 324 foreach (const CMediumAttachment &attachment, attachments) 325 { 326 if (attachment.GetType() != KDeviceType_HardDisk) 327 continue; 328 strAttData += QString("<br> <nobr>%1: %2</nobr>") 329 .arg(vboxGlobal().toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 330 .arg(VBoxMedium(attachment.GetMedium(), VBoxDefs::MediumType_HardDisk).location()); 331 bAttachmentsPresent = true; 332 } 333 if (!strAttData.isNull()) 334 strFullData += QString("<br><nobr><b>%1</b></nobr>").arg(controller.GetName()) + strAttData; 335 } 336 337 if (!bAttachmentsPresent) 338 strFullData += tr("<br><nobr><b>No hard disks attached</b></nobr>", "HDD tooltip"); 339 340 indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->setToolTip(strToolTip.arg(strFullData)); 341 indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->setState(bAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 342 } 321 indicatorsPool()->indicator(UIIndicatorIndex_HardDisks)->updateAppearance(); 343 322 if (iElement & UIVisualElement_CDStuff) 344 { 345 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity " 346 "of the CD/DVD devices:</nobr>%1</p>", "CD/DVD tooltip"); 347 348 QString strFullData; 349 bool bAttachmentsPresent = false; 350 351 CStorageControllerVector controllers = machine.GetStorageControllers(); 352 foreach (const CStorageController &controller, controllers) 353 { 354 QString strAttData; 355 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController(controller.GetName()); 356 foreach (const CMediumAttachment &attachment, attachments) 357 { 358 if (attachment.GetType() != KDeviceType_DVD) 359 continue; 360 VBoxMedium vboxMedium(attachment.GetMedium(), VBoxDefs::MediumType_DVD); 361 strAttData += QString("<br> <nobr>%1: %2</nobr>") 362 .arg(vboxGlobal().toString(StorageSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice()))) 363 .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location()); 364 if (!vboxMedium.isNull()) 365 bAttachmentsPresent = true; 366 } 367 if (!strAttData.isNull()) 368 strFullData += QString("<br><nobr><b>%1</b></nobr>").arg(controller.GetName()) + strAttData; 369 } 370 371 if (strFullData.isNull()) 372 strFullData = tr("<br><nobr><b>No CD/DVD devices attached</b></nobr>", "CD/DVD tooltip"); 373 374 indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->setToolTip(strToolTip.arg(strFullData)); 375 indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->setState(bAttachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null); 376 } 377 if (iElement & UIVisualElement_USBStuff) 378 { 379 if (!indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden()) 380 { 381 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of " 382 "the attached USB devices:</nobr>%1</p>", "USB device tooltip"); 383 QString strFullData; 384 385 CUSBController usbctl = machine.GetUSBController(); 386 if (!usbctl.isNull() && usbctl.GetEnabled()) 387 { 388 CUSBDeviceVector devsvec = console.GetUSBDevices(); 389 for (int i = 0; i < devsvec.size(); ++ i) 390 { 391 CUSBDevice usb = devsvec[i]; 392 strFullData += QString("<br><b><nobr>%1</nobr></b>").arg(vboxGlobal().details(usb)); 393 } 394 if (strFullData.isNull()) 395 strFullData = tr("<br><nobr><b>No USB devices attached</b></nobr>", "USB device tooltip"); 396 } 397 else 398 { 399 strFullData = tr("<br><nobr><b>USB Controller is disabled</b></nobr>", "USB device tooltip"); 400 } 401 402 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->setToolTip(strToolTip.arg(strFullData)); 403 } 404 } 323 indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance(); 324 #if 0 /* TODO: Allow to setup status-bar! */ 325 if (iElement & UIVisualElement_FDStuff) 326 indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks)->updateAppearance(); 327 #endif 328 if ( iElement & UIVisualElement_USBStuff 329 && !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden()) 330 indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance(); 405 331 if (iElement & UIVisualElement_NetworkStuff) 406 { 407 ulong uMaxCount = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount(); 408 ulong uCount = 0; 409 for (ulong uSlot = 0; uSlot < uMaxCount; ++ uSlot) 410 if (machine.GetNetworkAdapter(uSlot).GetEnabled()) 411 ++ uCount; 412 indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->setState(uCount > 0 ? KDeviceActivity_Idle : KDeviceActivity_Null); 413 414 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of the " 415 "network interfaces:</nobr>%1</p>", "Network adapters tooltip"); 416 QString strFullData; 417 418 for (ulong uSlot = 0; uSlot < uMaxCount; ++ uSlot) 419 { 420 CNetworkAdapter adapter = machine.GetNetworkAdapter(uSlot); 421 if (adapter.GetEnabled()) 422 strFullData += tr("<br><nobr><b>Adapter %1 (%2)</b>: cable %3</nobr>", "Network adapters tooltip") 423 .arg(uSlot + 1) 424 .arg(vboxGlobal().toString(adapter.GetAttachmentType())) 425 .arg(adapter.GetCableConnected() ? 426 tr("connected", "Network adapters tooltip") : 427 tr("disconnected", "Network adapters tooltip")); 428 } 429 430 if (strFullData.isNull()) 431 strFullData = tr("<br><nobr><b>All network adapters are disabled</b></nobr>", "Network adapters tooltip"); 432 433 indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->setToolTip(strToolTip.arg(strFullData)); 434 } 332 indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance(); 435 333 if (iElement & UIVisualElement_SharedFolderStuff) 436 { 437 QString strToolTip = tr("<p style='white-space:pre'><nobr>Indicates the activity of " 438 "the machine's shared folders:</nobr>%1</p>", "Shared folders tooltip"); 439 440 QString strFullData; 441 QMap<QString, QString> sfs; 442 443 /* Permanent folders */ 444 CSharedFolderVector psfvec = machine.GetSharedFolders(); 445 446 for (int i = 0; i < psfvec.size(); ++ i) 447 { 448 CSharedFolder sf = psfvec[i]; 449 sfs.insert(sf.GetName(), sf.GetHostPath()); 450 } 451 452 /* Transient folders */ 453 CSharedFolderVector tsfvec = console.GetSharedFolders(); 454 455 for (int i = 0; i < tsfvec.size(); ++ i) 456 { 457 CSharedFolder sf = tsfvec[i]; 458 sfs.insert(sf.GetName(), sf.GetHostPath()); 459 } 460 461 for (QMap<QString, QString>::const_iterator it = sfs.constBegin(); it != sfs.constEnd(); ++ it) 462 { 463 /* Select slashes depending on the OS type */ 464 if (VBoxGlobal::isDOSType(console.GetGuest().GetOSTypeId())) 465 strFullData += QString("<br><nobr><b>\\\\vboxsvr\\%1 </b></nobr><nobr>%2</nobr>") 466 .arg(it.key(), it.value()); 467 else 468 strFullData += QString("<br><nobr><b>%1 </b></nobr><nobr>%2</nobr>") 469 .arg(it.key(), it.value()); 470 } 471 472 if (sfs.count() == 0) 473 strFullData = tr("<br><nobr><b>No shared folders</b></nobr>", "Shared folders tooltip"); 474 475 indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->setToolTip(strToolTip.arg(strFullData)); 476 } 334 indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance(); 335 #if 0 /* TODO: Allow to setup status-bar! */ 477 336 if (iElement & UIVisualElement_VRDPStuff) 478 { 479 CVRDPServer vrdpsrv = session().GetMachine().GetVRDPServer(); 480 if (!vrdpsrv.isNull()) 481 { 482 /* Update menu&status icon state */ 483 bool isVRDPEnabled = vrdpsrv.GetEnabled(); 484 machineLogic()->actionsPool()->action(UIActionIndex_Toggle_VRDP)->setChecked(isVRDPEnabled); 485 } 486 } 337 indicatorsPool()->indicator(UIIndicatorIndex_VRDP)->updateAppearance(); 338 #endif 487 339 if (iElement & UIVisualElement_VirtualizationStuff) 488 { 489 bool bVirtEnabled = console.GetDebugger().GetHWVirtExEnabled(); 490 QString virtualization = bVirtEnabled ? 491 VBoxGlobal::tr("Enabled", "details report (VT-x/AMD-V)") : 492 VBoxGlobal::tr("Disabled", "details report (VT-x/AMD-V)"); 493 494 bool bNestEnabled = console.GetDebugger().GetHWVirtExNestedPagingEnabled(); 495 QString nestedPaging = bNestEnabled ? 496 VBoxVMInformationDlg::tr("Enabled", "nested paging") : 497 VBoxVMInformationDlg::tr("Disabled", "nested paging"); 498 499 QString tip(tr("Indicates the status of the hardware virtualization " 500 "features used by this virtual machine:" 501 "<br><nobr><b>%1:</b> %2</nobr>" 502 "<br><nobr><b>%3:</b> %4</nobr>", 503 "Virtualization Stuff LED") 504 .arg(VBoxGlobal::tr("VT-x/AMD-V", "details report"), virtualization) 505 .arg(VBoxVMInformationDlg::tr("Nested Paging"), nestedPaging)); 506 507 int cpuCount = console.GetMachine().GetCPUCount(); 508 if (cpuCount > 1) 509 tip += tr("<br><nobr><b>%1:</b> %2</nobr>", "Virtualization Stuff LED") 510 .arg(VBoxGlobal::tr("Processor(s)", "details report")).arg(cpuCount); 511 512 indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->setToolTip(tip); 513 indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->setState(bVirtEnabled); 514 } 340 indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance(); 515 341 } 516 342
Note:
See TracChangeset
for help on using the changeset viewer.