Changeset 45297 in vbox
- Timestamp:
- Apr 3, 2013 8:58:04 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp
r45296 r45297 40 40 #endif /* Q_WS_MAC */ 41 41 42 /** @class QIMessageBox 43 * 44 * The QIMessageBox class is a message box similar to QMessageBox. 45 * It partly implements the QMessageBox interface and adds some enhanced 46 * functionality. 47 */ 48 49 /** 50 * See QMessageBox for details. 51 */ 52 QIMessageBox::QIMessageBox (const QString &aCaption, const QString &aText, 53 AlertIconType aIcon, int aButton0, int aButton1, int aButton2, 54 QWidget *aParent, const char *aName, bool aModal) 55 : QIDialog (aParent) 56 , mText (aText) 57 , mDetailsIndex (-1) 58 , mWasDone (false) 59 , mWasPolished (false) 60 { 61 setWindowTitle (aCaption); 62 /* Necessary to later find some of the message boxes */ 63 setObjectName (aName); 64 setModal (aModal); 65 66 mButton0 = aButton0; 67 mButton1 = aButton1; 68 mButton2 = aButton2; 42 QIMessageBox::QIMessageBox(const QString &strCaption, const QString &strMessage, AlertIconType icon, 43 int iButton1 /*= 0*/, int iButton2 /*= 0*/, int iButton3 /*= 0*/, QWidget *pParent /*= 0*/) 44 : QIDialog(pParent) 45 , mButton1(iButton1) 46 , mButton2(iButton2) 47 , mButton3(iButton3) 48 , m_strMessage(strMessage) 49 , m_iDetailsIndex(-1) 50 , m_fDone(false) 51 { 52 /* Set alert caption: */ 53 setWindowTitle(strCaption); 69 54 70 55 QVBoxLayout *layout = new QVBoxLayout (this); … … 85 70 86 71 mIconLabel = new QLabel(); 87 mIconLabel->setPixmap (standardPixmap ( aIcon));72 mIconLabel->setPixmap (standardPixmap (icon)); 88 73 mIconLabel->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Minimum); 89 74 mIconLabel->setAlignment (Qt::AlignHCenter | Qt::AlignTop); … … 95 80 hLayout->addLayout (messageVBoxLayout); 96 81 97 mTextLabel = new QILabel ( aText);82 mTextLabel = new QILabel (m_strMessage); 98 83 mTextLabel->setAlignment (Qt::AlignLeft | Qt::AlignTop); 99 84 mTextLabel->setWordWrap (true); … … 144 129 mButtonEsc = 0; 145 130 146 mButton0PB = createButton ( aButton0);131 mButton0PB = createButton (iButton1); 147 132 if (mButton0PB) 148 133 connect (mButton0PB, SIGNAL (clicked()), SLOT (done0())); 149 mButton1PB = createButton ( aButton1);134 mButton1PB = createButton (iButton2); 150 135 if (mButton1PB) 151 136 connect (mButton1PB, SIGNAL (clicked()), SLOT (done1())); 152 mButton2PB = createButton ( aButton2);137 mButton2PB = createButton (iButton3); 153 138 if (mButton2PB) 154 139 connect (mButton2PB, SIGNAL (clicked()), SLOT (done2())); … … 156 141 /* If this is an error message add an "Copy to clipboard" button for easier 157 142 * bug reports. */ 158 if ( aIcon == AlertIconType_Critical)143 if (icon == AlertIconType_Critical) 159 144 { 160 145 QPushButton *pCopyButton = createButton(AlertButton_Copy); … … 312 297 313 298 mDetailsSplitter->setMultiPaging (mDetailsList.size() > 1); 314 m DetailsIndex = 0;299 m_iDetailsIndex = 0; 315 300 refreshDetails(); 316 301 } … … 350 335 void QIMessageBox::closeEvent (QCloseEvent *e) 351 336 { 352 if (m WasDone)337 if (m_fDone) 353 338 e->accept(); 354 339 else … … 356 341 } 357 342 358 void QIMessageBox::showEvent (QShowEvent *e) 359 { 360 if (!mWasPolished) 361 { 362 /* Polishing sub-widgets */ 363 resize (minimumSizeHint()); 364 mTextLabel->useSizeHintForWidth (mTextLabel->width()); 365 mTextLabel->updateGeometry(); 366 setFixedSize(size()); 367 mDetailsSplitter->toggleWidget(); 368 mWasPolished = true; 369 } 370 371 QIDialog::showEvent (e); 343 void QIMessageBox::polishEvent(QShowEvent *pPolishEvent) 344 { 345 /* Tune our size: */ 346 resize(minimumSizeHint()); 347 mTextLabel->useSizeHintForWidth(mTextLabel->width()); 348 mTextLabel->updateGeometry(); 349 350 /* Call to base-class: */ 351 QIDialog::polishEvent(pPolishEvent); 352 353 /* Make the size fixed: */ 354 setFixedSize(size()); 355 356 /* Toggle details-widget: */ 357 mDetailsSplitter->toggleWidget(); 372 358 } 373 359 … … 375 361 { 376 362 /* Update message text iteself */ 377 mTextLabel->setText (m Text + mDetailsList [mDetailsIndex].first);363 mTextLabel->setText (m_strMessage + mDetailsList [m_iDetailsIndex].first); 378 364 /* Update details table */ 379 mDetailsText->setText (mDetailsList [m DetailsIndex].second);365 mDetailsText->setText (mDetailsList [m_iDetailsIndex].second); 380 366 setDetailsShown (!mDetailsText->toPlainText().isEmpty()); 381 367 … … 383 369 if (mDetailsList.size() > 1) 384 370 { 385 mDetailsSplitter->setButtonEnabled (true, m DetailsIndex < mDetailsList.size() - 1);386 mDetailsSplitter->setButtonEnabled (false, m DetailsIndex > 0);371 mDetailsSplitter->setButtonEnabled (true, m_iDetailsIndex < mDetailsList.size() - 1); 372 mDetailsSplitter->setButtonEnabled (false, m_iDetailsIndex > 0); 387 373 } 388 374 389 375 /* Update details label */ 390 376 mDetailsSplitter->setName (mDetailsList.size() == 1 ? tr ("&Details") : 391 tr ("&Details (%1 of %2)").arg (m DetailsIndex + 1).arg (mDetailsList.size()));377 tr ("&Details (%1 of %2)").arg (m_iDetailsIndex + 1).arg (mDetailsList.size())); 392 378 } 393 379 … … 445 431 void QIMessageBox::detailsBack() 446 432 { 447 if (m DetailsIndex > 0)448 { 449 -- m DetailsIndex;433 if (m_iDetailsIndex > 0) 434 { 435 -- m_iDetailsIndex; 450 436 refreshDetails(); 451 437 } … … 454 440 void QIMessageBox::detailsNext() 455 441 { 456 if (m DetailsIndex < mDetailsList.size() - 1)457 { 458 ++ m DetailsIndex;442 if (m_iDetailsIndex < mDetailsList.size() - 1) 443 { 444 ++ m_iDetailsIndex; 459 445 refreshDetails(); 460 446 } … … 473 459 { 474 460 /* Create the error string with all errors. First the html version. */ 475 QString strError = "<html><body><p>" + m Text+ "</p>";461 QString strError = "<html><body><p>" + m_strMessage + "</p>"; 476 462 for (int i = 0; i < mDetailsList.size(); ++i) 477 463 strError += mDetailsList.at(i).first + mDetailsList.at(i).second + "<br>"; -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h
r45296 r45297 83 83 public: 84 84 85 QIMessageBox(const QString &aCaption, const QString &aText,86 AlertIconType aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0,87 QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE);85 /* Constructor: */ 86 QIMessageBox(const QString &strCaption, const QString &strMessage, AlertIconType icon, 87 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, QWidget *pParent = 0); 88 88 89 89 QString buttonText (int aButton) const; … … 106 106 107 107 void closeEvent (QCloseEvent *e); 108 void showEvent (QShowEvent *e);108 void polishEvent(QShowEvent *pPolishEvent); 109 109 110 110 void refreshDetails(); … … 118 118 void detailsNext(); 119 119 120 void done0() { m WasDone = true; done (mButton0& AlertButtonMask); }121 void done1() { m WasDone = true; done (mButton1& AlertButtonMask); }122 void done2() { m WasDone = true; done (mButton2& AlertButtonMask); }120 void done0() { m_fDone = true; done (mButton1 & AlertButtonMask); } 121 void done1() { m_fDone = true; done (mButton2 & AlertButtonMask); } 122 void done2() { m_fDone = true; done (mButton3 & AlertButtonMask); } 123 123 124 124 void reject(); … … 128 128 private: 129 129 130 int mButton 0, mButton1, mButton2, mButtonEsc;130 int mButton1, mButton2, mButton3, mButtonEsc; 131 131 QLabel *mIconLabel; 132 132 QILabel *mTextLabel; … … 138 138 QSpacerItem *mSpacer; 139 139 QIDialogButtonBox *mButtonBox; 140 QString m Text;140 QString m_strMessage; 141 141 QList < QPair <QString, QString> > mDetailsList; 142 int mDetailsIndex; 143 bool mWasDone : 1; 144 bool mWasPolished : 1; 142 int m_iDetailsIndex; 143 bool m_fDone : 1; 145 144 }; 146 145 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r45296 r45297 3018 3018 QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon, 3019 3019 iButton1, iButton2, iButton3, 3020 pMessageBoxParent , strAutoConfirmId.toAscii().constData());3020 pMessageBoxParent); 3021 3021 mwManager().registerNewParent(pMessageBox, pMessageBoxParent); 3022 3022
Note:
See TracChangeset
for help on using the changeset viewer.