Changeset 41064 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 26, 2012 9:31:55 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 77632
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r41063 r41064 60 60 ~UIVisualState() 61 61 { 62 /* Delete machine logic if exists: */62 /* Cleanup/delete machine logic if exists: */ 63 63 if (m_pMachineLogic) 64 { 65 /* Cleanup the logic object: */ 66 m_pMachineLogic->cleanup(); 67 /* Destroy the logic object: */ 64 68 UIMachineLogic::destroy(m_pMachineLogic); 69 } 65 70 } 66 71 … … 95 100 96 101 /* Method to change one visual state to another: */ 97 virtual void change() = 0; 102 virtual void change() 103 { 104 /* Prepare the logic object: */ 105 m_pMachineLogic->prepare(); 106 } 98 107 99 108 /* Method to finish change one visual state to another: */ … … 149 158 void change() 150 159 { 160 /* Call to base-class: */ 161 UIVisualState::change(); 162 151 163 /* Connect action handlers: */ 152 164 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SIGNAL(triggered(bool)), … … 156 168 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)), 157 169 this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection); 158 159 /* Initialize the logic object: */160 m_pMachineLogic->initialize();161 170 } 162 171 }; … … 213 222 void change() 214 223 { 224 /* Call to base-class: */ 225 UIVisualState::change(); 226 215 227 /* Connect action handlers: */ 216 228 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen), SIGNAL(triggered(bool)), … … 220 232 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)), 221 233 this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection); 222 223 /* Initialize the logic object: */224 m_pMachineLogic->initialize();225 234 } 226 235 }; … … 277 286 void change() 278 287 { 288 /* Call to base-class: */ 289 UIVisualState::change(); 290 279 291 /* Connect action handlers: */ 280 292 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SIGNAL(triggered(bool)), … … 284 296 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)), 285 297 this, SLOT(sltGoToScaleMode()), Qt::QueuedConnection); 286 287 /* Initialize the logic object: */288 m_pMachineLogic->initialize();289 298 } 290 299 }; … … 341 350 void change() 342 351 { 352 /* Call to base-class: */ 353 UIVisualState::change(); 354 343 355 /* Connect action handlers: */ 344 356 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Scale), SIGNAL(triggered(bool)), … … 348 360 connect(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless), SIGNAL(triggered(bool)), 349 361 this, SLOT(sltGoToSeamlessMode()), Qt::QueuedConnection); 350 351 /* Initialize the logic object: */352 m_pMachineLogic->initialize();353 362 } 354 363 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r41063 r41064 110 110 UIVisualStateType visualStateType) 111 111 { 112 UIMachineLogic * logic = 0;112 UIMachineLogic *pLogic = 0; 113 113 switch (visualStateType) 114 114 { 115 115 case UIVisualStateType_Normal: 116 logic = new UIMachineLogicNormal(pParent, pSession);116 pLogic = new UIMachineLogicNormal(pParent, pSession); 117 117 break; 118 118 case UIVisualStateType_Fullscreen: 119 logic = new UIMachineLogicFullscreen(pParent, pSession);119 pLogic = new UIMachineLogicFullscreen(pParent, pSession); 120 120 break; 121 121 case UIVisualStateType_Seamless: 122 logic = new UIMachineLogicSeamless(pParent, pSession);122 pLogic = new UIMachineLogicSeamless(pParent, pSession); 123 123 break; 124 124 case UIVisualStateType_Scale: 125 logic = new UIMachineLogicScale(pParent, pSession);125 pLogic = new UIMachineLogicScale(pParent, pSession); 126 126 break; 127 127 } 128 return logic;128 return pLogic; 129 129 } 130 130 … … 135 135 } 136 136 137 bool UIMachineLogic::checkAvailability() 138 { 139 return true; 137 void UIMachineLogic::prepare() 138 { 139 /* Prepare required features: */ 140 prepareRequiredFeatures(); 141 142 /* Prepare session connections: */ 143 prepareSessionConnections(); 144 145 /* Prepare action groups: 146 * Note: This has to be done before prepareActionConnections 147 * cause here actions/menus are recreated. */ 148 prepareActionGroups(); 149 /* Prepare action connections: */ 150 prepareActionConnections(); 151 152 /* Prepare handlers: */ 153 prepareHandlers(); 154 155 /* Prepare machine window(s): */ 156 prepareMachineWindows(); 157 158 #ifdef Q_WS_MAC 159 /* Prepare dock: */ 160 prepareDock(); 161 #endif /* Q_WS_MAC */ 162 163 #ifdef VBOX_WITH_DEBUGGER_GUI 164 /* Prepare debugger: */ 165 prepareDebugger(); 166 #endif /* VBOX_WITH_DEBUGGER_GUI */ 167 168 /* Power up machine: */ 169 uisession()->powerUp(); 170 171 /* Initialization: */ 172 sltMachineStateChanged(); 173 sltAdditionsStateChanged(); 174 sltMouseCapabilityChanged(); 175 176 /* Retranslate logic part: */ 177 retranslateUi(); 178 } 179 180 void UIMachineLogic::cleanup() 181 { 182 #ifdef VBOX_WITH_DEBUGGER_GUI 183 /* Cleanup debugger: */ 184 cleanupDebugger(); 185 #endif /* VBOX_WITH_DEBUGGER_GUI */ 186 187 #ifdef Q_WS_MAC 188 /* Cleanup dock: */ 189 cleanupDock(); 190 #endif /* Q_WS_MAC */ 191 192 /* Cleanup machine window(s): */ 193 cleanupMachineWindows(); 194 195 /* Cleanup handlers: */ 196 cleanupHandlers(); 197 198 /* Cleanup action groups: */ 199 cleanupActionGroups(); 200 } 201 202 CSession& UIMachineLogic::session() const 203 { 204 return uisession()->session(); 140 205 } 141 206 … … 146 211 return 0; 147 212 213 /* Otherwise return first of windows: */ 148 214 return machineWindows()[0]; 149 215 } … … 208 274 #endif /* Q_WS_MAC */ 209 275 210 UIMachineLogic::UIMachineLogic(QObject *pParent, 211 UISession *pSession, 212 UIVisualStateType visualStateType) 276 void UIMachineLogic::sltMachineStateChanged() 277 { 278 /* Get machine state: */ 279 KMachineState state = uisession()->machineState(); 280 281 /* Update action groups: */ 282 m_pRunningActions->setEnabled(uisession()->isRunning()); 283 m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused()); 284 285 switch (state) 286 { 287 case KMachineState_Stuck: // TODO: Test it! 288 { 289 /* Prevent machine view from resizing: */ 290 uisession()->setGuestResizeIgnored(true); 291 292 /* Get console and log folder. */ 293 CConsole console = session().GetConsole(); 294 const QString &strLogFolder = console.GetMachine().GetLogFolder(); 295 296 /* Take the screenshot for debugging purposes and save it. */ 297 takeScreenshot(strLogFolder + "/VBox.png", "png"); 298 299 /* Warn the user about GURU: */ 300 if (msgCenter().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder))) 301 { 302 console.PowerDown(); 303 if (!console.isOk()) 304 msgCenter().cannotStopMachine(console); 305 } 306 break; 307 } 308 case KMachineState_Paused: 309 case KMachineState_TeleportingPausedVM: 310 { 311 QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause); 312 if (!pPauseAction->isChecked()) 313 { 314 /* Was paused from CSession side: */ 315 pPauseAction->blockSignals(true); 316 pPauseAction->setChecked(true); 317 pPauseAction->blockSignals(false); 318 } 319 break; 320 } 321 case KMachineState_Running: 322 case KMachineState_Teleporting: 323 case KMachineState_LiveSnapshotting: 324 { 325 QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause); 326 if (pPauseAction->isChecked()) 327 { 328 /* Was resumed from CSession side: */ 329 pPauseAction->blockSignals(true); 330 pPauseAction->setChecked(false); 331 pPauseAction->blockSignals(false); 332 } 333 break; 334 } 335 case KMachineState_PoweredOff: 336 case KMachineState_Saved: 337 case KMachineState_Teleported: 338 case KMachineState_Aborted: 339 { 340 /* Close VM if it was turned off and closure allowed: */ 341 if (!isPreventAutoClose()) 342 { 343 /* VM has been powered off, saved or aborted, no matter 344 * internally or externally. We must *safely* close VM window(s): */ 345 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession())); 346 } 347 break; 348 } 349 #ifdef Q_WS_X11 350 case KMachineState_Starting: 351 case KMachineState_Restoring: 352 case KMachineState_TeleportingIn: 353 { 354 /* The keyboard handler may wish to do some release logging on startup. 355 * Tell it that the logger is now active. */ 356 doXKeyboardLogging(QX11Info::display()); 357 break; 358 } 359 #endif 360 default: 361 break; 362 } 363 364 #ifdef Q_WS_MAC 365 /* Update Dock Overlay: */ 366 updateDockOverlay(); 367 #endif /* Q_WS_MAC */ 368 } 369 370 void UIMachineLogic::sltAdditionsStateChanged() 371 { 372 /* Update action states: */ 373 gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(uisession()->isGuestSupportsGraphics()); 374 gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(uisession()->isGuestSupportsSeamless()); 375 } 376 377 void UIMachineLogic::sltMouseCapabilityChanged() 378 { 379 /* Variable falgs: */ 380 bool fIsMouseSupportsAbsolute = uisession()->isMouseSupportsAbsolute(); 381 bool fIsMouseSupportsRelative = uisession()->isMouseSupportsRelative(); 382 bool fIsMouseHostCursorNeeded = uisession()->isMouseHostCursorNeeded(); 383 384 /* Update action state: */ 385 QAction *pAction = gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration); 386 pAction->setEnabled(fIsMouseSupportsAbsolute && fIsMouseSupportsRelative && !fIsMouseHostCursorNeeded); 387 if (fIsMouseHostCursorNeeded) 388 pAction->setChecked(false); 389 } 390 391 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error) 392 { 393 /* Check if USB device have anything to tell us: */ 394 if (!error.isNull()) 395 { 396 if (fIsAttached) 397 msgCenter().cannotAttachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error); 398 else 399 msgCenter().cannotDetachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error); 400 } 401 } 402 403 void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage) 404 { 405 msgCenter().showRuntimeError(session().GetConsole(), fIsFatal, strErrorId, strMessage); 406 } 407 408 #ifdef Q_WS_MAC 409 void UIMachineLogic::sltShowWindows() 410 { 411 for (int i=0; i < m_machineWindowsList.size(); ++i) 412 { 413 UIMachineWindow *pMachineWindow = m_machineWindowsList.at(i); 414 /* Dunno what Qt thinks a window that has minimized to the dock 415 * should be - it is not hidden, neither is it minimized. OTOH it is 416 * marked shown and visible, but not activated. This latter isn't of 417 * much help though, since at this point nothing is marked activated. 418 * I might have overlooked something, but I'm buggered what if I know 419 * what. So, I'll just always show & activate the stupid window to 420 * make it get out of the dock when the user wishes to show a VM. */ 421 pMachineWindow->machineWindow()->raise(); 422 pMachineWindow->machineWindow()->activateWindow(); 423 } 424 } 425 #endif /* Q_WS_MAC */ 426 427 UIMachineLogic::UIMachineLogic(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType) 213 428 : QIWithRetranslateUI3<QObject>(pParent) 214 429 , m_pSession(pSession) … … 233 448 } 234 449 235 UIMachineLogic::~UIMachineLogic()236 {237 #ifdef VBOX_WITH_DEBUGGER_GUI238 /* Close debugger: */239 dbgDestroy();240 #endif /* VBOX_WITH_DEBUGGER_GUI */241 }242 243 CSession& UIMachineLogic::session() const244 {245 return uisession()->session();246 }247 248 450 void UIMachineLogic::addMachineWindow(UIMachineWindow *pMachineWindow) 249 451 { … … 300 502 #endif /* Q_WS_MAC */ 301 503 504 void UIMachineLogic::prepareRequiredFeatures() 505 { 506 #ifdef Q_WS_MAC 507 # ifdef VBOX_WITH_ICHAT_THEATER 508 /* Init shared AV manager: */ 509 initSharedAVManager(); 510 # endif /* VBOX_WITH_ICHAT_THEATER */ 511 #endif /* Q_WS_MAC */ 512 } 513 302 514 void UIMachineLogic::prepareSessionConnections() 303 515 { 304 /* Machine power-up notifier: */516 /* We should check for entering/exiting requested modes: */ 305 517 connect(uisession(), SIGNAL(sigMachineStarted()), this, SLOT(sltCheckRequestedModes())); 518 connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltCheckRequestedModes())); 306 519 307 520 /* Machine state-change updater: */ … … 324 537 #ifdef Q_WS_MAC 325 538 /* Show windows: */ 326 connect(uisession(), SIGNAL(sigShowWindows()), 327 this, SLOT(sltShowWindows())); 539 connect(uisession(), SIGNAL(sigShowWindows()), this, SLOT(sltShowWindows())); 328 540 #endif /* Q_WS_MAC */ 541 } 542 543 void UIMachineLogic::prepareActionGroups() 544 { 545 #ifdef Q_WS_MAC 546 /* On Mac OS X, all QMenu's are consumed by Qt after they are added to 547 * another QMenu or a QMenuBar. This means we have to recreate all QMenus 548 * when creating a new QMenuBar. */ 549 gActionPool->recreateMenus(); 550 #endif /* Q_WS_MAC */ 551 552 /* Create group for all actions that are enabled only when the VM is running. 553 * Note that only actions whose enabled state depends exclusively on the 554 * execution state of the VM are added to this group. */ 555 m_pRunningActions = new QActionGroup(this); 556 m_pRunningActions->setExclusive(false); 557 558 /* Create group for all actions that are enabled when the VM is running or paused. 559 * Note that only actions whose enabled state depends exclusively on the 560 * execution state of the VM are added to this group. */ 561 m_pRunningOrPausedActions = new QActionGroup(this); 562 m_pRunningOrPausedActions->setExclusive(false); 563 564 /* Move actions into running actions group: */ 565 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD)); 566 #ifdef Q_WS_X11 567 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS)); 568 #endif 569 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset)); 570 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown)); 571 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)); 572 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)); 573 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale)); 574 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)); 575 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow)); 576 577 /* Move actions into running-n-paused actions group: */ 578 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog)); 579 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot)); 580 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot)); 581 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog)); 582 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration)); 583 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration)); 584 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause)); 585 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices)); 586 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices)); 587 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)); 588 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_NetworkAdapters)); 589 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkAdaptersDialog)); 590 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders)); 591 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersDialog)); 592 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer)); 593 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools)); 329 594 } 330 595 … … 394 659 } 395 660 396 void UIMachineLogic::prepareActionGroups()397 {398 #ifdef Q_WS_MAC399 /* On Mac OS X, all QMenu's are consumed by Qt after they are added to400 * another QMenu or a QMenuBar. This means we have to recreate all QMenus401 * when creating a new QMenuBar. */402 gActionPool->recreateMenus();403 #endif /* Q_WS_MAC */404 405 /* Create group for all actions that are enabled only when the VM is running.406 * Note that only actions whose enabled state depends exclusively on the407 * execution state of the VM are added to this group. */408 m_pRunningActions = new QActionGroup(this);409 m_pRunningActions->setExclusive(false);410 411 /* Create group for all actions that are enabled when the VM is running or paused.412 * Note that only actions whose enabled state depends exclusively on the413 * execution state of the VM are added to this group. */414 m_pRunningOrPausedActions = new QActionGroup(this);415 m_pRunningOrPausedActions->setExclusive(false);416 417 /* Move actions into running actions group: */418 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCAD));419 #ifdef Q_WS_X11420 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TypeCABS));421 #endif422 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Reset));423 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_Shutdown));424 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen));425 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless));426 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Scale));427 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize));428 m_pRunningActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow));429 430 /* Move actions into running-n-paused actions group: */431 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SettingsDialog));432 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeSnapshot));433 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_TakeScreenshot));434 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InformationDialog));435 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_MouseIntegration));436 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration));437 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_Pause));438 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices));439 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices));440 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_USBDevices));441 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_NetworkAdapters));442 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_NetworkAdaptersDialog));443 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Menu_SharedFolders));444 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_SharedFoldersDialog));445 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Toggle_VRDEServer));446 m_pRunningOrPausedActions->addAction(gActionPool->action(UIActionIndexRuntime_Simple_InstallGuestTools));447 }448 449 661 void UIMachineLogic::prepareHandlers() 450 662 { … … 529 741 #endif /* Q_WS_MAC */ 530 742 531 void UIMachineLogic::prepareRequiredFeatures()532 {533 #ifdef Q_WS_MAC534 # ifdef VBOX_WITH_ICHAT_THEATER535 /* Init shared AV manager: */536 initSharedAVManager();537 # endif538 #endif539 }540 541 743 #ifdef VBOX_WITH_DEBUGGER_GUI 542 744 void UIMachineLogic::prepareDebugger() … … 563 765 #endif /* VBOX_WITH_DEBUGGER_GUI */ 564 766 767 #ifdef VBOX_WITH_DEBUGGER_GUI 768 void UIMachineLogic::cleanupDebugger() 769 { 770 /* Close debugger: */ 771 dbgDestroy(); 772 } 773 #endif /* VBOX_WITH_DEBUGGER_GUI */ 774 565 775 #ifdef Q_WS_MAC 566 776 void UIMachineLogic::cleanupDock() … … 583 793 } 584 794 585 void UIMachineLogic::sltMachineStateChanged() 586 { 587 /* Get machine state: */ 588 KMachineState state = uisession()->machineState(); 589 590 /* Update action groups: */ 591 m_pRunningActions->setEnabled(uisession()->isRunning()); 592 m_pRunningOrPausedActions->setEnabled(uisession()->isRunning() || uisession()->isPaused()); 593 594 switch (state) 595 { 596 case KMachineState_Stuck: // TODO: Test it! 597 { 598 /* Prevent machine view from resizing: */ 599 uisession()->setGuestResizeIgnored(true); 600 601 /* Get console and log folder. */ 602 CConsole console = session().GetConsole(); 603 const QString &strLogFolder = console.GetMachine().GetLogFolder(); 604 605 /* Take the screenshot for debugging purposes and save it. */ 606 takeScreenshot(strLogFolder + "/VBox.png", "png"); 607 608 /* Warn the user about GURU: */ 609 if (msgCenter().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder))) 610 { 611 console.PowerDown(); 612 if (!console.isOk()) 613 msgCenter().cannotStopMachine(console); 614 } 615 break; 616 } 617 case KMachineState_Paused: 618 case KMachineState_TeleportingPausedVM: 619 { 620 QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause); 621 if (!pPauseAction->isChecked()) 622 { 623 /* Was paused from CSession side: */ 624 pPauseAction->blockSignals(true); 625 pPauseAction->setChecked(true); 626 pPauseAction->blockSignals(false); 627 } 628 break; 629 } 630 case KMachineState_Running: 631 case KMachineState_Teleporting: 632 case KMachineState_LiveSnapshotting: 633 { 634 QAction *pPauseAction = gActionPool->action(UIActionIndexRuntime_Toggle_Pause); 635 if (pPauseAction->isChecked()) 636 { 637 /* Was resumed from CSession side: */ 638 pPauseAction->blockSignals(true); 639 pPauseAction->setChecked(false); 640 pPauseAction->blockSignals(false); 641 } 642 break; 643 } 644 case KMachineState_PoweredOff: 645 case KMachineState_Saved: 646 case KMachineState_Teleported: 647 case KMachineState_Aborted: 648 { 649 /* Close VM if it was turned off and closure allowed: */ 650 if (!isPreventAutoClose()) 651 { 652 /* VM has been powered off, saved or aborted, no matter 653 * internally or externally. We must *safely* close VM window(s): */ 654 QTimer::singleShot(0, uisession(), SLOT(sltCloseVirtualSession())); 655 } 656 break; 657 } 658 #ifdef Q_WS_X11 659 case KMachineState_Starting: 660 case KMachineState_Restoring: 661 case KMachineState_TeleportingIn: 662 { 663 /* The keyboard handler may wish to do some release logging on startup. 664 * Tell it that the logger is now active. */ 665 doXKeyboardLogging(QX11Info::display()); 666 break; 667 } 668 #endif 669 default: 670 break; 671 } 672 673 #ifdef Q_WS_MAC 674 /* Update Dock Overlay: */ 675 updateDockOverlay(); 676 #endif /* Q_WS_MAC */ 677 } 678 679 void UIMachineLogic::sltAdditionsStateChanged() 680 { 681 /* Variable flags: */ 682 bool fIsSupportsGraphics = uisession()->isGuestSupportsGraphics(); 683 bool fIsSupportsSeamless = uisession()->isGuestSupportsSeamless(); 684 685 /* Update action states: */ 686 gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setEnabled(fIsSupportsGraphics); 687 gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->setEnabled(fIsSupportsSeamless); 688 689 /* Check if we should enter some extended mode: */ 690 sltCheckRequestedModes(); 691 } 692 693 void UIMachineLogic::sltMouseCapabilityChanged() 694 { 695 /* Variable falgs: */ 696 bool fIsMouseSupportsAbsolute = uisession()->isMouseSupportsAbsolute(); 697 bool fIsMouseSupportsRelative = uisession()->isMouseSupportsRelative(); 698 bool fIsMouseHostCursorNeeded = uisession()->isMouseHostCursorNeeded(); 699 700 /* Update action state: */ 701 QAction *pAction = gActionPool->action(UIActionIndexRuntime_Toggle_MouseIntegration); 702 pAction->setEnabled(fIsMouseSupportsAbsolute && fIsMouseSupportsRelative && !fIsMouseHostCursorNeeded); 703 if (fIsMouseHostCursorNeeded) 704 pAction->setChecked(false); 705 } 706 707 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool fIsAttached, const CVirtualBoxErrorInfo &error) 708 { 709 bool fSuccess = error.isNull(); 710 711 if (!fSuccess) 712 { 713 if (fIsAttached) 714 msgCenter().cannotAttachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error); 715 else 716 msgCenter().cannotDetachUSBDevice(session().GetConsole(), vboxGlobal().details(device), error); 717 } 718 } 719 720 void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage) 721 { 722 msgCenter().showRuntimeError(session().GetConsole(), fIsFatal, strErrorId, strMessage); 723 } 724 725 #ifdef Q_WS_MAC 726 void UIMachineLogic::sltShowWindows() 727 { 728 for (int i=0; i < m_machineWindowsList.size(); ++i) 729 { 730 UIMachineWindow *pMachineWindow = m_machineWindowsList.at(i); 731 /* Dunno what Qt thinks a window that has minimized to the dock 732 * should be - it is not hidden, neither is it minimized. OTOH it is 733 * marked shown and visible, but not activated. This latter isn't of 734 * much help though, since at this point nothing is marked activated. 735 * I might have overlooked something, but I'm buggered what if I know 736 * what. So, I'll just always show & activate the stupid window to 737 * make it get out of the dock when the user wishes to show a VM. */ 738 pMachineWindow->machineWindow()->raise(); 739 pMachineWindow->machineWindow()->activateWindow(); 740 } 741 } 742 #endif /* Q_WS_MAC */ 795 void UIMachineLogic::cleanupActionGroups() 796 { 797 } 743 798 744 799 void UIMachineLogic::sltCheckRequestedModes() … … 832 887 AssertWrapperOk(keyboard); 833 888 } 834 #endif 889 #endif /* Q_WS_X11 */ 835 890 836 891 void UIMachineLogic::sltTakeSnapshot() -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r41063 r41064 25 25 #ifdef VBOX_WITH_DEBUGGER_GUI 26 26 # include <VBox/dbggui.h> 27 #endif 27 #endif /* VBOX_WITH_DEBUGGER_GUI */ 28 28 29 29 /* Global forwards */ … … 44 44 class UIDockIconPreview; 45 45 46 /* Machine logic interface: */ 46 47 class UIMachineLogic : public QIWithRetranslateUI3<QObject> 47 48 { … … 51 52 52 53 /* Factory functions to create/destroy required logic sub-child: */ 53 static UIMachineLogic* create(QObject *pParent, 54 UISession *pSession, 55 UIVisualStateType visualStateType); 54 static UIMachineLogic* create(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType); 56 55 static void destroy(UIMachineLogic *pWhichLogic); 57 56 58 /* Check if this mode is available: */ 59 virtual bool checkAvailability(); 60 61 /* Do the real initialization of the object: */ 62 virtual void initialize() = 0; 57 /* Check if this logic is available: */ 58 virtual bool checkAvailability() = 0; 59 60 /* Prepare/cleanup the logic: */ 61 virtual void prepare(); 62 virtual void cleanup(); 63 63 64 64 /* Main getters/setters: */ … … 82 82 #endif /* Q_WS_MAC */ 83 83 84 protected:85 86 /* Machine logic constructor/destructor: */87 UIMachineLogic(QObject *pParent,88 UISession *pSession,89 UIVisualStateType visualStateType);90 virtual ~UIMachineLogic();91 92 /* Protected getters/setters: */93 bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; }94 void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }95 96 /* Protected members: */97 void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler);98 void setMouseHandler(UIMouseHandler *pMouseHandler);99 void addMachineWindow(UIMachineWindow *pMachineWindow);100 void retranslateUi();101 #ifdef Q_WS_MAC102 bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; }103 void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; }104 void updateDockOverlay();105 #endif /* Q_WS_MAC */106 107 /* Prepare helpers: */108 virtual void prepareSessionConnections();109 virtual void prepareActionConnections();110 virtual void prepareActionGroups();111 virtual void prepareHandlers();112 #ifdef Q_WS_MAC113 virtual void prepareDock();114 #endif /* Q_WS_MAC */115 virtual void prepareRequiredFeatures();116 #ifdef VBOX_WITH_DEBUGGER_GUI117 virtual void prepareDebugger();118 #endif /* VBOX_WITH_DEBUGGER_GUI */119 120 /* Cleanup helpers: */121 //virtual void cleanupRequiredFeatures() {}122 #ifdef Q_WS_MAC123 virtual void cleanupDock();124 #endif /* Q_WS_MAC */125 virtual void cleanupHandlers();126 //virtual void cleanupActionGroups() {}127 //virtual void cleanupActionConnections() {}128 //virtual void cleanupSessionConnections() {}129 130 84 protected slots: 131 85 … … 140 94 #endif /* RT_OS_DARWIN */ 141 95 96 protected: 97 98 /* Constructor: */ 99 UIMachineLogic(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType); 100 101 /* Protected getters/setters: */ 102 bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; } 103 void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; } 104 105 /* Protected members: */ 106 void setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler); 107 void setMouseHandler(UIMouseHandler *pMouseHandler); 108 void addMachineWindow(UIMachineWindow *pMachineWindow); 109 void retranslateUi(); 110 #ifdef Q_WS_MAC 111 bool isDockIconPreviewEnabled() const { return m_fIsDockIconEnabled; } 112 void setDockIconPreviewEnabled(bool fIsDockIconPreviewEnabled) { m_fIsDockIconEnabled = fIsDockIconPreviewEnabled; } 113 void updateDockOverlay(); 114 #endif /* Q_WS_MAC */ 115 116 /* Prepare helpers: */ 117 virtual void prepareRequiredFeatures(); 118 virtual void prepareSessionConnections(); 119 virtual void prepareActionGroups(); 120 virtual void prepareActionConnections(); 121 virtual void prepareHandlers(); 122 virtual void prepareMachineWindows() = 0; 123 #ifdef Q_WS_MAC 124 virtual void prepareDock(); 125 #endif /* Q_WS_MAC */ 126 #ifdef VBOX_WITH_DEBUGGER_GUI 127 virtual void prepareDebugger(); 128 #endif /* VBOX_WITH_DEBUGGER_GUI */ 129 130 /* Cleanup helpers: */ 131 #ifdef VBOX_WITH_DEBUGGER_GUI 132 virtual void cleanupDebugger(); 133 #endif /* VBOX_WITH_DEBUGGER_GUI */ 134 #ifdef Q_WS_MAC 135 virtual void cleanupDock(); 136 #endif /* Q_WS_MAC */ 137 virtual void cleanupMachineWindows() = 0; 138 virtual void cleanupHandlers(); 139 //virtual void cleanupActionConnections() {} 140 virtual void cleanupActionGroups(); 141 //virtual void cleanupSessionConnections() {} 142 //virtual void cleanupRequiredFeatures() {} 143 144 private slots: 145 142 146 /* Mode request watch dog: */ 143 147 void sltCheckRequestedModes(); 144 148 145 private slots: 146 147 /* "Machine" menu functionality */ 149 /* "Machine" menu functionality: */ 148 150 void sltToggleGuestAutoresize(bool fEnabled); 149 151 void sltAdjustWindow(); … … 152 154 #ifdef Q_WS_X11 153 155 void sltTypeCABS(); 154 #endif 155 156 #endif /* Q_WS_X11 */ 156 157 void sltTakeSnapshot(); 157 158 void sltTakeScreenshot(); … … 162 163 void sltClose(); 163 164 164 /* "Device" menu functionality */165 /* "Device" menu functionality: */ 165 166 void sltOpenVMSettingsDialog(const QString &strCategory = QString()); 166 167 void sltOpenNetworkAdaptersDialog(); … … 175 176 176 177 #ifdef VBOX_WITH_DEBUGGER_GUI 178 /* "Debug" menu functionality: */ 177 179 void sltPrepareDebugMenu(); 178 180 void sltShowDebugStatistics(); … … 180 182 void sltLoggingToggled(bool); 181 183 void sltShowLogDialog(); 182 #endif 184 #endif /* VBOX_WITH_DEBUGGER_GUI */ 183 185 184 186 #ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */ … … 190 192 private: 191 193 192 /* Utility functions: */ 193 static int searchMaxSnapshotIndex(const CMachine &machine, 194 const CSnapshot &snapshot, 195 const QString &strNameTemplate); 196 194 /* Helpers: */ 195 static int searchMaxSnapshotIndex(const CMachine &machine, const CSnapshot &snapshot, const QString &strNameTemplate); 197 196 void takeScreenshot(const QString &strFile, const QString &strFormat /* = "png" */) const; 198 197 … … 219 218 /* The virtual method table for the debugger GUI: */ 220 219 PCDBGGUIVT m_pDbgGuiVT; 221 #endif 220 #endif /* VBOX_WITH_DEBUGGER_GUI */ 222 221 223 222 #ifdef Q_WS_MAC -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r38348 r41064 7 7 8 8 /* 9 * Copyright (C) 2010 Oracle Corporation9 * Copyright (C) 2010-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes */20 /* Global includes: */ 21 21 #include <QDesktopWidget> 22 22 23 /* Local includes */23 /* Local includes: */ 24 24 #include "COMDefs.h" 25 25 #include "VBoxGlobal.h" 26 26 #include "UIMessageCenter.h" 27 28 27 #include "UISession.h" 29 28 #include "UIActionPoolRuntime.h" … … 31 30 #include "UIMachineWindowFullscreen.h" 32 31 #include "UIMultiScreenLayout.h" 33 34 32 #ifdef Q_WS_MAC 35 33 # include "UIExtraDataEventHandler.h" … … 41 39 : UIMachineLogic(pParent, pSession, UIVisualStateType_Fullscreen) 42 40 { 41 /* Create multiscreen layout: */ 43 42 m_pScreenLayout = new UIMultiScreenLayout(this); 44 43 } … … 46 45 UIMachineLogicFullscreen::~UIMachineLogicFullscreen() 47 46 { 48 #ifdef Q_WS_MAC 49 /* Cleanup the dock stuff before the machine window(s): */ 50 cleanupDock(); 51 #endif /* Q_WS_MAC */ 52 53 /* Cleanup machine window(s): */ 54 cleanupMachineWindows(); 55 56 /* Cleanup handlers: */ 57 cleanupHandlers(); 58 59 /* Cleanup action related stuff */ 60 cleanupActionGroups(); 61 47 /* Delete multiscreen layout: */ 62 48 delete m_pScreenLayout; 63 49 } … … 65 51 bool UIMachineLogicFullscreen::checkAvailability() 66 52 { 67 /* Base class availability: */68 if (!UIMachineLogic::checkAvailability())69 return false;70 71 53 /* Temporary get a machine object: */ 72 54 const CMachine &machine = uisession()->session().GetMachine(); 73 55 56 /* Check that there are enough physical screens are connected: */ 74 57 int cHostScreens = m_pScreenLayout->hostScreenCount(); 75 58 int cGuestScreens = m_pScreenLayout->guestScreenCount(); 76 /* Check that there are enough physical screens are connected: */77 59 if (cHostScreens < cGuestScreens) 78 60 { … … 81 63 } 82 64 83 // TODO_NEW_CORE: this is how it looked in the old version 84 // bool VBoxConsoleView::isAutoresizeGuestActive() { return mGuestSupportsGraphics && mAutoresizeGuest; } 85 // if (uisession()->session().GetConsole().isAutoresizeGuestActive()) 65 /* Check if there is enough physical memory to enter fullscreen: */ 86 66 if (uisession()->isGuestAdditionsActive()) 87 67 { 88 quint64 availBits = machine.GetVRAMSize() /* VRAM */ 89 * _1M /* MiB to bytes */ 90 * 8; /* to bits */ 68 quint64 availBits = machine.GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */; 91 69 quint64 usedBits = m_pScreenLayout->memoryRequirements(); 92 70 if (availBits < usedBits) 93 71 { 94 72 int result = msgCenter().cannotEnterFullscreenMode(0, 0, 0, 95 73 (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M); 96 74 if (result == QIMessageBox::Cancel) 97 75 return false; … … 99 77 } 100 78 101 /* Take the toggle hot key from the menu item. Since102 * VBoxGlobal::extractKeyFromActionText gets exactly the103 * linked key without the 'Host+' part we are adding it here. */79 /* Take the toggle hot key from the menu item. 80 * Since VBoxGlobal::extractKeyFromActionText gets exactly 81 * the linked key without the 'Host+' part we are adding it here. */ 104 82 QString hotKey = QString("Host+%1") 105 83 .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Fullscreen)->text())); … … 113 91 } 114 92 115 void UIMachineLogicFullscreen::initialize() 116 { 117 /* Prepare required features: */ 118 prepareRequiredFeatures(); 119 120 #ifdef Q_WS_MAC 121 /* Prepare common connections: */ 122 prepareCommonConnections(); 123 #endif /* Q_WS_MAC */ 124 125 /* Prepare console connections: */ 126 prepareSessionConnections(); 127 128 /* Prepare action groups: 129 * Note: This has to be done before prepareActionConnections 130 * cause here actions/menus are recreated. */ 131 prepareActionGroups(); 132 133 /* Prepare action connections: */ 134 prepareActionConnections(); 135 136 /* Prepare handlers: */ 137 prepareHandlers(); 138 139 /* Prepare machine window: */ 140 prepareMachineWindows(); 141 142 #ifdef Q_WS_MAC 143 /* Prepare dock: */ 144 prepareDock(); 145 #endif /* Q_WS_MAC */ 146 147 /* Power up machine: */ 148 uisession()->powerUp(); 149 150 /* Initialization: */ 151 sltMachineStateChanged(); 152 sltAdditionsStateChanged(); 153 sltMouseCapabilityChanged(); 154 155 #ifdef VBOX_WITH_DEBUGGER_GUI 156 prepareDebugger(); 157 #endif /* VBOX_WITH_DEBUGGER_GUI */ 158 159 /* Retranslate logic part: */ 160 retranslateUi(); 93 void UIMachineLogicFullscreen::prepare() 94 { 95 /* Call to base-class: */ 96 UIMachineLogic::prepare(); 97 98 #ifdef Q_WS_MAC 99 /* Prepare fullscreen connections: */ 100 prepareFullscreenConnections(); 101 #endif /* Q_WS_MAC */ 161 102 } 162 103 … … 167 108 168 109 #ifdef Q_WS_MAC 169 void UIMachineLogicFullscreen::prepare CommonConnections()170 { 171 /* Presentation mode connection */110 void UIMachineLogicFullscreen::prepareFullscreenConnections() 111 { 112 /* Presentation mode connection: */ 172 113 connect(gEDataEvents, SIGNAL(sigPresentationModeChange(bool)), 173 114 this, SLOT(sltChangePresentationMode(bool))); … … 177 118 void UIMachineLogicFullscreen::prepareActionGroups() 178 119 { 179 /* Base class action groups: */120 /* Call to base-class: */ 180 121 UIMachineLogic::prepareActionGroups(); 181 122 … … 186 127 QMenu *pMenu = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu(); 187 128 m_pScreenLayout->initialize(pMenu); 129 pMenu->setVisible(true); 188 130 } 189 131 … … 242 184 void UIMachineLogicFullscreen::cleanupActionGroups() 243 185 { 186 /* Call to base-class: */ 187 UIMachineLogic::cleanupActionGroups(); 188 244 189 /* Reenable adjust-window action: */ 245 190 gActionPool->action(UIActionIndexRuntime_Simple_AdjustWindow)->setVisible(true); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
r38348 r41064 6 6 7 7 /* 8 * Copyright (C) 2010 Oracle Corporation8 * Copyright (C) 2010-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIMachineLogicFullscreen_h__ 21 21 22 /* Local includes */22 /* Local includes: */ 23 23 #include "UIMachineLogic.h" 24 24 25 /* Local forwards*/25 /* Forward declarations: */ 26 26 class UIMultiScreenLayout; 27 27 28 /* Fullscreen machine logic implementation: */ 28 29 class UIMachineLogicFullscreen : public UIMachineLogic 29 30 { … … 32 33 protected: 33 34 34 /* Fullscreen machine logic constructor/destructor: */ 35 UIMachineLogicFullscreen(QObject *pParent, 36 UISession *pSession); 35 /* Constructor/destructor: */ 36 UIMachineLogicFullscreen(QObject *pParent, UISession *pSession); 37 37 virtual ~UIMachineLogicFullscreen(); 38 38 39 /* Check if this logic is available: */ 39 40 bool checkAvailability(); 40 void initialize(); 41 42 /* Prepare logic: */ 43 void prepare(); 41 44 42 45 int hostScreenForGuestScreen(int screenId) const; … … 52 55 53 56 /* Prepare helpers: */ 54 #ifdef Q_WS_MAC55 void prepareCommonConnections();56 #endif /* Q_WS_MAC */57 57 void prepareActionGroups(); 58 58 void prepareMachineWindows(); 59 #ifdef Q_WS_MAC 60 void prepareFullscreenConnections(); 61 #endif /* Q_WS_MAC */ 59 62 60 63 /* Cleanup helpers: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r39932 r41064 7 7 8 8 /* 9 * Copyright (C) 2010 Oracle Corporation9 * Copyright (C) 2010-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes */20 /* Global includes: */ 21 21 #include <QMenu> 22 22 23 /* Local includes */23 /* Local includes: */ 24 24 #include "COMDefs.h" 25 25 #include "VBoxGlobal.h" 26 26 #include "UIMessageCenter.h" 27 28 27 #include "UISession.h" 29 28 #include "UIActionPoolRuntime.h" … … 33 32 #include "UIDownloaderUserManual.h" 34 33 #include "UIDownloaderExtensionPack.h" 35 36 34 #ifdef Q_WS_MAC 37 35 #include "VBoxUtils.h" … … 43 41 } 44 42 45 UIMachineLogicNormal::~UIMachineLogicNormal()43 bool UIMachineLogicNormal::checkAvailability() 46 44 { 47 #ifdef Q_WS_MAC 48 /* Cleanup the dock stuff before the machine window(s): */ 49 cleanupDock(); 50 #endif /* Q_WS_MAC */ 51 52 /* Cleanup machine window(s): */ 53 cleanupMachineWindow(); 54 55 /* Cleanup handlers: */ 56 cleanupHandlers(); 57 } 58 59 void UIMachineLogicNormal::initialize() 60 { 61 /* Prepare required features: */ 62 prepareRequiredFeatures(); 63 64 /* Prepare session connections: */ 65 prepareSessionConnections(); 66 67 /* Prepare action groups: 68 * Note: This has to be done before prepareActionConnections 69 * cause here actions/menus are recreated. */ 70 prepareActionGroups(); 71 72 /* Prepare action connections: */ 73 prepareActionConnections(); 74 75 /* Prepare handlers: */ 76 prepareHandlers(); 77 78 /* Prepare normal machine window: */ 79 prepareMachineWindows(); 80 81 #ifdef Q_WS_MAC 82 /* Prepare dock: */ 83 prepareDock(); 84 #endif /* Q_WS_MAC */ 85 86 /* Power up machine: */ 87 uisession()->powerUp(); 88 89 /* Initialization: */ 90 sltMachineStateChanged(); 91 sltAdditionsStateChanged(); 92 sltMouseCapabilityChanged(); 93 94 #ifdef VBOX_WITH_DEBUGGER_GUI 95 prepareDebugger(); 96 #endif /* VBOX_WITH_DEBUGGER_GUI */ 97 98 /* Retranslate logic part: */ 99 retranslateUi(); 45 /* Normal mode is always available: */ 46 return true; 100 47 } 101 48 … … 163 110 } 164 111 165 void UIMachineLogicNormal::cleanupMachineWindow ()112 void UIMachineLogicNormal::cleanupMachineWindows() 166 113 { 167 114 /* Do not cleanup machine window(s) if not present: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h
r38348 r41064 6 6 7 7 /* 8 * Copyright (C) 2010 Oracle Corporation8 * Copyright (C) 2010-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIMachineLogicNormal_h__ 21 21 22 /* Local includes */22 /* Local includes: */ 23 23 #include "UIMachineLogic.h" 24 24 25 /* Normal machine logic implementation: */ 25 26 class UIMachineLogicNormal : public UIMachineLogic 26 27 { … … 29 30 protected: 30 31 31 /* Normal machine logic constructor/destructor: */ 32 UIMachineLogicNormal(QObject *pParent, 33 UISession *pSession); 34 virtual ~UIMachineLogicNormal(); 32 /* Constructor: */ 33 UIMachineLogicNormal(QObject *pParent, UISession *pSession); 35 34 36 void initialize(); 35 /* Check if this logic is available: */ 36 bool checkAvailability(); 37 37 38 38 private slots: … … 50 50 51 51 /* Cleanup helpers: */ 52 void cleanupMachineWindow ();52 void cleanupMachineWindows(); 53 53 //void cleanupActionConnections() {} 54 54 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp
r39932 r41064 7 7 8 8 /* 9 * Copyright (C) 2010 Oracle Corporation9 * Copyright (C) 2010-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Local includes */20 /* Local includes: */ 21 21 #include "COMDefs.h" 22 22 #include "VBoxGlobal.h" 23 23 #include "UIMessageCenter.h" 24 25 24 #include "UISession.h" 26 25 #include "UIActionPoolRuntime.h" … … 29 28 #include "UIDownloaderAdditions.h" 30 29 #include "UIDownloaderExtensionPack.h" 31 32 30 #ifdef Q_WS_MAC 33 31 #include "VBoxUtils.h" … … 39 37 } 40 38 41 UIMachineLogicScale::~UIMachineLogicScale()42 {43 #ifdef Q_WS_MAC44 /* Cleanup the dock stuff before the machine window(s): */45 cleanupDock();46 #endif /* Q_WS_MAC */47 48 /* Cleanup machine window(s): */49 cleanupMachineWindow();50 51 /* Cleanup handlers: */52 cleanupHandlers();53 54 /* Cleanup actions groups: */55 cleanupActionGroups();56 }57 58 39 bool UIMachineLogicScale::checkAvailability() 59 40 { 60 /* Base class availability: */ 61 if (!UIMachineLogic::checkAvailability()) 62 return false; 63 64 /* Take the toggle hot key from the menu item. Since 65 * VBoxGlobal::extractKeyFromActionText gets exactly the 66 * linked key without the 'Host+' part we are adding it here. */ 41 /* Take the toggle hot key from the menu item. 42 * Since VBoxGlobal::extractKeyFromActionText gets exactly 43 * the linked key without the 'Host+' part we are adding it here. */ 67 44 QString strHotKey = QString("Host+%1") 68 45 .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Scale)->text())); … … 76 53 } 77 54 78 void UIMachineLogicScale::initialize()79 {80 /* Prepare required features: */81 prepareRequiredFeatures();82 83 /* Prepare session connections: */84 prepareSessionConnections();85 86 /* Prepare action groups:87 * Note: This has to be done before prepareActionConnections88 * cause here actions/menus are recreated. */89 prepareActionGroups();90 91 /* Prepare action connections: */92 prepareActionConnections();93 94 /* Prepare handlers: */95 prepareHandlers();96 97 /* Prepare scale machine window: */98 prepareMachineWindows();99 100 #ifdef Q_WS_MAC101 /* Prepare dock: */102 prepareDock();103 #endif /* Q_WS_MAC */104 105 /* Power up machine: */106 uisession()->powerUp();107 108 /* Initialization: */109 sltMachineStateChanged();110 sltAdditionsStateChanged();111 sltMouseCapabilityChanged();112 113 #ifdef VBOX_WITH_DEBUGGER_GUI114 prepareDebugger();115 #endif /* VBOX_WITH_DEBUGGER_GUI */116 117 /* Retranslate logic part: */118 retranslateUi();119 }120 121 55 void UIMachineLogicScale::prepareActionGroups() 122 56 { 123 /* Base class action groups: */57 /* Call to base-class: */ 124 58 UIMachineLogic::prepareActionGroups(); 125 59 … … 156 90 } 157 91 158 void UIMachineLogicScale::cleanupMachineWindow ()92 void UIMachineLogicScale::cleanupMachineWindows() 159 93 { 160 94 /* Do not cleanup machine window(s) if not present: */ … … 169 103 void UIMachineLogicScale::cleanupActionGroups() 170 104 { 105 /* Call to base-class: */ 106 UIMachineLogic::cleanupActionGroups(); 107 171 108 /* Reenable guest-autoresize action: */ 172 109 gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setVisible(true); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.h
r38348 r41064 6 6 7 7 /* 8 * Copyright (C) 2010 Oracle Corporation8 * Copyright (C) 2010-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIMachineLogicScale_h__ 21 21 22 /* Local includes */22 /* Local includes: */ 23 23 #include "UIMachineLogic.h" 24 24 25 /* Scale machine logic implementation: */ 25 26 class UIMachineLogicScale : public UIMachineLogic 26 27 { … … 29 30 protected: 30 31 31 /* Scale machine logic constructor/destructor: */ 32 UIMachineLogicScale(QObject *pParent, 33 UISession *pSession); 34 virtual ~UIMachineLogicScale(); 32 /* Constructor: */ 33 UIMachineLogicScale(QObject *pParent, UISession *pSession); 35 34 35 /* Check if this logic is available: */ 36 36 bool checkAvailability(); 37 void initialize();38 37 39 38 private: … … 44 43 45 44 /* Cleanup helpers: */ 46 void cleanupMachineWindow ();45 void cleanupMachineWindows(); 47 46 void cleanupActionGroups(); 48 47 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
r38348 r41064 7 7 8 8 /* 9 * Copyright (C) 2010 Oracle Corporation9 * Copyright (C) 2010-2012 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes */20 /* Global includes: */ 21 21 #include <QDesktopWidget> 22 22 23 /* Local includes */23 /* Local includes: */ 24 24 #include "COMDefs.h" 25 25 #include "VBoxGlobal.h" 26 26 #include "UIMessageCenter.h" 27 28 27 #include "UISession.h" 29 28 #include "UIActionPoolRuntime.h" … … 31 30 #include "UIMachineWindowSeamless.h" 32 31 #include "UIMultiScreenLayout.h" 33 34 32 #ifdef Q_WS_MAC 35 33 # include "VBoxUtils.h" … … 39 37 : UIMachineLogic(pParent, pSession, UIVisualStateType_Seamless) 40 38 { 39 /* Create multiscreen layout: */ 41 40 m_pScreenLayout = new UIMultiScreenLayout(this); 42 41 } … … 44 43 UIMachineLogicSeamless::~UIMachineLogicSeamless() 45 44 { 46 #ifdef Q_WS_MAC 47 /* Cleanup the dock stuff before the machine window(s): */ 48 cleanupDock(); 49 #endif /* Q_WS_MAC */ 50 51 /* Cleanup machine window(s): */ 52 cleanupMachineWindows(); 53 54 /* Cleanup handlers: */ 55 cleanupHandlers(); 56 57 /* Cleanup actions groups: */ 58 cleanupActionGroups(); 59 45 /* Delete multiscreen layout: */ 60 46 delete m_pScreenLayout; 61 47 } … … 63 49 bool UIMachineLogicSeamless::checkAvailability() 64 50 { 65 /* Base class availability: */66 if (!UIMachineLogic::checkAvailability())67 return false;68 69 51 /* Temporary get a machine object: */ 70 52 const CMachine &machine = uisession()->session().GetMachine(); 71 53 54 /* Check that there are enough physical screens are connected: */ 72 55 int cHostScreens = m_pScreenLayout->hostScreenCount(); 73 56 int cGuestScreens = m_pScreenLayout->guestScreenCount(); 74 /* Check that there are enough physical screens are connected: */75 57 if (cHostScreens < cGuestScreens) 76 58 { … … 79 61 } 80 62 81 // TODO_NEW_CORE: this is how it looked in the old version 82 // bool VBoxConsoleView::isAutoresizeGuestActive() { return mGuestSupportsGraphics && mAutoresizeGuest; } 83 // if (uisession()->session().GetConsole().isAutoresizeGuestActive()) 63 /* Check if there is enough physical memory to enter seamless: */ 84 64 if (uisession()->isGuestAdditionsActive()) 85 65 { 86 quint64 availBits = machine.GetVRAMSize() /* VRAM */ 87 * _1M /* MiB to bytes */ 88 * 8; /* to bits */ 66 quint64 availBits = machine.GetVRAMSize() /* VRAM */ * _1M /* MiB to bytes */ * 8 /* to bits */; 89 67 quint64 usedBits = m_pScreenLayout->memoryRequirements(); 90 68 if (availBits < usedBits) 91 69 { 92 70 msgCenter().cannotEnterSeamlessMode(0, 0, 0, 93 71 (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M); 94 72 return false; 95 73 } 96 74 } 97 75 98 /* Take the toggle hot key from the menu item. Since99 * VBoxGlobal::extractKeyFromActionText gets exactly the100 * linked key without the 'Host+' part we are adding it here. */76 /* Take the toggle hot key from the menu item. 77 * Since VBoxGlobal::extractKeyFromActionText gets exactly 78 * the linked key without the 'Host+' part we are adding it here. */ 101 79 QString hotKey = QString("Host+%1") 102 80 .arg(VBoxGlobal::extractKeyFromActionText(gActionPool->action(UIActionIndexRuntime_Toggle_Seamless)->text())); … … 110 88 } 111 89 112 void UIMachineLogicSeamless::initialize()113 {114 /* Prepare required features: */115 prepareRequiredFeatures();116 117 /* Prepare console connections: */118 prepareSessionConnections();119 120 /* Prepare action groups:121 * Note: This has to be done before prepareActionConnections122 * cause here actions/menus are recreated. */123 prepareActionGroups();124 125 /* Prepare action connections: */126 prepareActionConnections();127 128 /* Prepare handlers: */129 prepareHandlers();130 131 /* Prepare normal machine window: */132 prepareMachineWindows();133 134 #ifdef Q_WS_MAC135 /* Prepare dock: */136 prepareDock();137 #endif /* Q_WS_MAC */138 139 /* Power up machine: */140 uisession()->powerUp();141 142 /* Initialization: */143 sltMachineStateChanged();144 sltAdditionsStateChanged();145 sltMouseCapabilityChanged();146 147 #ifdef VBOX_WITH_DEBUGGER_GUI148 prepareDebugger();149 #endif /* VBOX_WITH_DEBUGGER_GUI */150 151 /* Retranslate logic part: */152 retranslateUi();153 }154 155 90 int UIMachineLogicSeamless::hostScreenForGuestScreen(int screenId) const 156 91 { … … 160 95 void UIMachineLogicSeamless::prepareActionGroups() 161 96 { 162 /* Base class action groups: */97 /* Call to base-class: */ 163 98 UIMachineLogic::prepareActionGroups(); 164 99 … … 219 154 void UIMachineLogicSeamless::cleanupActionGroups() 220 155 { 156 /* Call to base-class: */ 157 UIMachineLogic::cleanupActionGroups(); 158 221 159 /* Reenable guest-autoresize action: */ 222 160 gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->setVisible(true); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.h
r38348 r41064 6 6 7 7 /* 8 * Copyright (C) 2010 Oracle Corporation8 * Copyright (C) 2010-2012 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIMachineLogicSeamless_h__ 21 21 22 /* Local includes */22 /* Local includes: */ 23 23 #include "UIMachineLogic.h" 24 24 25 /* Local forwards*/25 /* Forward declarations: */ 26 26 class UIMultiScreenLayout; 27 27 28 /* Seamless machine logic implementation: */ 28 29 class UIMachineLogicSeamless : public UIMachineLogic 29 30 { … … 32 33 protected: 33 34 34 /* Seamless machine logic constructor/destructor: */ 35 UIMachineLogicSeamless(QObject *pParent, 36 UISession *pSession); 35 /* Constructor/destructor: */ 36 UIMachineLogicSeamless(QObject *pParent, UISession *pSession); 37 37 virtual ~UIMachineLogicSeamless(); 38 38 39 /* Check if this logic is available: */ 39 40 bool checkAvailability(); 40 void initialize();41 41 42 42 int hostScreenForGuestScreen(int screenId) const;
Note:
See TracChangeset
for help on using the changeset viewer.