@@ -9,38 +9,33 @@ using namespace QtAutoUpdater;
99
1010UpdateButton::UpdateButton (QWidget *parent, UpdateController *controller) :
1111 QWidget(parent),
12- d_ptr (new UpdateButtonPrivate(this , controller))
12+ d (new UpdateButtonPrivate(this , controller))
1313{}
1414
1515UpdateButton::~UpdateButton (){}
1616
1717QString UpdateButton::animationFile () const
1818{
19- const Q_D (UpdateButton);
2019 return d->loadingGif ->fileName ();
2120}
2221
2322bool UpdateButton::isShowingResult () const
2423{
25- const Q_D (UpdateButton);
2624 return d->showResult ;
2725}
2826
2927UpdateController::DisplayLevel UpdateButton::displayLevel () const
3028{
31- const Q_D (UpdateButton);
3229 return d->level ;
3330}
3431
3532UpdateController *UpdateButton::controller () const
3633{
37- const Q_D (UpdateButton);
3834 return d->controller ;
3935}
4036
4137void UpdateButton::resetState ()
4238{
43- Q_D (UpdateButton);
4439 d->loadingGif ->setPaused (true );
4540 d->ui ->loaderLabel ->setVisible (false );
4641 d->ui ->statusLabel ->setVisible (false );
@@ -49,43 +44,37 @@ void UpdateButton::resetState()
4944
5045void UpdateButton::setAnimationFile (QString animationFile, int speed)
5146{
52- Q_D (UpdateButton);
5347 d->loadingGif ->setFileName (animationFile);
5448 d->loadingGif ->setSpeed (speed);
5549}
5650
5751void UpdateButton::setAnimationDevice (QIODevice *animationDevice, int speed)
5852{
59- Q_D (UpdateButton);
6053 d->loadingGif ->setDevice (animationDevice);
6154 d->loadingGif ->setSpeed (speed);
6255}
6356
6457void UpdateButton::resetAnimationFile ()
6558{
66- Q_D (UpdateButton);
6759 d->loadingGif ->setFileName (QStringLiteral (" :/QtAutoUpdater/icons/updateRunning.gif" ));
6860 d->loadingGif ->setSpeed (200 );
6961}
7062
7163void UpdateButton::setShowResult (bool showResult)
7264{
73- Q_D (UpdateButton);
7465 d->showResult = showResult;
7566}
7667
7768void UpdateButton::setDisplayLevel (UpdateController::DisplayLevel displayLevel)
7869{
79- Q_D (UpdateButton);
8070 d->level = displayLevel;
8171}
8272
8373bool UpdateButton::setController (UpdateController *controller)
8474{
85- Q_D (UpdateButton);
8675 if (d->loadingGif ->state () != QMovie::Running) {
8776 d->updateController (controller);
88- this -> resetState ();
77+ resetState ();
8978 emit controllerChanged (controller);
9079 return true ;
9180 } else
@@ -94,14 +83,12 @@ bool UpdateButton::setController(UpdateController *controller)
9483
9584void UpdateButton::startUpdate ()
9685{
97- Q_D (UpdateButton);
9886 if (!d->controller .isNull ())
9987 d->controller ->start (d->level );
10088}
10189
10290void UpdateButton::changeUpdaterState (bool isRunning)
10391{
104- Q_D (UpdateButton);
10592 if (isRunning && d->loadingGif ->state () != QMovie::Running) {
10693 d->loadingGif ->start ();
10794 d->ui ->loaderLabel ->setVisible (true );
@@ -118,8 +105,7 @@ void UpdateButton::changeUpdaterState(bool isRunning)
118105
119106void UpdateButton::updatesReady (bool hasUpdate, bool )
120107{
121- Q_D (UpdateButton);
122- this ->changeUpdaterState (false );
108+ changeUpdaterState (false );
123109 if (d->showResult ) {
124110 d->ui ->checkButton ->setEnabled (!hasUpdate);
125111 d->ui ->statusLabel ->setText (hasUpdate ? tr (" New Update!" ) : tr (" No new updates available" ));
@@ -129,39 +115,38 @@ void UpdateButton::updatesReady(bool hasUpdate, bool)
129115
130116void UpdateButton::controllerDestroyed ()
131117{
132- this -> resetState ();
133- this -> setDisabled (true );
118+ resetState ();
119+ setDisabled (true );
134120 emit controllerChanged (nullptr );
135121}
136122
137123// -----------------PRIVATE IMPLEMENTATION-----------------
138124
139125QtAutoUpdater::UpdateButtonPrivate::UpdateButtonPrivate (UpdateButton *q_ptr, UpdateController *controller) :
140- q_ptr (q_ptr),
126+ q (q_ptr),
141127 controller(nullptr ),
142128 ui(new Ui::UpdateButton),
143129 level(UpdateController::ExtendedInfoLevel),
144130 loadingGif(new QMovie(QStringLiteral(" :/QtAutoUpdater/icons/updateRunning.gif" ), QByteArray(), q_ptr)),
145131 showResult(true )
146132{
147- this -> ui ->setupUi (this -> q_ptr );
148- this -> loadingGif ->setSpeed (200 );
133+ ui->setupUi (q );
134+ loadingGif->setSpeed (200 );
149135
150- this -> ui ->loaderLabel ->setMovie (this -> loadingGif );
151- this -> ui ->loaderLabel ->setVisible (false );
152- this -> ui ->statusLabel ->setVisible (false );
136+ ui->loaderLabel ->setMovie (loadingGif);
137+ ui->loaderLabel ->setVisible (false );
138+ ui->statusLabel ->setVisible (false );
153139
154- QObject::connect (this -> ui ->checkButton , &QPushButton::clicked,
155- this -> q_ptr , &UpdateButton::startUpdate);
140+ QObject::connect (ui->checkButton , &QPushButton::clicked,
141+ q , &UpdateButton::startUpdate);
156142
157- this -> updateController (controller);
143+ updateController (controller);
158144}
159145
160146UpdateButtonPrivate::~UpdateButtonPrivate () {}
161147
162148void UpdateButtonPrivate::updateController (UpdateController *controller)
163149{
164- Q_Q (UpdateButton);
165150 this ->controller = controller;
166151 if (controller) {
167152 QObject::connect (this ->controller .data (), &UpdateController::runningChanged,
0 commit comments