diff --git a/include/stats/connections/connectionLister.hpp b/include/stats/connections/connectionLister.hpp index 7a63791..62315ba 100644 --- a/include/stats/connections/connectionLister.hpp +++ b/include/stats/connections/connectionLister.hpp @@ -11,7 +11,8 @@ namespace NekoGui_traffic Default, ByDownload, ByUpload, - ByProcess + ByProcess, + ByTraffic }; class ConnectionMetadata diff --git a/include/ui/mainwindow.ui b/include/ui/mainwindow.ui index b813666..96e9d0c 100644 --- a/include/ui/mainwindow.ui +++ b/include/ui/mainwindow.ui @@ -437,11 +437,6 @@ Click To Sort By Process - - - Network - - Protocol @@ -449,18 +444,15 @@ - Download - - - Click To Sort By Download + Outbound - Upload + Traffic - Click To Sort By Upload + Click To Toggle sort by Traffic @@ -556,7 +548,7 @@ 0 0 800 - 17 + 25 diff --git a/src/stats/connectionLister/connectionLister.cpp b/src/stats/connectionLister/connectionLister.cpp index 29238ff..0705a79 100644 --- a/src/stats/connectionLister/connectionLister.cpp +++ b/src/stats/connectionLister/connectionLister.cpp @@ -128,6 +128,34 @@ namespace NekoGui_traffic void ConnectionLister::setSort(const ConnectionSort newSort) { + if (newSort == ByTraffic) + { + if (sort == ByDownload && asc) + { + sort = ByUpload; + asc = false; + return; + } + if (sort == ByUpload && asc) + { + sort = ByDownload; + asc = false; + return; + } + if (sort == ByDownload) + { + asc = true; + return; + } + if (sort == ByUpload) + { + asc = true; + return; + } + sort = ByDownload; + asc = false; + return; + } if (sort == newSort) asc = !asc; else { diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 681dd64..92b93a4 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -251,12 +251,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi } if (index == 4) { - NekoGui_traffic::connection_lister->setSort(NekoGui_traffic::ByDownload); - NekoGui_traffic::connection_lister->ForceUpdate(); - } - if (index == 5) - { - NekoGui_traffic::connection_lister->setSort(NekoGui_traffic::ByUpload); + NekoGui_traffic::connection_lister->setSort(NekoGui_traffic::ByTraffic); NekoGui_traffic::connection_lister->ForceUpdate(); } }); @@ -983,7 +978,6 @@ void MainWindow::setupConnectionList() ui->connections->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); ui->connections->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); ui->connections->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents); - ui->connections->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents); ui->connections->verticalHeader()->hide(); connect(ui->connections, &QTableWidget::cellClicked, this, [=](int row, int column) { @@ -1023,17 +1017,16 @@ void MainWindow::UpdateConnectionList(const QMapconnections->item(row, 1)->setText(conn.process); - // C2: Network - ui->connections->item(row, 2)->setText(conn.network); + // C2: Protocol + auto prot = conn.network; + if (!conn.protocol.isEmpty()) prot += " ("+conn.protocol+")"; + ui->connections->item(row, 2)->setText(prot); - // C3: Protocol - ui->connections->item(row, 3)->setText(conn.protocol); + // C3: Outbound + ui->connections->item(row, 3)->setText(conn.outbound); - // C4: Download - ui->connections->item(row, 4)->setText(ReadableSize(conn.download)); - - // C5: Upload - ui->connections->item(row, 5)->setText(ReadableSize(conn.upload)); + // C4: Traffic + ui->connections->item(row, 4)->setText(ReadableSize(conn.upload) + "↑" + " " + ReadableSize(conn.download) + "↓"); } int row = ui->connections->rowCount(); for (const auto& conn : toAdd) @@ -1052,26 +1045,23 @@ void MainWindow::UpdateConnectionList(const QMapsetText(conn.process); ui->connections->setItem(row, 1, f); - // C2: Network + // C2: Protocol f = f0->clone(); - f->setText(conn.network); + auto prot = conn.network; + if (!conn.protocol.isEmpty()) prot += " ("+conn.protocol+")"; + f->setText(prot); ui->connections->setItem(row, 2, f); - // C3: Protocol + // C3: Outbound f = f0->clone(); - f->setText(conn.protocol); + f->setText(conn.outbound); ui->connections->setItem(row, 3, f); - // C4: Download + // C4: Traffic f = f0->clone(); - f->setText(ReadableSize(conn.download)); + f->setText(ReadableSize(conn.upload) + "↑" + " " + ReadableSize(conn.download) + "↓"); ui->connections->setItem(row, 4, f); - // C5: Upload - f = f0->clone(); - f->setText(ReadableSize(conn.upload)); - ui->connections->setItem(row, 5, f); - row++; } ui->connections->setUpdatesEnabled(true); @@ -1098,26 +1088,23 @@ void MainWindow::UpdateConnectionListWithRecreate(const QListsetText(conn.process); ui->connections->setItem(row, 1, f); - // C2: Network + // C2: Protocol f = f0->clone(); - f->setText(conn.network); + auto prot = conn.network; + if (!conn.protocol.isEmpty()) prot += " ("+conn.protocol+")"; + f->setText(prot); ui->connections->setItem(row, 2, f); - // C3: Protocol + // C3: Outbound f = f0->clone(); - f->setText(conn.protocol); + f->setText(conn.outbound); ui->connections->setItem(row, 3, f); - // C4: Download + // C4: Traffic f = f0->clone(); - f->setText(ReadableSize(conn.download)); + f->setText(ReadableSize(conn.upload) + "↑" + " " + ReadableSize(conn.download) + "↓"); ui->connections->setItem(row, 4, f); - // C5: Upload - f = f0->clone(); - f->setText(ReadableSize(conn.upload)); - ui->connections->setItem(row, 5, f); - row++; } ui->connections->setUpdatesEnabled(true); diff --git a/src/ui/setting/dialog_basic_settings.cpp b/src/ui/setting/dialog_basic_settings.cpp index 76f5363..92972f2 100644 --- a/src/ui/setting/dialog_basic_settings.cpp +++ b/src/ui/setting/dialog_basic_settings.cpp @@ -141,7 +141,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent) ui->ntp_server->setText(NekoGui::dataStore->ntp_server_address); ui->ntp_port->setText(Int2String(NekoGui::dataStore->ntp_server_port)); ui->ntp_interval->setCurrentText(NekoGui::dataStore->ntp_interval); - connect(ui->ntp_enable, &QCheckBox::stateChanged, this, [=](const bool &state) { + connect(ui->ntp_enable, &QCheckBox::checkStateChanged, this, [=](const bool &state) { ui->ntp_server->setEnabled(state); ui->ntp_port->setEnabled(state); ui->ntp_interval->setEnabled(state); diff --git a/src/ui/setting/dialog_manage_routes.cpp b/src/ui/setting/dialog_manage_routes.cpp index 39d9e34..341b134 100644 --- a/src/ui/setting/dialog_manage_routes.cpp +++ b/src/ui/setting/dialog_manage_routes.cpp @@ -86,12 +86,12 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne ui->remote_dns_strategy->addItems(qsValue); ui->enable_fakeip->setChecked(NekoGui::dataStore->fake_dns); // - connect(ui->use_dns_object, &QCheckBox::stateChanged, this, [=](int state) { + connect(ui->use_dns_object, &QCheckBox::checkStateChanged, this, [=](int state) { auto useDNSObject = state == Qt::Checked; ui->simple_dns_box->setDisabled(useDNSObject); ui->dns_object->setDisabled(!useDNSObject); }); - ui->use_dns_object->stateChanged(Qt::Unchecked); // uncheck to uncheck + ui->use_dns_object->checkStateChanged(Qt::Unchecked); // uncheck to uncheck connect(ui->dns_document, &QPushButton::clicked, this, [=] { MessageBoxInfo("DNS", dnsHelpDocumentUrl); }); @@ -165,10 +165,10 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(ne ui->redirect_listenport->setValidator(QRegExpValidator_Number); ui->redirect_listenport->setText(Int2String(NekoGui::dataStore->redirect_listen_port)); - connect(ui->dnshijack_enable, &QCheckBox::stateChanged, this, [=](bool state) { + connect(ui->dnshijack_enable, &QCheckBox::checkStateChanged, this, [=](bool state) { set_dns_hijack_enability(state); }); - connect(ui->redirect_enable, &QCheckBox::stateChanged, this, [=](bool state) { + connect(ui->redirect_enable, &QCheckBox::checkStateChanged, this, [=](bool state) { ui->redirect_listenaddr->setEnabled(state); ui->redirect_listenport->setEnabled(state); });