forked from MatsuriDayo/nekoray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_naive.cpp
68 lines (56 loc) · 1.64 KB
/
edit_naive.cpp
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
#include "edit_naive.h"
#include "ui_edit_naive.h"
#include "fmt/NaiveBean.hpp"
#include <QInputDialog>
EditNaive::EditNaive(QWidget *parent) : QWidget(parent), ui(new Ui::EditNaive) {
ui->setupUi(this);
}
EditNaive::~EditNaive() {
delete ui;
}
void EditNaive::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
this->ent = _ent;
auto bean = this->ent->NaiveBean();
P_LOAD_STRING(username);
P_LOAD_STRING(password);
P_LOAD_COMBO_STRING(protocol);
P_C_LOAD_STRING(extra_headers);
P_LOAD_STRING(sni);
P_C_LOAD_STRING(certificate);
P_LOAD_INT(insecure_concurrency);
P_LOAD_BOOL(disable_log);
}
bool EditNaive::onEnd() {
auto bean = this->ent->NaiveBean();
P_SAVE_STRING(username);
P_SAVE_STRING(password);
P_SAVE_COMBO_STRING(protocol);
P_C_SAVE_STRING(extra_headers);
P_SAVE_STRING(sni);
P_C_SAVE_STRING(certificate);
P_SAVE_INT(insecure_concurrency);
P_SAVE_BOOL(disable_log);
return true;
}
QList<QPair<QPushButton *, QString>> EditNaive::get_editor_cached() {
return {
{ui->certificate, CACHE.certificate},
{ui->extra_headers, CACHE.extra_headers},
};
}
void EditNaive::on_certificate_clicked() {
bool ok;
auto txt = QInputDialog::getMultiLineText(this, tr("Certificate"), "", CACHE.certificate, &ok);
if (ok) {
CACHE.certificate = txt;
editor_cache_updated();
}
}
void EditNaive::on_extra_headers_clicked() {
bool ok;
auto txt = QInputDialog::getMultiLineText(this, tr("Extra headers"), "", CACHE.extra_headers, &ok);
if (ok) {
CACHE.extra_headers = txt;
editor_cache_updated();
}
}