mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
add outbound and improve connection lister
This commit is contained in:
parent
bc804ca16c
commit
d01ffbe2c5
@ -11,7 +11,8 @@ namespace NekoGui_traffic
|
||||
Default,
|
||||
ByDownload,
|
||||
ByUpload,
|
||||
ByProcess
|
||||
ByProcess,
|
||||
ByTraffic
|
||||
};
|
||||
|
||||
class ConnectionMetadata
|
||||
|
||||
@ -437,11 +437,6 @@
|
||||
<string>Click To Sort By Process</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Network</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Protocol</string>
|
||||
@ -449,18 +444,15 @@
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Download</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click To Sort By Download</string>
|
||||
<string>Outbound</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Upload</string>
|
||||
<string>Traffic</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click To Sort By Upload</string>
|
||||
<string>Click To Toggle sort by Traffic</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
@ -556,7 +548,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>17</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_program">
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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 QMap<QString, NekoGui_traffic::Conne
|
||||
// C1: Process
|
||||
ui->connections->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 QMap<QString, NekoGui_traffic::Conne
|
||||
f->setText(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 QList<NekoGui_traffic::C
|
||||
f->setText(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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user