qt/LedOK/base/updateledset3dialog.cpp
2022-10-27 15:07:45 +08:00

82 lines
3.4 KiB
C++

#include "updateledset3dialog.h"
#include "ui_updateledset3dialog.h"
#include <QSettings>
#include <cfg.h>
extern const QString DEFS_LEDSET_URL = "https://www.ledok.cn/download/definitions/ledset3updates.json";
UpdateLedset3Dialog::UpdateLedset3Dialog(QWidget *parent) :
BaseDlg(parent),
ui(new Ui::UpdateLedset3Dialog)
{
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
ui->pushButton_2->setVisible(false);
QString strCurApkVersion="";
QSettings settings;
strCurApkVersion = settings.value(DEFS_LEDSET_URL).toString();
if(strCurApkVersion.isEmpty()) strCurApkVersion="0.0.0";
strCurApkVersion="0.0.0";
ui->label_2->setText(tr("CurVersion")+":"+strCurApkVersion);
ui->label_2->setVisible(false);
QSimpleUpdater *m_updater=QSimpleUpdater::getInstance();
connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(OnCheckForUpdates()));
connect(m_updater,SIGNAL(checkingFinished(QString)),this,SLOT(updateChangelog(QString)));
connect(m_updater,SIGNAL(downloadFinished(QString,QString)),this,SLOT(OnDownloadFinished(QString,QString)));
m_updater->getInstance()->setModuleVersion(DEFS_LEDSET_URL,strCurApkVersion);
m_updater->getInstance()->setNotifyOnUpdate(DEFS_LEDSET_URL,false);
m_updater->getInstance()->setNotifyOnFinish(DEFS_LEDSET_URL,false);
m_updater->getInstance()->setCompareBySameString(DEFS_LEDSET_URL,true);
m_updater->getInstance()->checkForUpdates(DEFS_LEDSET_URL);
ui->pushButton->setProperty("ssType", "progManageTool");
ui->pushButton_2->setProperty("ssType", "progManageTool");
}
UpdateLedset3Dialog::~UpdateLedset3Dialog()
{
delete ui;
}
void UpdateLedset3Dialog::OnDownloadFinished( QString url, QString filepath)
{
ui->label_2->setText(tr("CurVersion")+":"+m_updater->getInstance()->getLatestVersion(DEFS_LEDSET_URL));
ui->textEdit->setText(tr("Apk is download finished from internet,you can select LED Screen SYNC firmware now!"));
ui->pushButton_2->setVisible(false);
QSettings settings;
settings.setValue(url, m_strLastestVersion);
settings.setValue("ledset", filepath);
}
void UpdateLedset3Dialog::OnCheckForUpdates()
{
m_updater->getInstance()->setNotifyOnUpdate(DEFS_LEDSET_URL,true);
m_updater->getInstance()->setNotifyOnFinish(DEFS_LEDSET_URL,false);
// m_updater->getInstance()->setUseCustomInstallProcedures(DEFS_LEDSET_URL,true);
m_updater->getInstance()->setNoNotifyDownload(DEFS_LEDSET_URL,true);
m_updater->getInstance()->setCompareBySameString(DEFS_LEDSET_URL,true);
m_updater->getInstance()->setMandatoryUpdate(DEFS_LEDSET_URL,false);
m_updater->getInstance()->checkForUpdates(DEFS_LEDSET_URL);
}
void UpdateLedset3Dialog::updateChangelog(QString strTip)
{
Q_UNUSED(strTip)
if(m_updater->getInstance()->getUpdateAvailable(DEFS_LEDSET_URL))
{
QString strtip=tr("LatestVersion:");
m_strLastestVersion=m_updater->getInstance()->getLatestVersion(DEFS_LEDSET_URL);
strtip+= m_strLastestVersion +"\r\n";
strtip+= tr("Update log:")+"\r\n"+m_updater->getInstance()->getChangelog (DEFS_LEDSET_URL) ;
ui->textEdit->setText(strtip);
ui->pushButton_2->setVisible(true);
}
else {
ui->textEdit->setText(tr("The current version is already the latest version,,you can select LED Screen SYNC firmware now!"));
}
disconnect(m_updater,SIGNAL(checkingFinished(QString)),this,SLOT(updateChangelog(QString)));
}