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

View File

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