2023-01-06 14:07:33 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Savoir-faire Linux Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import net.jami.Adapters 1.1
|
|
|
|
import net.jami.Enums 1.1
|
|
|
|
import net.jami.Models 1.1
|
|
|
|
import net.jami.Helpers 1.1
|
|
|
|
import net.jami.Constants 1.1
|
|
|
|
import "../../commoncomponents"
|
|
|
|
|
|
|
|
SimpleMessageDialog {
|
|
|
|
id: downloadDialog
|
|
|
|
|
|
|
|
property int bytesRead: 0
|
|
|
|
property int totalBytes: 0
|
2023-04-13 16:18:26 -04:00
|
|
|
property string hSizeRead: UtilsAdapter.humanFileSize(bytesRead)
|
2023-01-06 14:07:33 -05:00
|
|
|
property string hTotalBytes: UtilsAdapter.humanFileSize(totalBytes)
|
|
|
|
property alias progressBarValue: progressBar.value
|
|
|
|
|
|
|
|
Connections {
|
2023-06-28 10:45:04 -04:00
|
|
|
target: AppVersionManager
|
2023-01-06 14:07:33 -05:00
|
|
|
|
2023-06-28 10:45:04 -04:00
|
|
|
function onErrorOccurred(error, msg) {
|
|
|
|
console.warn("Error while downloading update: " + error + " - " + msg);
|
2023-06-02 18:34:28 -04:00
|
|
|
downloadDialog.close();
|
2023-01-06 14:07:33 -05:00
|
|
|
}
|
|
|
|
|
2023-06-02 18:34:28 -04:00
|
|
|
function onDownloadProgressChanged(bytesRead, totalBytes) {
|
|
|
|
downloadDialog.setDownloadProgress(bytesRead, totalBytes);
|
2023-01-06 14:07:33 -05:00
|
|
|
}
|
|
|
|
|
2023-06-28 10:45:04 -04:00
|
|
|
function onDownloadFinished() {
|
2023-04-13 16:18:26 -04:00
|
|
|
downloadDialog.close();
|
2023-01-06 14:07:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setDownloadProgress(bytesRead, totalBytes) {
|
2023-04-13 16:18:26 -04:00
|
|
|
downloadDialog.bytesRead = bytesRead;
|
|
|
|
downloadDialog.totalBytes = totalBytes;
|
2023-01-06 14:07:33 -05:00
|
|
|
}
|
|
|
|
|
2023-04-13 16:18:26 -04:00
|
|
|
infoText: JamiStrings.updateDownloading + " (%1 / %2)".arg(hSizeRead).arg(hTotalBytes)
|
2023-01-06 14:07:33 -05:00
|
|
|
|
|
|
|
innerContentData: ProgressBar {
|
|
|
|
id: progressBar
|
|
|
|
|
2023-04-13 16:18:26 -04:00
|
|
|
value: downloadDialog.bytesRead / downloadDialog.totalBytes
|
2023-01-06 14:07:33 -05:00
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: JamiTheme.preferredMarginSize
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: JamiTheme.preferredMarginSize
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
implicitWidth: parent.width
|
|
|
|
implicitHeight: 24
|
|
|
|
color: JamiTheme.darkGrey
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
implicitWidth: parent.width
|
|
|
|
implicitHeight: 22
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: progressBar.visualPosition * parent.width
|
|
|
|
height: parent.height
|
|
|
|
color: JamiTheme.selectionBlue
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
color: JamiTheme.whiteColor
|
|
|
|
font.bold: true
|
|
|
|
font.pointSize: JamiTheme.textFontSize + 1
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
text: Math.ceil(progressBar.value * 100).toString() + "%"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonTitles: [JamiStrings.optionCancel]
|
|
|
|
buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue]
|
2023-04-13 16:18:26 -04:00
|
|
|
buttonCallBacks: [function () {
|
2023-06-28 10:45:04 -04:00
|
|
|
AppVersionManager.cancelUpdate();
|
2023-04-13 16:18:26 -04:00
|
|
|
}]
|
2023-01-06 14:07:33 -05:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (!visible)
|
2023-06-28 10:45:04 -04:00
|
|
|
AppVersionManager.cancelUpdate();
|
2023-01-06 14:07:33 -05:00
|
|
|
}
|
|
|
|
}
|