progresswin.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "progresswin.h"
  2. #include <QCoreApplication>
  3. #include <QMessageBox>
  4. ProgressWin::ProgressWin(QWidget *parent)
  5. : QDialog(parent), m_curStep(0),m_isCancel(false)
  6. {
  7. ui.setupUi(this);
  8. }
  9. ProgressWin::~ProgressWin()
  10. {
  11. }
  12. void ProgressWin::info(QString text)
  13. {
  14. ui.output->append(text);
  15. }
  16. void ProgressWin::setTotalSteps(int step)
  17. {
  18. ui.progressBar->setValue(0);
  19. ui.progressBar->setMaximum(step);
  20. m_curStep = 0;
  21. }
  22. void ProgressWin::moveStep()
  23. {
  24. ++m_curStep;
  25. ui.progressBar->setValue(m_curStep);
  26. ui.progressBar->update();
  27. //QCoreApplication::processEvents();
  28. }
  29. int ProgressWin::getTotalStep()
  30. {
  31. return ui.progressBar->maximum();
  32. }
  33. void ProgressWin::setStep(int step)
  34. {
  35. ui.progressBar->setValue(step);
  36. ui.progressBar->update();
  37. m_curStep = step;
  38. //QCoreApplication::processEvents();
  39. }
  40. bool ProgressWin::isCancel()
  41. {
  42. return m_isCancel;
  43. }
  44. void ProgressWin::setCancel()
  45. {
  46. m_isCancel = true;
  47. emit quitClick();
  48. }
  49. void ProgressWin::closeEvent(QCloseEvent* e)
  50. {
  51. e->ignore();
  52. }
  53. void ProgressWin::slot_quitBt()
  54. {
  55. if (QMessageBox::Yes != QMessageBox::question(this, tr("Notice"), tr("Are you sure to cancel?")))
  56. {
  57. return;
  58. }
  59. m_isCancel = true;
  60. emit quitClick();
  61. }