Changeset 20594 in vbox
- Timestamp:
- Jun 15, 2009 2:46:15 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProgressDialog.h
r20265 r20594 53 53 54 54 public: 55 55 56 VBoxProgressDialog (CProgress &aProgress, const QString &aTitle, 56 int aMinDuration = 2000, QWidget *aParent = NULL);57 int aMinDuration = 2000, QWidget *aParent = 0); 57 58 58 59 int run (int aRefreshInterval); … … 60 61 61 62 protected: 63 62 64 virtual void retranslateUi(); 63 65 64 66 virtual void reject(); 67 65 68 virtual void timerEvent (QTimerEvent *aEvent); 66 69 virtual void closeEvent (QCloseEvent *aEvent); 67 70 68 71 private slots: 72 73 void showDialog(); 69 74 void cancelOperation(); 70 75 71 76 private: 77 72 78 /* Private member vars */ 73 79 CProgress &mProgress; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r20123 r20594 249 249 int aMinDuration) 250 250 { 251 QApplication::setOverrideCursor (QCursor (Qt::WaitCursor)); 252 253 VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, 254 aParent); 251 VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, aParent); 255 252 256 253 /* run the dialog with the 100 ms refresh interval */ 257 254 progressDlg.run (100); 258 259 QApplication::restoreOverrideCursor();260 255 261 256 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProgressDialog.cpp
r20469 r20594 22 22 23 23 /* VBox includes */ 24 #include "COMDefs.h" 25 #include "QIDialogButtonBox.h" 26 #include "QILabel.h" 27 #include "VBoxGlobal.h" 24 28 #include "VBoxProgressDialog.h" 25 #include "COMDefs.h"26 #include "QILabel.h"27 #include "QIDialogButtonBox.h"28 #include "VBoxGlobal.h"29 29 30 30 #ifdef Q_WS_MAC … … 33 33 34 34 /* Qt includes */ 35 #include <QVBoxLayout> 35 #include <QCloseEvent> 36 #include <QEventLoop> 36 37 #include <QProgressBar> 37 38 #include <QTime> 38 #include <QEventLoop>39 #include <QCloseEvent>40 39 #include <QTimer> 40 #include <QVBoxLayout> 41 41 42 42 const char *VBoxProgressDialog::sOpDescTpl = "%1... (%2/%3)"; 43 43 44 VBoxProgressDialog::VBoxProgressDialog (CProgress &aProgress, const QString &aTitle, 45 int aMinDuration /* = 2000 */, QWidget *aParent /* = NULL */) 44 VBoxProgressDialog::VBoxProgressDialog (CProgress &aProgress, 45 const QString &aTitle, 46 int aMinDuration /* = 2000 */, 47 QWidget *aParent /* = 0 */) 46 48 : QIDialog (aParent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint) 47 49 , mProgress (aProgress) … … 83 85 .arg (mProgress.GetOperationDescription())); 84 86 mProgressBar->setMaximum (100); 85 setWindowTitle (QString ("%1: %2") 86 .arg (aTitle, mProgress.GetDescription())); 87 QTimer::singleShot (aMinDuration, this, SLOT (show())); 87 setWindowTitle (QString ("%1: %2").arg (aTitle, mProgress.GetDescription())); 88 88 mProgressBar->setValue (0); 89 89 mCancelEnabled = aProgress.GetCancelable(); 90 90 if (mCancelEnabled) 91 91 { 92 QDialogButtonBox *pBtnBox = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this); 92 QDialogButtonBox *pBtnBox = new QDialogButtonBox (QDialogButtonBox::Cancel, 93 Qt::Horizontal, this); 93 94 pLayout1->addWidget (pBtnBox); 94 connect (pBtnBox, SIGNAL (rejected()), 95 this, SLOT (cancelOperation())); 95 connect (pBtnBox, SIGNAL (rejected()), this, SLOT (cancelOperation())); 96 96 } 97 97 98 98 retranslateUi(); 99 100 /* The progress dialog will be shown automatically after 101 * the duration is over if progress is not finished yet. */ 102 QTimer::singleShot (aMinDuration, this, SLOT (showDialog())); 99 103 } 100 104 … … 111 115 int id = startTimer (aRefreshInterval); 112 116 113 /* The progress dialog is automatically shown after the duration is over */ 117 /* Set busy cursor */ 118 QApplication::setOverrideCursor (QCursor (Qt::WaitCursor)); 114 119 115 120 /* Enter the modal loop */ … … 124 129 } 125 130 131 void VBoxProgressDialog::showDialog() 132 { 133 /* We should not show progress-dialog 134 * if it was already finalized but not yet closed. 135 * This could happens in case of some other 136 * modal dialog prevents our event-loop from 137 * being exit overlapping 'this'. */ 138 if (!mEnded) 139 show(); 140 } 141 126 142 void VBoxProgressDialog::cancelOperation() 127 143 { … … 131 147 void VBoxProgressDialog::timerEvent (QTimerEvent * /* aEvent */) 132 148 { 149 /* We should hide progress-dialog 150 * if it was already finalized but not yet closed. 151 * This could happens in case of some other 152 * modal dialog prevents our event-loop from 153 * being exit overlapping 'this'. */ 154 if (mEnded && !isHidden()) 155 hide(); 156 133 157 if (!mEnded && (!mProgress.isOk() || mProgress.GetCompleted())) 134 158 { … … 153 177 if (mEnded) 154 178 { 155 /* Exit loop if it is running */156 179 if (mEventLoop->isRunning()) 180 { 181 /* Exit loop if it is running */ 157 182 mEventLoop->quit(); 183 184 /* Restore normal cursor */ 185 QApplication::restoreOverrideCursor(); 186 } 158 187 return; 159 188 } … … 166 195 if (newTime >= 0) 167 196 { 168 QTime time (0, 0);197 QTime time (0, 0); 169 198 time = time.addSecs (newTime); 170 199 mETA->setText (mETAText.arg (time.toString())); 171 }else 200 } 201 else 172 202 mETA->clear(); 173 203 /* Then operation text if changed */
Note:
See TracChangeset
for help on using the changeset viewer.