Changeset 47455 in vbox for trunk/src/VBox
- Timestamp:
- Jul 29, 2013 12:07:32 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r47230 r47455 317 317 return; 318 318 319 /* Just raise, its: 320 * useful for Win host, 321 * do not work on Mac host and 322 * need to check for x11/KDE still. */ 323 UIPopupStack *pPopupStack = m_stacks[strPopupStackID]; 324 pPopupStack->raise(); 319 /* Remove stack: */ 320 hidePopupStack(pParent); 321 322 /* Make sure integration type is correct: */ 323 setStackIntegrationType(UIPopupIntegrationType_Toplevel); 324 325 /* Return stack again: */ 326 showPopupStack(pParent); 325 327 } 326 328 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r47209 r47455 89 89 } 90 90 91 void UIPopupPane::setDesiredWidth(int iWidth)92 {93 /* Make sure text-pane exists: */94 if (!m_pTextPane)95 return;96 97 /* Propagate desired width to the text-pane we have: */98 m_pTextPane->setDesiredWidth(iWidth - 2 * m_iLayoutMargin99 - m_pButtonPane->minimumSizeHint().width());100 }101 102 91 void UIPopupPane::setMinimumSizeHint(const QSize &minimumSizeHint) 103 92 { … … 148 137 } 149 138 139 void UIPopupPane::sltHandleProposalForWidth(int iWidth) 140 { 141 /* Make sure text-pane exists: */ 142 if (!m_pTextPane) 143 return; 144 145 /* Subtract layout margins: */ 146 iWidth -= 2 * m_iLayoutMargin; 147 /* Subtract layout spacing: */ 148 iWidth -= m_iLayoutSpacing; 149 /* Subtract button-pane width: */ 150 iWidth -= m_pButtonPane->minimumSizeHint().width(); 151 152 /* Propose resulting width to text-pane: */ 153 emit sigProposeTextPaneWidth(iWidth); 154 } 155 150 156 void UIPopupPane::sltUpdateSizeHint() 151 157 { … … 197 203 void UIPopupPane::prepare() 198 204 { 205 /* Prepare this: */ 206 installEventFilter(this); 207 /* Prepare background: */ 208 prepareBackground(); 199 209 /* Prepare content: */ 200 210 prepareContent(); … … 206 216 } 207 217 218 void UIPopupPane::prepareBackground() 219 { 220 /* Prepare palette: */ 221 QPalette pal = palette(); 222 pal.setColor(QPalette::Window, QApplication::palette().color(QPalette::Window)); 223 setPalette(pal); 224 } 225 208 226 void UIPopupPane::prepareContent() 209 227 { 210 /* Prepare this: */211 installEventFilter(this);212 213 228 /* Create message-label: */ 214 229 m_pTextPane = new UIPopupPaneTextPane(this, m_strMessage, m_fProposeAutoConfirmation); 215 230 { 216 231 /* Prepare label: */ 232 connect(this, SIGNAL(sigProposeTextPaneWidth(int)), m_pTextPane, SLOT(sltHandleProposalForWidth(int))); 217 233 connect(m_pTextPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltUpdateSizeHint())); 218 234 m_pTextPane->installEventFilter(this); … … 301 317 break; 302 318 } 303 /* Pane is focused: */304 case QEvent:: FocusIn:319 /* Pane is clicked with mouse: */ 320 case QEvent::MouseButtonPress: 305 321 { 306 322 /* Focus pane if not focused: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h
r47209 r47455 59 59 void sigFocusLeave(); 60 60 61 /* Notifier: Layout stuff: */ 61 /* Notifiers: Layout stuff: */ 62 void sigProposeTextPaneWidth(int iWidth); 62 63 void sigSizeHintChanged(); 63 64 … … 86 87 QSize minimumSizeHint() const { return m_minimumSizeHint; } 87 88 void setMinimumSizeHint(const QSize &minimumSizeHint); 88 void setDesiredWidth(int iWidth);89 89 void layoutContent(); 90 90 … … 94 94 void sltMarkAsShown(); 95 95 96 /* Handler: Layout stuff: */ 96 /* Handlers: Layout stuff: */ 97 void sltHandleProposalForWidth(int iWidth); 97 98 void sltUpdateSizeHint(); 98 99 … … 104 105 /* Helpers: Prepare stuff: */ 105 106 void prepare(); 107 void prepareBackground(); 106 108 void prepareContent(); 107 109 void prepareAnimation(); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.cpp
r47043 r47455 51 51 m_strText = strText; 52 52 m_pLabel->setText(m_strText); 53 54 /* Update size-hint: */55 updateSizeHint();56 }57 58 void UIPopupPaneTextPane::setDesiredWidth(int iDesiredWidth)59 {60 /* Make sure the desired-width has changed: */61 if (m_iDesiredLabelWidth == iDesiredWidth)62 return;63 64 /* Fetch new desired-width: */65 m_iDesiredLabelWidth = iDesiredWidth;66 53 67 54 /* Update size-hint: */ … … 151 138 } 152 139 140 void UIPopupPaneTextPane::sltHandleProposalForWidth(int iWidth) 141 { 142 /* Make sure the desired-width has changed: */ 143 if (m_iDesiredLabelWidth == iWidth) 144 return; 145 146 /* Fetch new desired-width: */ 147 m_iDesiredLabelWidth = iWidth; 148 149 /* Update size-hint: */ 150 updateSizeHint(); 151 } 152 153 153 void UIPopupPaneTextPane::sltFocusEnter() 154 154 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPaneTextPane.h
r47042 r47455 56 56 void setText(const QString &strText); 57 57 58 /* API: Desired-width stuff: */59 void setDesiredWidth(int iDesiredWidth);60 61 58 /* API: Auto-confirmation stuff: */ 62 59 void setProposeAutoConfirmation(bool fPropose); … … 70 67 71 68 private slots: 69 70 /* Handler: Layout stuff: */ 71 void sltHandleProposalForWidth(int iWidth); 72 72 73 73 /* Handlers: Focus stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r47230 r47455 19 19 20 20 /* Qt includes: */ 21 #include <QVBoxLayout> 22 #include <QScrollArea> 21 23 #include <QEvent> 22 24 #include <QMainWindow> … … 33 35 34 36 UIPopupStack::UIPopupStack() 35 : m_ iLayoutMargin(1)36 , m_ iLayoutSpacing(1)37 : m_pScrollArea(0) 38 , m_pScrollViewport(0) 37 39 , m_iParentMenuBarHeight(0) 38 40 , m_iParentStatusBarHeight(0) 39 41 { 40 /* Make sure cursor is *always* valid: */ 41 setCursor(Qt::ArrowCursor); 42 42 /* Prepare: */ 43 prepare(); 44 } 45 46 bool UIPopupStack::exists(const QString &strPopupPaneID) const 47 { 48 /* Redirect question to viewport: */ 49 return m_pScrollViewport->exists(strPopupPaneID); 50 } 51 52 void UIPopupStack::createPopupPane(const QString &strPopupPaneID, 53 const QString &strMessage, const QString &strDetails, 54 const QMap<int, QString> &buttonDescriptions, 55 bool fProposeAutoConfirmation) 56 { 57 /* Redirect request to viewport: */ 58 m_pScrollViewport->createPopupPane(strPopupPaneID, 59 strMessage, strDetails, 60 buttonDescriptions, 61 fProposeAutoConfirmation); 62 63 /* Propagate width: */ 64 propagateWidth(); 65 } 66 67 void UIPopupStack::updatePopupPane(const QString &strPopupPaneID, 68 const QString &strMessage, const QString &strDetails) 69 { 70 /* Redirect request to viewport: */ 71 m_pScrollViewport->updatePopupPane(strPopupPaneID, 72 strMessage, strDetails); 73 74 /* Propagate width: */ 75 propagateWidth(); 76 } 77 78 void UIPopupStack::recallPopupPane(const QString &strPopupPaneID) 79 { 80 /* Redirect request to viewport: */ 81 m_pScrollViewport->recallPopupPane(strPopupPaneID); 82 83 /* Propagate width: */ 84 propagateWidth(); 85 } 86 87 void UIPopupStack::setParent(QWidget *pParent) 88 { 89 /* Call to base-class: */ 90 QWidget::setParent(pParent); 91 /* Recalculate parent menu-bar height: */ 92 m_iParentMenuBarHeight = parentMenuBarHeight(pParent); 93 /* Recalculate parent status-bar height: */ 94 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 95 } 96 97 void UIPopupStack::setParent(QWidget *pParent, Qt::WindowFlags flags) 98 { 99 /* Call to base-class: */ 100 QWidget::setParent(pParent, flags); 101 /* Recalculate parent menu-bar height: */ 102 m_iParentMenuBarHeight = parentMenuBarHeight(pParent); 103 /* Recalculate parent status-bar height: */ 104 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 105 } 106 107 void UIPopupStack::sltAdjustGeometry() 108 { 109 /* Make sure parent is currently set: */ 110 if (!parent()) 111 return; 112 113 /* Read parent geometry: */ 114 QRect geo(parentWidget()->geometry()); 115 116 /* Determine origin: */ 117 bool fIsWindow = isWindow(); 118 int iX = fIsWindow ? geo.x() : 0; 119 int iY = fIsWindow ? geo.y() : 0; 120 /* Subtract menu-bar height: */ 121 iY += m_iParentMenuBarHeight; 122 123 /* Determine size: */ 124 int iWidth = parentWidget()->width(); 125 int iHeight = parentWidget()->height(); 126 /* Subtract menu-bar and status-bar heights: */ 127 iHeight -= (m_iParentMenuBarHeight + m_iParentStatusBarHeight); 128 /* Check if minimum height is even less than current: */ 129 if (m_pScrollViewport) 130 { 131 /* Get minimum viewport height: */ 132 int iMinimumHeight = m_pScrollViewport->minimumSizeHint().height(); 133 /* Subtract layout margins: */ 134 int iLeft, iTop, iRight, iBottom; 135 m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 136 iMinimumHeight += (iTop + iBottom); 137 /* Compare minimum and current height: */ 138 iHeight = qMin(iHeight, iMinimumHeight); 139 } 140 141 /* Adjust geometry: */ 142 setGeometry(iX, iY, iWidth, iHeight); 143 } 144 145 void UIPopupStack::sltPopupPaneRemoved(QString) 146 { 147 /* Move focus to the parent: */ 148 if (parentWidget()) 149 parentWidget()->setFocus(); 150 } 151 152 void UIPopupStack::prepare() 153 { 154 /* Configure background: */ 155 setAutoFillBackground(false); 43 156 #if defined(Q_WS_WIN) || defined (Q_WS_MAC) 44 157 /* Using Qt API to enable translucent background for the Win/Mac host. … … 53 166 setAttribute(Qt::WA_MacAlwaysShowToolWindow); 54 167 #endif /* Q_WS_MAC */ 55 } 56 57 bool UIPopupStack::exists(const QString &strPopupPaneID) const 168 169 /* Prepare content: */ 170 prepareContent(); 171 } 172 173 void UIPopupStack::prepareContent() 174 { 175 /* Create main-layout: */ 176 m_pMainLayout = new QVBoxLayout(this); 177 { 178 /* Configure main-layout: */ 179 m_pMainLayout->setContentsMargins(0, 0, 0, 0); 180 /* Create scroll-area: */ 181 m_pScrollArea = new QScrollArea; 182 { 183 /* Configure scroll-area: */ 184 m_pScrollArea->setCursor(Qt::ArrowCursor); 185 m_pScrollArea->setWidgetResizable(true); 186 m_pScrollArea->setFrameStyle(QFrame::NoFrame | QFrame::Plain); 187 m_pScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 188 //m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 189 QPalette pal = m_pScrollArea->palette(); 190 pal.setColor(QPalette::Window, QColor(Qt::transparent)); 191 m_pScrollArea->setPalette(pal); 192 /* Create scroll-viewport: */ 193 m_pScrollViewport = new UIPopupStackViewport; 194 { 195 /* Configure scroll-viewport: */ 196 m_pScrollViewport->setCursor(Qt::ArrowCursor); 197 /* Connect scroll-viewport: */ 198 connect(this, SIGNAL(sigProposeStackViewportWidth(int)), 199 m_pScrollViewport, SLOT(sltHandleProposalForWidth(int))); 200 connect(m_pScrollViewport, SIGNAL(sigSizeHintChanged()), 201 this, SLOT(sltAdjustGeometry())); 202 connect(m_pScrollViewport, SIGNAL(sigPopupPaneDone(QString, int)), 203 this, SIGNAL(sigPopupPaneDone(QString, int))); 204 connect(m_pScrollViewport, SIGNAL(sigPopupPaneRemoved(QString)), 205 this, SLOT(sltPopupPaneRemoved(QString))); 206 connect(m_pScrollViewport, SIGNAL(sigRemove()), 207 this, SIGNAL(sigRemove())); 208 } 209 /* Assign scroll-viewport to scroll-area: */ 210 m_pScrollArea->setWidget(m_pScrollViewport); 211 } 212 /* Add scroll-area to layout: */ 213 m_pMainLayout->addWidget(m_pScrollArea); 214 } 215 } 216 217 bool UIPopupStack::eventFilter(QObject *pWatched, QEvent *pEvent) 218 { 219 /* Call to base-class if that is not parent event: */ 220 if (!parent() || pWatched != parent()) 221 return QWidget::eventFilter(pWatched, pEvent); 222 223 /* Handle parent geometry events: */ 224 switch (pEvent->type()) 225 { 226 case QEvent::Resize: 227 { 228 /* Propagate stack width: */ 229 propagateWidth(); 230 /* Adjust geometry: */ 231 sltAdjustGeometry(); 232 break; 233 } 234 case QEvent::Move: 235 { 236 /* Adjust geometry: */ 237 sltAdjustGeometry(); 238 break; 239 } 240 } 241 242 /* Call to base-class: */ 243 return QWidget::eventFilter(pWatched, pEvent); 244 } 245 246 void UIPopupStack::showEvent(QShowEvent*) 247 { 248 /* Propagate width: */ 249 propagateWidth(); 250 /* Adjust geometry: */ 251 sltAdjustGeometry(); 252 } 253 254 void UIPopupStack::propagateWidth() 255 { 256 /* Make sure parent is currently set: */ 257 if (!parent()) 258 return; 259 260 /* Get parent width: */ 261 int iWidth = parentWidget()->width(); 262 /* Subtract left/right layout margins: */ 263 if (m_pMainLayout) 264 { 265 int iLeft, iTop, iRight, iBottom; 266 m_pMainLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 267 iWidth -= (iLeft + iRight); 268 } 269 /* Subtract scroll-area frame-width: */ 270 if (m_pScrollArea) 271 { 272 iWidth -= 2 * m_pScrollArea->frameWidth(); 273 } 274 275 /* Propose resulting width to viewport: */ 276 emit sigProposeStackViewportWidth(iWidth); 277 } 278 279 /* static */ 280 int UIPopupStack::parentMenuBarHeight(QWidget *pParent) 281 { 282 /* Menu-bar can exist only on QMainWindow sub-class: */ 283 if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent)) 284 { 285 /* Search for existing menu-bar child: */ 286 if (QMenuBar *pMenuBar = pMainWindow->findChild<QMenuBar*>()) 287 return pMenuBar->height(); 288 } 289 /* Zero by default: */ 290 return 0; 291 } 292 293 /* static */ 294 int UIPopupStack::parentStatusBarHeight(QWidget *pParent) 295 { 296 /* Status-bar can exist only on QMainWindow sub-class: */ 297 if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent)) 298 { 299 /* Search for existing status-bar child: */ 300 if (QStatusBar *pStatusBar = pMainWindow->findChild<QStatusBar*>()) 301 return pStatusBar->height(); 302 } 303 /* Zero by default: */ 304 return 0; 305 } 306 307 308 UIPopupStackViewport::UIPopupStackViewport() 309 : m_iLayoutMargin(1) 310 , m_iLayoutSpacing(1) 311 { 312 } 313 314 bool UIPopupStackViewport::exists(const QString &strPopupPaneID) const 58 315 { 59 316 /* Is there already popup-pane with the same ID? */ … … 61 318 } 62 319 63 void UIPopupStack ::createPopupPane(const QString &strPopupPaneID,64 const QString &strMessage, const QString &strDetails,65 const QMap<int, QString> &buttonDescriptions,66 bool fProposeAutoConfirmation)320 void UIPopupStackViewport::createPopupPane(const QString &strPopupPaneID, 321 const QString &strMessage, const QString &strDetails, 322 const QMap<int, QString> &buttonDescriptions, 323 bool fProposeAutoConfirmation) 67 324 { 68 325 /* Make sure there is no such popup-pane already: */ … … 78 335 buttonDescriptions, 79 336 fProposeAutoConfirmation); 337 80 338 /* Attach popup-pane connection: */ 339 connect(this, SIGNAL(sigProposePopupPaneWidth(int)), pPopupPane, SLOT(sltHandleProposalForWidth(int))); 81 340 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry())); 82 341 connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int))); 342 83 343 /* Show popup-pane: */ 84 344 pPopupPane->show(); 85 86 /* Adjust geometry only if parent is currently set: */ 87 if (parent()) 88 { 89 /* Propagate desired width: */ 90 setDesiredWidth(parentWidget()->width()); 91 /* Adjust geometry: */ 92 sltAdjustGeometry(); 93 } 94 } 95 96 void UIPopupStack::updatePopupPane(const QString &strPopupPaneID, 97 const QString &strMessage, const QString &strDetails) 345 } 346 347 void UIPopupStackViewport::updatePopupPane(const QString &strPopupPaneID, 348 const QString &strMessage, const QString &strDetails) 98 349 { 99 350 /* Make sure there is such popup-pane already: */ … … 110 361 pPopupPane->setMessage(strMessage); 111 362 pPopupPane->setDetails(strDetails); 112 113 /* Adjust geometry only if parent is currently set: */ 114 if (parent()) 115 { 116 /* Propagate desired width: */ 117 setDesiredWidth(parentWidget()->width()); 118 /* Adjust geometry: */ 119 sltAdjustGeometry(); 120 } 121 } 122 123 void UIPopupStack::recallPopupPane(const QString &strPopupPaneID) 363 } 364 365 void UIPopupStackViewport::recallPopupPane(const QString &strPopupPaneID) 124 366 { 125 367 /* Make sure there is such popup-pane already: */ … … 137 379 } 138 380 139 void UIPopupStack::setParent(QWidget *pParent) 140 { 141 /* Call to base-class: */ 142 QWidget::setParent(pParent); 143 /* Recalculate parent menu-bar height: */ 144 m_iParentMenuBarHeight = parentMenuBarHeight(pParent); 145 /* Recalculate parent status-bar height: */ 146 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 147 } 148 149 void UIPopupStack::setParent(QWidget *pParent, Qt::WindowFlags flags) 150 { 151 /* Call to base-class: */ 152 QWidget::setParent(pParent, flags); 153 /* Recalculate parent menu-bar height: */ 154 m_iParentMenuBarHeight = parentMenuBarHeight(pParent); 155 /* Recalculate parent status-bar height: */ 156 m_iParentStatusBarHeight = parentStatusBarHeight(pParent); 157 } 158 159 void UIPopupStack::sltAdjustGeometry() 160 { 161 /* Adjust geometry only if parent is currently set: */ 162 if (!parent()) 163 return; 164 381 void UIPopupStackViewport::sltHandleProposalForWidth(int iWidth) 382 { 383 /* Subtract layout margins: */ 384 iWidth -= 2 * m_iLayoutMargin; 385 386 /* Propagate resulting width to popups: */ 387 emit sigProposePopupPaneWidth(iWidth); 388 } 389 390 void UIPopupStackViewport::sltAdjustGeometry() 391 { 165 392 /* Update size-hint: */ 166 393 updateSizeHint(); 167 394 168 /* Get this attributes: */169 bool fIsWindow = isWindow();170 const int iX = fIsWindow ? parentWidget()->x() : 0;171 const int iY = fIsWindow ? parentWidget()->y() : m_iParentMenuBarHeight;172 const int iWidth = parentWidget()->width();173 const int iHeight = m_minimumSizeHint.height();174 175 /* Move/resize according parent: */176 setGeometry(iX, iY, iWidth, iHeight);177 178 395 /* Layout content: */ 179 396 layoutContent(); 180 } 181 182 void UIPopupStack::sltPopupPaneDone(int iResultCode) 397 398 /* Notify parent popup-stack: */ 399 emit sigSizeHintChanged(); 400 } 401 402 void UIPopupStackViewport::sltPopupPaneDone(int iResultCode) 183 403 { 184 404 /* Make sure the sender is the popup-pane: */ … … 198 418 } 199 419 200 /* Notify listeners about popup-pane : */420 /* Notify listeners about popup-pane removal: */ 201 421 emit sigPopupPaneDone(strPopupPaneID, iResultCode); 202 422 … … 205 425 delete pPopupPane; 206 426 207 /* Give focus back to parent: */ 208 if (parentWidget()) 209 parentWidget()->setFocus(); 210 211 /* Layout content: */ 212 layoutContent(); 427 /* Notify listeners about popup-pane removed: */ 428 emit sigPopupPaneRemoved(strPopupPaneID); 429 430 /* Adjust geometry: */ 431 sltAdjustGeometry(); 213 432 214 433 /* Make sure this stack still contains popup-panes: */ … … 220 439 } 221 440 222 void UIPopupStack ::updateSizeHint()441 void UIPopupStackViewport::updateSizeHint() 223 442 { 224 443 /* Calculate minimum width-hint: */ … … 252 471 } 253 472 254 void UIPopupStack::setDesiredWidth(int iWidth) 255 { 256 /* Propagate desired width to all the popup-panes we have: */ 257 foreach (UIPopupPane *pPane, m_panes) 258 pPane->setDesiredWidth(iWidth - 2 * m_iLayoutMargin); 259 } 260 261 void UIPopupStack::layoutContent() 473 void UIPopupStackViewport::layoutContent() 262 474 { 263 475 /* Get attributes: */ … … 269 481 { 270 482 /* Get pane attributes: */ 271 const int iPaneWidth = width() - 2 * m_iLayoutMargin; 272 const int iPaneHeight = pPane->minimumSizeHint().height(); 483 QSize paneSize = pPane->minimumSizeHint(); 484 const int iPaneWidth = paneSize.width(); 485 const int iPaneHeight = paneSize.height(); 273 486 /* Adjust geometry for the pane: */ 274 pPane->move(iX, iY); 275 pPane->resize(iPaneWidth, iPaneHeight); 487 pPane->setGeometry(iX, iY, iPaneWidth, iPaneHeight); 276 488 pPane->layoutContent(); 277 489 /* Increment placeholder: */ … … 280 492 } 281 493 282 bool UIPopupStack::eventFilter(QObject *pWatched, QEvent *pEvent)283 {284 /* Make sure its parent event came: */285 if (!parent() || pWatched != parent())286 return false;287 288 /* Make sure its resize event came: */289 if (pEvent->type() != QEvent::Resize)290 return false;291 292 /* Propagate desired width: */293 setDesiredWidth(parentWidget()->width());294 /* Adjust geometry: */295 sltAdjustGeometry();296 297 /* Do not filter anything: */298 return false;299 }300 301 void UIPopupStack::showEvent(QShowEvent*)302 {303 /* Adjust geometry only if parent is currently set: */304 if (parent())305 {306 /* Propagate desired width: */307 setDesiredWidth(parentWidget()->width());308 /* Adjust geometry: */309 sltAdjustGeometry();310 }311 }312 313 /* static */314 int UIPopupStack::parentMenuBarHeight(QWidget *pParent)315 {316 /* Menu-bar can exist only on QMainWindow sub-class: */317 if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent))318 {319 /* Search for existing menu-bar child: */320 if (QMenuBar *pMenuBar = pMainWindow->findChild<QMenuBar*>())321 return pMenuBar->height();322 }323 /* Zero by default: */324 return 0;325 }326 327 /* static */328 int UIPopupStack::parentStatusBarHeight(QWidget *pParent)329 {330 /* Status-bar can exist only on QMainWindow sub-class: */331 if (QMainWindow *pMainWindow = qobject_cast<QMainWindow*>(pParent))332 {333 /* Search for existing status-bar child: */334 if (QStatusBar *pStatusBar = pMainWindow->findChild<QStatusBar*>())335 return pStatusBar->height();336 }337 /* Zero by default: */338 return 0;339 }340 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r47209 r47455 25 25 26 26 /* Forward declaration: */ 27 class QVBoxLayout; 28 class QScrollArea; 27 29 class UIPopupPane; 30 class UIPopupStackViewport; 28 31 29 32 /* Popup-stack prototype class: */ … … 33 36 34 37 signals: 38 39 /* Notifier: Layout stuff: */ 40 void sigProposeStackViewportWidth(int iWidth); 35 41 36 42 /* Notifier: Popup-pane stuff: */ … … 64 70 void sltAdjustGeometry(); 65 71 66 /* Handler: Popu p-pane stuff: */67 void sltPopupPane Done(int iButtonCode);72 /* Handler: Popuyp-pane stuff: */ 73 void sltPopupPaneRemoved(QString strPopupPaneID); 68 74 69 75 private: 70 76 71 /* Helpers: Layout stuff: */ 72 QSize minimumSizeHint() const { return m_minimumSizeHint; } 73 void updateSizeHint(); 74 void setDesiredWidth(int iWidth); 75 void layoutContent(); 77 /* Helpers: Prepare stuff: */ 78 void prepare(); 79 void prepareContent(); 76 80 77 81 /* Handler: Event-filter stuff: */ … … 81 85 void showEvent(QShowEvent *pEvent); 82 86 87 /* Helper: Layout stuff: */ 88 void propagateWidth(); 89 83 90 /* Static helpers: Prepare stuff: */ 84 91 static int parentMenuBarHeight(QWidget *pParent); 85 92 static int parentStatusBarHeight(QWidget *pParent); 86 93 87 /* Variables: */ 94 /* Variables: Widget stuff: */ 95 QVBoxLayout *m_pMainLayout; 96 QScrollArea *m_pScrollArea; 97 UIPopupStackViewport *m_pScrollViewport; 98 99 /* Variables: Layout stuff: */ 100 int m_iParentMenuBarHeight; 101 int m_iParentStatusBarHeight; 102 }; 103 104 /* Popup-stack viewport prototype class: */ 105 class UIPopupStackViewport : public QWidget 106 { 107 Q_OBJECT; 108 109 signals: 110 111 /* Notifier: Layout stuff: */ 112 void sigProposePopupPaneWidth(int iWidth); 113 void sigSizeHintChanged(); 114 115 /* Notifier: Popup-pane stuff: */ 116 void sigPopupPaneDone(QString strPopupPaneID, int iResultCode); 117 void sigPopupPaneRemoved(QString strPopupPaneID); 118 119 /* Notifier: Popup-stack stuff: */ 120 void sigRemove(); 121 122 public: 123 124 /* Constructor: */ 125 UIPopupStackViewport(); 126 127 /* API: Popup-pane stuff: */ 128 bool exists(const QString &strPopupPaneID) const; 129 void createPopupPane(const QString &strPopupPaneID, 130 const QString &strMessage, const QString &strDetails, 131 const QMap<int, QString> &buttonDescriptions, 132 bool fProposeAutoConfirmation); 133 void updatePopupPane(const QString &strPopupPaneID, 134 const QString &strMessage, const QString &strDetails); 135 void recallPopupPane(const QString &strPopupPaneID); 136 137 /* API: Layout stuff: */ 138 QSize minimumSizeHint() const { return m_minimumSizeHint; } 139 140 private slots: 141 142 /* Handlers: Layout stuff: */ 143 void sltHandleProposalForWidth(int iWidth); 144 void sltAdjustGeometry(); 145 146 /* Handler: Popup-pane stuff: */ 147 void sltPopupPaneDone(int iButtonCode); 148 149 private: 150 151 /* Helpers: Layout stuff: */ 152 void updateSizeHint(); 153 void layoutContent(); 154 155 /* Variables: Layout stuff: */ 88 156 const int m_iLayoutMargin; 89 157 const int m_iLayoutSpacing; 90 158 QSize m_minimumSizeHint; 91 int m_iParentMenuBarHeight; 92 int m_iParentStatusBarHeight;159 160 /* Variables: Children stuff: */ 93 161 QMap<QString, UIPopupPane*> m_panes; 94 162 };
Note:
See TracChangeset
for help on using the changeset viewer.