qt/LedOK/LoUIClass/updaterdialog.cpp

39 lines
1.7 KiB
C++
Raw Normal View History

2022-01-04 18:11:48 +08:00
#include "updaterdialog.h"
2022-08-25 18:37:24 +08:00
#include "cfg.h"
2022-01-04 18:11:48 +08:00
#include "ui_updaterdialog.h"
2022-08-25 18:37:24 +08:00
UpdaterDialog::UpdaterDialog(QWidget *parent) : BaseDlg(parent), ui(new Ui::UpdaterDialog) {
setAttribute(Qt::WA_DeleteOnClose);
2022-01-04 18:11:48 +08:00
ui->setupUi(this);
ui->pushButton_2->setVisible(false);
ui->label_2->setText(tr("CurVersion")+":"+APP_VERSION);
2022-08-25 18:37:24 +08:00
QSimpleUpdater *m_updater = QSimpleUpdater::getInstance();
2022-01-04 18:11:48 +08:00
connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(OnCheckForUpdates()));
2022-08-25 18:37:24 +08:00
connect(m_updater, SIGNAL(checkingFinished(QString)), this, SLOT(updateChangelog(QString)));
m_updater->setModuleVersion(UpdVerUrl, APP_VERSION);
m_updater->setNotifyOnUpdate(UpdVerUrl, false);
m_updater->setNotifyOnFinish(UpdVerUrl, false);
m_updater->checkForUpdates(UpdVerUrl);
2022-01-04 18:11:48 +08:00
}
2022-08-25 18:37:24 +08:00
UpdaterDialog::~UpdaterDialog(){
2022-01-04 18:11:48 +08:00
delete ui;
}
2022-08-25 18:37:24 +08:00
void UpdaterDialog::OnCheckForUpdates(){
QSimpleUpdater::getInstance()->setNotifyOnUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->setNotifyOnFinish(UpdVerUrl, false);
QSimpleUpdater::getInstance()->setMandatoryUpdate(UpdVerUrl, true);
QSimpleUpdater::getInstance()->checkForUpdates(UpdVerUrl);
2022-01-04 18:11:48 +08:00
}
2022-08-25 18:37:24 +08:00
void UpdaterDialog::updateChangelog(QString){
if(QSimpleUpdater::getInstance()->getUpdateAvailable(UpdVerUrl)){
QString strtip = tr("LatestVersion:") + QSimpleUpdater::getInstance()->getLatestVersion(UpdVerUrl) + "\r\n"
+ tr("Update log:") + "\r\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl);
ui->textEdit->setText(strtip);
ui->pushButton_2->setVisible(true);
} else {
ui->textEdit->setText(tr("The current version is already the latest version") + "\r\n\r\n"
+ tr("Update log:") + "\r\n" + QSimpleUpdater::getInstance()->getChangelog(UpdVerUrl));
2022-01-04 18:11:48 +08:00
}
}