Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keybinds to toggle configuration #1419

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main/NekoGui_DataStore.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// DO NOT INCLUDE THIS

namespace NekoGui {

class Routing : public JsonStore {
Expand Down Expand Up @@ -89,6 +87,7 @@ namespace NekoGui {
bool flag_debug = false;
bool flag_restart_tun_on = false;
bool flag_reorder = false;
bool flag_toggle_config = false; // Pbac2

// Saved

Expand Down Expand Up @@ -159,6 +158,7 @@ namespace NekoGui {
QString hotkey_group = "";
QString hotkey_route = "";
QString hotkey_system_proxy_menu = "";
QString hotkey_toggle_config = ""; // Pf754

// Core
int core_box_clash_api = -9090;
Expand Down
1 change: 1 addition & 0 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ int main(int argc, char* argv[]) {
if (NekoGui::dataStore->argv.contains("-debug")) NekoGui::dataStore->flag_debug = true;
if (NekoGui::dataStore->argv.contains("-flag_restart_tun_on")) NekoGui::dataStore->flag_restart_tun_on = true;
if (NekoGui::dataStore->argv.contains("-flag_reorder")) NekoGui::dataStore->flag_reorder = true;
if (NekoGui::dataStore->argv.contains("-toggle_config")) NekoGui::dataStore->flag_toggle_config = true;
#ifdef NKR_CPP_USE_APPDATA
NekoGui::dataStore->flag_use_appdata = true; // Example: Package & MacOS
#endif
Expand Down
2 changes: 2 additions & 0 deletions ui/dialog_hotkey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DialogHotkey::DialogHotkey(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog
ui->show_groups->setKeySequence(NekoGui::dataStore->hotkey_group);
ui->show_routes->setKeySequence(NekoGui::dataStore->hotkey_route);
ui->system_proxy->setKeySequence(NekoGui::dataStore->hotkey_system_proxy_menu);
ui->toggle_config->setKeySequence(NekoGui::dataStore->hotkey_toggle_config);
GetMainWindow()->RegisterHotkey(true);
}

Expand All @@ -18,6 +19,7 @@ DialogHotkey::~DialogHotkey() {
NekoGui::dataStore->hotkey_group = ui->show_groups->keySequence().toString();
NekoGui::dataStore->hotkey_route = ui->show_routes->keySequence().toString();
NekoGui::dataStore->hotkey_system_proxy_menu = ui->system_proxy->keySequence().toString();
NekoGui::dataStore->hotkey_toggle_config = ui->toggle_config->keySequence().toString();
NekoGui::dataStore->Save();
}
GetMainWindow()->RegisterHotkey(false);
Expand Down
7 changes: 7 additions & 0 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ void MainWindow::RegisterHotkey(bool unregister) {
NekoGui::dataStore->hotkey_group,
NekoGui::dataStore->hotkey_route,
NekoGui::dataStore->hotkey_system_proxy_menu,
NekoGui::dataStore->hotkey_toggle_config,
};

for (const auto &key: regstr) {
Expand Down Expand Up @@ -1754,6 +1755,12 @@ void MainWindow::HotkeyEvent(const QString &key) {
on_menu_routing_settings_triggered();
} else if (key == NekoGui::dataStore->hotkey_system_proxy_menu) {
ui->menu_spmode->popup(QCursor::pos());
} else if (key == NekoGui::dataStore->hotkey_toggle_config) {
if (NekoGui::dataStore->started_id >= 0) {
neko_stop();
} else {
neko_start();
}
}
});
}
Expand Down