-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
164 lines (137 loc) · 4.39 KB
/
MainWindow.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
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
#include "MainWindow.h"
void MainWindow::InitAccountView()
{
// setModel
ui->AccountView->setModel(&m_AccountModel);
// 设置右键菜单
ui->AccountView->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->AccountView->addActions(ui->menuAccount->actions());
// 交替行的颜色
ui->AccountView->setAlternatingRowColors(true);
// 自动调整宽度
ui->AccountView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
}
// 保存设置
void MainWindow::saveSettings()
{
// json
QJsonObject JsonObject;
JsonObject.insert("AccountList", m_AccountModel.toJson());
QJsonDocument JsonDocument(JsonObject);
QByteArray Json = JsonDocument.toJson();
// save
QSettings settings;
settings.setValue("geometry", this->saveGeometry());
settings.setValue("windowState", this->saveState());
settings.setValue("Json", Json);
}
// 读取设置
void MainWindow::readSettings()
{
// read
QSettings settings;
this->restoreGeometry(settings.value("geometry").toByteArray());
this->restoreState(settings.value("windowState").toByteArray());
QByteArray Json = settings.value("Json").toByteArray();
// json
QJsonDocument JsonDocument = QJsonDocument::fromJson(Json);
QJsonObject JsonObject = JsonDocument.object();
m_AccountModel.fromJson(JsonObject.value("AccountList"));
}
void MainWindow::on_actionInsert_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
m_AccountModel.insertRow(currentIndex.row());
}
else
{
m_AccountModel.insertRow(0);
}
}
void MainWindow::on_actionRemove_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
m_AccountModel.removeRow(currentIndex.row());
}
}
void MainWindow::on_actionMyAccount_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
QUrl url("https://www.pathofexile.com/my-account");
QByteArray POESESSID = m_AccountModel.at(currentIndex.row())->m_POESESSID.toLatin1();
QNetworkCookie cookie("POESESSID", POESESSID);
QWebEnginePage *page = m_WebEngineView.page();
QWebEngineProfile *profile = page->profile();
QWebEngineCookieStore *cookieStore = profile->cookieStore();
cookieStore->deleteAllCookies();
cookieStore->setCookie(cookie, url);
m_WebEngineView.setWindowTitle(POESESSID);
m_WebEngineView.load(url);
m_WebEngineView.show();
}
}
void MainWindow::on_actionStart_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
m_AccountModel.start(currentIndex);
}
}
void MainWindow::on_actionQuit_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
m_AccountModel.quit(currentIndex);
}
}
void MainWindow::on_actionPacketList_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
Account *account = m_AccountModel.at(currentIndex.row());
if (account->isRunning())
{
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
// proxyModel->setFilterRegularExpression("021a");
// proxyModel->setFilterKeyColumn(3); // Data
// proxyModel->setSourceModel(&account->m_ExileGame->m_PacketListModel);
m_PacketView.setModel(&account->m_ExileGame->m_PacketListModel);
m_PacketView.show();
}
}
}
void MainWindow::on_actionScene_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
Account *account = m_AccountModel.at(currentIndex.row());
if (account->isRunning())
{
m_SceneView.setScene(&account->m_ExileGame->m_Scene);
m_SceneView.show();
}
}
}
void MainWindow::on_actionCharacterList_triggered()
{
QModelIndex currentIndex = ui->AccountView->currentIndex();
if (currentIndex.isValid())
{
Account *account = m_AccountModel.at(currentIndex.row());
if (account->isRunning())
{
m_CharacterView.setModel(&account->m_ExileClient->m_CharacterModel);
m_CharacterView.show();
}
}
}