-
Notifications
You must be signed in to change notification settings - Fork 4
/
gui_fu.cpp
66 lines (55 loc) · 1.81 KB
/
gui_fu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <QMessageBox>
#include "gui_fu.h"
#include "ui_gui_fu.h"
Gui_FU::Gui_FU(const QString &version, QWidget *parent) :
QDialog(parent),
ui(new Ui::Gui_FU)
{
ui->setupUi(this);
setWindowTitle(tr("Update master"));
connect(ui->closeBtn, &QPushButton::clicked, this, &Gui_FU::accept);
connect(ui->checkUpdBtn, &QPushButton::clicked, this, &Gui_FU::checkUpdate);
connect(ui->downloadBtn, &QPushButton::clicked, this, &Gui_FU::downloadUpdate);
connect(ui->installBtn, &QPushButton::clicked, this, &Gui_FU::install);
ui->availableVersionLbl->setVisible(false);
ui->availableversionValueLbl->setVisible(false);
ui->currentVerLbl->setText(version);
ui->installBtn->setVisible(false);
}
Gui_FU::~Gui_FU()
{
delete ui;
}
bool Gui_FU::askForRestart()
{
return !QMessageBox::question(0, tr("Retstart application"), tr("Do you want to restart the app?"),
tr("Yes"), tr("No"));
}
void Gui_FU::updateAvailable(const QString &version, const QString &desc, int filesSize)
{
ui->downloadBtn->setEnabled(true);
ui->descLabel->setText(desc);
ui->availableVersionLbl->setVisible(true);
ui->availableversionValueLbl->setVisible(true);
ui->availableversionValueLbl->setText(version);
ui->downloadBar->setMaximum(filesSize);
ui->checkUpdBtn->setEnabled(false);
}
void Gui_FU::showError(const QString &err)
{
QMessageBox::critical(0, tr("Error"), err);
}
void Gui_FU::showStatus(const QString &err)
{
ui->statusLabel->setText(err);
}
void Gui_FU::successDownloadUpdate()
{
ui->statusLabel->setText(tr("Update successfully downloaded!"));
ui->downloadBtn->setVisible(false);
ui->installBtn->setVisible(true);
}
void Gui_FU::updateProgress(int remain)
{
ui->downloadBar->setValue(ui->downloadBar->maximum() - remain);
}