forked from MatsuriDayo/nekoray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
206 lines (126 loc) · 4.42 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#pragma once
#include <QMainWindow>
#include "main/NekoGui.hpp"
#ifndef MW_INTERFACE
#include <QTime>
#include <QTableWidgetItem>
#include <QKeyEvent>
#include <QSystemTrayIcon>
#include <QProcess>
#include <QTextDocument>
#include <QShortcut>
#include <QSemaphore>
#include <QMutex>
#include "GroupSort.hpp"
#include "db/ProxyEntity.hpp"
#include "main/GuiUtils.hpp"
#endif
namespace NekoGui_sys {
class CoreProcess;
}
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
void refresh_proxy_list(const int &id = -1);
void show_group(int gid);
void refresh_groups();
void refresh_status(const QString &traffic_update = "");
void neko_start(int _id = -1);
void neko_stop(bool crash = false, bool sem = false);
void neko_set_spmode_system_proxy(bool enable, bool save = true);
void neko_set_spmode_vpn(bool enable, bool save = true);
void show_log_impl(const QString &log);
void start_select_mode(QObject *context, const std::function<void(int)> &callback);
void refresh_connection_list(const QJsonArray &arr);
void RegisterHotkey(bool unregister);
bool StopVPNProcess(bool unconditional = false);
signals:
void profile_selected(int id);
public slots:
void on_commitDataRequest();
void on_menu_exit_triggered();
#ifndef MW_INTERFACE
private slots:
void on_masterLogBrowser_customContextMenuRequested(const QPoint &pos);
void on_menu_basic_settings_triggered();
void on_menu_routing_settings_triggered();
void on_menu_vpn_settings_triggered();
void on_menu_hotkey_settings_triggered();
void on_menu_add_from_input_triggered();
void on_menu_add_from_clipboard_triggered();
void on_menu_clone_triggered();
void on_menu_move_triggered();
void on_menu_delete_triggered();
void on_menu_reset_traffic_triggered();
void on_menu_profile_debug_info_triggered();
void on_menu_copy_links_triggered();
void on_menu_copy_links_nkr_triggered();
void on_menu_export_config_triggered();
void display_qr_link(bool nkrFormat = false);
void on_menu_scan_qr_triggered();
void on_menu_clear_test_result_triggered();
void on_menu_manage_groups_triggered();
void on_menu_select_all_triggered();
void on_menu_delete_repeat_triggered();
void on_menu_remove_unavailable_triggered();
void on_menu_update_subscription_triggered();
void on_menu_resolve_domain_triggered();
void on_proxyListTable_itemDoubleClicked(QTableWidgetItem *item);
void on_proxyListTable_customContextMenuRequested(const QPoint &pos);
void on_tabWidget_currentChanged(int index);
private:
Ui::MainWindow *ui;
QSystemTrayIcon *tray;
QShortcut *shortcut_ctrl_f = new QShortcut(QKeySequence("Ctrl+F"), this);
QShortcut *shortcut_esc = new QShortcut(QKeySequence("Esc"), this);
//
NekoGui_sys::CoreProcess *core_process;
qint64 vpn_pid = 0;
//
bool qvLogAutoScoll = true;
QTextDocument *qvLogDocument = new QTextDocument(this);
//
QString title_error;
int icon_status = -1;
std::shared_ptr<NekoGui::ProxyEntity> running;
QString traffic_update_cache;
QTime last_test_time;
//
int proxy_last_order = -1;
bool select_mode = false;
QMutex mu_starting;
QMutex mu_stopping;
QMutex mu_exit;
QSemaphore sem_stopped;
int exit_reason = 0;
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_now_selected_list();
QList<std::shared_ptr<NekoGui::ProxyEntity>> get_selected_or_group();
void dialog_message_impl(const QString &sender, const QString &info);
void refresh_proxy_list_impl(const int &id = -1, GroupSortAction groupSortAction = {});
void refresh_proxy_list_impl_refresh_data(const int &id = -1);
void keyPressEvent(QKeyEvent *event) override;
void closeEvent(QCloseEvent *event) override;
//
void HotkeyEvent(const QString &key);
bool StartVPNProcess();
// grpc and ...
static void setup_grpc();
void speedtest_current_group(int mode);
void speedtest_current();
static void stop_core_daemon();
void CheckUpdate();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
#endif // MW_INTERFACE
};
inline MainWindow *GetMainWindow() {
return (MainWindow *) mainwindow;
}
void UI_InitMainWindow();