Skip to content

Commit 35dd6a5

Browse files
committed
updates
some more updates -> safer "binding" to the window seperation of parent and parentWindow documentation update
1 parent 72893a5 commit 35dd6a5

File tree

7 files changed

+150
-135
lines changed

7 files changed

+150
-135
lines changed

AutoUpdaterGui/progressdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using namespace QtAutoUpdater;
88

99
ProgressDialog::ProgressDialog(QWidget *parent) :
10-
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint),
10+
QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint),//TODO no maximize on linux...
1111
ui(new Ui::ProgressDialog)
1212
#ifdef Q_OS_WIN
1313
,tButton(new QWinTaskbarButton(this))

AutoUpdaterGui/updatecontroller.cpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include "updatecontroller_p.h"
33
#include <QProgressBar>
44
#include <QCoreApplication>
5+
#include <QDir>
6+
#include <QFileInfo>
57
#include <updatescheduler.h>
68
#include "messagemaster.h"
79
#include "adminauthorization.h"
@@ -19,8 +21,8 @@ UpdateController::UpdateController(QObject *parent) :
1921
d_ptr(new UpdateControllerPrivate(this, NULL))
2022
{}
2123

22-
UpdateController::UpdateController(QWidget *parentWidget) :
23-
QObject(parentWidget),
24+
UpdateController::UpdateController(QWidget *parentWidget, QObject *parent) :
25+
QObject(parent),
2426
d_ptr(new UpdateControllerPrivate(this, parentWidget))
2527
{}
2628

@@ -29,8 +31,8 @@ UpdateController::UpdateController(const QString &maintenanceToolPath, QObject *
2931
d_ptr(new UpdateControllerPrivate(this, maintenanceToolPath, NULL))
3032
{}
3133

32-
UpdateController::UpdateController(const QString &maintenanceToolPath, QWidget *parentWidget) :
33-
QObject(parentWidget),
34+
UpdateController::UpdateController(const QString &maintenanceToolPath, QWidget *parentWidget, QObject *parent) :
35+
QObject(parent),
3436
d_ptr(new UpdateControllerPrivate(this, maintenanceToolPath, parentWidget))
3537
{}
3638

@@ -70,6 +72,18 @@ QString UpdateController::maintenanceToolPath() const
7072
return d->mainUpdater->maintenanceToolPath();
7173
}
7274

75+
QWidget *UpdateController::parentWindow() const
76+
{
77+
const Q_D(UpdateController);
78+
return d->window;
79+
}
80+
81+
void UpdateController::setParentWindow(QWidget *parentWindow)
82+
{
83+
Q_D(UpdateController);
84+
d->window = parentWindow;
85+
}
86+
7387
UpdateController::DisplayLevel UpdateController::currentDisplayLevel() const
7488
{
7589
const Q_D(UpdateController);
@@ -136,26 +150,6 @@ const Updater * UpdateController::getUpdater() const
136150
return d->mainUpdater;
137151
}
138152

139-
QWidget *UpdateController::parentWidget() const
140-
{
141-
const Q_D(UpdateController);
142-
return d->window;
143-
}
144-
145-
void UpdateController::setParent(QWidget *parent)
146-
{
147-
Q_D(UpdateController);
148-
d->window = parent;
149-
this->QObject::setParent(parent);
150-
}
151-
152-
void UpdateController::setParent(QObject *parent)
153-
{
154-
Q_D(UpdateController);
155-
d->window = NULL;
156-
this->QObject::setParent(parent);
157-
}
158-
159153
bool UpdateController::start(DisplayLevel displayLevel)
160154
{
161155
Q_D(UpdateController);
@@ -243,9 +237,11 @@ void UpdateController::checkUpdatesDone(bool hasUpdates, bool hasError)
243237
iconType = QMessageBox::Critical;
244238
}
245239

246-
d->checkUpdatesProgress->hide(iconType);
247-
d->checkUpdatesProgress->deleteLater();
248-
d->checkUpdatesProgress = NULL;
240+
if(d->checkUpdatesProgress) {
241+
d->checkUpdatesProgress->hide(iconType);
242+
d->checkUpdatesProgress->deleteLater();
243+
d->checkUpdatesProgress = NULL;
244+
}
249245
}
250246
if(d->wasCanceled) {
251247
if(d->displayLevel >= ExtendedInfoLevel) {
@@ -332,6 +328,7 @@ UpdateControllerPrivate::UpdateControllerPrivate(UpdateController *q_ptr, QWidge
332328
UpdateControllerPrivate(q_ptr, QString(), window)
333329
{}
334330

331+
#include <QDebug>
335332
UpdateControllerPrivate::UpdateControllerPrivate(UpdateController *q_ptr, const QString &toolPath, QWidget *window) :
336333
q_ptr(q_ptr),
337334
window(window),
@@ -356,6 +353,14 @@ UpdateControllerPrivate::UpdateControllerPrivate(UpdateController *q_ptr, const
356353
QObject::connect(UpdateScheduler::instance(), &UpdateScheduler::taskFinished,
357354
q_ptr, &UpdateController::taskDone,
358355
Qt::QueuedConnection);
356+
357+
#ifdef Q_OS_UNIX
358+
//TODO test
359+
QFileInfo maintenanceInfo(QCoreApplication::applicationDirPath(),
360+
this->mainUpdater->maintenanceToolPath());
361+
qDebug() << maintenanceInfo.ownerId();
362+
this->runAdmin = (maintenanceInfo.ownerId() == 0);
363+
#endif
359364
}
360365

361366
UpdateControllerPrivate::~UpdateControllerPrivate()
@@ -365,6 +370,8 @@ UpdateControllerPrivate::~UpdateControllerPrivate()
365370
"This may crash your application!");
366371
}
367372

373+
if(this->checkUpdatesProgress)
374+
this->checkUpdatesProgress->deleteLater();
368375
for(int taskID : this->updateTasks.keys())
369376
UpdateScheduler::instance()->cancelTask(taskID);
370377
}

0 commit comments

Comments
 (0)