-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.h
executable file
·80 lines (66 loc) · 2.14 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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QAbstractNativeEventFilter>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
#include <QProcess>
#include <QSettings>
#include <QSystemTrayIcon>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void updateTrafficStats(double ulTraffic, double dlTraffic);
void updateConnStats(double ulTotal, double dlTotal, int numOfConns);
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
signals:
void clashApiReady();
private:
virtual void showEvent(QShowEvent *event) override;
virtual void closeEvent(QCloseEvent *event) override;
virtual bool event(QEvent *event) override;
void fetchConfig(const QString &profile);
void fetchClashVer();
QByteArray decryptConfig(const QByteArray &ba);
void setIcon(QIcon::Mode mode);
bool isAutoStart();
void fetchCfgReplyFinished();
void getVerReplyFinished();
void clashErrorOccurred(QProcess::ProcessError error);
void clashFinished(int exitCode, QProcess::ExitStatus exitStatus);
void clashStdoutReady();
void clashStarted();
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
void actionGroupTriggered(QAction *action);
void openCfgTriggered();
void openClashCfgTriggered();
void openWorkDirTriggered();
void autoStartTriggered(bool checked);
enum class PathType {
BaseDir,
IniFile,
ClashExecutable,
ClashConfig,
};
static QString getFilePath(PathType pt);
static void sendCtrlCToProcess(qint64 pid);
private:
Ui::MainWindow *ui;
char m_iv[9];
bool m_sizeAdjusted;
bool m_sysShutdown;
QSettings m_settings;
QMenu m_trayIconMenu;
QActionGroup m_actionGroup;
QSystemTrayIcon m_trayIcon;
QLabel m_trafficStats;
QLabel m_connStats;
QProcess m_clash;
};
#endif // MAINWINDOW_H