Skip to content

Commit 348ccf0

Browse files
committed
feat: hotkey system proxy
1 parent 9c0816c commit 348ccf0

File tree

6 files changed

+44
-21
lines changed

6 files changed

+44
-21
lines changed

main/NekoRay.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace NekoRay {
5050
_add(new configItem("hk_mw", &hotkey_mainwindow, itemType::string));
5151
_add(new configItem("hk_group", &hotkey_group, itemType::string));
5252
_add(new configItem("hk_route", &hotkey_route, itemType::string));
53+
_add(new configItem("hk_spmenu", &hotkey_system_proxy_menu, itemType::string));
5354
_add(new configItem("fakedns", &fake_dns, itemType::boolean));
5455
_add(new configItem("active_routing", &active_routing, itemType::string));
5556
_add(new configItem("mw_size", &mw_size, itemType::string));

main/NekoRay_DataStore.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ namespace NekoRay {
126126
QString hotkey_mainwindow = "";
127127
QString hotkey_group = "";
128128
QString hotkey_route = "";
129+
QString hotkey_system_proxy_menu = "";
129130

130131
// Other Core
131132
ExtraCore *extraCore = new ExtraCore;

translations/zh_CN.ts

+4
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@
376376
<source>Trigger main window</source>
377377
<translation>显示/隐藏主窗口</translation>
378378
</message>
379+
<message>
380+
<source>System Proxy</source>
381+
<translation>系统代理</translation>
382+
</message>
379383
</context>
380384
<context>
381385
<name>DialogManageGroups</name>

ui/dialog_hotkey.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ DialogHotkey::DialogHotkey(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog
88
ui->show_mainwindow->setKeySequence(NekoRay::dataStore->hotkey_mainwindow);
99
ui->show_groups->setKeySequence(NekoRay::dataStore->hotkey_group);
1010
ui->show_routes->setKeySequence(NekoRay::dataStore->hotkey_route);
11+
ui->system_proxy->setKeySequence(NekoRay::dataStore->hotkey_system_proxy_menu);
1112
GetMainWindow()->RegisterHotkey(true);
1213
}
1314

@@ -16,6 +17,7 @@ DialogHotkey::~DialogHotkey() {
1617
NekoRay::dataStore->hotkey_mainwindow = ui->show_mainwindow->keySequence().toString();
1718
NekoRay::dataStore->hotkey_group = ui->show_groups->keySequence().toString();
1819
NekoRay::dataStore->hotkey_route = ui->show_routes->keySequence().toString();
20+
NekoRay::dataStore->hotkey_system_proxy_menu = ui->system_proxy->keySequence().toString();
1921
NekoRay::dataStore->Save();
2022
}
2123
GetMainWindow()->RegisterHotkey(false);

ui/dialog_hotkey.ui

+28-17
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
<string>Hotkey</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
17-
<item row="0" column="0">
18-
<widget class="QLabel" name="label">
17+
<item row="1" column="1">
18+
<widget class="QtExtKeySequenceEdit" name="show_groups"/>
19+
</item>
20+
<item row="2" column="0">
21+
<widget class="QLabel" name="label_4">
1922
<property name="text">
20-
<string>Trigger main window</string>
23+
<string>Show routes</string>
2124
</property>
2225
</widget>
2326
</item>
24-
<item row="1" column="1">
25-
<widget class="QtExtKeySequenceEdit" name="show_groups"/>
27+
<item row="2" column="1">
28+
<widget class="QtExtKeySequenceEdit" name="show_routes"/>
2629
</item>
27-
<item row="3" column="1">
30+
<item row="4" column="1">
2831
<widget class="QDialogButtonBox" name="buttonBox">
2932
<property name="focusPolicy">
3033
<enum>Qt::StrongFocus</enum>
@@ -34,26 +37,33 @@
3437
</property>
3538
</widget>
3639
</item>
37-
<item row="2" column="0">
38-
<widget class="QLabel" name="label_4">
39-
<property name="text">
40-
<string>Show routes</string>
41-
</property>
42-
</widget>
43-
</item>
4440
<item row="0" column="1">
4541
<widget class="QtExtKeySequenceEdit" name="show_mainwindow"/>
4642
</item>
47-
<item row="2" column="1">
48-
<widget class="QtExtKeySequenceEdit" name="show_routes"/>
49-
</item>
5043
<item row="1" column="0">
5144
<widget class="QLabel" name="label_3">
5245
<property name="text">
5346
<string>Show groups</string>
5447
</property>
5548
</widget>
5649
</item>
50+
<item row="0" column="0">
51+
<widget class="QLabel" name="label">
52+
<property name="text">
53+
<string>Trigger main window</string>
54+
</property>
55+
</widget>
56+
</item>
57+
<item row="3" column="0">
58+
<widget class="QLabel" name="label_2">
59+
<property name="text">
60+
<string>System Proxy</string>
61+
</property>
62+
</widget>
63+
</item>
64+
<item row="3" column="1">
65+
<widget class="QtExtKeySequenceEdit" name="system_proxy"/>
66+
</item>
5767
</layout>
5868
</widget>
5969
<customwidgets>
@@ -64,10 +74,11 @@
6474
</customwidget>
6575
</customwidgets>
6676
<tabstops>
67-
<tabstop>buttonBox</tabstop>
6877
<tabstop>show_mainwindow</tabstop>
6978
<tabstop>show_groups</tabstop>
7079
<tabstop>show_routes</tabstop>
80+
<tabstop>system_proxy</tabstop>
81+
<tabstop>buttonBox</tabstop>
7182
</tabstops>
7283
<resources/>
7384
<connections>

ui/mainwindow.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -1401,10 +1401,12 @@ void MainWindow::RegisterHotkey(bool unregister) {
14011401
}
14021402
if (unregister) return;
14031403

1404-
QStringList regstr;
1405-
regstr += NekoRay::dataStore->hotkey_mainwindow;
1406-
regstr += NekoRay::dataStore->hotkey_group;
1407-
regstr += NekoRay::dataStore->hotkey_route;
1404+
QStringList regstr{
1405+
NekoRay::dataStore->hotkey_mainwindow,
1406+
NekoRay::dataStore->hotkey_group,
1407+
NekoRay::dataStore->hotkey_route,
1408+
NekoRay::dataStore->hotkey_system_proxy_menu,
1409+
};
14081410

14091411
for (const auto &key: regstr) {
14101412
if (key.isEmpty()) continue;
@@ -1432,6 +1434,8 @@ void MainWindow::HotkeyEvent(const QString &key) {
14321434
on_menu_manage_groups_triggered();
14331435
} else if (key == NekoRay::dataStore->hotkey_route) {
14341436
on_menu_routing_settings_triggered();
1437+
} else if (key == NekoRay::dataStore->hotkey_system_proxy_menu) {
1438+
ui->menu_spmode->popup(QCursor::pos());
14351439
}
14361440
});
14371441
}

0 commit comments

Comments
 (0)