From 0890ca46fddb78d87d5414f8a5d41d0c1a393c7a Mon Sep 17 00:00:00 2001 From: CHN-STUDENT Date: Sat, 19 Jan 2019 01:12:36 +0800 Subject: [PATCH] V2.0.2 --- .gitignore | 2 + srun-3k-ui/Resouces/png/radius_back.png | Bin 0 -> 17957 bytes srun-3k-ui/Resouces/png/radius_front.png | Bin 0 -> 17956 bytes srun-3k-ui/mainwindow.cpp | 182 ++++++++++++++++++-- srun-3k-ui/mainwindow.h | 7 +- srun-3k-ui/mainwindow.qrc | 6 + srun-3k-ui/mainwindow.ui | 201 +++++++++++++---------- srun-3k-ui/radiusprogressbar.cpp | 35 ++++ srun-3k-ui/radiusprogressbar.h | 21 +++ srun-3k-ui/srun-3k-ui.pro | 6 +- srun-3k-ui/storage.cpp | 29 ++++ srun-3k-ui/storage.h | 4 + srun-3k-ui/version.h | 2 +- 13 files changed, 392 insertions(+), 103 deletions(-) create mode 100644 .gitignore create mode 100644 srun-3k-ui/Resouces/png/radius_back.png create mode 100644 srun-3k-ui/Resouces/png/radius_front.png create mode 100644 srun-3k-ui/radiusprogressbar.cpp create mode 100644 srun-3k-ui/radiusprogressbar.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e31cfb2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.user diff --git a/srun-3k-ui/Resouces/png/radius_back.png b/srun-3k-ui/Resouces/png/radius_back.png new file mode 100644 index 0000000000000000000000000000000000000000..c8aa2d287848005d5d50724747b8fb6a8d34ede8 GIT binary patch literal 17957 zcmeI4c{J2t_{XoMLMbUJD$_{cwlOmdF)?JxC?dN`HD+O$t(mcmO4@gnBx{P28d|;; zDbY&VqNq?Lk`OASRKE`jeX7stoZt8N&+p6}X6CuieLv6VzV37H+;PswZu@0ciVA89 z002d6vV{Wx(jm}$Be{{#bJvQ|ve1h>kL)f0VDyB(Unvk1HyHp0Tc)|Wy}dVA$Q5{V zc_?dha}X0NQ0lfx*IaCcRQ; zxj-85%C%=I=e_v0HO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(%J#*;w7VW|3xJ#mD^1V~R;e{hgL%6|%N&Y}7Z zloA|zXz9~9R5<)_fe>-}IBgwm2*ThgG#DfvGQd#u4R9C;NAQFfJ{?D;>U~c%D%ekn zYN*6azi{_Y}Vf z^HVA^gAdn}a8#Ya)i${II6&)vZ2j(FG6we$E``U329~A~`uo}(-gJidlmX4)5+_oq z1G^82I#9q6%@F%T>&R&hE5FGYKTqeMAsC83O8)yC0p1W>RQV5u8tnD^Abbv85J2HU zCSGub{Mp(ZiuhyTJV-K5@uAtQE>*|>WJ`;16My~aHYeV zpW2Z9T?cj!rr%)y#RMFDVDSTw-=w46NU57>>1a1nI-+!9GXx~Uw`_>!QL2IWW8xrG z2l&zvBEdsLHX(c4F#;i`t2qOHzu*t-dwM$Xpaw-q&o7m3qm(}gM>)O;hw5q672e=h zG1LlQKf;%;*x_r}pLUVq?e@QXF*2h6GAbgLI0*uXXj6r0ZvhQ}@Ab5P`GyJKCyJty?QH-E(gYx68vuP@;pbKW{BQug@_=tKJpzCV z=is_q%K(s2urfDs46JFdHkkx)G6m=G6R)OOE_~TQp7XBiL*FX^&fSg#paA|65f2~% za3KIpGX`J+3V^YS07%Jz5DDpDxqs9A->ZIq3Zil$R7a8|0QmY<3cx>sVZ3^A${YY6 NRu(JF&zO2_{U1PSjv@d6 literal 0 HcmV?d00001 diff --git a/srun-3k-ui/mainwindow.cpp b/srun-3k-ui/mainwindow.cpp index 14628c0..5c16ae6 100644 --- a/srun-3k-ui/mainwindow.cpp +++ b/srun-3k-ui/mainwindow.cpp @@ -2,11 +2,14 @@ #include "ui_mainwindow.h" //#include "QDebug" +MainWindow *singleton; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + singleton = this; setWindowFlags(Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); mLocation = this->geometry(); @@ -51,6 +54,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->usernameLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false); ui->passwordLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false); ui->stackedWidget->setCurrentIndex(2); + ui->stackedWidgetBottom->setCurrentIndex(0); AboutButton->hide();//在获取公告前隐藏这两个按钮 AdvancedButton->hide(); n=new network(); @@ -91,7 +95,6 @@ MainWindow::MainWindow(QWidget *parent) : ui->autoLoginCheckBox->setCheckState(Qt::Checked); } } - } void MainWindow::showMessage(void) @@ -434,14 +437,13 @@ void MainWindow::on_checkUpdateButton_clicked() { ui->enterButtonInAboutPage->setEnabled(false); ui->checkUpdateButton->setEnabled(false); - QStringList list; ui->statusBar->setText("检查更新中..."); setStyleSheet("QWidget#centralWidget{color:black;background:white;border:1px solid #3498DB;}"); ui->widgetBottom->setStyleSheet("QLabel#statusBar{color:white;padding:5px 0px 5px;}" "QWidget#widgetBottom{background:#3498DB;}"); if(isOnline) { - int c=checkVersion(list,n); + int c=checkVersion(updateInfo,n); if(c!=-1) { ui->statusBar->setText("检查更新中...成功!"); @@ -475,12 +477,10 @@ void MainWindow::on_checkUpdateButton_clicked() QString v; v.sprintf("%s",version); QString ehaut=ui->eHautIco->text(); - QString url=QString("%2").arg(list.at(4)).arg(ehaut); - s=s+" "+v+" 。最新版本 "+list.at(0)+" ,发布于 "+list.at(1)+" 。

<=====================
    点击左边蜗牛下载最新版!

备用地址:"+QString("%2").arg(list.at(4)).arg("点我下载!"); - - ui->eHautIco->setText(url); - ui->eHautIco->setOpenExternalLinks(true); - ui->aboutBox->setHtml(s); + QString url=QString("%2").arg(updateInfo.at(4)).arg(ehaut); + s=s+" "+v+" 。最新版本 "+updateInfo.at(0)+" ,发布于 "+updateInfo.at(1)+" 。

<=====================
    点击左边蜗牛下载最新版!

备用地址:"+QString("%2").arg(updateInfo.at(4)).arg("点我下载!"); + ui->aboutBox->setText(s); + ui->eHautIco->setEnabled(true); } } else @@ -737,8 +737,7 @@ void MainWindow::on_loginButton_clicked(bool showmode) } ui->stackedWidget->setCurrentIndex(3); getUserInfo(false); - QStringList list; - int c=checkVersion(list,n); + int c=checkVersion(updateInfo,n); if(c==1) { @@ -749,20 +748,18 @@ void MainWindow::on_loginButton_clicked(bool showmode) list[3] sha1 list[4] url */ - QString s="当前版本"; QString v; v.sprintf("%s",version); QString ehaut=ui->eHautIco->text(); - QString url=QString("%2").arg(list.at(4)).arg(ehaut); - s=s+" "+v+" 。最新版本 "+list.at(0)+" ,发布于 "+list.at(1)+" 。

<=====================
    点击左边蜗牛下载最新版!

备用地址:"+QString("%2").arg(list.at(4)).arg("点我下载!"); + s=s+" "+v+" 。最新版本 "+updateInfo.at(0)+" ,发布于 "+updateInfo.at(1)+" 。

<=====================
    点击左边蜗牛下载最新版!

备用地址:"+QString("%2").arg(updateInfo.at(4)).arg("点我下载!"); AboutButton->setStyleSheet("QPushButton {border-image: url(:/titleButtons/about_alert);}" "QPushButton:hover {border-image: url(:/titleButtons/about_alert_hover);}" "QPushButton:pressed {border-image: url(:/titleButtons/about_alert_pressed);}"); - ui->eHautIco->setText(url); - ui->eHautIco->setOpenExternalLinks(true); + ui->aboutBox->setHtml(s); + ui->eHautIco->setEnabled(true); } } @@ -814,3 +811,156 @@ void MainWindow::on_loginButton_clicked(bool showmode) } ui->loginButton->setEnabled(true); } + +void MainWindow::on_eHautIco_clicked() +{ + ui->eHautIco->setEnabled(false); + ui->enterButtonInAboutPage->setEnabled(false); + ui->checkUpdateButton->setEnabled(false); + setStyleSheet("QWidget#centralWidget{color:black;background:white;border:1px solid #1aad18;}"); + ui->widgetBottom->setStyleSheet("QLabel#statusBar{color:white;padding:5px 0px 5px;}" + "QWidget#widgetBottom{background:#1aad18;}"); + info="检查是否存在老版本更新包..."; + ui->aboutBox->setHtml(info); + bool isUpdateProgramExist=s->checkUpdateProgramisExist("update.exe"); + if(isUpdateProgramExist) + { + info=info+"删除成功!
"; + } + else + { + info=info+"无需删除!
"; + } + info=info+"下载更新包中..."; + ui->aboutBox->setHtml(info); + ui->stackedWidgetBottom->setCurrentIndex(1); + ui->downloadBar->setMaximum(100); + ui->downloadBar->setValue(0); + QString downloadUrl=updateInfo.at(4); + static int retry=1; + static bool isTrue=false; + QString path=QCoreApplication::applicationDirPath()+"/update.exe"; + FILE* fp = nullptr; + while(retry<=3) + { + if(retry>1) + { + Sleep(5000); + info=info+"尝试第 "+QString::number(retry)+" 次下载:
"; + info=info+"下载更新包中..."; + ui->aboutBox->setHtml(info); + } + CURL* curl = curl_easy_init(); + if(!(curl)) + {//如果非正常初始化 + exit(-1); + } + fp=fopen(path.toStdString().c_str(), "wb"); + rewind(fp); + curl_easy_setopt(curl, CURLOPT_URL,downloadUrl.toStdString().c_str()); + //设置接收数据的回调 + curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,false);//设定为不验证证书和HOST + curl_easy_setopt(curl,CURLOPT_SSL_VERIFYHOST,false); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, storage::saveDataTodisk); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); + // 设置重定向的最大次数 + curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 5); + // 设置301、302跳转跟随location + //curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); + //设置进度回调函数 + curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, MainWindow::progressUpdate); + //设置超时 + curl_easy_setopt(curl,CURLOPT_CONNECTTIMEOUT,3L); + //开始执行请求 + CURLcode retcCode = curl_easy_perform(curl); + if(retcCode!=CURLE_OK) + { + info=info+"下载失败!
"; + ui->aboutBox->setHtml(info); + retry++; + } + else + { + info=info+"下载成功!
"; + isTrue=true; + ui->aboutBox->setHtml(info); + break; + } + curl_easy_cleanup(curl); + } + if(fp!=nullptr) + fclose(fp); + if(isTrue) + { + info=info+"校验下载值中..."; + ui->aboutBox->setHtml(info); + QString sha1; + sha1.prepend(s->fileChecksum("update.exe")); + //qDebug()<"; + ui->aboutBox->setHtml(info); + ui->downloadBar->setMaximum(100); + ui->downloadBar->setValue(100); + info=info+"5s后尝试启动自动更新程序!
"; + ui->aboutBox->setHtml(info); + QTimer::singleShot(5000, this, SLOT(startUpdate())); + } + else + { + info=info+"校验失败!
"; + ui->statusBar->setText("自动更新失败!请重试!"); + setStyleSheet("QWidget#centralWidget{color:black;background:white;border:1px solid #E05D6F;}"); + ui->widgetBottom->setStyleSheet("QLabel#statusBar{color:white;padding:5px 0px 5px;}" + "QWidget#widgetBottom{background:#E05D6F;}"); + ui->stackedWidgetBottom->setCurrentIndex(0); + info=info+"正在删除更新包..."; + ui->aboutBox->setHtml(info); + bool isDelete=s->checkUpdateProgramisExist("update.exe"); + if(isDelete) + { + info=info+"删除成功!
请您重试自动更新!"; + ui->aboutBox->setHtml(info); + } + else + { + info=info+"不可预知的错误!
"; + ui->aboutBox->setHtml(info); + } + } + } + + ui->enterButtonInAboutPage->setEnabled(true); + ui->checkUpdateButton->setEnabled(true); + ui->eHautIco->setEnabled(true); +} + +void MainWindow::startUpdate() +{ + QString path=QCoreApplication::applicationDirPath()+"/update.exe"; + QProcess process(this); + bool isStart=process.startDetached(path);\ + if(isStart) + qApp->exit(0); + else + { + info=info+"调用失败请重试!
"; + ui->statusBar->setText("自动更新失败!请重试!"); + setStyleSheet("QWidget#centralWidget{color:black;background:white;border:1px solid #E05D6F;}"); + ui->widgetBottom->setStyleSheet("QLabel#statusBar{color:white;padding:5px 0px 5px;}" + "QWidget#widgetBottom{background:#E05D6F;}"); + ui->stackedWidgetBottom->setCurrentIndex(0); + } +} + +int MainWindow::progressUpdate(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +{ + if ( dltotal > -0.1 && dltotal < 0.1 ) + return 0; + int nPos = (int) ( (dlnow/dltotal)*90.0 ); + //ui->downloadBar->setValue(nPos); + singleton->ui->downloadBar->setValue(nPos); + return 0; +} diff --git a/srun-3k-ui/mainwindow.h b/srun-3k-ui/mainwindow.h index 61dd9ba..6f6c127 100644 --- a/srun-3k-ui/mainwindow.h +++ b/srun-3k-ui/mainwindow.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "network.h" #include "version.h" #include "storage.h" @@ -61,7 +62,9 @@ private slots: void on_autoStartCheckBox_clicked(); void on_autoLoginCheckBox_clicked(); void on_loginButton_clicked(bool); - + void on_eHautIco_clicked(); + static int progressUpdate(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); + void startUpdate(); private: bool mDrag; bool isUserinfoExists=false; @@ -87,6 +90,8 @@ private slots: QTimer *meTimer=nullptr; QString logoutname; bool set=false; + QStringList updateInfo; + QString info; }; #endif // MAINWINDOW_H diff --git a/srun-3k-ui/mainwindow.qrc b/srun-3k-ui/mainwindow.qrc index 9c4af86..6af80ae 100644 --- a/srun-3k-ui/mainwindow.qrc +++ b/srun-3k-ui/mainwindow.qrc @@ -20,7 +20,13 @@ Resouces/titleButtons/setting.png Resouces/titleButtons/setting_horver.png Resouces/titleButtons/setting_press.png + + + Resouces/png/radius_back.png + Resouces/png/radius_front.png + + Resouces/Ico/new.png Resouces/Ico/myappSysTrayIcon.png diff --git a/srun-3k-ui/mainwindow.ui b/srun-3k-ui/mainwindow.ui index 257786f..8bd56f5 100644 --- a/srun-3k-ui/mainwindow.ui +++ b/srun-3k-ui/mainwindow.ui @@ -167,7 +167,7 @@ QLabel#labelTitle{ - 4 + 5 @@ -1466,25 +1466,6 @@ background:#0b4a73; - - - - 30 - 30 - 180 - 131 - - - - - 微软雅黑 - 10 - - - - <html><head/><body><p align="center"><img src=":/Ico/R"/></p><p align="center"><br/></p></body></html> - - @@ -1518,7 +1499,7 @@ background:#0b4a73; p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'微软雅黑'; font-size:9pt; font-weight:400; font-style:normal;"> <p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" font-size:16pt; background-color:#ffffff;">E-HAUT </span></p> -<p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" background-color:#ffffff;">Easy Internet In HAUT V2.0.1</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" background-color:#ffffff;">Easy Internet In HAUT V2.0.2</span></p> <p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" background-color:#ffffff;">-------------------------------------------------</span></p> <p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" background-color:#ffffff;">新河南工业大学校园登陆器 Qt 版</span></p> <p align="center" style=" margin-top:0px; margin-bottom:10px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" font-family:'Arial,Helvetica'; font-size:13px; color:#666666; background-color:#ffffff;">©2019 E-haut Team</span></p> @@ -1570,6 +1551,9 @@ background:#0b4a73; + + true + 360 @@ -1606,12 +1590,39 @@ background:#0b4a73; 检查更新 + + + false + + + + 60 + 40 + 101 + 101 + + + + QPushButton{ +background-image: url(:/Ico/R); +background-color:transparent; + + +} + + + + + + true + + - + 0 @@ -1625,76 +1636,100 @@ background:#0b4a73; - -QLabel#statusBar{color:white;padding:5px 0px 5px;} + QLabel#statusBar{color:white;padding:5px 0px 5px;} QWidget#widgetBottom{background:#3498DB;} - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - true - - - - 微软雅黑 - 12 - - - - 欢迎使用校园网登陆器! - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 225 + 17 + + + + + + + + true + + + + 微软雅黑 + 12 + + + + 欢迎使用校园网登陆器! + + + + + + + Qt::Horizontal + + + + 225 + 17 + + + + + + + + + + + 0 + 0 + 640 + 60 + + + + + + + RadiusProgressBar + QProgressBar +
radiusprogressbar.h
+ 1 +
+
diff --git a/srun-3k-ui/radiusprogressbar.cpp b/srun-3k-ui/radiusprogressbar.cpp new file mode 100644 index 0000000..135b048 --- /dev/null +++ b/srun-3k-ui/radiusprogressbar.cpp @@ -0,0 +1,35 @@ +#include "radiusprogressbar.h" +#include + +RadiusProgressBar::RadiusProgressBar(QWidget *parent) : QProgressBar(parent) +{ + setMinimum(0); + setMaximum(100); + setValue(0); +} + +void RadiusProgressBar::paintEvent(QPaintEvent *) +{ + QPainter p(this); + QRect rect = QRect(0, 0, width(), height()); + QRect textRect = QRect(0, 0, width(), height()); + + const double k = (double)(value() - minimum()) / (maximum()-minimum()); + int x = (int)(rect.width() * k); + QRect fillRect = rect.adjusted(0, 0, x-rect.width(), 0); + + QString valueStr = QString("正在更新中...%1 %").arg(QString::number(value())); + QPixmap buttomMap = QPixmap(":/png/radius_back"); + QPixmap fillMap = QPixmap(":/png/radius_front"); + + //画进度条 + p.drawPixmap(rect, buttomMap); + p.drawPixmap(fillRect, fillMap, fillRect); + + //画文字 + QFont f = QFont("Microsoft YaHei",12, QFont::Normal); + p.setFont(f); + p.setPen(QColor("#ffffff")); + p.drawText(textRect, Qt::AlignCenter, valueStr); +} + diff --git a/srun-3k-ui/radiusprogressbar.h b/srun-3k-ui/radiusprogressbar.h new file mode 100644 index 0000000..2aef59f --- /dev/null +++ b/srun-3k-ui/radiusprogressbar.h @@ -0,0 +1,21 @@ +#ifndef RADIUSPROGRESSBAR_H +#define RADIUSPROGRESSBAR_H + +#include + +class RadiusProgressBar : public QProgressBar +{ + Q_OBJECT +public: + explicit RadiusProgressBar(QWidget *parent = nullptr); + + +signals: + +public slots: + +protected: + void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; +}; + +#endif // RADIUSPROGRESSBAR_H diff --git a/srun-3k-ui/srun-3k-ui.pro b/srun-3k-ui/srun-3k-ui.pro index 957ed37..cefa045 100644 --- a/srun-3k-ui/srun-3k-ui.pro +++ b/srun-3k-ui/srun-3k-ui.pro @@ -28,13 +28,15 @@ SOURCES += \ mainwindow.cpp \ version.cpp \ network.cpp \ - storage.cpp + storage.cpp \ + radiusprogressbar.cpp HEADERS += \ mainwindow.h \ version.h \ network.h \ - storage.h + storage.h \ + radiusprogressbar.h FORMS += \ mainwindow.ui diff --git a/srun-3k-ui/storage.cpp b/srun-3k-ui/storage.cpp index d7bc2ae..f2645b4 100644 --- a/srun-3k-ui/storage.cpp +++ b/srun-3k-ui/storage.cpp @@ -198,3 +198,32 @@ QByteArray storage::passwordEncrypy(QString passwd) } return PASSWD_ENCRYPT; } + +QByteArray storage::fileChecksum(const QString &fileName) +{ + //检查文件的SHA1值:https://stackoverflow.com/questions/16383392/how-to-get-the-sha-1-md5-checksum-of-a-file-with-qt/16383433 + QString path=QCoreApplication::applicationDirPath()+"/"+fileName; + //qDebug()< #include #include +#include class storage @@ -19,6 +20,9 @@ class storage QByteArray passwordEncrypy(QString password); bool saveUserConfigToFile(QStringList list); bool saveserverConfigToFile(QStringList list); + QByteArray fileChecksum(const QString &fileName); + bool checkUpdateProgramisExist(const QString &fileName); + static size_t saveDataTodisk(void *pBuffer, size_t nSize, size_t nMemByte, FILE *fp); }; diff --git a/srun-3k-ui/version.h b/srun-3k-ui/version.h index 5eef655..ead90e8 100644 --- a/srun-3k-ui/version.h +++ b/srun-3k-ui/version.h @@ -2,7 +2,7 @@ #define VERSION_H #include "network.h" -static char * version="V2.0.1"; +static char * version="V2.0.2"; static char * checkUpdateURL="https://pc.ehaut.cn/download/checkupdate.json"; int checkVersion(QStringList &list,network *n);