Changeset 53041 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 13, 2014 1:38:17 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r52820 r53041 490 490 src/runtime/UIActionPoolRuntime.cpp \ 491 491 src/runtime/UIIndicatorsPool.cpp \ 492 src/runtime/UIMachine.cpp \493 492 src/runtime/UIMenuBarEditorWindow.cpp \ 494 493 src/runtime/UIStatusBarEditorWindow.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r53040 r53041 39 39 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 40 40 41 42 /* Visual state interface: */43 class UIVisualState : public QObject44 {45 Q_OBJECT;46 47 public:48 49 /* Constructor: */50 UIVisualState(QObject *pParent, UISession *pSession, UIVisualStateType type)51 : QObject(pParent)52 , m_type(type)53 , m_pSession(pSession)54 , m_pMachineLogic(0)55 {56 }57 58 /* Destructor: */59 ~UIVisualState()60 {61 /* Cleanup/delete machine logic if exists: */62 if (m_pMachineLogic)63 {64 /* Cleanup the logic object: */65 m_pMachineLogic->cleanup();66 /* Destroy the logic object: */67 UIMachineLogic::destroy(m_pMachineLogic);68 }69 }70 71 /* Visual state type getter: */72 UIVisualStateType visualStateType() const { return m_type; }73 74 /* Machine logic getter: */75 UIMachineLogic* machineLogic() const { return m_pMachineLogic; }76 77 /* Method to prepare change one visual state to another: */78 bool prepareChange()79 {80 m_pMachineLogic = UIMachineLogic::create(this, m_pSession, visualStateType());81 return m_pMachineLogic->checkAvailability();82 }83 84 /* Method to change one visual state to another: */85 void change()86 {87 /* Prepare the logic object: */88 m_pMachineLogic->prepare();89 }90 91 protected:92 93 /* Variables: */94 UIVisualStateType m_type;95 UISession *m_pSession;96 UIMachineLogic *m_pMachineLogic;97 };98 99 41 /* static */ 100 42 UIMachine* UIMachine::m_spInstance = 0; … … 188 130 } 189 131 190 UIMachineLogic* UIMachine::machineLogic() const191 {192 if (m_pVisualState && m_pVisualState->machineLogic())193 return m_pVisualState->machineLogic();194 return 0;195 }196 197 132 QWidget* UIMachine::activeWindow() const 198 133 { … … 202 137 } 203 138 204 void UIMachine::asyncChangeVisualState(UIVisualStateType visualStateType) 205 { 206 emit sigRequestAsyncVisualStateChange(visualStateType); 207 } 208 209 void UIMachine::sltChangeVisualState(UIVisualStateType newVisualStateType) 210 { 211 /* Create new state: */ 212 UIVisualState *pNewVisualState = new UIVisualState(this, m_pSession, newVisualStateType); 213 214 /* First we have to check if the selected mode is available at all. 215 * Only then we delete the old mode and switch to the new mode. */ 216 if (pNewVisualState->prepareChange()) 217 { 218 /* Delete previous state: */ 219 delete m_pVisualState; 220 221 /* Set the new mode as current mode: */ 222 m_pVisualState = pNewVisualState; 223 m_pVisualState->change(); 139 void UIMachine::asyncChangeVisualState(UIVisualStateType visualState) 140 { 141 emit sigRequestAsyncVisualStateChange(visualState); 142 } 143 144 void UIMachine::sltChangeVisualState(UIVisualStateType visualState) 145 { 146 /* Create new machine-logic: */ 147 UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, m_pSession, visualState); 148 149 /* First we have to check if the selected machine-logic is available at all. 150 * Only then we delete the old machine-logic and switch to the new one. */ 151 if (pMachineLogic->checkAvailability()) 152 { 153 /* Delete previous machine-logic if exists: */ 154 if (m_pMachineLogic) 155 { 156 m_pMachineLogic->cleanup(); 157 UIMachineLogic::destroy(m_pMachineLogic); 158 } 159 160 /* Set the new machine-logic as current one: */ 161 m_pMachineLogic = pMachineLogic; 162 m_pMachineLogic->prepare(); 163 164 /* Remember new visual state: */ 165 m_visualState = visualState; 224 166 } 225 167 else 226 168 { 227 /* Discard the temporary created new state: */ 228 delete pNewVisualState; 229 230 /* If there is no state currently created => we have to exit: */ 231 if (!m_pVisualState) 232 deleteLater(); 169 /* Delete temporary created machine-logic: */ 170 pMachineLogic->cleanup(); 171 UIMachineLogic::destroy(pMachineLogic); 172 } 173 174 /* Make sure machine-logic exists: */ 175 if (!m_pMachineLogic) 176 { 177 /* Reset initial visual state to normal: */ 178 m_initialVisualState = UIVisualStateType_Normal; 179 /* Enter initial visual state again: */ 180 enterInitialVisualState(); 233 181 } 234 182 } … … 238 186 , m_pSession(0) 239 187 , m_allowedVisualStates(UIVisualStateType_Invalid) 240 , m_initialStateType(UIVisualStateType_Normal) 241 , m_pVisualState(0) 188 , m_initialVisualState(UIVisualStateType_Normal) 189 , m_visualState(UIVisualStateType_Invalid) 190 , m_pMachineLogic(0) 242 191 { 243 192 m_spInstance = this; … … 261 210 vboxGlobal().startMediumEnumeration(false /* force start */); 262 211 263 /* Prepare visual state: */264 prepare VisualState();212 /* Prepare machine-logic: */ 213 prepareMachineLogic(); 265 214 266 215 /* Now power up the machine. … … 287 236 } 288 237 289 void UIMachine::prepare VisualState()238 void UIMachine::prepareMachineLogic() 290 239 { 291 240 /* Prepare async visual state type change handler: */ … … 308 257 { 309 258 /* Direct transition to scale/fullscreen mode allowed: */ 310 case UIVisualStateType_Scale: m_initial StateType = UIVisualStateType_Scale; break;311 case UIVisualStateType_Fullscreen: m_initial StateType = UIVisualStateType_Fullscreen; break;259 case UIVisualStateType_Scale: m_initialVisualState = UIVisualStateType_Scale; break; 260 case UIVisualStateType_Fullscreen: m_initialVisualState = UIVisualStateType_Fullscreen; break; 312 261 /* While to seamless is not, so we have to make request to do transition later: */ 313 262 case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break; … … 320 269 } 321 270 322 void UIMachine::cleanup VisualState()271 void UIMachine::cleanupMachineLogic() 323 272 { 324 273 /* Session UI can have requested visual state: */ … … 327 276 /* Get requested visual state: */ 328 277 UIVisualStateType requestedVisualState = uisession()->requestedVisualState(); 329 /* If requested stateis invalid: */278 /* Or current visual state if requested is invalid: */ 330 279 if (requestedVisualState == UIVisualStateType_Invalid) 331 { 332 /* Get current if still exists or normal otherwise: */ 333 requestedVisualState = m_pVisualState ? m_pVisualState->visualStateType() : UIVisualStateType_Normal; 334 } 280 requestedVisualState = m_visualState; 335 281 336 282 /* Save requested visual state: */ … … 338 284 } 339 285 340 /* Delete visual state: */ 341 delete m_pVisualState; 342 m_pVisualState = 0; 286 /* Destroy machine-logic if exists: */ 287 if (machineLogic()) 288 { 289 m_pMachineLogic->cleanup(); 290 UIMachineLogic::destroy(m_pMachineLogic); 291 } 343 292 } 344 293 345 294 void UIMachine::cleanupSession() 346 295 { 347 /* Destroy session UI if necessary: */296 /* Destroy session UI if exists: */ 348 297 if (uisession()) 349 298 UISession::destroy(m_pSession); … … 352 301 void UIMachine::cleanup() 353 302 { 354 /* Cleanup visual state: */355 cleanup VisualState();303 /* Cleanup machine-logic: */ 304 cleanupMachineLogic(); 356 305 357 306 /* Cleanup session UI: */ … … 364 313 void UIMachine::enterInitialVisualState() 365 314 { 366 sltChangeVisualState(m_initial StateType);315 sltChangeVisualState(m_initialVisualState); 367 316 } 368 317 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r53040 r53041 31 31 class QWidget; 32 32 class UISession; 33 class UIVisualState;34 33 class UIMachineLogic; 35 34 … … 57 56 static UIMachine* instance() { return m_spInstance; } 58 57 59 /** Returns UI sessioninstance. */58 /** Returns session UI instance. */ 60 59 UISession *uisession() const { return m_pSession; } 61 /** Returns machine-logic reference (if possible). */62 UIMachineLogic* machineLogic() const ;60 /** Returns machine-logic instance. */ 61 UIMachineLogic* machineLogic() const { return m_pMachineLogic; } 63 62 /** Returns active machine-window reference (if possible). */ 64 63 QWidget* activeWindow() const; … … 86 85 /** Prepare routine: Session stuff. */ 87 86 bool prepareSession(); 88 /** Prepare routine: Visual statestuff. */89 void prepare VisualState();87 /** Prepare routine: Machine-logic stuff. */ 88 void prepareMachineLogic(); 90 89 91 /** Cleanup routine: Visual statestuff. */92 void cleanup VisualState();90 /** Cleanup routine: Machine-logic stuff. */ 91 void cleanupMachineLogic(); 93 92 /** Cleanup routine: Session stuff. */ 94 93 void cleanupSession(); … … 96 95 void cleanup(); 97 96 98 /** Moves VM to default (normal)state. */97 /** Moves VM to initial state. */ 99 98 void enterInitialVisualState(); 100 99 … … 105 104 UISession *m_pSession; 106 105 107 /** Holds allowed visual state types. */106 /** Holds allowed visual states. */ 108 107 UIVisualStateType m_allowedVisualStates; 109 /** Holds initial visual state type. */110 UIVisualStateType m_initial StateType;108 /** Holds initial visual state. */ 109 UIVisualStateType m_initialVisualState; 111 110 /** Holds current visual state. */ 112 UIVisualState *m_pVisualState; 111 UIVisualStateType m_visualState; 112 /** Holds current machine-logic. */ 113 UIMachineLogic *m_pMachineLogic; 113 114 }; 114 115
Note:
See TracChangeset
for help on using the changeset viewer.