- Timestamp:
- Oct 13, 2014 1:08:07 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r53000 r53040 251 251 bool UIMachine::prepare() 252 252 { 253 /* Try to prepare session UI: */ 254 if (!prepareSession()) 255 return false; 256 257 /* Prevent application from closing when all window(s) closed: */ 258 qApp->setQuitOnLastWindowClosed(false); 259 260 /* Cache medium data if necessary: */ 261 vboxGlobal().startMediumEnumeration(false /* force start */); 262 263 /* Prepare visual state: */ 264 prepareVisualState(); 265 266 /* Now power up the machine. 267 * Actually powerUp does more that just a power up, 268 * so call it regardless of isSeparateProcess setting. */ 269 uisession()->powerUp(); 270 271 /* Initialization of MachineLogic internals after the powerUp. 272 * This is a hack, maybe more generic approach can be used. */ 273 machineLogic()->initializePostPowerUp(); 274 275 /* True by default: */ 276 return true; 277 } 278 279 bool UIMachine::prepareSession() 280 { 253 281 /* Try to create session UI: */ 254 282 if (!UISession::create(m_pSession, this)) 255 283 return false; 256 284 257 /* Preventing application from closing in case of window(s) closed: */ 258 qApp->setQuitOnLastWindowClosed(false); 259 260 /* Cache medium data only if really necessary: */ 261 vboxGlobal().startMediumEnumeration(false /* force start */); 262 263 /* Load settings: */ 264 loadSettings(); 265 266 /* Prepare async visual-state change handler: */ 285 /* True by default: */ 286 return true; 287 } 288 289 void UIMachine::prepareVisualState() 290 { 291 /* Prepare async visual state type change handler: */ 267 292 qRegisterMetaType<UIVisualStateType>(); 268 293 connect(this, SIGNAL(sigRequestAsyncVisualStateChange(UIVisualStateType)), … … 270 295 Qt::QueuedConnection); 271 296 272 /* Enter default (normal) state */ 297 /* Load restricted visual states: */ 298 UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid()); 299 /* Acquire allowed visual states: */ 300 m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates); 301 302 /* Load requested visual state: */ 303 UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid()); 304 /* Check if requested visual state is allowed: */ 305 if (isVisualStateAllowed(requestedVisualState)) 306 { 307 switch (requestedVisualState) 308 { 309 /* Direct transition to scale/fullscreen mode allowed: */ 310 case UIVisualStateType_Scale: m_initialStateType = UIVisualStateType_Scale; break; 311 case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break; 312 /* While to seamless is not, so we have to make request to do transition later: */ 313 case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break; 314 default: break; 315 } 316 } 317 318 /* Enter initial visual state: */ 273 319 enterInitialVisualState(); 274 275 /* Now power up the machine. 276 * Actually powerUp does more that just a power up, 277 * so call it regardless of isSeparateProcess setting. */ 278 uisession()->powerUp(); 279 280 /* Initialization of MachineLogic internals after the powerUp. 281 * This is a hack, maybe more generic approach can be used. */ 282 machineLogic()->initializePostPowerUp(); 283 284 /* True by default: */ 285 return true; 286 } 287 288 void UIMachine::loadSettings() 289 { 290 /* Load 'visual state' option: */ 291 if (uisession()) 292 { 293 /* Load restricted visual states: */ 294 UIVisualStateType restrictedVisualStates = gEDataManager->restrictedVisualStates(vboxGlobal().managedVMUuid()); 295 /* Acquire allowed visual states: */ 296 m_allowedVisualStates = static_cast<UIVisualStateType>(UIVisualStateType_All ^ restrictedVisualStates); 297 298 /* Load requested visual state: */ 299 UIVisualStateType requestedVisualState = gEDataManager->requestedVisualState(vboxGlobal().managedVMUuid()); 300 /* Check if requested visual state type allowed: */ 301 if (isVisualStateAllowed(requestedVisualState)) 302 { 303 switch (requestedVisualState) 304 { 305 /* Direct transition to scale/fullscreen mode allowed: */ 306 case UIVisualStateType_Scale: m_initialStateType = UIVisualStateType_Scale; break; 307 case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break; 308 /* While to seamless is not, so we have to request transition on GA capability-change event: */ 309 case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break; 310 default: break; 311 } 312 } 313 } 314 } 315 316 void UIMachine::saveSettings() 317 { 318 /* Save 'visual state' option: */ 320 } 321 322 void UIMachine::cleanupVisualState() 323 { 324 /* Session UI can have requested visual state: */ 319 325 if (uisession()) 320 326 { 321 327 /* Get requested visual state: */ 322 328 UIVisualStateType requestedVisualState = uisession()->requestedVisualState(); 323 324 329 /* If requested state is invalid: */ 325 330 if (requestedVisualState == UIVisualStateType_Invalid) … … 332 337 gEDataManager->setRequestedVisualState(requestedVisualState, vboxGlobal().managedVMUuid()); 333 338 } 334 }335 336 void UIMachine::cleanup()337 {338 /* Save settings: */339 saveSettings();340 339 341 340 /* Delete visual state: */ 342 341 delete m_pVisualState; 343 342 m_pVisualState = 0; 344 343 } 344 345 void UIMachine::cleanupSession() 346 { 345 347 /* Destroy session UI if necessary: */ 346 348 if (uisession()) 347 349 UISession::destroy(m_pSession); 350 } 351 352 void UIMachine::cleanup() 353 { 354 /* Cleanup visual state: */ 355 cleanupVisualState(); 356 357 /* Cleanup session UI: */ 358 cleanupSession(); 348 359 349 360 /* Quit application: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r53000 r53040 84 84 /** Prepare routine. */ 85 85 bool prepare(); 86 /** Prepare routine: Loading stuff. */ 87 void loadSettings(); 88 /** Cleanup routine: Saving stuff. */ 89 void saveSettings(); 86 /** Prepare routine: Session stuff. */ 87 bool prepareSession(); 88 /** Prepare routine: Visual state stuff. */ 89 void prepareVisualState(); 90 91 /** Cleanup routine: Visual state stuff. */ 92 void cleanupVisualState(); 93 /** Cleanup routine: Session stuff. */ 94 void cleanupSession(); 90 95 /** Cleanup routine. */ 91 96 void cleanup();
Note:
See TracChangeset
for help on using the changeset viewer.