Changeset 34479 in vbox
- Timestamp:
- Nov 29, 2010 4:44:03 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 added
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r34401 r34479 320 320 src/wizards/importappliance/UIImportApplianceWzd.h \ 321 321 src/widgets/UIBar.h \ 322 src/widgets/UIBootTable.h \ 322 323 src/widgets/UIDownloader.h \ 323 324 src/widgets/UIDownloaderAdditions.h \ 324 325 src/widgets/UIDownloaderUserManual.h \ 325 326 src/widgets/UIPopupBox.h \ 327 src/widgets/UIProgressDialog.h \ 326 328 src/widgets/UISpacerWidgets.h \ 327 329 src/widgets/UISpecialControls.h \ 328 330 src/widgets/VBoxApplianceEditorWgt.h \ 329 src/widgets/UIBootTable.h \330 331 src/widgets/VBoxExportApplianceWgt.h \ 331 332 src/widgets/VBoxFilePathSelectorWidget.h \ … … 336 337 src/widgets/VBoxOSTypeSelectorButton.h \ 337 338 src/widgets/VBoxOSTypeSelectorWidget.h \ 338 src/widgets/VBoxProgressDialog.h \339 339 src/widgets/VBoxWarningPane.h \ 340 340 src/selector/UIVMDesktop.h \ … … 483 483 src/wizards/importappliance/UIImportApplianceWzd.cpp \ 484 484 src/widgets/UIBar.cpp \ 485 src/widgets/UIBootTable.cpp \ 485 486 src/widgets/UIDownloader.cpp \ 486 487 src/widgets/UIDownloaderAdditions.cpp \ 487 488 src/widgets/UIDownloaderUserManual.cpp \ 488 489 src/widgets/UIPopupBox.cpp \ 490 src/widgets/UIProgressDialog.cpp \ 489 491 src/widgets/UISpecialControls.cpp \ 490 492 src/widgets/UIToolBar.cpp \ 491 493 src/widgets/VBoxApplianceEditorWgt.cpp \ 492 src/widgets/UIBootTable.cpp \493 494 src/widgets/VBoxExportApplianceWgt.cpp \ 494 495 src/widgets/VBoxFilePathSelectorWidget.cpp \ … … 500 501 src/widgets/VBoxOSTypeSelectorButton.cpp \ 501 502 src/widgets/VBoxOSTypeSelectorWidget.cpp \ 502 src/widgets/VBoxProgressDialog.cpp \503 503 src/widgets/VBoxWarningPane.cpp \ 504 504 src/selector/UIVMDesktop.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc
r31286 r34479 147 147 <file alias="attachment_remove_16px.png">images/attachment_remove_16px.png</file> 148 148 <file alias="attachment_remove_disabled_16px.png">images/attachment_remove_disabled_16px.png</file> 149 <file alias="progress_state_save_90px.png">images/progress_state_save_90px.png</file> 150 <file alias="progress_state_restore_90px.png">images/progress_state_restore_90px.png</file> 149 151 </qresource> 150 152 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r33683 r34479 1082 1082 if (hardDisk.isOk()) 1083 1083 { 1084 vboxProblem().showModalProgressDialog (progress, windowTitle(), parentWidget());1084 vboxProblem().showModalProgressDialog (progress, windowTitle(), "", parentWidget()); 1085 1085 if (progress.isOk() && progress.GetResultCode() == S_OK) 1086 1086 success = true; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r34374 r34479 5574 5574 /* I hope 1 minute will be enough to spawn any running VM silently, isn't it? */ 5575 5575 int iSpawningDuration = 60000; 5576 vboxProblem().showModalProgressDialog(progress, machine.GetName(), 0, iSpawningDuration);5576 vboxProblem().showModalProgressDialog(progress, machine.GetName(), "", 0, false, iSpawningDuration); 5577 5577 if (progress.GetResultCode() != 0) 5578 5578 vboxProblem().cannotOpenSession(vbox, machine, progress); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
r34343 r34479 22 22 #include "VBoxGlobal.h" 23 23 #include "VBoxSelectorWnd.h" 24 #include " VBoxProgressDialog.h"24 #include "UIProgressDialog.h" 25 25 #include "UIDownloaderUserManual.h" 26 26 #include "UIMachine.h" … … 286 286 * @param aMinDuration time (ms) that must pass before the dialog appears 287 287 */ 288 bool VBoxProblemReporter::showModalProgressDialog ( 289 CProgress &aProgress, const QString &aTitle, QWidget *aParent, 290 int aMinDuration) 291 { 292 VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, aParent ? aParent : mainWindowShown()); 293 288 bool VBoxProblemReporter::showModalProgressDialog(CProgress &progress, const QString &strTitle, const QString &strImage /* = "" */, QWidget *pParent /* = 0 */, bool fSheetOnDarwin /* = false */, int cMinDuration /* = 2000 */) 289 { 290 QPixmap *pPixmap = 0; 291 if (!strImage.isEmpty()) 292 pPixmap = new QPixmap(strImage); 293 294 UIProgressDialog progressDlg(progress, strTitle, pPixmap, fSheetOnDarwin, cMinDuration, pParent ? pParent : mainWindowShown()); 294 295 /* Run the dialog with the 350 ms refresh interval. */ 295 progressDlg.run (350); 296 progressDlg.run(350); 297 298 if (pPixmap) 299 delete pPixmap; 296 300 297 301 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
r34329 r34479 143 143 aAutoConfirmId, aOkText, aCancelText); } 144 144 145 bool showModalProgressDialog (CProgress &aProgress, const QString &aTitle, 146 QWidget *aParent, int aMinDuration = 2000); 145 bool showModalProgressDialog(CProgress &progress, const QString &strTitle, 146 const QString &strImage = "", QWidget *pParent = 0, 147 bool fSheetOnDarwin = false, int cMinDuration = 2000); 147 148 148 149 QWidget* mainWindowShown() const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r34471 r34479 320 320 { 321 321 /* Show the "VM saving" progress dialog: */ 322 vboxProblem().showModalProgressDialog(progress, machine.GetName(), 0, 0);322 vboxProblem().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_save_90px.png", 0, true); 323 323 if (progress.GetResultCode() != 0) 324 324 vboxProblem().cannotSaveMachineState(progress); … … 352 352 { 353 353 /* Show the power down progress dialog: */ 354 vboxProblem().showModalProgressDialog(progress, machine.GetName() , 0);354 vboxProblem().showModalProgressDialog(progress, machine.GetName()); 355 355 if (progress.GetResultCode() != 0) 356 356 vboxProblem().cannotStopMachine(progress); … … 371 371 { 372 372 /* Show the progress dialog: */ 373 vboxProblem().showModalProgressDialog(progress, machine.GetName() , 0);373 vboxProblem().showModalProgressDialog(progress, machine.GetName()); 374 374 if (progress.GetResultCode() != 0) 375 375 vboxProblem().cannotRestoreSnapshot(progress, snapshot.GetName()); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r34398 r34479 203 203 /* Show "Starting/Restoring" progress dialog: */ 204 204 if (isSaved()) 205 vboxProblem().showModalProgressDialog(progress, machine.GetName(), mainMachineWindow(), 0);205 vboxProblem().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_restore_90px.png", mainMachineWindow(), true, 0); 206 206 else 207 vboxProblem().showModalProgressDialog(progress, machine.GetName(), mainMachineWindow());207 vboxProblem().showModalProgressDialog(progress, machine.GetName(), "", mainMachineWindow()); 208 208 209 209 /* Check for a progress failure: */ … … 258 258 uimachine()->machineLogic()->setPreventAutoClose(true); 259 259 /* Show the power down progress dialog */ 260 vboxProblem().showModalProgressDialog(progress, machine.GetName(), mainMachineWindow());260 vboxProblem().showModalProgressDialog(progress, machine.GetName(), "", mainMachineWindow()); 261 261 if (progress.GetResultCode() != 0) 262 262 vboxProblem().cannotStopMachine(progress); … … 376 376 if (fResult) 377 377 { 378 vboxProblem().showModalProgressDialog(progressInstall, tr("Install"), 379 mainMachineWindow(), 500 /* 500ms delay. */);378 vboxProblem().showModalProgressDialog(progressInstall, tr("Install"), "", 379 mainMachineWindow(), false, 500 /* 500ms delay. */); 380 380 if (progressInstall.GetCanceled()) 381 381 return; … … 1009 1009 /* Check if we are in teleportation waiting mode. In that case no first run 1010 1010 * wizard is necessary. */ 1011 KMachineState state = machine.GetState();1011 m_machineState = machine.GetState(); 1012 1012 if ( isFirstTimeStarted() 1013 && !(( state == KMachineState_PoweredOff1014 || state == KMachineState_Aborted1015 || state == KMachineState_Teleported)1013 && !(( m_machineState == KMachineState_PoweredOff 1014 || m_machineState == KMachineState_Aborted 1015 || m_machineState == KMachineState_Teleported) 1016 1016 && machine.GetTeleporterEnabled())) 1017 1017 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r34453 r34479 770 770 if (machine.isOk()) 771 771 { 772 vboxProblem().showModalProgressDialog(progress, item->name(), 0, 0);772 vboxProblem().showModalProgressDialog(progress, item->name(), ""); 773 773 if (progress.GetResultCode() != 0) 774 774 vboxProblem().cannotDeleteMachine(machine); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
r33540 r34479 536 536 { 537 537 /* Show the progress dialog */ 538 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), 538 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), "", 539 539 vboxProblem().mainWindowShown()); 540 540 … … 582 582 { 583 583 /* Show the progress dialog */ 584 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), 584 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), "", 585 585 vboxProblem().mainWindowShown()); 586 586 … … 653 653 { 654 654 /* Show the progress dialog */ 655 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), 655 vboxProblem().showModalProgressDialog (progress, mMachine.GetName(), "", 656 656 vboxProblem().mainWindowShown()); 657 657 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp
r34443 r34479 3 3 * 4 4 * VBox frontends: Qt GUI ("VirtualBox"): 5 * VBoxProgressDialog class implementation5 * UIProgressDialog class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 2006-20 09Oracle Corporation9 * Copyright (C) 2006-2010 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 20 20 /* VBox includes */ 21 #include "UIProgressDialog.h" 21 22 #include "COMDefs.h" 22 23 #include "QIDialogButtonBox.h" 23 24 #include "QILabel.h" 25 #include "UISpecialControls.h" 24 26 #include "VBoxGlobal.h" 25 #include "VBoxProgressDialog.h" 26 #include "UISpecialControls.h" 27 27 28 #ifdef Q_WS_MAC 28 29 # include "VBoxUtils-darwin.h" 29 #endif 30 #endif /* Q_WS_MAC */ 30 31 31 32 /* Qt includes */ … … 42 43 #define VBOX_DAY VBOX_HOUR * 24 43 44 44 const char *VBoxProgressDialog::sOpDescTpl = "%1... (%2/%3)"; 45 46 VBoxProgressDialog::VBoxProgressDialog (CProgress &aProgress, 47 const QString &aTitle, 48 int aMinDuration /* = 2000 */, 49 QWidget *aParent /* = 0 */) 50 // : QIDialog (aParent, Qt::Sheet | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint) 51 : QIDialog (aParent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint) 52 , mProgress (aProgress) 53 , mCancelBtn (0) 54 , mCancelEnabled (false) 55 , mOpCount (mProgress.GetOperationCount()) 56 , mCurOp (mProgress.GetOperation() + 1) 57 , mEnded (false) 58 { 59 setModal (true); 60 61 QVBoxLayout *pLayout1 = new QVBoxLayout (this); 45 const char *UIProgressDialog::m_spcszOpDescTpl = "%1 ... (%2/%3)"; 46 47 UIProgressDialog::UIProgressDialog(CProgress &progress, 48 const QString &strTitle, 49 QPixmap *pImage /* = 0 */, 50 bool fSheetOnDarwin /* = false */, 51 int cMinDuration /* = 2000 */, 52 QWidget *pParent /* = 0 */) 53 // : QIDialog(aParent, Qt::Sheet | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint) 54 : QIDialog(pParent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint) 55 , m_progress(progress) 56 , m_pImageLbl(0) 57 , m_pCancelBtn(0) 58 , m_fCancelEnabled(false) 59 , m_cOperations(m_progress.GetOperationCount()) 60 , m_iCurrentOperation(m_progress.GetOperation() + 1) 61 , m_fEnded(false) 62 { 63 setModal(true); 64 65 QHBoxLayout *pLayout0 = new QHBoxLayout(this); 62 66 63 67 #ifdef Q_WS_MAC 64 ::darwinSetHidesAllTitleButtons (this); 65 ::darwinSetShowsResizeIndicator (this, false); 66 VBoxGlobal::setLayoutMargin (pLayout1, 6); 68 /* No sheets in another mode than normal for now. Firstly it looks ugly and 69 * secondly in some cases it is broken. */ 70 if ( fSheetOnDarwin 71 && vboxGlobal().isSheetWindowsAllowed(pParent)) 72 setWindowFlags(Qt::Sheet); 73 ::darwinSetHidesAllTitleButtons(this); 74 ::darwinSetShowsResizeIndicator(this, false); 75 if (pImage) 76 pLayout0->setContentsMargins(30, 15, 30, 15); 77 else 78 pLayout0->setContentsMargins(6, 6, 6, 6); 79 #else 80 NOREF(fSheetOnDarwin); 67 81 #endif /* Q_WS_MAC */ 68 82 69 mLabel = new QILabel (this); 70 pLayout1->addWidget (mLabel, 0, Qt::AlignHCenter); 83 if (pImage) 84 { 85 m_pImageLbl = new QILabel(this); 86 m_pImageLbl->setPixmap(*pImage); 87 pLayout0->addWidget(m_pImageLbl); 88 } 89 90 QVBoxLayout *pLayout1 = new QVBoxLayout(); 91 pLayout1->setMargin(0); 92 pLayout0->addLayout(pLayout1); 93 pLayout1->addStretch(1); 94 m_pDescriptionLbl = new QILabel(this); 95 pLayout1->addWidget(m_pDescriptionLbl, 0, Qt::AlignHCenter); 71 96 72 97 QHBoxLayout *pLayout2 = new QHBoxLayout(); 73 pLayout2->setMargin 74 pLayout1->addLayout 75 76 m ProgressBar = new QProgressBar(this);77 pLayout2->addWidget (mProgressBar, 0, Qt::AlignVCenter);78 79 if (m OpCount> 1)80 m Label->setText (QString (sOpDescTpl)81 .arg (mProgress.GetOperationDescription())82 .arg (mCurOp).arg (mOpCount));98 pLayout2->setMargin(0); 99 pLayout1->addLayout(pLayout2); 100 101 m_progressBar = new QProgressBar(this); 102 pLayout2->addWidget(m_progressBar, 0, Qt::AlignVCenter); 103 104 if (m_cOperations > 1) 105 m_pDescriptionLbl->setText(QString(m_spcszOpDescTpl) 106 .arg(m_progress.GetOperationDescription()) 107 .arg(m_iCurrentOperation).arg(m_cOperations)); 83 108 else 84 mLabel->setText (QString ("%1...") 85 .arg (mProgress.GetOperationDescription())); 86 mProgressBar->setMaximum (100); 87 setWindowTitle (QString ("%1: %2").arg (aTitle, mProgress.GetDescription())); 88 mProgressBar->setValue (0); 89 mCancelEnabled = aProgress.GetCancelable(); 90 if (mCancelEnabled) 91 { 92 mCancelBtn = new UIMiniCancelButton (this); 93 mCancelBtn->setFocusPolicy (Qt::ClickFocus); 94 pLayout2->addWidget (mCancelBtn, 0, Qt::AlignVCenter); 95 connect (mCancelBtn, SIGNAL (clicked()), this, SLOT (cancelOperation())); 96 } 97 98 mETA = new QILabel (this); 99 pLayout1->addWidget (mETA, 0, Qt::AlignLeft | Qt::AlignVCenter); 100 101 setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); 109 m_pDescriptionLbl->setText(QString("%1 ...") 110 .arg(m_progress.GetOperationDescription())); 111 m_progressBar->setMaximum(100); 112 setWindowTitle(QString("%1: %2").arg(strTitle, m_progress.GetDescription())); 113 m_progressBar->setValue(0); 114 m_fCancelEnabled = m_progress.GetCancelable(); 115 if (m_fCancelEnabled) 116 { 117 m_pCancelBtn = new UIMiniCancelButton(this); 118 m_pCancelBtn->setFocusPolicy(Qt::ClickFocus); 119 pLayout2->addWidget(m_pCancelBtn, 0, Qt::AlignVCenter); 120 connect(m_pCancelBtn, SIGNAL(clicked()), this, SLOT(cancelOperation())); 121 } 122 123 m_pEtaLbl = new QILabel(this); 124 pLayout1->addWidget(m_pEtaLbl, 0, Qt::AlignLeft | Qt::AlignVCenter); 125 126 pLayout1->addStretch(1); 127 128 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 102 129 103 130 retranslateUi(); … … 105 132 /* The progress dialog will be shown automatically after 106 133 * the duration is over if progress is not finished yet. */ 107 QTimer::singleShot (aMinDuration, this, SLOT(showDialog()));108 } 109 110 void VBoxProgressDialog::retranslateUi()111 { 112 m CancelText = tr("Canceling...");113 if (m CancelBtn)114 { 115 m CancelBtn->setText (tr("&Cancel"));116 m CancelBtn->setToolTip (tr("Cancel the current operation"));117 } 118 } 119 120 int VBoxProgressDialog::run (int aRefreshInterval)121 { 122 if (m Progress.isOk())134 QTimer::singleShot(cMinDuration, this, SLOT(showDialog())); 135 } 136 137 void UIProgressDialog::retranslateUi() 138 { 139 m_strCancel = tr("Canceling..."); 140 if (m_pCancelBtn) 141 { 142 m_pCancelBtn->setText(tr("&Cancel")); 143 m_pCancelBtn->setToolTip(tr("Cancel the current operation")); 144 } 145 } 146 147 int UIProgressDialog::run(int cRefreshInterval) 148 { 149 if (m_progress.isOk()) 123 150 { 124 151 /* Start refresh timer */ 125 int id = startTimer (aRefreshInterval);152 int id = startTimer(cRefreshInterval); 126 153 127 154 /* Set busy cursor */ 128 QApplication::setOverrideCursor (QCursor(Qt::WaitCursor));155 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 129 156 130 157 /* Enter the modal loop, but don't show the window immediately */ 131 exec 158 exec(false); 132 159 133 160 /* Kill refresh timer */ 134 killTimer 161 killTimer(id); 135 162 136 163 QApplication::restoreOverrideCursor(); … … 141 168 } 142 169 143 void VBoxProgressDialog::showDialog() 170 void UIProgressDialog::reject() 171 { 172 if (m_fCancelEnabled) 173 cancelOperation(); 174 } 175 176 void UIProgressDialog::timerEvent(QTimerEvent * /* pEvent */) 177 { 178 /* We should hide progress-dialog 179 * if it was already finalized but not yet closed. 180 * This could happens in case of some other 181 * modal dialog prevents our event-loop from 182 * being exit overlapping 'this'. */ 183 if (m_fEnded && !isHidden()) 184 { 185 hide(); 186 return; 187 } 188 else if (m_fEnded) 189 return; 190 191 if (!m_fEnded && (!m_progress.isOk() || m_progress.GetCompleted())) 192 { 193 /* Progress finished */ 194 if (m_progress.isOk()) 195 { 196 m_progressBar->setValue(100); 197 done(Accepted); 198 } 199 /* Progress is not valid */ 200 else 201 done(Rejected); 202 203 /* Request to exit loop */ 204 m_fEnded = true; 205 return; 206 } 207 208 if (!m_progress.GetCanceled()) 209 { 210 /* Update the progress dialog */ 211 /* First ETA */ 212 long newTime = m_progress.GetTimeRemaining(); 213 QDateTime time; 214 time.setTime_t(newTime); 215 QDateTime refTime; 216 refTime.setTime_t(0); 217 218 int days = refTime.daysTo(time); 219 int hours = time.addDays(-days).time().hour(); 220 int minutes = time.addDays(-days).time().minute(); 221 int seconds = time.addDays(-days).time().second(); 222 223 QString strDays = VBoxGlobal::daysToString(days); 224 QString strHours = VBoxGlobal::hoursToString(hours); 225 QString strMinutes = VBoxGlobal::minutesToString(minutes); 226 QString strSeconds = VBoxGlobal::secondsToString(seconds); 227 228 QString strTwoComp = tr("%1, %2 remaining", "You may wish to translate this more like \"Time remaining: %1, %2\""); 229 QString strOneComp = tr("%1 remaining", "You may wish to translate this more like \"Time remaining: %1\""); 230 231 if (newTime > VBOX_DAY * 2 + VBOX_HOUR) 232 m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours)); 233 else if (newTime > VBOX_DAY * 2 + VBOX_MINUTE * 5) 234 m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes)); 235 else if (newTime > VBOX_DAY * 2) 236 m_pEtaLbl->setText(strOneComp.arg(strDays)); 237 else if (newTime > VBOX_DAY + VBOX_HOUR) 238 m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours)); 239 else if (newTime > VBOX_DAY + VBOX_MINUTE * 5) 240 m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes)); 241 else if (newTime > VBOX_HOUR * 23 + VBOX_MINUTE * 55) 242 m_pEtaLbl->setText(strOneComp.arg(strDays)); 243 else if (newTime >= VBOX_HOUR * 2) 244 m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes)); 245 else if (newTime > VBOX_HOUR + VBOX_MINUTE * 5) 246 m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes)); 247 else if (newTime > VBOX_MINUTE * 55) 248 m_pEtaLbl->setText(strOneComp.arg(strHours)); 249 else if (newTime > VBOX_MINUTE * 2) 250 m_pEtaLbl->setText(strOneComp.arg(strMinutes)); 251 else if (newTime > VBOX_MINUTE + VBOX_SECOND * 5) 252 m_pEtaLbl->setText(strTwoComp.arg(strMinutes).arg(strSeconds)); 253 else if (newTime > VBOX_SECOND * 55) 254 m_pEtaLbl->setText(strOneComp.arg(strMinutes)); 255 else if (newTime > VBOX_SECOND * 5) 256 m_pEtaLbl->setText(strOneComp.arg(strSeconds)); 257 else if (newTime >= 0) 258 m_pEtaLbl->setText(tr("A few seconds remaining")); 259 else 260 m_pEtaLbl->clear(); 261 262 /* Then operation text if changed */ 263 ulong newOp = m_progress.GetOperation() + 1; 264 if (newOp != m_iCurrentOperation) 265 { 266 m_iCurrentOperation = newOp; 267 m_pDescriptionLbl->setText(QString(m_spcszOpDescTpl) 268 .arg(m_progress.GetOperationDescription()) 269 .arg(m_iCurrentOperation).arg(m_cOperations)); 270 } 271 m_progressBar->setValue(m_progress.GetPercent()); 272 }else 273 m_pEtaLbl->setText(m_strCancel); 274 } 275 276 void UIProgressDialog::closeEvent(QCloseEvent *pEvent) 277 { 278 if (m_fCancelEnabled) 279 cancelOperation(); 280 else 281 pEvent->ignore(); 282 } 283 284 void UIProgressDialog::showDialog() 144 285 { 145 286 /* We should not show progress-dialog … … 148 289 * modal dialog prevents our event-loop from 149 290 * being exit overlapping 'this'. */ 150 if (!m Ended)291 if (!m_fEnded) 151 292 show(); 152 293 } 153 294 154 void VBoxProgressDialog::cancelOperation() 155 { 156 if (mCancelBtn) 157 mCancelBtn->setEnabled (false); 158 mProgress.Cancel(); 159 } 160 161 void VBoxProgressDialog::timerEvent (QTimerEvent * /* aEvent */) 162 { 163 /* We should hide progress-dialog 164 * if it was already finalized but not yet closed. 165 * This could happens in case of some other 166 * modal dialog prevents our event-loop from 167 * being exit overlapping 'this'. */ 168 if (mEnded && !isHidden()) 169 { 170 hide(); 171 return; 172 } 173 else if (mEnded) 174 return; 175 176 if (!mEnded && (!mProgress.isOk() || mProgress.GetCompleted())) 177 { 178 /* Progress finished */ 179 if (mProgress.isOk()) 180 { 181 mProgressBar->setValue (100); 182 done (Accepted); 183 } 184 /* Progress is not valid */ 185 else 186 done (Rejected); 187 188 /* Request to exit loop */ 189 mEnded = true; 190 return; 191 } 192 193 if (!mProgress.GetCanceled()) 194 { 195 /* Update the progress dialog */ 196 /* First ETA */ 197 long newTime = mProgress.GetTimeRemaining(); 198 QDateTime time; 199 time.setTime_t (newTime); 200 QDateTime refTime; 201 refTime.setTime_t (0); 202 203 int days = refTime.daysTo (time); 204 int hours = time.addDays (-days).time().hour(); 205 int minutes = time.addDays (-days).time().minute(); 206 int seconds = time.addDays (-days).time().second(); 207 208 QString strDays = VBoxGlobal::daysToString(days); 209 QString strHours = VBoxGlobal::hoursToString(hours); 210 QString strMinutes = VBoxGlobal::minutesToString(minutes); 211 QString strSeconds = VBoxGlobal::secondsToString(seconds); 212 213 QString strTwoComp = tr ("%1, %2 remaining", "You may wish to translate this more like \"Time remaining: %1, %2\""); 214 QString strOneComp = tr ("%1 remaining", "You may wish to translate this more like \"Time remaining: %1\""); 215 216 if (newTime > VBOX_DAY * 2 + VBOX_HOUR) 217 mETA->setText (strTwoComp.arg (strDays).arg (strHours)); 218 else if (newTime > VBOX_DAY * 2 + VBOX_MINUTE * 5) 219 mETA->setText (strTwoComp.arg (strDays).arg (strMinutes)); 220 else if (newTime > VBOX_DAY * 2) 221 mETA->setText (strOneComp.arg (strDays)); 222 else if (newTime > VBOX_DAY + VBOX_HOUR) 223 mETA->setText (strTwoComp.arg (strDays).arg (strHours)); 224 else if (newTime > VBOX_DAY + VBOX_MINUTE * 5) 225 mETA->setText (strTwoComp.arg (strDays).arg (strMinutes)); 226 else if (newTime > VBOX_HOUR * 23 + VBOX_MINUTE * 55) 227 mETA->setText (strOneComp.arg (strDays)); 228 else if (newTime >= VBOX_HOUR * 2) 229 mETA->setText (strTwoComp.arg (strHours).arg (strMinutes)); 230 else if (newTime > VBOX_HOUR + VBOX_MINUTE * 5) 231 mETA->setText (strTwoComp.arg (strHours).arg (strMinutes)); 232 else if (newTime > VBOX_MINUTE * 55) 233 mETA->setText (strOneComp.arg (strHours)); 234 else if (newTime > VBOX_MINUTE * 2) 235 mETA->setText (strOneComp.arg (strMinutes)); 236 else if (newTime > VBOX_MINUTE + VBOX_SECOND * 5) 237 mETA->setText (strTwoComp.arg (strMinutes).arg (strSeconds)); 238 else if (newTime > VBOX_SECOND * 55) 239 mETA->setText (strOneComp.arg (strMinutes)); 240 else if (newTime > VBOX_SECOND * 5) 241 mETA->setText (strOneComp.arg (strSeconds)); 242 else if (newTime >= 0) 243 mETA->setText (tr ("A few seconds remaining")); 244 else 245 mETA->clear(); 246 247 /* Then operation text if changed */ 248 ulong newOp = mProgress.GetOperation() + 1; 249 if (newOp != mCurOp) 250 { 251 mCurOp = newOp; 252 mLabel->setText (QString (sOpDescTpl) 253 .arg (mProgress.GetOperationDescription()) 254 .arg (mCurOp).arg (mOpCount)); 255 } 256 mProgressBar->setValue (mProgress.GetPercent()); 257 }else 258 mETA->setText (mCancelText); 259 } 260 261 void VBoxProgressDialog::reject() 262 { 263 if (mCancelEnabled) 264 cancelOperation(); 265 } 266 267 void VBoxProgressDialog::closeEvent (QCloseEvent *aEvent) 268 { 269 if (mCancelEnabled) 270 cancelOperation(); 271 else 272 aEvent->ignore(); 273 } 274 295 void UIProgressDialog::cancelOperation() 296 { 297 if (m_pCancelBtn) 298 m_pCancelBtn->setEnabled(false); 299 m_progress.Cancel(); 300 } 301 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.h
r34443 r34479 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * VBoxProgressDialog class declaration4 * UIProgressDialog class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2009 Oracle Corporation8 * Copyright (C) 2009-2010 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __ VBoxProgressDialog_h__20 #define __ VBoxProgressDialog_h__19 #ifndef __UIProgressDialog_h__ 20 #define __UIProgressDialog_h__ 21 21 22 22 /* Qt includes */ … … 41 41 * @note The CProgress instance is passed as a non-const reference to the 42 42 * constructor (to memorize COM errors if they happen), and therefore must 43 * not be destroyed before the created VBoxProgressDialog instance is43 * not be destroyed before the created UIProgressDialog instance is 44 44 * destroyed. 45 45 */ 46 class VBoxProgressDialog: protected QIDialog46 class UIProgressDialog: protected QIDialog 47 47 { 48 48 Q_OBJECT; 49 49 50 50 public: 51 VBoxProgressDialog (CProgress &aProgress, const QString &aTitle,52 int aMinDuration = 2000, QWidget *aParent = 0);53 51 54 int run (int aRefreshInterval); 55 bool cancelEnabled() const { return mCancelEnabled; } 52 UIProgressDialog(CProgress &progress, const QString &strTitle, 53 QPixmap *pImage = 0, bool fSheetOnDarwin = false, 54 int cMinDuration = 2000, QWidget *pParent = 0); 55 56 int run(int aRefreshInterval); 57 bool cancelEnabled() const { return m_fCancelEnabled; } 56 58 57 59 protected: 60 58 61 virtual void retranslateUi(); 59 62 60 63 virtual void reject(); 61 64 62 virtual void timerEvent (QTimerEvent *aEvent);63 virtual void closeEvent (QCloseEvent *aEvent);65 virtual void timerEvent(QTimerEvent *pEvent); 66 virtual void closeEvent(QCloseEvent *pEvent); 64 67 65 68 private slots: 69 66 70 void showDialog(); 67 71 void cancelOperation(); 68 72 69 73 private: 74 70 75 /* Private member vars */ 71 CProgress &mProgress; 72 QILabel *mLabel; 73 QILabel *mETA; 74 QString mCancelText; 75 QProgressBar *mProgressBar; 76 UIMiniCancelButton *mCancelBtn; 77 bool mCancelEnabled; 78 const ulong mOpCount; 79 ulong mCurOp; 80 bool mEnded; 76 CProgress &m_progress; 77 QILabel *m_pImageLbl; 78 QILabel *m_pDescriptionLbl; 79 QILabel *m_pEtaLbl; 80 QString m_strCancel; 81 QProgressBar *m_progressBar; 82 UIMiniCancelButton *m_pCancelBtn; 83 bool m_fCancelEnabled; 84 const ulong m_cOperations; 85 ulong m_iCurrentOperation; 86 bool m_fEnded; 81 87 82 static const char * sOpDescTpl;88 static const char *m_spcszOpDescTpl; 83 89 }; 84 90 85 #endif /* __ VBoxProgressDialog_h__ */91 #endif /* __UIProgressDialog_h__ */ 86 92 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxImportApplianceWgt.cpp
r33079 r34479 61 61 { 62 62 /* Show some progress, so the user know whats going on */ 63 vboxProblem().showModalProgressDialog (progress, tr ("Reading Appliance ..."), this);63 vboxProblem().showModalProgressDialog (progress, tr ("Reading Appliance ..."), "", this); 64 64 if (!progress.isOk() || progress.GetResultCode() != 0) 65 65 { … … 135 135 { 136 136 /* Show some progress, so the user know whats going on */ 137 vboxProblem().showModalProgressDialog (progress, tr ("Importing Appliance ..."), this);137 vboxProblem().showModalProgressDialog (progress, tr ("Importing Appliance ..."), "", this); 138 138 if (progress.GetCanceled()) 139 139 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIExportApplianceWzd.cpp
r34065 r34479 584 584 { 585 585 /* Show some progress, so the user know whats going on */ 586 vboxProblem().showModalProgressDialog(progress, tr("Checking files ..."), this);586 vboxProblem().showModalProgressDialog(progress, tr("Checking files ..."), "", this); 587 587 if (progress.GetCanceled()) 588 588 return false; … … 605 605 { 606 606 /* Show some progress, so the user know whats going on */ 607 vboxProblem().showModalProgressDialog(progress1, tr("Removing files ..."), this);607 vboxProblem().showModalProgressDialog(progress1, tr("Removing files ..."), "", this); 608 608 if (progress1.GetCanceled()) 609 609 return false; … … 641 641 { 642 642 /* Show some progress, so the user know whats going on */ 643 vboxProblem().showModalProgressDialog(progress, tr("Exporting Appliance ..."), this);643 vboxProblem().showModalProgressDialog(progress, tr("Exporting Appliance ..."), "", this); 644 644 if (progress.GetCanceled()) 645 645 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWzd.cpp
r33824 r34479 522 522 } 523 523 524 vboxProblem().showModalProgressDialog(progress, windowTitle(), parentWidget());524 vboxProblem().showModalProgressDialog(progress, windowTitle(), "", parentWidget()); 525 525 526 526 if (progress.GetCanceled()) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r33882 r34479 496 496 if (m_HardDisk.isOk()) 497 497 { 498 vboxProblem().showModalProgressDialog(progress, windowTitle(), this);498 vboxProblem().showModalProgressDialog(progress, windowTitle(), "", this); 499 499 if (progress.isOk() && progress.GetResultCode() == S_OK) 500 500 success = true;
Note:
See TracChangeset
for help on using the changeset viewer.