Skip to content

Commit 8d76f15

Browse files
committed
Plugin: modify security level, add GetSecurityLevelUnicode
1 parent a8d1e76 commit 8d76f15

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

App/Client/mainwindow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,14 +1273,14 @@ void MainWindow::SetSecureLevel(COperate* o)
12731273
{
12741274
if(!m_pSecureLevel) return;
12751275
if(o) {
1276-
if(COperate::SecurityLevel::No == o->GetSecurityLevel())
1277-
{
1276+
QString szLevel = o->GetSecurityLevelUnicode(o->GetSecurityLevel());
1277+
if(szLevel.isEmpty()) {
12781278
m_pSecureLevel->hide();
12791279
return;
12801280
}
1281-
SetIndicator(m_pSecureLevel, o->GetSecurityLevelColor(), statusBar()->height() / 2);
1281+
m_pSecureLevel->setText(szLevel);
12821282
m_pSecureLevel->setToolTip(o->GetSecurityLevelString());
1283-
m_pSecureLevel->setStatusTip(o->GetSecurityLevelString());
1283+
//m_pSecureLevel->setStatusTip(o->GetSecurityLevelString());
12841284
m_pSecureLevel->show();
12851285
} else
12861286
m_pSecureLevel->hide();

Src/Operate.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,42 @@ QString COperate::GetSecurityLevelString(SecurityLevel level)
150150
return QString();
151151
}
152152

153+
/*!
154+
* \brief COperate::GetSecurityLevelUnicode
155+
* \param level
156+
* \return
157+
* | 符号 | Unicode 编码 | 说明 | 含义 |
158+
* |:----:|-------------|------|------|
159+
* | 🔓 | `U+1F513` | 开锁 | 未加密、无保护 |
160+
* | 🔐 | `U+1F510` | 带钥匙的锁(关闭) | 安全(有保护) |
161+
* | 🔒 | `U+1F512` | 闭锁 | 安全(已锁定) |
162+
* | 🔏 | `U+1F50F` | 带笔的锁 | 隐私模式 |
163+
* | ⚠ | `U+26A0` | 警告 | 不安全警告 |
164+
* | ❌ | `U+274C` | 红叉 | 错误、不安全 |
165+
* | 🛡 | `U+1F6E1` | 盾牌 | 有保护(安全) |
166+
* | 🔴 | `U+1F534` | 红圈 | 危险、警告 |
167+
* | 🟡 | `U+1F7E1` | 黄圈 | 注意、谨慎 |
168+
* | 🟢 | `U+1F7E2` | 绿圈 | 安全 |
169+
*/
170+
QString COperate::GetSecurityLevelUnicode(SecurityLevel level)
171+
{
172+
switch (level) {
173+
case SecurityLevel::Secure:
174+
return "🟢🛡🔐";
175+
case SecurityLevel::NonSecureAuthentication:
176+
return "🟡🛡🔓";
177+
case SecurityLevel::SecureChannel:
178+
return "🟡🛡";
179+
case SecurityLevel::SecureAuthentication:
180+
return "🟡🔐";
181+
case SecurityLevel::Risky:
182+
return "🔴🔓";
183+
default:
184+
break;
185+
}
186+
return QString();
187+
}
188+
153189
QColor COperate::GetSecurityLevelColor()
154190
{
155191
return GetSecurityLevelColor(GetSecurityLevel());

Src/Operate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class PLUGIN_EXPORT COperate : public QObject
129129
[[nodiscard]] virtual QString GetSecurityLevelString();
130130
[[nodiscard]] virtual QColor GetSecurityLevelColor();
131131
[[nodiscard]] static QString GetSecurityLevelString(SecurityLevel level);
132+
[[nodiscard]] static QString GetSecurityLevelUnicode(SecurityLevel level);
132133
[[nodiscard]] static QColor GetSecurityLevelColor(SecurityLevel level);
133134

134135
public:

0 commit comments

Comments
 (0)