- Timestamp:
- Mar 10, 2010 11:38:45 AM (15 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
r27148 r27243 260 260 : QObject(0) 261 261 , m_ppThis(ppSelf) 262 , initialStateType(UIVisualStateType_Normal) 262 263 , m_session(session) 263 264 , m_pActionsPool(new UIActionsPool(this)) … … 278 279 *m_ppThis = this; 279 280 281 /* Load machine settings: */ 282 loadMachineSettings(); 283 280 284 /* Enter default (normal) state */ 281 enter BaseVisualState();285 enterInitialVisualState(); 282 286 } 283 287 284 288 UIMachine::~UIMachine() 285 289 { 290 /* Save machine settings: */ 291 saveMachineSettings(); 286 292 /* Erase itself pointer: */ 287 293 *m_ppThis = 0; … … 308 314 } 309 315 316 void UIMachine::sltChangeVisualState(UIVisualStateType visualStateType) 317 { 318 /* Create new state: */ 319 UIVisualState *pNewVisualState = 0; 320 switch (visualStateType) 321 { 322 case UIVisualStateType_Normal: 323 { 324 /* Create normal visual state: */ 325 pNewVisualState = new UIVisualStateNormal(this, m_pSession, m_pActionsPool); 326 break; 327 } 328 case UIVisualStateType_Fullscreen: 329 { 330 /* Create fullscreen visual state: */ 331 pNewVisualState = new UIVisualStateFullscreen(this, m_pSession, m_pActionsPool); 332 break; 333 } 334 case UIVisualStateType_Seamless: 335 { 336 /* Create seamless visual state: */ 337 pNewVisualState = new UIVisualStateSeamless(this, m_pSession, m_pActionsPool); 338 break; 339 } 340 default: 341 break; 342 } 343 344 UIVisualStateType previousVisualStateType = UIVisualStateType_Normal; 345 if (m_pVisualState) 346 previousVisualStateType = m_pVisualState->visualStateType(); 347 348 /* First we have to check if the selected mode is available at all. 349 * Only then we delete the old mode and switch to the new mode. */ 350 if (pNewVisualState->prepareChange(previousVisualStateType)) 351 { 352 /* Delete previous state: */ 353 delete m_pVisualState; 354 355 /* Set the new mode as current mode: */ 356 m_pVisualState = pNewVisualState; 357 m_pVisualState->change(); 358 359 /* Finish any setup: */ 360 m_pVisualState->finishChange(); 361 } 362 else 363 /* Discard the temporary created new state: */ 364 delete pNewVisualState; 365 } 366 367 void UIMachine::closeVirtualMachine() 368 { 369 delete this; 370 } 371 372 void UIMachine::enterInitialVisualState() 373 { 374 sltChangeVisualState(initialStateType); 375 } 376 310 377 UIMachineLogic* UIMachine::machineLogic() const 311 378 { … … 316 383 } 317 384 318 void UIMachine::sltChangeVisualState(UIVisualStateType visualStateType) 319 { 320 /* Create new state: */ 321 UIVisualState *pNewVisualState = 0; 322 switch (visualStateType) 323 { 324 case UIVisualStateType_Normal: 325 { 326 /* Create normal visual state: */ 327 pNewVisualState = new UIVisualStateNormal(this, m_pSession, m_pActionsPool); 328 break; 329 } 330 case UIVisualStateType_Fullscreen: 331 { 332 /* Create fullscreen visual state: */ 333 pNewVisualState = new UIVisualStateFullscreen(this, m_pSession, m_pActionsPool); 334 break; 335 } 336 case UIVisualStateType_Seamless: 337 { 338 /* Create seamless visual state: */ 339 pNewVisualState = new UIVisualStateSeamless(this, m_pSession, m_pActionsPool); 340 break; 341 } 342 default: 343 break; 344 } 345 346 UIVisualStateType previousVisualStateType = UIVisualStateType_Normal; 347 if (m_pVisualState) 348 previousVisualStateType = m_pVisualState->visualStateType(); 349 350 /* First we have to check if the selected mode is available at all. 351 * Only then we delete the old mode and switch to the new mode. */ 352 if (pNewVisualState->prepareChange(previousVisualStateType)) 353 { 354 /* Delete previous state: */ 355 delete m_pVisualState; 356 357 /* Set the new mode as current mode: */ 358 m_pVisualState = pNewVisualState; 359 m_pVisualState->change(); 360 361 /* Finish any setup: */ 362 m_pVisualState->finishChange(); 363 } 364 else 365 /* Discard the temporary created new state: */ 366 delete pNewVisualState; 367 } 368 369 void UIMachine::closeVirtualMachine() 370 { 371 delete this; 372 } 373 374 void UIMachine::enterBaseVisualState() 375 { 376 sltChangeVisualState(UIVisualStateType_Normal); 385 void UIMachine::loadMachineSettings() 386 { 387 /* Load machine settings: */ 388 CMachine machine = uisession()->session().GetMachine(); 389 390 /* Load extra-data settings: */ 391 { 392 /* Get 'fullscreen' attributes: */ 393 QString strFullscreenSettings = machine.GetExtraData(VBoxDefs::GUI_Fullscreen); 394 if (strFullscreenSettings == "yes") 395 initialStateType = UIVisualStateType_Fullscreen; 396 } 397 } 398 399 void UIMachine::saveMachineSettings() 400 { 401 /* Save machine settings: */ 402 CMachine machine = uisession()->session().GetMachine(); 403 404 /* Save extra-data settings: */ 405 { 406 /* Set 'fullscreen' attributes: */ 407 machine.SetExtraData(VBoxDefs::GUI_Fullscreen, m_pVisualState && 408 m_pVisualState->visualStateType() == UIVisualStateType_Fullscreen ? "yes" : QString()); 409 } 377 410 } 378 411 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r27215 r27243 65 65 66 66 /* Move VM to default (normal) state: */ 67 void enter BaseVisualState();67 void enterInitialVisualState(); 68 68 69 69 /* Private getters: */ … … 71 71 UIActionsPool* actionsPool() const { return m_pActionsPool; } 72 72 73 /* Prepare helpers: */ 74 void loadMachineSettings(); 75 76 /* Cleanup helpers: */ 77 void saveMachineSettings(); 78 73 79 /* Private variables: */ 74 80 UIMachine **m_ppThis; 81 UIVisualStateType initialStateType; 75 82 CSession m_session; 76 83 UIActionsPool *m_pActionsPool;
Note:
See TracChangeset
for help on using the changeset viewer.