From 51e00eeaaf2e51cbc0a4535a91aa292cf86a9f17 Mon Sep 17 00:00:00 2001
From: arm64v8a <48624112+arm64v8a@users.noreply.github.com>
Date: Thu, 12 Jan 2023 13:14:54 +0900
Subject: [PATCH] chore: connection list icon
---
res/icon/material/cancel.svg | 1 +
res/icon/material/history.svg | 1 +
res/icon/material/swap-vertical.svg | 1 +
res/neko.qrc | 3 +++
translations/fa_IR.ts | 4 ++--
translations/zh_CN.ts | 4 ++--
ui/Icon.cpp | 4 ++--
ui/Icon.hpp | 6 +++---
ui/mainwindow.cpp | 29 +++++++++++++++++++----------
9 files changed, 34 insertions(+), 19 deletions(-)
create mode 100644 res/icon/material/cancel.svg
create mode 100644 res/icon/material/history.svg
create mode 100644 res/icon/material/swap-vertical.svg
diff --git a/res/icon/material/cancel.svg b/res/icon/material/cancel.svg
new file mode 100644
index 0000000..3327c05
--- /dev/null
+++ b/res/icon/material/cancel.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/res/icon/material/history.svg b/res/icon/material/history.svg
new file mode 100644
index 0000000..20c490c
--- /dev/null
+++ b/res/icon/material/history.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/res/icon/material/swap-vertical.svg b/res/icon/material/swap-vertical.svg
new file mode 100644
index 0000000..41d46a9
--- /dev/null
+++ b/res/icon/material/swap-vertical.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/res/neko.qrc b/res/neko.qrc
index 1b52064..4d1987d 100644
--- a/res/neko.qrc
+++ b/res/neko.qrc
@@ -8,6 +8,9 @@
icon/system-software-update.svg
icon/material/lock-open-outline.svg
icon/material/lock-outline.svg
+ icon/material/cancel.svg
+ icon/material/history.svg
+ icon/material/swap-vertical.svg
public/nekobox.png
diff --git a/translations/fa_IR.ts b/translations/fa_IR.ts
index c4e56f5..64902fb 100644
--- a/translations/fa_IR.ts
+++ b/translations/fa_IR.ts
@@ -1177,11 +1177,11 @@ Split by line.
End
- پایان
+ پایان
Active
- فعال
+ فعال
Start: %1
diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts
index 0b0f460..ff8b0b1 100644
--- a/translations/zh_CN.ts
+++ b/translations/zh_CN.ts
@@ -1009,11 +1009,11 @@
End
- 结束
+ 结束
Active
- 活动
+ 活动
Start: %1
diff --git a/ui/Icon.cpp b/ui/Icon.cpp
index d2338df..2e83c34 100644
--- a/ui/Icon.cpp
+++ b/ui/Icon.cpp
@@ -4,7 +4,7 @@
#include
-QIcon Icon::GetTrayIcon(Icon::TrayIconStatus status) {
+QPixmap Icon::GetTrayIcon(Icon::TrayIconStatus status) {
QPixmap pixmap;
// software embedded icon
@@ -47,7 +47,7 @@ QIcon Icon::GetTrayIcon(Icon::TrayIconStatus status) {
return pixmap;
}
-QIcon Icon::GetMaterialIcon(const QString &name) {
+QPixmap Icon::GetMaterialIcon(const QString &name) {
QPixmap pixmap(":/icon/material/" + name + ".svg");
return pixmap;
}
diff --git a/ui/Icon.hpp b/ui/Icon.hpp
index 9ceae93..4395344 100644
--- a/ui/Icon.hpp
+++ b/ui/Icon.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
namespace Icon {
@@ -11,8 +11,8 @@ namespace Icon {
VPN,
};
- QIcon GetTrayIcon(TrayIconStatus status);
+ QPixmap GetTrayIcon(TrayIconStatus status);
- QIcon GetMaterialIcon(const QString &name);
+ QPixmap GetMaterialIcon(const QString &name);
} // namespace Icon
diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp
index 6516834..f2608d8 100644
--- a/ui/mainwindow.cpp
+++ b/ui/mainwindow.cpp
@@ -1438,27 +1438,36 @@ void MainWindow::refresh_connection_list(const QJsonArray &arr) {
row++;
ui->tableWidget_conn->insertRow(row);
+ auto f0 = std::make_unique();
+ f0->setData(114514, item["ID"].toInt());
+
// C0: Status
- auto *f = new QTableWidgetItem("");
- f->setData(114514, item["ID"].toInt());
+ auto c0 = new QLabel;
auto start_t = item["Start"].toInt();
auto end_t = item["End"].toInt();
- if (end_t > 0) {
- f->setText(tr("End"));
+ // icon
+ auto outboundTag = item["Tag"].toString();
+ if (outboundTag == "block") {
+ c0->setPixmap(Icon::GetMaterialIcon("cancel"));
} else {
- f->setText(tr("Active"));
+ if (end_t > 0) {
+ c0->setPixmap(Icon::GetMaterialIcon("history"));
+ } else {
+ c0->setPixmap(Icon::GetMaterialIcon("swap-vertical"));
+ }
}
- f->setToolTip(tr("Start: %1\nEnd: %2").arg(DisplayTime(start_t), end_t > 0 ? DisplayTime(end_t) : ""));
- ui->tableWidget_conn->setItem(row, 0, f);
+ c0->setAlignment(Qt::AlignCenter);
+ c0->setToolTip(tr("Start: %1\nEnd: %2").arg(DisplayTime(start_t), end_t > 0 ? DisplayTime(end_t) : ""));
+ ui->tableWidget_conn->setCellWidget(row, 0, c0);
// C1: Outbound
- f = f->clone();
+ auto f = f0->clone();
f->setToolTip("");
- f->setText(item["Tag"].toString());
+ f->setText(outboundTag);
ui->tableWidget_conn->setItem(row, 1, f);
// C2: Destination
- f = f->clone();
+ f = f0->clone();
QString target1 = item["Dest"].toString();
QString target2 = item["RDest"].toString();
if (target2.isEmpty() || target1 == target2) {