Changeset 26950 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Mar 2, 2010 3:08:43 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r26873 r26950 1015 1015 } 1016 1016 1017 int VBoxProblemReporter::cannotEnterFullscreenMode() 1018 { 1019 return message(mainMachineWindowShown(), Error, 1020 tr ("<p>Can not switch the guest display to fullscreen mode. You " 1021 "have more virtual screens configured than physical screens are " 1022 "attached to your host.</p><p>Please either lower the virtual " 1023 "screens in your VM configuration or attach additional screens " 1024 "to your host.</p>"), 1025 0, /* aAutoConfirmId */ 1026 QIMessageBox::Ok | QIMessageBox::Default); 1027 } 1028 1017 1029 bool VBoxProblemReporter::confirmMachineDeletion (const CMachine &machine) 1018 1030 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r26868 r26950 227 227 ULONG aBpp, ULONG64 aMinVRAM); 228 228 229 int cannotEnterFullscreenMode(); 230 229 231 bool confirmMachineDeletion (const CMachine &machine); 230 232 bool confirmDiscardSavedState (const CMachine &machine); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r26921 r26950 37 37 38 38 /* Visual state holder constructor: */ 39 UIVisualState(QObject *pParent) : QObject(pParent), m_pMachineLogic(0) 39 UIVisualState(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool) 40 : QObject(pParent) 41 , m_pSession(pSession) 42 , m_pActionsPool(pActionsPool) 43 , m_pMachineLogic(0) 40 44 { 41 45 /* Connect state-change handler: */ … … 45 49 /* Public getters: */ 46 50 UIMachineLogic* machineLogic() const { return m_pMachineLogic; } 47 51 virtual UIVisualStateType visualStateType() const = 0; 52 53 virtual bool prepareChange() 54 { 55 m_pMachineLogic = UIMachineLogic::create(this, m_pSession, m_pActionsPool, visualStateType()); 56 return m_pMachineLogic->checkAvailability(); 57 } 58 59 virtual void change() = 0; 60 virtual void finishChange() {} 48 61 signals: 49 62 … … 54 67 55 68 /* Protected members: */ 69 UISession *m_pSession; 70 UIActionsPool *m_pActionsPool; 56 71 UIMachineLogic *m_pMachineLogic; 57 72 }; … … 65 80 /* Normal visual state holder constructor: */ 66 81 UIVisualStateNormal(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool) 67 : UIVisualState(pParent) 82 : UIVisualState(pParent, pSession, pActionsPool) 83 {} 84 85 UIVisualStateType visualStateType() const { return UIVisualStateType_Normal; } 86 87 void change() 68 88 { 69 89 /* Connect action handlers: */ 70 connect( pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)),90 connect(m_pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)), 71 91 this, SLOT(sltGoToFullscreenMode())); 72 connect( pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)),92 connect(m_pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)), 73 93 this, SLOT(sltGoToSeamlessMode())); 74 94 75 /* Create state logic:*/76 m_pMachineLogic = UIMachineLogic::create(this, pSession, pActionsPool, UIVisualStateType_Normal);95 /* Initialize the logic object */ 96 m_pMachineLogic->initialize(); 77 97 } 78 98 … … 100 120 /* Fullscreen visual state holder constructor: */ 101 121 UIVisualStateFullscreen(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool) 102 : UIVisualState(pParent) 122 : UIVisualState(pParent, pSession, pActionsPool) 123 {} 124 125 UIVisualStateType visualStateType() const { return UIVisualStateType_Fullscreen; } 126 127 void change() 103 128 { 104 129 /* Connect action handlers: */ 105 connect( pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)),130 connect(m_pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)), 106 131 this, SLOT(sltGoToNormalMode())); 107 connect( pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)),132 connect(m_pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)), 108 133 this, SLOT(sltGoToSeamlessMode())); 109 134 110 /* Create state logic:*/111 m_pMachineLogic = UIMachineLogic::create(this, pSession, pActionsPool, UIVisualStateType_Fullscreen);135 /* Initialize the logic object */ 136 m_pMachineLogic->initialize(); 112 137 } 113 138 … … 135 160 /* Seamless visual state holder constructor: */ 136 161 UIVisualStateSeamless(QObject *pParent, UISession *pSession, UIActionsPool *pActionsPool) 137 : UIVisualState(pParent) 162 : UIVisualState(pParent, pSession, pActionsPool) 163 {} 164 165 UIVisualStateType visualStateType() const { return UIVisualStateType_Seamless; } 166 167 void change() 138 168 { 139 169 /* Connect action handlers */ 140 connect( pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)),170 connect(m_pActionsPool->action(UIActionIndex_Toggle_Fullscreen), SIGNAL(triggered(bool)), 141 171 this, SLOT(sltGoToFullscreenMode())); 142 connect( pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)),172 connect(m_pActionsPool->action(UIActionIndex_Toggle_Seamless), SIGNAL(triggered(bool)), 143 173 this, SLOT(sltGoToNormalMode())); 144 174 145 /* Create state logic*/146 m_pMachineLogic = UIMachineLogic::create(this, pSession, pActionsPool, UIVisualStateType_Seamless);175 /* Initialize the logic object */ 176 m_pMachineLogic->initialize(); 147 177 } 148 178 … … 225 255 void UIMachine::sltChangeVisualState(UIVisualStateType visualStateType) 226 256 { 227 /* Delete previous state: */ 228 delete m_pVisualState; 229 m_pVisualState = 0; 230 257 UIVisualState *pNewVisualState = 0; 231 258 /* Create new state: */ 232 259 switch (visualStateType) … … 235 262 { 236 263 /* Create normal visual state: */ 237 m_pVisualState = new UIVisualStateNormal(this, m_pSession, m_pActionsPool);264 pNewVisualState = new UIVisualStateNormal(this, m_pSession, m_pActionsPool); 238 265 break; 239 266 } … … 241 268 { 242 269 /* Create fullscreen visual state: */ 243 m_pVisualState = new UIVisualStateFullscreen(this, m_pSession, m_pActionsPool);270 pNewVisualState = new UIVisualStateFullscreen(this, m_pSession, m_pActionsPool); 244 271 break; 245 272 } … … 247 274 { 248 275 /* Create seamless visual state: */ 249 m_pVisualState = new UIVisualStateSeamless(this, m_pSession, m_pActionsPool);276 pNewVisualState = new UIVisualStateSeamless(this, m_pSession, m_pActionsPool); 250 277 break; 251 278 } … … 253 280 break; 254 281 } 282 283 /* First we have to check if the selected mode is available at all. Only 284 * then we delete the old mode and switch to the new mode. */ 285 if (pNewVisualState->prepareChange()) 286 { 287 /* Delete previous state: */ 288 delete m_pVisualState; 289 290 /* Set the new mode as current mode. */ 291 m_pVisualState = pNewVisualState; 292 m_pVisualState->change(); 293 /* Finish any setup. */ 294 m_pVisualState->finishChange(); 295 } 296 else 297 /* Discard the temporary create new state */ 298 delete pNewVisualState; 255 299 } 256 300 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r26938 r26950 58 58 UIVisualStateType visualStateType); 59 59 60 /* Check if this mode is available */ 61 virtual bool checkAvailability() { return true; } 62 63 /* Do the real initialization of the object */ 64 virtual void initialize() {} 65 60 66 /* Main getters/setters: */ 61 67 UISession* uisession() { return m_pSession; } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r26938 r26950 48 48 : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_Fullscreen) 49 49 { 50 /* Prepare console connections: */ 51 prepareConsoleConnections(); 52 53 /* Prepare action groups: */ 54 prepareActionGroups(); 55 56 /* Prepare action connections: */ 57 prepareActionConnections(); 58 50 } 51 52 UIMachineLogicFullscreen::~UIMachineLogicFullscreen() 53 { 54 /* Cleanup machine window: */ 55 cleanupMachineWindow(); 56 } 57 58 bool UIMachineLogicFullscreen::checkAvailability() 59 { 60 int cHostScreens = QApplication::desktop()->screenCount(); 61 int cGuestScreens = uisession()->session().GetMachine().GetMonitorCount(); 62 /* Check that there are enough physical screens are connected */ 63 if (cHostScreens < cGuestScreens) 64 { 65 vboxProblem().cannotEnterFullscreenMode(); 66 setPreventAutoStart(true); 67 return false; 68 } 69 70 return true; 71 } 72 73 void UIMachineLogicFullscreen::initialize() 74 { 59 75 /* Check the status of required features: */ 60 76 prepareRequiredFeatures(); 61 77 62 /* Prepare machine window: */ 63 prepareMachineWindows(); 64 65 /* Initialization: */ 66 sltMachineStateChanged(); 67 sltAdditionsStateChanged(); 68 sltMouseCapabilityChanged(); 69 } 70 71 UIMachineLogicFullscreen::~UIMachineLogicFullscreen() 72 { 73 /* Cleanup machine window: */ 74 cleanupMachineWindow(); 78 /* If required features are ready: */ 79 if (!isPreventAutoStart()) 80 { 81 /* Prepare console connections: */ 82 prepareConsoleConnections(); 83 84 /* Prepare action groups: */ 85 prepareActionGroups(); 86 87 /* Prepare action connections: */ 88 prepareActionConnections(); 89 90 /* Prepare machine window: */ 91 prepareMachineWindows(); 92 93 /* Initialization: */ 94 sltMachineStateChanged(); 95 sltAdditionsStateChanged(); 96 sltMouseCapabilityChanged(); 97 } 75 98 } 76 99 … … 117 140 // TODO_NEW_CORE 118 141 // if (session().GetConsole().isAutoresizeGuestActive()) 119 { 120 // QRect screen = QApplication::desktop()->screenGeometry(this); 121 // ULONG64 availBits = session().GetMachine().GetVRAMSize() /* vram */ 122 // * _1M /* mb to bytes */ 123 // * 8; /* to bits */ 124 // ULONG guestBpp = mConsole->console().GetDisplay().GetBitsPerPixel(); 125 // ULONG64 usedBits = (screen.width() /* display width */ 126 // * screen.height() /* display height */ 127 // * guestBpp 128 // + _1M * 8) /* current cache per screen - may be changed in future */ 129 // * session().GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */ 130 // + 4096 * 8; /* adapter info */ 142 // { 143 // ULONG64 availBits = session().GetMachine().GetVRAMSize() /* VRAM */ 144 // * _1M /* MB to bytes */ 145 // * 8; /* to bits */ 146 // for (ulong uScreenId = 0; uScreenId < uMonitorCount; ++ uScreenId) 147 // { 148 // QRect screen = QApplication::desktop()->screenGeometry(this); 149 // ULONG guestBpp = mConsole->console().GetDisplay().GetBitsPerPixel(); 150 // ULONG64 usedBits = (screen.width() /* display width */ 151 // * screen.height() /* display height */ 152 // * guestBpp 153 // + _1M * 8) /* current cache per screen - may be changed in future */ 154 // * session().GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */ 155 // + 4096 * 8; /* adapter info */ 156 // } 157 // 131 158 // if (availBits < usedBits) 132 159 // { 133 160 // int result = vboxProblem().cannotEnterFullscreenMode( 134 // screen.width(), screen.height(), guestBpp,135 // (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);161 // screen.width(), screen.height(), guestBpp, 162 // (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M); 136 163 // if (result == QIMessageBox::Cancel) 137 164 // sltClose(); 138 165 // } 139 } 166 // } 167 // 168 UIMachineLogic::prepareRequiredFeatures(); 140 169 } 141 170 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
r26937 r26950 42 42 virtual ~UIMachineLogicFullscreen(); 43 43 44 bool checkAvailability(); 45 void initialize(); 46 44 47 private slots: 45 48 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r26938 r26950 41 41 : UIMachineLogic(pParent, pSession, pActionsPool, UIVisualStateType_Normal) 42 42 { 43 } 44 45 UIMachineLogicNormal::~UIMachineLogicNormal() 46 { 47 /* Cleanup normal machine window: */ 48 cleanupMachineWindow(); 49 } 50 51 void UIMachineLogicNormal::initialize() 52 { 43 53 /* Check the status of required features: */ 44 54 prepareRequiredFeatures(); … … 64 74 sltMouseCapabilityChanged(); 65 75 } 66 }67 68 UIMachineLogicNormal::~UIMachineLogicNormal()69 {70 /* Cleanup normal machine window: */71 cleanupMachineWindow();72 76 } 73 77 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h
r26921 r26950 42 42 virtual ~UIMachineLogicNormal(); 43 43 44 void initialize(); 45 44 46 private slots: 45 47
Note:
See TracChangeset
for help on using the changeset viewer.