Skip to content

Commit 0159cc5

Browse files
committed
same for gui
1 parent 204b4e6 commit 0159cc5

13 files changed

+78
-117
lines changed

src/autoupdatergui/adminauthorization_win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool AdminAuthorization::executeAsAdmin(const QString &program, const QStringLis
8686
// administrator yet and the computer's policies are set to not use UAC (which is the case
8787
// in some corporate networks), the call to execute() will simply succeed and not at all
8888
// launch the child process. To avoid this, we detect this situation here and return early.
89-
if (!this->hasAdminRights()) {
89+
if (!hasAdminRights()) {
9090
QLatin1String key("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
9191
QSettings registry(key, QSettings::NativeFormat);
9292
const QVariant enableLUA = registry.value(QLatin1String("EnableLUA"));

src/autoupdatergui/adminauthorization_x11.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ bool AdminAuthorization::executeAsAdmin(const QString &program, const QStringLis
8585
tmpList.append(arguments);
8686
args.append(QLatin1Char('\"') + tmpList.join(QStringLiteral("\" \"")) + QLatin1Char('\"'));
8787

88-
qDebug() << command << args;
8988
return QProcess::startDetached(command, args);
9089
}
9190

src/autoupdatergui/progressdialog.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,32 @@ ProgressDialog::ProgressDialog(QWidget *parent) :
1616
,tButton(new QWinTaskbarButton(this))
1717
#endif
1818
{
19-
this->ui->setupUi(this);
19+
ui->setupUi(this);
2020
DialogMaster::masterDialog(this, true, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
2121
#ifdef Q_OS_WIN
2222
if(parent)
23-
this->setupTaskbar(parent);
23+
setupTaskbar(parent);
2424
#endif
2525
}
2626

2727
ProgressDialog::~ProgressDialog()
2828
{
2929
#ifdef Q_OS_WIN
30-
this->tButton->progress()->hide();
30+
tButton->progress()->hide();
3131
#endif
3232
}
3333

3434
void ProgressDialog::setCanceled()
3535
{
36-
this->ui->label->setText(tr("Canceling update check…"));
37-
this->ui->buttonBox->setEnabled(false);
36+
ui->label->setText(tr("Canceling update check…"));
37+
ui->buttonBox->setEnabled(false);
3838
}
3939

4040
void ProgressDialog::hide(QMessageBox::Icon hideType)
4141
{
4242
#ifdef Q_OS_WIN
43-
if(this->tButton->window()) {
44-
QWinTaskbarProgress *progress = this->tButton->progress();
43+
if(tButton->window()) {
44+
QWinTaskbarProgress *progress = tButton->progress();
4545
progress->setRange(0, 1);
4646
progress->setValue(1);
4747
switch (hideType) {
@@ -62,14 +62,14 @@ void ProgressDialog::hide(QMessageBox::Icon hideType)
6262
#else
6363
Q_UNUSED(hideType)
6464
#endif
65-
this->QDialog::hide();
65+
QDialog::hide();
6666
}
6767

6868
void ProgressDialog::closeEvent(QCloseEvent *event)
6969
{
7070
event->ignore();
71-
if(this->ui->buttonBox->isEnabled()) {
72-
this->setCanceled();
71+
if(ui->buttonBox->isEnabled()) {
72+
setCanceled();
7373
emit canceled();
7474
}
7575
}
@@ -78,14 +78,14 @@ void ProgressDialog::closeEvent(QCloseEvent *event)
7878
void ProgressDialog::showEvent(QShowEvent *event)
7979
{
8080
event->accept();
81-
this->setupTaskbar(this);
81+
setupTaskbar(this);
8282
}
8383

8484
void ProgressDialog::setupTaskbar(QWidget *window)
8585
{
86-
if(!this->tButton->window()) {
87-
this->tButton->setWindow(window->windowHandle());
88-
QWinTaskbarProgress *progress = this->tButton->progress();
86+
if(!tButton->window()) {
87+
tButton->setWindow(window->windowHandle());
88+
QWinTaskbarProgress *progress = tButton->progress();
8989
progress->setRange(0, 0);
9090
progress->resume();
9191
progress->show();

src/autoupdatergui/progressdialog_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Q_AUTOUPDATERGUI_EXPORT ProgressDialog : public QDialog
3434
connect(this, &ProgressDialog::canceled, object, [=](){
3535
(object->*member)(3000, true);
3636
});
37-
this->show();
37+
show();
3838
}
3939

4040
void setCanceled();

src/autoupdatergui/translations/QtAutoUpdaterController_de.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@
7676
<context>
7777
<name>QtAutoUpdater::UpdateButton</name>
7878
<message>
79-
<location filename="../updatebutton.cpp" line="+108"/>
79+
<location filename="../updatebutton.cpp" line="+95"/>
8080
<source>Checking for updates…</source>
8181
<translation>Suche nach Updates…</translation>
8282
</message>
8383
<message>
84-
<location line="+17"/>
84+
<location line="+16"/>
8585
<source>New Update!</source>
8686
<translation>Neues Update verfügbar!</translation>
8787
</message>
@@ -95,16 +95,16 @@
9595
<name>QtAutoUpdater::UpdateController</name>
9696
<message>
9797
<location filename="../updatecontroller.cpp" line="+40"/>
98-
<location line="+113"/>
98+
<location line="+98"/>
9999
<location line="+12"/>
100-
<location line="+81"/>
100+
<location line="+75"/>
101101
<location line="+49"/>
102102
<location line="+4"/>
103103
<source>Check for Updates</source>
104104
<translation>Suche nach Updates</translation>
105105
</message>
106106
<message>
107-
<location line="-145"/>
107+
<location line="-139"/>
108108
<source>Do you want to check for updates now?</source>
109109
<translation>Möchten Sie jetzt nach Updates suchen?</translation>
110110
</message>
@@ -114,7 +114,7 @@
114114
<translation>Das Programm sucht bereits nach neuen Updates!</translation>
115115
</message>
116116
<message>
117-
<location line="+81"/>
117+
<location line="+75"/>
118118
<source>Checking for updates was canceled!</source>
119119
<translation>Suche nach Updates wurde abgebrochen!</translation>
120120
</message>
@@ -139,7 +139,7 @@
139139
<translation>Es sind keine neuen Updates verfügbar!</translation>
140140
</message>
141141
<message>
142-
<location line="-253"/>
142+
<location line="-232"/>
143143
<source>Checks if new updates are available. You will be prompted before updates are installed.</source>
144144
<translation>Überprüft, ob neue Updates verfügbar sind. Sie erhalten eine entsprechende Meldung bevor Diese installiert werden.</translation>
145145
</message>

src/autoupdatergui/translations/QtAutoUpdaterController_template.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@
7676
<context>
7777
<name>QtAutoUpdater::UpdateButton</name>
7878
<message>
79-
<location filename="../updatebutton.cpp" line="+108"/>
79+
<location filename="../updatebutton.cpp" line="+95"/>
8080
<source>Checking for updates…</source>
8181
<translation type="unfinished"></translation>
8282
</message>
8383
<message>
84-
<location line="+17"/>
84+
<location line="+16"/>
8585
<source>New Update!</source>
8686
<translation type="unfinished"></translation>
8787
</message>
@@ -95,16 +95,16 @@
9595
<name>QtAutoUpdater::UpdateController</name>
9696
<message>
9797
<location filename="../updatecontroller.cpp" line="+40"/>
98-
<location line="+113"/>
98+
<location line="+98"/>
9999
<location line="+12"/>
100-
<location line="+81"/>
100+
<location line="+75"/>
101101
<location line="+49"/>
102102
<location line="+4"/>
103103
<source>Check for Updates</source>
104104
<translation type="unfinished"></translation>
105105
</message>
106106
<message>
107-
<location line="-145"/>
107+
<location line="-139"/>
108108
<source>Do you want to check for updates now?</source>
109109
<translation type="unfinished"></translation>
110110
</message>
@@ -114,7 +114,7 @@
114114
<translation type="unfinished"></translation>
115115
</message>
116116
<message>
117-
<location line="+81"/>
117+
<location line="+75"/>
118118
<source>Checking for updates was canceled!</source>
119119
<translation type="unfinished"></translation>
120120
</message>
@@ -139,7 +139,7 @@
139139
<translation type="unfinished"></translation>
140140
</message>
141141
<message>
142-
<location line="-253"/>
142+
<location line="-232"/>
143143
<source>Checks if new updates are available. You will be prompted before updates are installed.</source>
144144
<translation type="unfinished"></translation>
145145
</message>

src/autoupdatergui/updatebutton.cpp

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,33 @@ using namespace QtAutoUpdater;
99

1010
UpdateButton::UpdateButton(QWidget *parent, UpdateController *controller) :
1111
QWidget(parent),
12-
d_ptr(new UpdateButtonPrivate(this, controller))
12+
d(new UpdateButtonPrivate(this, controller))
1313
{}
1414

1515
UpdateButton::~UpdateButton(){}
1616

1717
QString UpdateButton::animationFile() const
1818
{
19-
const Q_D(UpdateButton);
2019
return d->loadingGif->fileName();
2120
}
2221

2322
bool UpdateButton::isShowingResult() const
2423
{
25-
const Q_D(UpdateButton);
2624
return d->showResult;
2725
}
2826

2927
UpdateController::DisplayLevel UpdateButton::displayLevel() const
3028
{
31-
const Q_D(UpdateButton);
3229
return d->level;
3330
}
3431

3532
UpdateController *UpdateButton::controller() const
3633
{
37-
const Q_D(UpdateButton);
3834
return d->controller;
3935
}
4036

4137
void 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

5045
void UpdateButton::setAnimationFile(QString animationFile, int speed)
5146
{
52-
Q_D(UpdateButton);
5347
d->loadingGif->setFileName(animationFile);
5448
d->loadingGif->setSpeed(speed);
5549
}
5650

5751
void UpdateButton::setAnimationDevice(QIODevice *animationDevice, int speed)
5852
{
59-
Q_D(UpdateButton);
6053
d->loadingGif->setDevice(animationDevice);
6154
d->loadingGif->setSpeed(speed);
6255
}
6356

6457
void UpdateButton::resetAnimationFile()
6558
{
66-
Q_D(UpdateButton);
6759
d->loadingGif->setFileName(QStringLiteral(":/QtAutoUpdater/icons/updateRunning.gif"));
6860
d->loadingGif->setSpeed(200);
6961
}
7062

7163
void UpdateButton::setShowResult(bool showResult)
7264
{
73-
Q_D(UpdateButton);
7465
d->showResult = showResult;
7566
}
7667

7768
void UpdateButton::setDisplayLevel(UpdateController::DisplayLevel displayLevel)
7869
{
79-
Q_D(UpdateButton);
8070
d->level = displayLevel;
8171
}
8272

8373
bool 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

9584
void UpdateButton::startUpdate()
9685
{
97-
Q_D(UpdateButton);
9886
if(!d->controller.isNull())
9987
d->controller->start(d->level);
10088
}
10189

10290
void 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

119106
void 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

130116
void 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

139125
QtAutoUpdater::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

160146
UpdateButtonPrivate::~UpdateButtonPrivate() {}
161147

162148
void UpdateButtonPrivate::updateController(UpdateController *controller)
163149
{
164-
Q_Q(UpdateButton);
165150
this->controller = controller;
166151
if(controller) {
167152
QObject::connect(this->controller.data(), &UpdateController::runningChanged,

src/autoupdatergui/updatebutton.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class UpdateButtonPrivate;
1414
//! A simple button for update checks
1515
class Q_AUTOUPDATERGUI_EXPORT UpdateButton : public QWidget
1616
{
17+
friend class UpdateButtonPrivate;
1718
Q_OBJECT
1819

1920
//! The file of the animation to be shown
@@ -68,8 +69,7 @@ private Q_SLOTS:
6869
void controllerDestroyed();
6970

7071
private:
71-
QScopedPointer<UpdateButtonPrivate> d_ptr;
72-
Q_DECLARE_PRIVATE(UpdateButton)
72+
QScopedPointer<UpdateButtonPrivate> d;
7373
};
7474

7575
}

src/autoupdatergui/updatebutton_p.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ namespace QtAutoUpdater
1919
class Q_AUTOUPDATERGUI_EXPORT UpdateButtonPrivate
2020
{
2121
public:
22-
UpdateButton *q_ptr;
23-
Q_DECLARE_PUBLIC(UpdateButton)
22+
UpdateButton *q;
2423

2524
QPointer<UpdateController> controller;
2625
QScopedPointer<Ui::UpdateButton> ui;

0 commit comments

Comments
 (0)