Changeset 45939 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 7, 2013 5:16:31 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r45696 r45939 21 21 #include "UIPopupCenter.h" 22 22 #include "UIPopupStack.h" 23 #include "UIMachineWindow.h" 23 24 #include "QIMessageBox.h" 24 25 #include "VBoxGlobal.h" … … 49 50 return; 50 51 52 /* Cleanup instance: */ 53 m_spInstance->cleanup(); 51 54 /* Destroy instance: */ 52 55 delete m_spInstance; … … 63 66 /* Unassign instance: */ 64 67 m_spInstance = 0; 68 } 69 70 void UIPopupCenter::cleanup() 71 { 72 /* Make sure all the popup-stacks destroyed: */ 73 foreach (const QString &strPopupStackID, m_stacks.keys()) 74 { 75 delete m_stacks[strPopupStackID]; 76 m_stacks.remove(strPopupStackID); 77 } 65 78 } 66 79 … … 162 175 163 176 /* Looking for the corresponding popup-stack: */ 164 QString strPopupStackID = pParent->metaObject()->className();177 const QString strPopupStackID(popupStackID(pParent)); 165 178 UIPopupStack *pPopupStack = 0; 166 179 /* Is there already popup-stack with the same ID? */ … … 174 187 { 175 188 /* Create new one: */ 176 pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack (pParent);189 pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack; 177 190 /* Attach popup-stack connections: */ 178 191 connect(pPopupStack, SIGNAL(sigPopupPaneDone(QString, int)), this, SLOT(sltPopupPaneDone(QString, int))); 179 192 connect(pPopupStack, SIGNAL(sigRemove()), this, SLOT(sltRemovePopupStack())); 180 193 /* Show popup-stack: */ 181 pPopupStack->show();194 showPopupStack(pParent); 182 195 } 183 196 … … 202 215 } 203 216 217 void UIPopupCenter::showPopupStack(QWidget *pParent) 218 { 219 /* Make sure passed parent is valid: */ 220 if (!pParent) 221 { 222 AssertMsgFailed(("Passed parent is NULL")); 223 return; 224 } 225 226 /* Do we have a stack for passed parent? */ 227 const QString strPopupStackID(popupStackID(pParent)); 228 if (!m_stacks.contains(strPopupStackID)) 229 return; 230 231 /* Install stack to passed parent: */ 232 UIPopupStack *pPopupStack = m_stacks[strPopupStackID]; 233 pParent->installEventFilter(pPopupStack); 234 pPopupStack->setParent(pParent); 235 pPopupStack->show(); 236 } 237 238 void UIPopupCenter::hidePopupStack(QWidget *pParent) 239 { 240 /* Make sure passed parent is valid: */ 241 if (!pParent) 242 { 243 AssertMsgFailed(("Passed parent is NULL")); 244 return; 245 } 246 247 /* Do we have a stack for passed parent? */ 248 const QString strPopupStackID(popupStackID(pParent)); 249 if (!m_stacks.contains(strPopupStackID)) 250 return; 251 252 /* Uninstall stack from passed parent: */ 253 UIPopupStack *pPopupStack = m_stacks[strPopupStackID]; 254 pPopupStack->hide(); 255 pPopupStack->setParent(0); 256 pParent->removeEventFilter(pPopupStack); 257 } 258 204 259 void UIPopupCenter::sltPopupPaneDone(QString strPopupPaneID, int iResultCode) 205 260 { … … 217 272 } 218 273 274 void UIPopupCenter::sltShowPopupStack() 275 { 276 showPopupStack(vboxGlobal().activeMachineWindow()); 277 } 278 279 void UIPopupCenter::sltHidePopupStack() 280 { 281 hidePopupStack(vboxGlobal().activeMachineWindow()); 282 } 283 219 284 void UIPopupCenter::sltRemovePopupStack() 220 285 { … … 238 303 m_stacks.remove(strPopupStackID); 239 304 delete pPopupStack; 305 } 306 307 /* static */ 308 QString UIPopupCenter::popupStackID(QWidget *pParent) 309 { 310 /* Make sure passed parent is always valid: */ 311 if (!pParent) 312 { 313 AssertMsgFailed(("Passed parent is NULL")); 314 return QString(); 315 } 316 317 /* Special handling for Runtime UI: */ 318 if (qobject_cast<UIMachineWindow*>(pParent)) 319 return QString("UIMachineWindow"); 320 321 /* Common handling for other cases: */ 322 return pParent->metaObject()->className(); 240 323 } 241 324 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h
r45696 r45939 93 93 void sltPopupPaneDone(QString strPopupPaneID, int iResultCode); 94 94 95 /* Handler: Popup-stack stuff: */ 95 /* Handlers: Popup-stack stuff: */ 96 void sltShowPopupStack(); 97 void sltHidePopupStack(); 96 98 void sltRemovePopupStack(); 97 99 … … 102 104 ~UIPopupCenter(); 103 105 106 /* Helper: Cleanup stuff: */ 107 void cleanup(); 108 104 109 /* Helper: Popup-pane stuff: */ 105 110 void showPopupPane(QWidget *pParent, const QString &strPopupPaneID, … … 108 113 const QString &strButtonText1, const QString &strButtonText2, 109 114 bool fProposeAutoConfirmation); 115 116 /* Helpers: Popup-stack stuff: */ 117 void showPopupStack(QWidget *pParent); 118 void hidePopupStack(QWidget *pParent); 119 120 /* Static helper: Popup-stack stuff: */ 121 static QString popupStackID(QWidget *pParent); 110 122 111 123 /* Variable: Popup-stack stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r45736 r45939 47 47 #include "VBoxGlobal.h" 48 48 #include "UIMessageCenter.h" 49 #include "UIPopupCenter.h" 49 50 #include "VBoxTakeSnapshotDlg.h" 50 51 #include "VBoxVMInformationDlg.h" … … 533 534 #endif /* Q_WS_MAC */ 534 535 { 536 /* Register popup-center connections: */ 537 connect(this, SIGNAL(sigMachineWidnowsCreated()), 538 &popupCenter(), SLOT(sltShowPopupStack())); 539 connect(this, SIGNAL(sigMachineWidnowsDestroyed()), 540 &popupCenter(), SLOT(sltHidePopupStack())); 541 } 542 543 UIMachineLogic::~UIMachineLogic() 544 { 545 /* Unregister popup-center connections: */ 546 disconnect(this, SIGNAL(sigMachineWidnowsCreated()), 547 &popupCenter(), SLOT(sltShowPopupStack())); 548 disconnect(this, SIGNAL(sigMachineWidnowsDestroyed()), 549 &popupCenter(), SLOT(sltHidePopupStack())); 550 } 551 552 void UIMachineLogic::setMachineWindowsCreated(bool fIsWindowsCreated) 553 { 554 /* Make sure something changed: */ 555 if (m_fIsWindowsCreated == fIsWindowsCreated) 556 return; 557 558 /* Special handling for 'destroyed' case: */ 559 if (!fIsWindowsCreated) 560 { 561 /* We emit this signal *before* the remembering new value 562 * because we want UIMachineLogic::activeMachineWindow() to be yet alive. */ 563 emit sigMachineWidnowsDestroyed(); 564 } 565 566 /* Remember new value: */ 567 m_fIsWindowsCreated = fIsWindowsCreated; 568 569 /* Special handling for 'created' case: */ 570 if (fIsWindowsCreated) 571 { 572 /* We emit this signal *after* the remembering new value 573 * because we want UIMachineLogic::activeMachineWindow() to be already alive. */ 574 emit sigMachineWidnowsCreated(); 575 } 535 576 } 536 577 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r45736 r45939 53 53 Q_OBJECT; 54 54 55 signals: 56 57 /* Notifiers: Machine-window(s) stuff: */ 58 void sigMachineWidnowsCreated(); 59 void sigMachineWidnowsDestroyed(); 60 55 61 public: 56 62 … … 112 118 protected: 113 119 114 /* Constructor : */120 /* Constructor/destructor: */ 115 121 UIMachineLogic(QObject *pParent, UISession *pSession, UIVisualStateType visualStateType); 122 ~UIMachineLogic(); 116 123 117 124 /* Protected getters/setters: */ 118 125 bool isMachineWindowsCreated() const { return m_fIsWindowsCreated; } 119 void setMachineWindowsCreated(bool fIsWindowsCreated) { m_fIsWindowsCreated = fIsWindowsCreated; }126 void setMachineWindowsCreated(bool fIsWindowsCreated); 120 127 121 128 /* Protected members: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r45333 r45939 141 141 void UIMachineLogicFullscreen::prepareMachineWindows() 142 142 { 143 /* Do not create window(s) if they created already: */143 /* Do not create machine-window(s) if they created already: */ 144 144 if (isMachineWindowsCreated()) 145 145 return; … … 151 151 #endif /* Q_WS_MAC */ 152 152 153 /* Update the multi 153 /* Update the multi-screen layout: */ 154 154 m_pScreenLayout->update(); 155 155 156 /* Create machine 156 /* Create machine-window(s): */ 157 157 for (uint cScreenId = 0; cScreenId < session().GetMachine().GetMonitorCount(); ++cScreenId) 158 158 addMachineWindow(UIMachineWindow::create(this, cScreenId)); 159 159 160 /* Connect screen-layout change handler: */160 /* Connect multi-screen layout change handler: */ 161 161 for (int i = 0; i < machineWindows().size(); ++i) 162 162 connect(m_pScreenLayout, SIGNAL(sigScreenLayoutChanged()), … … 172 172 #endif /* Q_WS_MAC */ 173 173 174 /* Remember what machinewindow(s) created: */174 /* Mark machine-window(s) created: */ 175 175 setMachineWindowsCreated(true); 176 176 } … … 187 187 void UIMachineLogicFullscreen::cleanupMachineWindows() 188 188 { 189 /* Do not cleanup machine window(s) if not present: */189 /* Do not destroy machine-window(s) if they destroyed already: */ 190 190 if (!isMachineWindowsCreated()) 191 191 return; 192 192 193 /* Cleanup machine window(s): */ 193 /* Mark machine-window(s) destroyed: */ 194 setMachineWindowsCreated(false); 195 196 /* Cleanup machine-window(s): */ 194 197 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 195 198 UIMachineWindow::destroy(pMachineWindow); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
r41587 r45939 86 86 void UIMachineLogicNormal::prepareMachineWindows() 87 87 { 88 /* Do not create window(s) if they created already: */88 /* Do not create machine-window(s) if they created already: */ 89 89 if (isMachineWindowsCreated()) 90 90 return; … … 105 105 machineWindows()[uScreenId - 1]->raise(); 106 106 107 /* Remember what machinewindow(s) created: */107 /* Mark machine-window(s) created: */ 108 108 setMachineWindowsCreated(true); 109 109 } … … 111 111 void UIMachineLogicNormal::cleanupMachineWindows() 112 112 { 113 /* Do not cleanup machine window(s) if not present: */113 /* Do not destroy machine-window(s) if they destroyed already: */ 114 114 if (!isMachineWindowsCreated()) 115 115 return; 116 116 117 /* Cleanup machine window(s): */ 117 /* Mark machine-window(s) destroyed: */ 118 setMachineWindowsCreated(false); 119 120 /* Cleanup machine-window(s): */ 118 121 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 119 122 UIMachineWindow::destroy(pMachineWindow); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp
r41587 r45939 66 66 void UIMachineLogicScale::prepareMachineWindows() 67 67 { 68 /* Do not create window(s) if they created already: */68 /* Do not create machine-window(s) if they created already: */ 69 69 if (isMachineWindowsCreated()) 70 70 return; … … 85 85 machineWindows()[uScreenId - 1]->raise(); 86 86 87 /* Remember what machinewindow(s) created: */87 /* Mark machine-window(s) created: */ 88 88 setMachineWindowsCreated(true); 89 89 } … … 91 91 void UIMachineLogicScale::cleanupMachineWindows() 92 92 { 93 /* Do not cleanup machine window(s) if not present: */93 /* Do not destroy machine-window(s) if they destroyed already: */ 94 94 if (!isMachineWindowsCreated()) 95 95 return; 96 96 97 /* Cleanup machine window(s): */ 97 /* Mark machine-window(s) destroyed: */ 98 setMachineWindowsCreated(false); 99 100 /* Cleanup machine-window(s): */ 98 101 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 99 102 UIMachineWindow::destroy(pMachineWindow); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
r45233 r45939 125 125 void UIMachineLogicSeamless::prepareMachineWindows() 126 126 { 127 /* Do not create window(s) if they created already: */127 /* Do not create machine-window(s) if they created already: */ 128 128 if (isMachineWindowsCreated()) 129 129 return; … … 135 135 #endif /* Q_WS_MAC */ 136 136 137 /* Update the multi 137 /* Update the multi-screen layout: */ 138 138 m_pScreenLayout->update(); 139 139 … … 142 142 addMachineWindow(UIMachineWindow::create(this, cScreenId)); 143 143 144 /* Connect screen-layout change handler: */144 /* Connect multi-screen layout change handler: */ 145 145 for (int i = 0; i < machineWindows().size(); ++i) 146 146 connect(m_pScreenLayout, SIGNAL(sigScreenLayoutChanged()), 147 147 static_cast<UIMachineWindowSeamless*>(machineWindows()[i]), SLOT(sltShowInNecessaryMode())); 148 148 149 /* Remember what machinewindow(s) created: */149 /* Mark machine-window(s) created: */ 150 150 setMachineWindowsCreated(true); 151 151 } … … 162 162 void UIMachineLogicSeamless::cleanupMachineWindows() 163 163 { 164 /* Do not cleanup machine window(s) if not present: */164 /* Do not destroy machine-window(s) if they destroyed already: */ 165 165 if (!isMachineWindowsCreated()) 166 166 return; 167 167 168 /* Cleanup machine window(s): */ 168 /* Mark machine-window(s) destroyed: */ 169 setMachineWindowsCreated(false); 170 171 /* Cleanup machine-window(s): */ 169 172 foreach (UIMachineWindow *pMachineWindow, machineWindows()) 170 173 UIMachineWindow::destroy(pMachineWindow); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r45696 r45939 26 26 #include "UIPopupStack.h" 27 27 #include "UIPopupPane.h" 28 #include "UIMachineWindowNormal.h" 28 29 29 30 /* Other VBox includes: */ 30 31 #include <VBox/sup.h> 31 32 32 UIPopupStack::UIPopupStack(QWidget *pParent) 33 : QWidget(pParent) 34 , m_fPolished(false) 35 , m_iLayoutMargin(2), m_iLayoutSpacing(0) 36 , m_iParentStatusBarHeight(parentStatusBarHeight(pParent)) 37 { 38 /* Prepare: */ 39 prepare(); 33 UIPopupStack::UIPopupStack() 34 : m_iLayoutMargin(1), m_iLayoutSpacing(1) 35 { 40 36 } 41 37 … … 69 65 pPopupPane->show(); 70 66 71 /* Propagate desired width: */ 72 setDesiredWidth(parentWidget()->width()); 73 /* Adjust geometry: */ 74 sltAdjustGeometry(); 67 /* Adjust geometry only if parent is currently set: */ 68 if (parent()) 69 { 70 /* Propagate desired width: */ 71 setDesiredWidth(parentWidget()->width()); 72 /* Adjust geometry: */ 73 sltAdjustGeometry(); 74 } 75 75 } 76 76 … … 91 91 pPopupPane->setDetails(strDetails); 92 92 93 /* Propagate desired width: */ 94 setDesiredWidth(parentWidget()->width()); 95 /* Adjust geometry: */ 96 sltAdjustGeometry(); 93 /* Adjust geometry only if parent is currently set: */ 94 if (parent()) 95 { 96 /* Propagate desired width: */ 97 setDesiredWidth(parentWidget()->width()); 98 /* Adjust geometry: */ 99 sltAdjustGeometry(); 100 } 101 } 102 103 void UIPopupStack::setParent(QWidget *pParent) 104 { 105 /* Call to base-class: */ 106 QWidget::setParent(pParent); 107 /* Recalculate parent status-bar height: */ 108 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 97 109 } 98 110 99 111 void UIPopupStack::sltAdjustGeometry() 100 112 { 113 /* Adjust geometry only if parent is currently set: */ 114 if (!parent()) 115 return; 116 101 117 /* Get this attributes: */ 102 118 const int iWidth = parentWidget()->width(); … … 137 153 delete pPopupPane; 138 154 155 /* Layout content: */ 156 layoutContent(); 157 139 158 /* Make sure this stack still contains popup-panes: */ 140 159 if (!m_panes.isEmpty()) … … 143 162 /* Notify listeners about popup-stack: */ 144 163 emit sigRemove(); 145 }146 147 void UIPopupStack::prepare()148 {149 /* Install event-filter to parent: */150 parent()->installEventFilter(this);151 164 } 152 165 … … 226 239 { 227 240 /* Make sure its parent event came: */ 228 if ( pWatched != parent())241 if (!parent() || pWatched != parent()) 229 242 return false; 230 243 … … 242 255 } 243 256 244 void UIPopupStack::showEvent(QShowEvent *pEvent) 245 { 246 /* Make sure we should polish dialog: */ 247 if (m_fPolished) 248 return; 249 250 /* Call to polish-event: */ 251 polishEvent(pEvent); 252 253 /* Mark dialog as polished: */ 254 m_fPolished = true; 255 } 256 257 void UIPopupStack::polishEvent(QShowEvent*) 258 { 259 /* Propagate desired width: */ 260 setDesiredWidth(parentWidget()->width()); 261 /* Adjust geometry: */ 262 sltAdjustGeometry(); 257 void UIPopupStack::showEvent(QShowEvent*) 258 { 259 /* Adjust geometry only if parent is currently set: */ 260 if (parent()) 261 { 262 /* Propagate desired width: */ 263 setDesiredWidth(parentWidget()->width()); 264 /* Adjust geometry: */ 265 sltAdjustGeometry(); 266 } 263 267 } 264 268 … … 266 270 int UIPopupStack::parentStatusBarHeight(QWidget *pParent) 267 271 { 268 /* Check if passed parent is QMainWindow and contains status-bar: */ 269 if (QMainWindow *pParentWindow = qobject_cast<QMainWindow*>(pParent)) 270 if (pParentWindow->statusBar()) 271 return pParentWindow->statusBar()->height(); 272 /* Status-bar can exist only on QMainWindow sub-class: */ 273 if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent)) 274 { 275 /* Status-bar can exist only: 276 * 1. on non-machine-window 277 * 2. on machine-window in normal mode: */ 278 if (!qobject_cast<UIMachineWindow*>(pMainWindow) || 279 qobject_cast<UIMachineWindowNormal*>(pMainWindow)) 280 return pMainWindow->statusBar()->height(); 281 } 272 282 /* Zero by default: */ 273 283 return 0; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r45696 r45939 43 43 44 44 /* Constructor: */ 45 UIPopupStack( QWidget *pParent);45 UIPopupStack(); 46 46 47 47 /* API: Popup-pane stuff: */ … … 53 53 void updatePopupPane(const QString &strPopupPaneID, 54 54 const QString &strMessage, const QString &strDetails); 55 56 /* API: Parent stuff: */ 57 void setParent(QWidget *pParent); 55 58 56 59 private slots: … … 64 67 private: 65 68 66 /* Helper: Prepare stuff: */67 void prepare();68 69 69 /* Helpers: Layout stuff: */ 70 70 int minimumWidthHint(); … … 77 77 bool eventFilter(QObject *pWatched, QEvent *pEvent); 78 78 79 /* Handlers: Event stuff: */ 80 virtual void showEvent(QShowEvent *pEvent); 81 virtual void polishEvent(QShowEvent *pEvent); 79 /* Handler: Event stuff: */ 80 void showEvent(QShowEvent *pEvent); 82 81 83 82 /* Static helpers: Prepare stuff: */ … … 85 84 86 85 /* Variables: */ 87 bool m_fPolished;88 86 const int m_iLayoutMargin; 89 87 const int m_iLayoutSpacing; 90 constint m_iParentStatusBarHeight;88 int m_iParentStatusBarHeight; 91 89 QMap<QString, UIPopupPane*> m_panes; 92 90 };
Note:
See TracChangeset
for help on using the changeset viewer.