CProgressDialog: Make use of in-class initializers where applicable

This commit is contained in:
Lioncash 2020-06-28 04:38:15 -04:00
parent 49c5947731
commit 152d638f7a
2 changed files with 11 additions and 14 deletions

View File

@ -5,11 +5,9 @@
CProgressDialog::CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent) CProgressDialog::CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent)
: IProgressNotifierUI(pParent) : IProgressNotifierUI(pParent)
, mpUI(new Ui::CProgressDialog) , mpUI(std::make_unique<Ui::CProgressDialog>())
, mUseBusyIndicator(UseBusyIndicator) , mUseBusyIndicator(UseBusyIndicator)
, mAlertOnFinish(AlertOnFinish) , mAlertOnFinish(AlertOnFinish)
, mFinished(false)
, mCanceled(false)
{ {
mpUI->setupUi(this); mpUI->setupUi(this);
mpUI->ProgressBar->setMinimum(0); mpUI->ProgressBar->setMinimum(0);
@ -37,10 +35,7 @@ CProgressDialog::CProgressDialog(QString OperationName, bool UseBusyIndicator, b
connect(mpUI->CancelButton, SIGNAL(pressed()), this, SLOT(CancelButtonClicked())); connect(mpUI->CancelButton, SIGNAL(pressed()), this, SLOT(CancelButtonClicked()));
} }
CProgressDialog::~CProgressDialog() CProgressDialog::~CProgressDialog() = default;
{
delete mpUI;
}
void CProgressDialog::DisallowCanceling() void CProgressDialog::DisallowCanceling()
{ {

View File

@ -15,6 +15,8 @@
#include <QtWinExtras/QWinTaskbarProgress> #include <QtWinExtras/QWinTaskbarProgress>
#endif #endif
#include <memory>
namespace Ui { namespace Ui {
class CProgressDialog; class CProgressDialog;
} }
@ -22,31 +24,31 @@ class CProgressDialog;
class CProgressDialog : public IProgressNotifierUI class CProgressDialog : public IProgressNotifierUI
{ {
Q_OBJECT Q_OBJECT
Ui::CProgressDialog *mpUI; std::unique_ptr<Ui::CProgressDialog> mpUI;
bool mUseBusyIndicator; bool mUseBusyIndicator;
bool mAlertOnFinish; bool mAlertOnFinish;
bool mFinished; bool mFinished = false;
bool mCanceled; bool mCanceled = false;
#ifdef WIN32 #ifdef WIN32
QWinTaskbarProgress *mpTaskbarProgress; QWinTaskbarProgress *mpTaskbarProgress;
#endif #endif
public: public:
explicit CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent = 0); explicit CProgressDialog(QString OperationName, bool UseBusyIndicator, bool AlertOnFinish, QWidget *pParent = nullptr);
~CProgressDialog(); ~CProgressDialog();
void DisallowCanceling(); void DisallowCanceling();
// IProgressNotifier interface // IProgressNotifier interface
virtual bool ShouldCancel() const; bool ShouldCancel() const override;
// Slots // Slots
public slots: public slots:
void closeEvent(QCloseEvent *pEvent); void closeEvent(QCloseEvent *pEvent) override;
void FinishAndClose(); void FinishAndClose();
void CancelButtonClicked(); void CancelButtonClicked();
void UpdateUI(const QString& rkTaskDesc, const QString& rkStepDesc, float ProgressPercent); void UpdateUI(const QString& rkTaskDesc, const QString& rkStepDesc, float ProgressPercent) override;
// Results // Results
protected: protected: