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