Changeset 45659 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 22, 2013 8:14:33 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85178
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r45523 r45659 384 384 src/widgets/UIPopupBox.h \ 385 385 src/widgets/UIPopupPane.h \ 386 src/widgets/UIPopupStack.h \ 386 387 src/widgets/UIProgressDialog.h \ 387 388 src/widgets/UISpacerWidgets.h \ … … 630 631 src/widgets/UIPopupBox.cpp \ 631 632 src/widgets/UIPopupPane.cpp \ 633 src/widgets/UIPopupStack.cpp \ 632 634 src/widgets/UIProgressDialog.cpp \ 633 635 src/widgets/UISpecialControls.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.cpp
r45658 r45659 20 20 /* GUI includes: */ 21 21 #include "UIPopupCenter.h" 22 #include "UIPopupPane.h" 22 #include "UIPopupStack.h" 23 #include "QIMessageBox.h" 23 24 24 25 /* Other VBox includes: */ … … 65 66 void UIPopupCenter::message(QWidget *pParent, const QString &strId, 66 67 const QString &strMessage, const QString &strDetails, 67 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,68 int iButton1 /*= 0*/, int iButton2 /*= 0*/, 68 69 const QString &strButtonText1 /* = QString() */, 69 const QString &strButtonText2 /* = QString() */, 70 const QString &strButtonText3 /* = QString() */) 70 const QString &strButtonText2 /* = QString() */) 71 71 { 72 72 showPopupPane(pParent, strId, 73 73 strMessage, strDetails, 74 iButton1, iButton2, iButton3,75 strButtonText1, strButtonText2 , strButtonText3);74 iButton1, iButton2, 75 strButtonText1, strButtonText2); 76 76 } 77 77 … … 93 93 void UIPopupCenter::question(QWidget *pParent, const QString &strId, 94 94 const QString &strMessage, 95 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,95 int iButton1 /*= 0*/, int iButton2 /*= 0*/, 96 96 const QString &strButtonText1 /*= QString()*/, 97 const QString &strButtonText2 /*= QString()*/, 98 const QString &strButtonText3 /*= QString()*/) 97 const QString &strButtonText2 /*= QString()*/) 99 98 { 100 99 message(pParent, strId, 101 100 strMessage, QString(), 102 iButton1, iButton2, iButton3,103 strButtonText1, strButtonText2 , strButtonText3);101 iButton1, iButton2, 102 strButtonText1, strButtonText2); 104 103 } 105 104 … … 113 112 AlertButton_Ok | AlertButtonOption_Default, 114 113 AlertButton_Cancel | AlertButtonOption_Escape, 115 0 /* third button */,116 114 strOkButtonText, 117 strCancelButtonText,118 QString() /* third button */);119 }120 121 void UIPopupCenter::questionTrinary(QWidget *pParent, const QString &strId,122 const QString &strMessage,123 const QString &strChoice1ButtonText /*= QString()*/,124 const QString &strChoice2ButtonText /*= QString()*/,125 const QString &strCancelButtonText /*= QString()*/)126 {127 question(pParent, strId,128 strMessage,129 AlertButton_Choice1,130 AlertButton_Choice2 | AlertButtonOption_Default,131 AlertButton_Cancel | AlertButtonOption_Escape,132 strChoice1ButtonText,133 strChoice2ButtonText,134 115 strCancelButtonText); 135 116 } … … 137 118 void UIPopupCenter::showPopupPane(QWidget *pParent, const QString &strPopupPaneID, 138 119 const QString &strMessage, const QString &strDetails, 139 int iButton1, int iButton2, int iButton3, 140 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3) 141 { 120 int iButton1, int iButton2, 121 const QString &strButtonText1, const QString &strButtonText2) 122 { 123 /* Make sure parent is always set! */ 124 AssertMsg(pParent, ("Parent is NULL!")); 125 if (!pParent) 126 return; 142 127 /* Looking for the corresponding popup-stack: */ 143 128 QString strPopupStackID = pParent->metaObject()->className(); … … 161 146 pPopupStack->show(); 162 147 163 /* Choose at least one button to be the 'default' and 'escape': */164 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)148 /* Make sure at least one button is valid: */ 149 if (iButton1 == 0 && iButton2 == 0) 165 150 iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape; 166 151 /* Compose button description map: */ … … 170 155 if (iButton2 != 0 && !buttonDescriptions.contains(iButton2)) 171 156 buttonDescriptions[iButton2] = strButtonText2; 172 if (iButton3 != 0 && !buttonDescriptions.contains(iButton3))173 buttonDescriptions[iButton3] = strButtonText3;174 157 /* Update corresponding popup-pane: */ 175 158 pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions); … … 199 182 } 200 183 201 void UIPopupCenter::remindAboutMouseIntegration( bool fSupportsAbsolute, QWidget *pParent)184 void UIPopupCenter::remindAboutMouseIntegration(QWidget *pParent, bool fSupportsAbsolute) 202 185 { 203 186 if (fSupportsAbsolute) … … 223 206 } 224 207 225 226 /* Qt includes: */227 #include <QVBoxLayout>228 #include <QEvent>229 #include <QMainWindow>230 #include <QStatusBar>231 232 UIPopupStack::UIPopupStack(QWidget *pParent)233 : QWidget(pParent)234 , m_fPolished(false)235 , m_iStackLayoutMargin(0)236 , m_iStackLayoutSpacing(0)237 , m_iParentStatusBarHeight(parentStatusBarHeight(pParent))238 {239 /* Prepare: */240 prepare();241 }242 243 void UIPopupStack::updatePopupPane(const QString &strPopupPaneID,244 const QString &strMessage, const QString &strDetails,245 const QMap<int, QString> &buttonDescriptions)246 {247 /* Looking for the corresponding popup-pane: */248 UIPopupPane *pPopupPane = 0;249 /* Is there already popup-pane with the same ID? */250 if (m_panes.contains(strPopupPaneID))251 {252 /* Get existing one: */253 pPopupPane = m_panes[strPopupPaneID];254 /* And update message and details: */255 pPopupPane->setMessage(strMessage);256 pPopupPane->setDetails(strDetails);257 }258 /* There is no popup-pane with the same ID? */259 else260 {261 /* Create new one: */262 pPopupPane = m_panes[strPopupPaneID] = new UIPopupPane(this,263 strMessage, strDetails,264 buttonDescriptions);265 pPopupPane->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);266 /* Attach popup-pane connection: */267 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry()));268 connect(pPopupPane, SIGNAL(sigDone(int)), this, SLOT(sltPopupPaneDone(int)));269 /* Show popup-pane: */270 pPopupPane->show();271 }272 273 /* Propagate desired width: */274 setDesiredWidth(parentWidget()->width());275 /* Adjust geometry: */276 sltAdjustGeometry();277 }278 279 void UIPopupStack::sltAdjustGeometry()280 {281 /* Get this attributes: */282 const int iWidth = parentWidget()->width();283 const int iHeight = minimumHeightHint();284 285 /* Move according parent: */286 move(0, parentWidget()->height() - iHeight - m_iParentStatusBarHeight);287 /* Resize according parent: */288 resize(iWidth, iHeight);289 290 /* Layout content: */291 layoutContent();292 }293 294 void UIPopupStack::sltPopupPaneDone(int iButtonCode)295 {296 /* Make sure the sender is the popup-pane: */297 UIPopupPane *pPopupPane = qobject_cast<UIPopupPane*>(sender());298 if (!pPopupPane)299 {300 AssertMsgFailed(("Should be called by popup-pane only!"));301 return;302 }303 304 /* Make sure the popup-pane still exists: */305 const QString strPopupPaneID(m_panes.key(pPopupPane, QString()));306 if (strPopupPaneID.isNull())307 {308 AssertMsgFailed(("Popup-pane already destroyed!"));309 return;310 }311 312 /* Notify listeners about popup-pane: */313 emit sigPopupPaneDone(strPopupPaneID, iButtonCode);314 315 /* Cleanup the popup-pane: */316 m_panes.remove(strPopupPaneID);317 delete pPopupPane;318 319 /* Make sure this stack still contains popup-panes: */320 if (!m_panes.isEmpty())321 return;322 323 /* Notify listeners about popup-stack: */324 emit sigRemove();325 }326 327 void UIPopupStack::prepare()328 {329 /* Install event-filter to parent: */330 parent()->installEventFilter(this);331 }332 333 int UIPopupStack::minimumWidthHint()334 {335 /* Prepare width hint: */336 int iWidthHint = 0;337 338 /* Take into account all the panes: */339 foreach (UIPopupPane *pPane, m_panes)340 iWidthHint = qMax(iWidthHint, pPane->minimumWidthHint());341 342 /* And two margins finally: */343 iWidthHint += 2 * m_iStackLayoutMargin;344 345 /* Return width hint: */346 return iWidthHint;347 }348 349 int UIPopupStack::minimumHeightHint()350 {351 /* Prepare height hint: */352 int iHeightHint = 0;353 354 /* Take into account all the panes: */355 foreach (UIPopupPane *pPane, m_panes)356 iHeightHint += pPane->minimumHeightHint();357 358 /* Take into account all the spacings, if any: */359 if (!m_panes.isEmpty())360 iHeightHint += (m_panes.size() - 1) * m_iStackLayoutSpacing;361 362 /* And two margins finally: */363 iHeightHint += 2 * m_iStackLayoutMargin;364 365 /* Return height hint: */366 return iHeightHint;367 }368 369 QSize UIPopupStack::minimumSizeHint()370 {371 /* Wrap reimplemented getters: */372 return QSize(minimumWidthHint(), minimumHeightHint());373 }374 375 void UIPopupStack::setDesiredWidth(int iWidth)376 {377 /* Propagate desired width to all the popup-panes we have: */378 foreach (UIPopupPane *pPane, m_panes)379 pPane->setDesiredWidth(iWidth - 2 * m_iStackLayoutMargin);380 }381 382 void UIPopupStack::layoutContent()383 {384 /* Get attributes: */385 const int iWidth = width();386 const int iHeight = height();387 int iX = m_iStackLayoutMargin;388 int iY = iHeight - m_iStackLayoutMargin;389 390 /* Layout every pane we have: */391 foreach (UIPopupPane *pPane, m_panes)392 {393 /* Get pane attributes: */394 const int iPaneWidth = iWidth - 2 * m_iStackLayoutMargin;395 const int iPaneHeight = pPane->minimumHeightHint();396 /* Adjust geometry for the pane: */397 pPane->move(iX, iY - iPaneHeight);398 pPane->resize(iPaneWidth, iPaneHeight);399 pPane->layoutContent();400 /* Increment placeholder: */401 iY -= (iPaneHeight + m_iStackLayoutSpacing);402 }403 }404 405 bool UIPopupStack::eventFilter(QObject *pWatched, QEvent *pEvent)406 {407 /* Make sure its parent event came: */408 if (pWatched != parent())409 return false;410 411 /* Make sure its resize event came: */412 if (pEvent->type() != QEvent::Resize)413 return false;414 415 /* Propagate desired width: */416 setDesiredWidth(parentWidget()->width());417 /* Adjust geometry: */418 sltAdjustGeometry();419 420 /* Do not filter anything: */421 return false;422 }423 424 void UIPopupStack::showEvent(QShowEvent *pEvent)425 {426 /* Make sure we should polish dialog: */427 if (m_fPolished)428 return;429 430 /* Call to polish-event: */431 polishEvent(pEvent);432 433 /* Mark dialog as polished: */434 m_fPolished = true;435 }436 437 void UIPopupStack::polishEvent(QShowEvent*)438 {439 /* Propagate desired width: */440 setDesiredWidth(parentWidget()->width());441 /* Adjust geometry: */442 sltAdjustGeometry();443 }444 445 /* static */446 int UIPopupStack::parentStatusBarHeight(QWidget *pParent)447 {448 /* Check if passed parent is QMainWindow and contains status-bar: */449 if (QMainWindow *pParentWindow = qobject_cast<QMainWindow*>(pParent))450 if (pParentWindow->statusBar())451 return pParentWindow->statusBar()->height();452 /* Zero by default: */453 return 0;454 }455 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIPopupCenter.h
r45658 r45659 28 28 class QWidget; 29 29 class UIPopupStack; 30 class UIPopupPane;31 30 32 31 /* Popup-center singleton: */ … … 46 45 static void destroy(); 47 46 48 /* API: Main message function, used directly only in exceptional cases: */ 47 /* API: Main message function. 48 * Provides up to two buttons. 49 * Used directly only in exceptional cases: */ 49 50 void message(QWidget *pParent, const QString &strId, 50 51 const QString &strMessage, const QString &strDetails, 51 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0,52 int iButton1 = 0, int iButton2 = 0, 52 53 const QString &strButtonText1 = QString(), 53 const QString &strButtonText2 = QString(), 54 const QString &strButtonText3 = QString()); 54 const QString &strButtonText2 = QString()); 55 55 56 56 /* API: Wrapper to 'message' function. … … 65 65 66 66 /* API: Wrapper to 'message' function. 67 * Omits details, provides two or three buttons: */ 67 * Omits details, provides up to two buttons. 68 * Used directly only in exceptional cases: */ 68 69 void question(QWidget *pParent, const QString &strId, 69 70 const QString &strMessage, 70 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0,71 int iButton1 = 0, int iButton2 = 0, 71 72 const QString &strButtonText1 = QString(), 72 const QString &strButtonText2 = QString(), 73 const QString &strButtonText3 = QString()); 73 const QString &strButtonText2 = QString()); 74 74 75 75 /* API: Wrapper to 'question' function, … … 80 80 const QString &strCancelButtonText = QString()); 81 81 82 /* API: Wrapper to 'question' function,83 * Question providing three buttons (Yes, No and Cancel by default): */84 void questionTrinary(QWidget *pParent, const QString &strId,85 const QString &strMessage,86 const QString &strChoice1ButtonText = QString(),87 const QString &strChoice2ButtonText = QString(),88 const QString &strCancelButtonText = QString());89 90 82 /* API: Runtime UI stuff: */ 91 void remindAboutMouseIntegration( bool fSupportsAbsolute, QWidget *pParent);83 void remindAboutMouseIntegration(QWidget *pParent, bool fSupportsAbsolute); 92 84 93 85 private slots: … … 105 97 void showPopupPane(QWidget *pParent, const QString &strPopupPaneID, 106 98 const QString &strMessage, const QString &strDetails, 107 int iButton1, int iButton2, int iButton3,108 const QString &strButtonText1, const QString &strButtonText2 , const QString &strButtonText3);99 int iButton1, int iButton2, 100 const QString &strButtonText1, const QString &strButtonText2); 109 101 110 /* Variable s: Popup-stack stuff: */102 /* Variable: Popup-stack stuff: */ 111 103 QMap<QString, QPointer<UIPopupStack> > m_stacks; 112 104 … … 120 112 inline UIPopupCenter& popupCenter() { return *UIPopupCenter::instance(); } 121 113 122 123 /* Qt includes: */124 #include <QWidget>125 126 /* Popup-stack prototype class: */127 class UIPopupStack : public QWidget128 {129 Q_OBJECT;130 131 signals:132 133 /* Notifier: Popup-pane stuff: */134 void sigPopupPaneDone(QString strID, int iButtonCode);135 136 /* Notifier: Popup-stack stuff: */137 void sigRemove();138 139 public:140 141 /* Constructor: */142 UIPopupStack(QWidget *pParent);143 144 /* API: Popup-pane stuff: */145 void updatePopupPane(const QString &strPopupPaneID,146 const QString &strMessage, const QString &strDetails,147 const QMap<int, QString> &buttonDescriptions);148 149 private slots:150 151 /* Handler: Layout stuff: */152 void sltAdjustGeometry();153 154 /* Handler: Popup-pane stuff: */155 void sltPopupPaneDone(int iButtonCode);156 157 private:158 159 /* Prepare stuff: */160 void prepare();161 162 /* Helpers: Layout stuff: */163 int minimumWidthHint();164 int minimumHeightHint();165 QSize minimumSizeHint();166 void setDesiredWidth(int iWidth);167 void layoutContent();168 169 /* Handler: Event-filter stuff: */170 bool eventFilter(QObject *pWatched, QEvent *pEvent);171 172 /* Handlers: Event stuff: */173 virtual void showEvent(QShowEvent *pEvent);174 virtual void polishEvent(QShowEvent *pEvent);175 176 /* Static helpers: Prepare stuff: */177 static int parentStatusBarHeight(QWidget *pParent);178 179 /* Variables: */180 bool m_fPolished;181 const int m_iStackLayoutMargin;182 const int m_iStackLayoutSpacing;183 QMap<QString, UIPopupPane*> m_panes;184 const int m_iParentStatusBarHeight;185 };186 187 114 #endif /* __UIPopupCenter_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.cpp
r45658 r45659 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * UIPopup Centerclass implementation5 * UIPopupStack class implementation 6 6 */ 7 7 … … 18 18 */ 19 19 20 /* GUI includes: */21 #include "UIPopupCenter.h"22 #include "UIPopupPane.h"23 24 /* Other VBox includes: */25 #include <VBox/sup.h>26 27 /* static */28 UIPopupCenter* UIPopupCenter::m_spInstance = 0;29 UIPopupCenter* UIPopupCenter::instance() { return m_spInstance; }30 31 /* static */32 void UIPopupCenter::create()33 {34 /* Make sure instance is NOT created yet: */35 if (m_spInstance)36 return;37 38 /* Create instance: */39 new UIPopupCenter;40 }41 42 /* static */43 void UIPopupCenter::destroy()44 {45 /* Make sure instance is NOT destroyed yet: */46 if (!m_spInstance)47 return;48 49 /* Destroy instance: */50 delete m_spInstance;51 }52 53 UIPopupCenter::UIPopupCenter()54 {55 /* Assign instance: */56 m_spInstance = this;57 }58 59 UIPopupCenter::~UIPopupCenter()60 {61 /* Unassign instance: */62 m_spInstance = 0;63 }64 65 void UIPopupCenter::message(QWidget *pParent, const QString &strId,66 const QString &strMessage, const QString &strDetails,67 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,68 const QString &strButtonText1 /* = QString() */,69 const QString &strButtonText2 /* = QString() */,70 const QString &strButtonText3 /* = QString() */)71 {72 showPopupPane(pParent, strId,73 strMessage, strDetails,74 iButton1, iButton2, iButton3,75 strButtonText1, strButtonText2, strButtonText3);76 }77 78 void UIPopupCenter::error(QWidget *pParent, const QString &strId,79 const QString &strMessage, const QString &strDetails)80 {81 message(pParent, strId,82 strMessage, strDetails,83 AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape);84 }85 86 void UIPopupCenter::alert(QWidget *pParent, const QString &strId,87 const QString &strMessage)88 {89 error(pParent, strId,90 strMessage, QString());91 }92 93 void UIPopupCenter::question(QWidget *pParent, const QString &strId,94 const QString &strMessage,95 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/,96 const QString &strButtonText1 /*= QString()*/,97 const QString &strButtonText2 /*= QString()*/,98 const QString &strButtonText3 /*= QString()*/)99 {100 message(pParent, strId,101 strMessage, QString(),102 iButton1, iButton2, iButton3,103 strButtonText1, strButtonText2, strButtonText3);104 }105 106 void UIPopupCenter::questionBinary(QWidget *pParent, const QString &strId,107 const QString &strMessage,108 const QString &strOkButtonText /*= QString()*/,109 const QString &strCancelButtonText /*= QString()*/)110 {111 question(pParent, strId,112 strMessage,113 AlertButton_Ok | AlertButtonOption_Default,114 AlertButton_Cancel | AlertButtonOption_Escape,115 0 /* third button */,116 strOkButtonText,117 strCancelButtonText,118 QString() /* third button */);119 }120 121 void UIPopupCenter::questionTrinary(QWidget *pParent, const QString &strId,122 const QString &strMessage,123 const QString &strChoice1ButtonText /*= QString()*/,124 const QString &strChoice2ButtonText /*= QString()*/,125 const QString &strCancelButtonText /*= QString()*/)126 {127 question(pParent, strId,128 strMessage,129 AlertButton_Choice1,130 AlertButton_Choice2 | AlertButtonOption_Default,131 AlertButton_Cancel | AlertButtonOption_Escape,132 strChoice1ButtonText,133 strChoice2ButtonText,134 strCancelButtonText);135 }136 137 void UIPopupCenter::showPopupPane(QWidget *pParent, const QString &strPopupPaneID,138 const QString &strMessage, const QString &strDetails,139 int iButton1, int iButton2, int iButton3,140 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3)141 {142 /* Looking for the corresponding popup-stack: */143 QString strPopupStackID = pParent->metaObject()->className();144 UIPopupStack *pPopupStack = 0;145 /* Is there already popup-stack with the same ID? */146 if (m_stacks.contains(strPopupStackID))147 {148 /* Get existing one: */149 pPopupStack = m_stacks[strPopupStackID];150 }151 /* There is no popup-stack with the same ID? */152 else153 {154 /* Create new one: */155 pPopupStack = m_stacks[strPopupStackID] = new UIPopupStack(pParent);156 /* Attach popup-stack connections: */157 connect(pPopupStack, SIGNAL(sigPopupPaneDone(QString, int)), this, SIGNAL(sigPopupPaneDone(QString, int)));158 connect(pPopupStack, SIGNAL(sigRemove()), this, SLOT(sltRemovePopupStack()));159 }160 /* Show popup-stack: */161 pPopupStack->show();162 163 /* Choose at least one button to be the 'default' and 'escape': */164 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)165 iButton1 = AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape;166 /* Compose button description map: */167 QMap<int, QString> buttonDescriptions;168 if (iButton1 != 0 && !buttonDescriptions.contains(iButton1))169 buttonDescriptions[iButton1] = strButtonText1;170 if (iButton2 != 0 && !buttonDescriptions.contains(iButton2))171 buttonDescriptions[iButton2] = strButtonText2;172 if (iButton3 != 0 && !buttonDescriptions.contains(iButton3))173 buttonDescriptions[iButton3] = strButtonText3;174 /* Update corresponding popup-pane: */175 pPopupStack->updatePopupPane(strPopupPaneID, strMessage, strDetails, buttonDescriptions);176 }177 178 void UIPopupCenter::sltRemovePopupStack()179 {180 /* Make sure the sender is the popup-stack: */181 UIPopupStack *pPopupStack = qobject_cast<UIPopupStack*>(sender());182 if (!pPopupStack)183 {184 AssertMsgFailed(("Should be called by popup-stack only!"));185 return;186 }187 188 /* Make sure the popup-stack still exists: */189 const QString strPopupStackID(m_stacks.key(pPopupStack, QString()));190 if (strPopupStackID.isNull())191 {192 AssertMsgFailed(("Popup-stack already destroyed!"));193 return;194 }195 196 /* Cleanup the popup-stack: */197 m_stacks.remove(strPopupStackID);198 delete pPopupStack;199 }200 201 void UIPopupCenter::remindAboutMouseIntegration(bool fSupportsAbsolute, QWidget *pParent)202 {203 if (fSupportsAbsolute)204 {205 alert(pParent, QString("remindAboutMouseIntegration"),206 tr("<p>The Virtual Machine reports that the guest OS supports <b>mouse pointer integration</b>. "207 "This means that you do not need to <i>capture</i> the mouse pointer to be able to use it in your guest OS -- "208 "all mouse actions you perform when the mouse pointer is over the Virtual Machine's display "209 "are directly sent to the guest OS. If the mouse is currently captured, it will be automatically uncaptured.</p>"210 "<p>The mouse icon on the status bar will look like <img src=:/mouse_seamless_16px.png/> to inform you "211 "that mouse pointer integration is supported by the guest OS and is currently turned on.</p>"212 "<p><b>Note</b>: Some applications may behave incorrectly in mouse pointer integration mode. "213 "You can always disable it for the current session (and enable it again) "214 "by selecting the corresponding action from the menu bar.</p>"));215 }216 else217 {218 alert(pParent, QString("remindAboutMouseIntegration"),219 tr("<p>The Virtual Machine reports that the guest OS does not support <b>mouse pointer integration</b> "220 "in the current video mode. You need to capture the mouse (by clicking over the VM display "221 "or pressing the host key) in order to use the mouse inside the guest OS.</p>"));222 }223 }224 225 226 20 /* Qt includes: */ 227 #include <QVBoxLayout>228 21 #include <QEvent> 229 22 #include <QMainWindow> 230 23 #include <QStatusBar> 24 25 /* GUI includes: */ 26 #include "UIPopupStack.h" 27 #include "UIPopupPane.h" 28 29 /* Other VBox includes: */ 30 #include <VBox/sup.h> 231 31 232 32 UIPopupStack::UIPopupStack(QWidget *pParent) … … 263 63 strMessage, strDetails, 264 64 buttonDescriptions); 265 pPopupPane->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);266 65 /* Attach popup-pane connection: */ 267 66 connect(pPopupPane, SIGNAL(sigSizeHintChanged()), this, SLOT(sltAdjustGeometry())); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupStack.h
r45658 r45659 2 2 * 3 3 * VBox frontends: Qt GUI ("VirtualBox"): 4 * UIPopup Centerclass declaration4 * UIPopupStack class declaration 5 5 */ 6 6 … … 17 17 */ 18 18 19 #ifndef __UIPopupCenter_h__ 20 #define __UIPopupCenter_h__ 21 22 /* Qt includes: */ 23 #include <QMap> 24 #include <QObject> 25 #include <QPointer> 26 27 /* Forward declaration: */ 28 class QWidget; 29 class UIPopupStack; 30 class UIPopupPane; 31 32 /* Popup-center singleton: */ 33 class UIPopupCenter: public QObject 34 { 35 Q_OBJECT; 36 37 signals: 38 39 /* Notifier: Popup-pane done stuff: */ 40 void sigPopupPaneDone(QString strID, int iButtonCode); 41 42 public: 43 44 /* Static API: Create/destroy stuff: */ 45 static void create(); 46 static void destroy(); 47 48 /* API: Main message function, used directly only in exceptional cases: */ 49 void message(QWidget *pParent, const QString &strId, 50 const QString &strMessage, const QString &strDetails, 51 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 52 const QString &strButtonText1 = QString(), 53 const QString &strButtonText2 = QString(), 54 const QString &strButtonText3 = QString()); 55 56 /* API: Wrapper to 'message' function. 57 * Provides single OK button: */ 58 void error(QWidget *pParent, const QString &strId, 59 const QString &strMessage, const QString &strDetails); 60 61 /* API: Wrapper to 'error' function. 62 * Omits details: */ 63 void alert(QWidget *pParent, const QString &strId, 64 const QString &strMessage); 65 66 /* API: Wrapper to 'message' function. 67 * Omits details, provides two or three buttons: */ 68 void question(QWidget *pParent, const QString &strId, 69 const QString &strMessage, 70 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, 71 const QString &strButtonText1 = QString(), 72 const QString &strButtonText2 = QString(), 73 const QString &strButtonText3 = QString()); 74 75 /* API: Wrapper to 'question' function, 76 * Question providing two buttons (OK and Cancel by default): */ 77 void questionBinary(QWidget *pParent, const QString &strId, 78 const QString &strMessage, 79 const QString &strOkButtonText = QString(), 80 const QString &strCancelButtonText = QString()); 81 82 /* API: Wrapper to 'question' function, 83 * Question providing three buttons (Yes, No and Cancel by default): */ 84 void questionTrinary(QWidget *pParent, const QString &strId, 85 const QString &strMessage, 86 const QString &strChoice1ButtonText = QString(), 87 const QString &strChoice2ButtonText = QString(), 88 const QString &strCancelButtonText = QString()); 89 90 /* API: Runtime UI stuff: */ 91 void remindAboutMouseIntegration(bool fSupportsAbsolute, QWidget *pParent); 92 93 private slots: 94 95 /* Handler: Popup-stack stuff: */ 96 void sltRemovePopupStack(); 97 98 private: 99 100 /* Constructor/destructor: */ 101 UIPopupCenter(); 102 ~UIPopupCenter(); 103 104 /* Helper: Popup-pane stuff: */ 105 void showPopupPane(QWidget *pParent, const QString &strPopupPaneID, 106 const QString &strMessage, const QString &strDetails, 107 int iButton1, int iButton2, int iButton3, 108 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3); 109 110 /* Variables: Popup-stack stuff: */ 111 QMap<QString, QPointer<UIPopupStack> > m_stacks; 112 113 /* Instance stuff: */ 114 static UIPopupCenter* m_spInstance; 115 static UIPopupCenter* instance(); 116 friend UIPopupCenter& popupCenter(); 117 }; 118 119 /* Shortcut to the static UIPopupCenter::instance() method: */ 120 inline UIPopupCenter& popupCenter() { return *UIPopupCenter::instance(); } 121 19 #ifndef __UIPopupStack_h__ 20 #define __UIPopupStack_h__ 122 21 123 22 /* Qt includes: */ 124 23 #include <QWidget> 24 #include <QMap> 25 26 /* Forward declaration: */ 27 class UIPopupPane; 125 28 126 29 /* Popup-stack prototype class: */ … … 157 60 private: 158 61 159 /* Prepare stuff: */62 /* Helper: Prepare stuff: */ 160 63 void prepare(); 161 64 … … 181 84 const int m_iStackLayoutMargin; 182 85 const int m_iStackLayoutSpacing; 86 const int m_iParentStatusBarHeight; 183 87 QMap<QString, UIPopupPane*> m_panes; 184 const int m_iParentStatusBarHeight;185 88 }; 186 89 187 #endif /* __UIPopup Center_h__ */90 #endif /* __UIPopupStack_h__ */
Note:
See TracChangeset
for help on using the changeset viewer.