Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leander Schulten
Lichtsteuerung
Commits
39fd2ba5
Commit
39fd2ba5
authored
Aug 14, 2019
by
Leander Schulten
Browse files
Fixes
#33
. Show more information about the update progress.
parent
a51e59fe
Pipeline
#171692
passed with stage
in 1 minute and 42 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main.cpp
View file @
39fd2ba5
...
...
@@ -184,6 +184,7 @@ int main(int argc, char *argv[])
qmlRegisterType
<
SortedModelVectorView
>
(
"custom.licht"
,
1
,
0
,
"SortedModelVectorView"
);
qRegisterMetaType
<
DMXChannelFilter
::
Operation
>
(
"Operation"
);
qmlRegisterUncreatableType
<
UserManagment
>
(
"custom.licht"
,
1
,
0
,
"Permission"
,
"Singletone in c++"
);
qmlRegisterUncreatableMetaObject
(
Updater
::
staticMetaObject
,
"custom.licht"
,
1
,
0
,
"UpdaterState"
,
QStringLiteral
(
"Enum in c++"
));
qRegisterMetaType
<
UserManagment
::
Permission
>
(
"Permission"
);
qRegisterMetaType
<
Modules
::
detail
::
PropertyInformation
::
Type
>
(
"Type"
);
qRegisterMetaType
<
Modules
::
ValueType
>
(
"ValueType"
);
...
...
src/qml/main.qml
View file @
39fd2ba5
...
...
@@ -26,10 +26,35 @@ ApplicationWindow {
}
}
ToolTip.visible
:
updater
.
progress
>=
0
&&
updater
.
progress
<=
100
ToolTip.visible
:
updater
.
progress
>=
0
&&
updater
.
progress
<=
100
||
updater
.
state
===
UpdaterState
.
DownloadUpdateFailed
ToolTip.delay
:
0
ToolTip.timeout
:
20000
ToolTip.text
:
updater
.
progress
<
100
?
"
Downloading update. Progress :
"
+
updater
.
progress
+
"
%
"
:
"
Downloading update finished. Restart to update.
"
function
getText
(
state
,
progress
){
// enum UpdaterState {IDE_ENV, NotChecked, NoUpdateAvailible, UpdateAvailible, DownloadingUpdate, UnzippingUpdate, UnzippingFailed, PreparationForInstallationFailed, ReadyToInstall, DownloadUpdateFailed};
switch
(
state
){
case
UpdaterState.IDE_ENV
:
return
"
You are running the light control in an IDE, make no update
"
;
case
UpdaterState.NotChecked
:
case
UpdaterState.NoUpdateAvailible
:
return
""
;
case
UpdaterState.UpdateAvailible
:
return
"
Update availible
"
;
case
UpdaterState.DownloadingUpdate
:
return
"
Downloading update. Progress :
"
+
updater
.
progress
+
"
%
"
;
case
UpdaterState.UnzippingUpdate
:
return
"
Unzipping update ...
"
;
case
UpdaterState.ReadyToInstall
:
return
"
Close this application to install the update
"
;
case
UpdaterState.DownloadUpdateFailed
:
return
"
Error while downloading the update
"
;
case
UpdaterState.UnzippingFailed
:
return
"
Error while unzipping the update
"
;
case
UpdaterState.PreparationForInstallationFailed
:
return
"
Error while preparation for the installation of the update
"
;
}
return
"
Unknown update state
"
;
}
ToolTip.text
:
getText
(
updater
.
state
,
updater
.
progress
)
VerticalTabBar
{
...
...
src/updater.cpp
View file @
39fd2ba5
...
...
@@ -40,6 +40,8 @@ void Updater::checkForUpdate(){
redirect
->
deleteLater
();
auto
redirectURL
=
redirect
->
header
(
QNetworkRequest
::
KnownHeaders
::
LocationHeader
);
if
(
!
redirectURL
.
isValid
()){
state
=
UpdaterState
::
DownloadUpdateFailed
;
emit
stateChanged
();
qDebug
()
<<
"can not redirect version.zip"
;
return
;
}
...
...
@@ -95,6 +97,8 @@ void Updater::update(){
auto
redirectURL
=
redirect
->
header
(
QNetworkRequest
::
KnownHeaders
::
LocationHeader
);
if
(
!
redirectURL
.
isValid
()){
qDebug
()
<<
"can not redirect deploy.zip"
;
state
=
UpdaterState
::
DownloadUpdateFailed
;
emit
stateChanged
();
return
;
}
auto
response
=
http
->
get
(
QNetworkRequest
(
redirectURL
.
toUrl
()));
...
...
@@ -120,11 +124,13 @@ void Updater::update(){
qDebug
()
<<
response
->
atEnd
();
response
->
deleteLater
();
deploy
->
close
();
state
=
UpdaterState
::
UnzippingUpdate
;
emit
stateChanged
();
Zip
::
unzip
(
QFileInfo
(
*
deploy
),
QFileInfo
(
*
deploy
).
absolutePath
(),[
this
,
deploy
](
auto
success
){
std
::
unique_ptr
<
QFile
>
deleteMe
(
deploy
);
if
(
!
success
){
qDebug
()
<<
"not successful when unzipping deploy.zip"
;
state
=
UpdaterState
::
DownloadUpdate
Failed
;
state
=
UpdaterState
::
Unzipping
Failed
;
emit
stateChanged
();
return
;
}
...
...
@@ -134,14 +140,14 @@ void Updater::update(){
if
(
QFile
::
exists
(
targetInstallerPath
)){
if
(
!
QFile
::
remove
(
targetInstallerPath
)){
qWarning
()
<<
"Failed to remove old Windows Installer"
;
state
=
UpdaterState
::
DownloadUpdate
Failed
;
state
=
UpdaterState
::
PreparationForInstallation
Failed
;
emit
stateChanged
();
return
;
}
}
if
(
!
QFile
::
rename
(
deployPath
+
"/"
+
WINDOWS_INSTALLER_NAME
,
targetInstallerPath
)){
qWarning
()
<<
"Failed to rename Windows Installer"
;
state
=
UpdaterState
::
DownloadUpdate
Failed
;
state
=
UpdaterState
::
PreparationForInstallation
Failed
;
emit
stateChanged
();
return
;
}
...
...
@@ -150,7 +156,7 @@ void Updater::update(){
for
(
const
auto
&
e
:
entries
){
QFile
::
copy
(
e
.
absoluteFilePath
()
,
deployPath
+
"/"
+
e
.
fileName
());
}
state
=
UpdaterState
::
UpdateDownloaded
;
state
=
UpdaterState
::
ReadyToInstall
;
emit
stateChanged
();
});
});
...
...
@@ -159,7 +165,7 @@ void Updater::update(){
}
void
Updater
::
runUpdateInstaller
(){
if
(
state
!=
UpdaterState
::
UpdateDownloaded
){
if
(
state
!=
UpdaterState
::
ReadyToInstall
){
return
;
}
QString
from
=
deployPath
;
...
...
src/updater.h
View file @
39fd2ba5
...
...
@@ -9,6 +9,7 @@
class
Updater
:
public
QObject
{
Q_OBJECT
Q_PROPERTY
(
int
progress
READ
getUpdateProgress
NOTIFY
updateProgressChanged
)
Q_PROPERTY
(
UpdaterState
state
READ
getState
NOTIFY
stateChanged
)
const
inline
static
QString
VERSION_FILE_NAME
=
QStringLiteral
(
"version.txt"
);
const
inline
static
QString
NAME_OF_DEPLOY_FOLDER
=
QStringLiteral
(
"windows-release-5.13.0"
);
const
inline
static
QString
WINDOWS_INSTALLER_NAME
=
QStringLiteral
(
"WindowsInstaller.exe"
);
...
...
@@ -16,7 +17,8 @@ class Updater : public QObject{
QString
deployDownloadURL
=
QStringLiteral
(
"https://git.rwth-aachen.de/leander.schulten/Lichtsteuerung/-/jobs/artifacts/windows-release/download?job=deploy"
);
std
::
unique_ptr
<
QNetworkAccessManager
>
http
=
std
::
make_unique
<
QNetworkAccessManager
>
();
public:
enum
class
UpdaterState
{
IDE_ENV
,
NotChecked
,
NoUpdateAvailible
,
UpdateAvailible
,
DownloadingUpdate
,
UpdateDownloaded
,
DownloadUpdateFailed
};
enum
UpdaterState
{
IDE_ENV
,
NotChecked
,
NoUpdateAvailible
,
UpdateAvailible
,
DownloadingUpdate
,
UnzippingUpdate
,
UnzippingFailed
,
PreparationForInstallationFailed
,
ReadyToInstall
,
DownloadUpdateFailed
};
Q_ENUM
(
UpdaterState
)
private:
UpdaterState
state
=
UpdaterState
::
NotChecked
;
int
progress
=
-
1
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment