diff --git a/maintray.cpp b/maintray.cpp index b730f3e..dd140d5 100644 --- a/maintray.cpp +++ b/maintray.cpp @@ -209,8 +209,6 @@ void MainTray::showToolTip(NetController::State state) case NetController::WrongPass: tooltipString += tr("当前状态:密码错误"); break; - default: - break; } tooltipString += tr("(") + (netctrl->getMobile() ? tr("Mobile") : tr("PC")) + tr(")"); tooltipString += tr("\n自动登陆:"); @@ -424,12 +422,12 @@ void MainTray::handleState(NetController::State state) void MainTray::handleInfo(QString byte, QString sec, QString balance, QString ip) { - QString mbString = QString::number(byte.toDouble() / 1048576.0, 'f', 2); + QString mbString = QString::number(byte.toDouble() / 1000000.0, 'f', 2); QString gbString = QString::number(byte.toDouble() / 1000000000.0, 'f', 2); QString leftoverString = QString::number(totalTraffic - byte.toDouble() / 1000000000.0, 'f', 2); double totalSec = sec.toDouble(); double hour = (totalSec / 3600); - int min = ((totalSec - hour * 3600) / 60); + int min = int((totalSec - hour * 3600) / 60); QString second = QString::number(totalSec - hour * 3600 - min * 60); mbAction->setText(tr("已用流量:\t") + mbString + tr(" M")); timeAction->setText(tr("已用时长:\t") + QString::number(hour, 'f', 2) + tr(" 小时") /*+ ":" +QString::number(min) + ":" + second*/); @@ -438,7 +436,7 @@ void MainTray::handleInfo(QString byte, QString sec, QString balance, QString ip if (!hasWarned && totalTraffic > 0) { hasWarned = true; - if (byte.toDouble() / 1048576.0 > totalTraffic * 1024) + if (byte.toDouble() / 1000000.0 > totalTraffic * 1024) { //流量已超 trafficstate = Over; if (!muteAction->isChecked()) @@ -446,7 +444,7 @@ void MainTray::handleInfo(QString byte, QString sec, QString balance, QString ip showMessage(tr("流量警告"), tr("本月流量已超"), QSystemTrayIcon::Warning); }); } - else if (byte.toDouble() / 1048576.0 + 5000 > totalTraffic * 1024) + else if (byte.toDouble() / 1000000.0 + 5000 > totalTraffic * 1024) { //流量将超 trafficstate = Nearly; if (!muteAction->isChecked()) diff --git a/netcontroller.cpp b/netcontroller.cpp index f2f3e89..1a8e0e7 100644 --- a/netcontroller.cpp +++ b/netcontroller.cpp @@ -11,7 +11,13 @@ NetController::NetController(QByteArray id, QByteArray passwd, QObject *parent) desktopRequest.setRawHeader("Cache-Control", "max-age=0"); desktopRequest.setRawHeader("Origin", "http://ipgw.neu.edu.cn"); desktopRequest.setRawHeader("Upgrade-Insecure-Requests", "1"); +#ifdef Q_OS_LINUX + desktopRequest.setRawHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"); +#endif + +#ifdef Q_OS_WIN32 desktopRequest.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36"); +#endif desktopRequest.setRawHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); desktopRequest.setRawHeader("Referer", "http://ipgw.neu.edu.cn/srun_portal_pc.php?ac_id=1&"); desktopRequest.setRawHeader("Accept-Encoding", "gzip, deflate"); diff --git a/qt/etc/qt.conf b/qt/etc/qt.conf index e69de29..629705c 100644 --- a/qt/etc/qt.conf +++ b/qt/etc/qt.conf @@ -0,0 +1,2 @@ +[Paths] +Plugins = /usr/lib/qt/plugins/