feat: hotkey system proxy

This commit is contained in:
arm64v8a
2022-12-04 16:24:39 +09:00
parent 9c0816c71a
commit 348ccf097f
6 changed files with 46 additions and 23 deletions

View File

@@ -50,6 +50,7 @@ namespace NekoRay {
_add(new configItem("hk_mw", &hotkey_mainwindow, itemType::string));
_add(new configItem("hk_group", &hotkey_group, itemType::string));
_add(new configItem("hk_route", &hotkey_route, itemType::string));
_add(new configItem("hk_spmenu", &hotkey_system_proxy_menu, itemType::string));
_add(new configItem("fakedns", &fake_dns, itemType::boolean));
_add(new configItem("active_routing", &active_routing, itemType::string));
_add(new configItem("mw_size", &mw_size, itemType::string));

View File

@@ -126,6 +126,7 @@ namespace NekoRay {
QString hotkey_mainwindow = "";
QString hotkey_group = "";
QString hotkey_route = "";
QString hotkey_system_proxy_menu = "";
// Other Core
ExtraCore *extraCore = new ExtraCore;

View File

@@ -376,6 +376,10 @@
<source>Trigger main window</source>
<translation>/</translation>
</message>
<message>
<source>System Proxy</source>
<translation></translation>
</message>
</context>
<context>
<name>DialogManageGroups</name>

View File

@@ -8,6 +8,7 @@ DialogHotkey::DialogHotkey(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog
ui->show_mainwindow->setKeySequence(NekoRay::dataStore->hotkey_mainwindow);
ui->show_groups->setKeySequence(NekoRay::dataStore->hotkey_group);
ui->show_routes->setKeySequence(NekoRay::dataStore->hotkey_route);
ui->system_proxy->setKeySequence(NekoRay::dataStore->hotkey_system_proxy_menu);
GetMainWindow()->RegisterHotkey(true);
}
@@ -16,6 +17,7 @@ DialogHotkey::~DialogHotkey() {
NekoRay::dataStore->hotkey_mainwindow = ui->show_mainwindow->keySequence().toString();
NekoRay::dataStore->hotkey_group = ui->show_groups->keySequence().toString();
NekoRay::dataStore->hotkey_route = ui->show_routes->keySequence().toString();
NekoRay::dataStore->hotkey_system_proxy_menu = ui->system_proxy->keySequence().toString();
NekoRay::dataStore->Save();
}
GetMainWindow()->RegisterHotkey(false);

View File

@@ -14,17 +14,20 @@
<string>Hotkey</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Trigger main window</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QtExtKeySequenceEdit" name="show_groups"/>
</item>
<item row="3" column="1">
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Show routes</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QtExtKeySequenceEdit" name="show_routes"/>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
@@ -34,19 +37,9 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Show routes</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QtExtKeySequenceEdit" name="show_mainwindow"/>
</item>
<item row="2" column="1">
<widget class="QtExtKeySequenceEdit" name="show_routes"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@@ -54,6 +47,23 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Trigger main window</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>System Proxy</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QtExtKeySequenceEdit" name="system_proxy"/>
</item>
</layout>
</widget>
<customwidgets>
@@ -64,10 +74,11 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>show_mainwindow</tabstop>
<tabstop>show_groups</tabstop>
<tabstop>show_routes</tabstop>
<tabstop>system_proxy</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>

View File

@@ -1401,10 +1401,12 @@ void MainWindow::RegisterHotkey(bool unregister) {
}
if (unregister) return;
QStringList regstr;
regstr += NekoRay::dataStore->hotkey_mainwindow;
regstr += NekoRay::dataStore->hotkey_group;
regstr += NekoRay::dataStore->hotkey_route;
QStringList regstr{
NekoRay::dataStore->hotkey_mainwindow,
NekoRay::dataStore->hotkey_group,
NekoRay::dataStore->hotkey_route,
NekoRay::dataStore->hotkey_system_proxy_menu,
};
for (const auto &key: regstr) {
if (key.isEmpty()) continue;
@@ -1432,6 +1434,8 @@ void MainWindow::HotkeyEvent(const QString &key) {
on_menu_manage_groups_triggered();
} else if (key == NekoRay::dataStore->hotkey_route) {
on_menu_routing_settings_triggered();
} else if (key == NekoRay::dataStore->hotkey_system_proxy_menu) {
ui->menu_spmode->popup(QCursor::pos());
}
});
}