mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-22 16:20:07 +08:00
fix: use QDateTime instead of QTime to handle cross-day comparison
This commit is contained in:
parent
30b76780e5
commit
02587bbe96
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#ifndef MW_INTERFACE
|
#ifndef MW_INTERFACE
|
||||||
|
|
||||||
#include <QTime>
|
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
@ -182,7 +181,7 @@ private:
|
|||||||
int icon_status = -1;
|
int icon_status = -1;
|
||||||
std::shared_ptr<Configs::ProxyEntity> running;
|
std::shared_ptr<Configs::ProxyEntity> running;
|
||||||
QString traffic_update_cache;
|
QString traffic_update_cache;
|
||||||
QTime last_test_time;
|
qint64 last_test_time = 0;
|
||||||
//
|
//
|
||||||
int proxy_last_order = -1;
|
int proxy_last_order = -1;
|
||||||
bool select_mode = false;
|
bool select_mode = false;
|
||||||
|
|||||||
@ -1239,10 +1239,8 @@ void MainWindow::refresh_status(const QString &traffic_update) {
|
|||||||
if (group != nullptr) group_name = group->name;
|
if (group != nullptr) group_name = group->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_test_time.addSecs(2) < QTime::currentTime()) {
|
if (QDateTime::currentSecsSinceEpoch() - last_test_time > 2) {
|
||||||
auto txt = running == nullptr ? tr("Not Running")
|
ui->label_running->setText(running ? QString("[%1] %2").arg(group_name, running->bean->DisplayName()).left(30) : tr("Not Running"));
|
||||||
: QString("[%1] %2").arg(group_name, running->bean->DisplayName()).left(30);
|
|
||||||
ui->label_running->setText(txt);
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
auto display_socks = DisplayAddress(Configs::dataStore->inbound_address, Configs::dataStore->inbound_socks_port);
|
auto display_socks = DisplayAddress(Configs::dataStore->inbound_address, Configs::dataStore->inbound_socks_port);
|
||||||
|
|||||||
@ -195,7 +195,7 @@ void MainWindow::stopTests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::url_test_current() {
|
void MainWindow::url_test_current() {
|
||||||
last_test_time = QTime::currentTime();
|
last_test_time = QDateTime::currentSecsSinceEpoch();
|
||||||
ui->label_running->setText(tr("Testing"));
|
ui->label_running->setText(tr("Testing"));
|
||||||
|
|
||||||
runOnNewThread([=,this] {
|
runOnNewThread([=,this] {
|
||||||
@ -208,7 +208,7 @@ void MainWindow::url_test_current() {
|
|||||||
if (!rpcOK || result.results.empty()) return;
|
if (!rpcOK || result.results.empty()) return;
|
||||||
|
|
||||||
auto latency = result.results[0].latency_ms.value();
|
auto latency = result.results[0].latency_ms.value();
|
||||||
last_test_time = QTime::currentTime();
|
last_test_time = QDateTime::currentSecsSinceEpoch();
|
||||||
|
|
||||||
runOnUiThread([=,this] {
|
runOnUiThread([=,this] {
|
||||||
if (!result.results[0].error.value().empty()) {
|
if (!result.results[0].error.value().empty()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user