Changeset 52989 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 8, 2014 11:29:07 AM (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
r52987 r52989 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* Localincludes: */22 /* GUI includes: */ 23 23 # include "VBoxGlobal.h" 24 24 # include "UIExtraDataManager.h" … … 142 142 } 143 143 144 UIMachineLogic* UIMachine::machineLogic() const 145 { 146 if (m_pVisualState && m_pVisualState->machineLogic()) 147 return m_pVisualState->machineLogic(); 148 return 0; 149 } 150 151 QWidget* UIMachine::activeWindow() const 152 { 153 if (machineLogic() && machineLogic()->activeMachineWindow()) 154 return machineLogic()->activeMachineWindow(); 155 return 0; 156 } 157 158 void UIMachine::asyncChangeVisualState(UIVisualStateType visualStateType) 159 { 160 emit sigRequestAsyncVisualStateChange(visualStateType); 161 } 162 163 void UIMachine::sltChangeVisualState(UIVisualStateType newVisualStateType) 164 { 165 /* Create new state: */ 166 UIVisualState *pNewVisualState = new UIVisualState(this, m_pSession, newVisualStateType); 167 168 /* First we have to check if the selected mode is available at all. 169 * Only then we delete the old mode and switch to the new mode. */ 170 if (pNewVisualState->prepareChange()) 171 { 172 /* Delete previous state: */ 173 delete m_pVisualState; 174 175 /* Set the new mode as current mode: */ 176 m_pVisualState = pNewVisualState; 177 m_pVisualState->change(); 178 } 179 else 180 { 181 /* Discard the temporary created new state: */ 182 delete pNewVisualState; 183 184 /* If there is no state currently created => we have to exit: */ 185 if (!m_pVisualState) 186 deleteLater(); 187 } 188 } 189 144 190 UIMachine::UIMachine() 145 191 : QObject(0) 146 , initialStateType(UIVisualStateType_Normal)147 192 , m_pSession(0) 193 , m_allowedVisualStates(UIVisualStateType_Invalid) 194 , m_initialStateType(UIVisualStateType_Normal) 148 195 , m_pVisualState(0) 149 , m_allowedVisualStates(UIVisualStateType_Invalid)150 196 { 151 197 /* Make sure VBoxGlobal is aware of VM creation: */ 152 198 vboxGlobal().setVirtualMachine(this); 199 } 200 201 UIMachine::~UIMachine() 202 { 203 /* Make sure VBoxGlobal is aware of VM destruction: */ 204 vboxGlobal().setVirtualMachine(0); 205 206 /* Cleanup machine UI: */ 207 cleanup(); 153 208 } 154 209 … … 192 247 vboxGlobal().startMediumEnumeration(false /* force start */); 193 248 194 /* Load machinesettings: */195 load MachineSettings();249 /* Load settings: */ 250 loadSettings(); 196 251 197 252 /* Prepare async visual-state change handler: */ … … 217 272 } 218 273 219 UIMachine::~UIMachine() 220 { 221 /* Save machine settings: */ 222 saveMachineSettings(); 223 224 /* Delete visual state: */ 225 delete m_pVisualState; 226 m_pVisualState = 0; 227 228 /* Delete UI session: */ 229 delete m_pSession; 230 m_pSession = 0; 231 232 /* Free session finally: */ 233 m_session.UnlockMachine(); 234 m_session.detach(); 235 236 /* Make sure VBoxGlobal is aware of VM destruction: */ 237 vboxGlobal().setVirtualMachine(0); 238 239 /* Quit application: */ 240 QApplication::quit(); 241 } 242 243 QWidget* UIMachine::activeWindow() const 244 { 245 if (machineLogic() && machineLogic()->activeMachineWindow()) 246 return machineLogic()->activeMachineWindow(); 247 return 0; 248 } 249 250 void UIMachine::asyncChangeVisualState(UIVisualStateType visualStateType) 251 { 252 emit sigRequestAsyncVisualStateChange(visualStateType); 253 } 254 255 void UIMachine::sltChangeVisualState(UIVisualStateType newVisualStateType) 256 { 257 /* Create new state: */ 258 UIVisualState *pNewVisualState = new UIVisualState(this, m_pSession, newVisualStateType); 259 260 /* First we have to check if the selected mode is available at all. 261 * Only then we delete the old mode and switch to the new mode. */ 262 if (pNewVisualState->prepareChange()) 263 { 264 /* Delete previous state: */ 265 delete m_pVisualState; 266 267 /* Set the new mode as current mode: */ 268 m_pVisualState = pNewVisualState; 269 m_pVisualState->change(); 270 } 271 else 272 { 273 /* Discard the temporary created new state: */ 274 delete pNewVisualState; 275 276 /* If there is no state currently created => we have to exit: */ 277 if (!m_pVisualState) 278 deleteLater(); 279 } 280 } 281 282 void UIMachine::enterInitialVisualState() 283 { 284 sltChangeVisualState(initialStateType); 285 } 286 287 UIMachineLogic* UIMachine::machineLogic() const 288 { 289 if (m_pVisualState && m_pVisualState->machineLogic()) 290 return m_pVisualState->machineLogic(); 291 return 0; 292 } 293 294 void UIMachine::loadMachineSettings() 274 void UIMachine::loadSettings() 295 275 { 296 276 /* Load 'visual state' option: */ … … 309 289 { 310 290 /* Direct transition to scale/fullscreen mode allowed: */ 311 case UIVisualStateType_Scale: initialStateType = UIVisualStateType_Scale; break;312 case UIVisualStateType_Fullscreen: initialStateType = UIVisualStateType_Fullscreen; break;291 case UIVisualStateType_Scale: m_initialStateType = UIVisualStateType_Scale; break; 292 case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break; 313 293 /* While to seamless is not, so we have to request transition on GA capability-change event: */ 314 294 case UIVisualStateType_Seamless: uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break; … … 319 299 } 320 300 321 void UIMachine::save MachineSettings()301 void UIMachine::saveSettings() 322 302 { 323 303 /* Save 'visual state' option: */ … … 338 318 } 339 319 320 void UIMachine::cleanup() 321 { 322 /* Save settings: */ 323 saveSettings(); 324 325 /* Delete visual state: */ 326 delete m_pVisualState; 327 m_pVisualState = 0; 328 329 /* Delete UI session: */ 330 delete m_pSession; 331 m_pSession = 0; 332 333 /* Free session finally: */ 334 m_session.UnlockMachine(); 335 m_session.detach(); 336 337 /* Make sure VBoxGlobal is aware of VM destruction: */ 338 vboxGlobal().setVirtualMachine(0); 339 340 /* Quit application: */ 341 QApplication::quit(); 342 } 343 344 void UIMachine::enterInitialVisualState() 345 { 346 sltChangeVisualState(m_initialStateType); 347 } 348 340 349 #include "UIMachine.moc" 341 350 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r52987 r52989 4 4 5 5 /* 6 * Copyright (C) 2010-201 3Oracle Corporation6 * Copyright (C) 2010-2014 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 52 52 static bool startMachine(const QString &strID); 53 53 54 /** Constructor. */ 55 UIMachine(); 56 /** Destructor. */ 57 ~UIMachine(); 58 54 /** Returns UI session instance. */ 55 UISession *uisession() const { return m_pSession; } 56 /** Returns machine-logic reference (if possible). */ 57 UIMachineLogic* machineLogic() const; 59 58 /** Returns active machine-window reference (if possible). */ 60 59 QWidget* activeWindow() const; 61 /** Returns UI session instance. */62 UISession *uisession() const { return m_pSession; }63 60 64 61 /** Returns whether requested visual @a state allowed. */ … … 75 72 private: 76 73 74 /** Constructor. */ 75 UIMachine(); 76 /** Destructor. */ 77 ~UIMachine(); 78 77 79 /** Prepare routine. */ 78 80 bool prepare(); 81 /** Prepare routine: Loading stuff. */ 82 void loadSettings(); 83 /** Prepare routine: Saving stuff. */ 84 void saveSettings(); 85 /** Cleanup routine. */ 86 void cleanup(); 79 87 80 88 /** Moves VM to default (normal) state. */ 81 89 void enterInitialVisualState(); 82 90 83 /** Returns machine-logic reference (if possible). */84 UIMachineLogic* machineLogic() const;91 /** Holds the session instance. */ 92 CSession m_session; 85 93 86 /** Prepare routine: Loading stuff. */87 void loadMachineSettings();94 /** Holds the session UI instance. */ 95 UISession *m_pSession; 88 96 89 /** Prepare routine: Saving stuff. */ 90 void saveMachineSettings(); 97 /** Holds allowed visual state types. */ 98 UIVisualStateType m_allowedVisualStates; 99 /** Holds initial visual state type. */ 100 UIVisualStateType m_initialStateType; 101 /** Holds current visual state. */ 102 UIVisualState *m_pVisualState; 91 103 92 /* Private variables: */ 93 UIVisualStateType initialStateType; 94 CSession m_session; 95 UISession *m_pSession; 96 UIVisualState *m_pVisualState; 97 UIVisualStateType m_allowedVisualStates; 98 99 /* Friend classes: */ 100 friend class UISession; 104 /* Temporary access: */ 105 friend class VBoxGlobal; 101 106 }; 102 107
Note:
See TracChangeset
for help on using the changeset viewer.