Changeset 44833 in vbox
- Timestamp:
- Feb 26, 2013 4:41:59 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp
r44832 r44833 21 21 #include <QApplication> 22 22 #include <QDesktopWidget> 23 #include <QMap>24 23 #include <QMenu> 25 24 … … 41 40 UIMultiScreenLayout::UIMultiScreenLayout(UIMachineLogic *pMachineLogic) 42 41 : m_pMachineLogic(pMachineLogic) 43 , m_pScreenMap(new QMap<int, int>())44 42 , m_pViewMenu(0) 45 43 { … … 51 49 UIMultiScreenLayout::~UIMultiScreenLayout() 52 50 { 53 /* Cleanup screen-map: */54 delete m_pScreenMap;55 51 /* Cleanup view-menu: */ 56 52 cleanupViewMenu(); … … 85 81 if (!( fOk /* Valid data */ 86 82 && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */ 87 && m_ pScreenMap->key(cScreen, -1) == -1)) /* Not taken already? */83 && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */ 88 84 { 89 85 /* If not, check the position of the guest window in normal mode. … … 105 101 && fOk2 /* Valid data */ 106 102 && cScreen >= 0 && cScreen < m_cHostScreens /* In the host screen bounds? */ 107 && m_ pScreenMap->key(cScreen, -1) == -1)) /* Not taken already? */103 && m_screenMap.key(cScreen, -1) == -1)) /* Not taken already? */ 108 104 /* If not, simply pick the next one of the still available 109 105 * host screens. */ … … 115 111 cScreen = availableScreens.first(); 116 112 } 117 m_ pScreenMap->insert(i, cScreen);113 m_screenMap.insert(i, cScreen); 118 114 /* Remove the just selected screen from the list of available screens. */ 119 115 availableScreens.removeOne(cScreen); … … 136 132 int UIMultiScreenLayout::hostScreenForGuestScreen(int iScreenId) const 137 133 { 138 return m_ pScreenMap->value(iScreenId, 0);134 return m_screenMap.value(iScreenId, 0); 139 135 } 140 136 141 137 quint64 UIMultiScreenLayout::memoryRequirements() const 142 138 { 143 return memoryRequirements(m_ pScreenMap);139 return memoryRequirements(m_screenMap); 144 140 } 145 141 … … 153 149 * is present. */ 154 150 QDesktopWidget *pDW = QApplication::desktop(); 155 for (int i = 0; i < m_ pScreenMap->size(); ++i)156 { 157 int hostScreen = m_ pScreenMap->value(i);151 for (int i = 0; i < m_screenMap.size(); ++i) 152 { 153 int hostScreen = m_screenMap.value(i); 158 154 if (pDW->availableGeometry(hostScreen) != pDW->screenGeometry(hostScreen)) 159 155 return true; … … 169 165 170 166 CMachine machine = m_pMachineLogic->session().GetMachine(); 171 QMap<int,int> *pTmpMap = new QMap<int,int>(*m_pScreenMap);167 QMap<int,int> tmpMap(m_screenMap); 172 168 /* Search for the virtual screen which is currently displayed on the 173 169 * requested host screen. When there is one found, we swap both. */ 174 int r = pTmpMap->key(cHostScreen, -1);170 int r = tmpMap.key(cHostScreen, -1); 175 171 if (r != -1) 176 pTmpMap->insert(r, pTmpMap->value(cGuestScreen));172 tmpMap.insert(r, tmpMap.value(cGuestScreen)); 177 173 /* Set the new host screen */ 178 pTmpMap->insert(cGuestScreen, cHostScreen);174 tmpMap.insert(cGuestScreen, cHostScreen); 179 175 180 176 bool fSuccess = true; … … 184 180 * _1M /* MiB to bytes */ 185 181 * 8; /* to bits */ 186 quint64 usedBits = memoryRequirements( pTmpMap);182 quint64 usedBits = memoryRequirements(tmpMap); 187 183 188 184 fSuccess = availBits >= usedBits; … … 200 196 { 201 197 /* Swap the temporary with the previous map. */ 202 delete m_pScreenMap; 203 m_pScreenMap = pTmpMap; 198 m_screenMap = tmpMap; 204 199 } 205 200 … … 281 276 for (int i = 0; i < viewActions.size(); ++i) 282 277 { 283 int iHostScreen = m_ pScreenMap->value(i);278 int iHostScreen = m_screenMap.value(i); 284 279 if (fWithSave) 285 280 machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(i), QString::number(iHostScreen)); … … 296 291 } 297 292 298 quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> *pScreenLayout) const293 quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> &screenLayout) const 299 294 { 300 295 ULONG width = 0; … … 307 302 QRect screen; 308 303 if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless) 309 screen = QApplication::desktop()->availableGeometry( pScreenLayout->value(i, 0));304 screen = QApplication::desktop()->availableGeometry(screenLayout.value(i, 0)); 310 305 else 311 screen = QApplication::desktop()->screenGeometry( pScreenLayout->value(i, 0));306 screen = QApplication::desktop()->screenGeometry(screenLayout.value(i, 0)); 312 307 display.GetScreenResolution(i, width, height, guestBpp); 313 308 usedBits += screen.width() * /* display width */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h
r44832 r44833 22 22 /* Qt includes: */ 23 23 #include <QObject> 24 #include <QMap> 24 25 25 26 /* Forward declarations: */ … … 27 28 class QMenu; 28 29 class QAction; 29 template <class Key, class T> class QMap;30 30 31 31 /* Multi-screen layout manager: */ … … 75 75 /* Other helpers: */ 76 76 void updateMenuActions(bool fWithSave); 77 quint64 memoryRequirements(const QMap<int, int> *pScreenLayout) const;77 quint64 memoryRequirements(const QMap<int, int> &screenLayout) const; 78 78 79 79 /* Variables: */ … … 81 81 int m_cGuestScreens; 82 82 int m_cHostScreens; 83 QMap<int, int> *m_pScreenMap;83 QMap<int, int> m_screenMap; 84 84 QMenu *m_pViewMenu; 85 85 QList<QMenu*> m_screenMenuList;
Note:
See TracChangeset
for help on using the changeset viewer.