-
Notifications
You must be signed in to change notification settings - Fork 16
/
wkinstaller.cpp
50 lines (43 loc) · 1.18 KB
/
wkinstaller.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
#include "wkinstaller.h"
#include <QProcess>
#include <QString>
WKInstaller::WKInstaller(WKSettings& settings) : settings(settings) {}
void WKInstaller::process() {
converter = std::make_unique<WKConverter>(settings, this);
try {
converter->run();
} catch (const std::exception& e) {
error(e);
emit setInfo("error");
// Retry once…
try {
converter->retryInstall();
} catch (const std::exception& e) {
error(e, true);
emit finished();
emit setInfo("error");
}
}
}
void WKInstaller::error(std::exception const& err, bool showDialog) {
std::string errorMessage = err.what();
if (showDialog)
emit createDialog("dialogError$" + errorMessage, "Error");
emit log(errorMessage);
}
void WKInstaller::installUserPatch(fs::path exePath,
std::vector<std::string> cliFlags) {
QProcess process;
QStringList args;
QString name = QString::fromStdString(exePath.string());
#ifndef _WIN32
// Use wine on non-windows
args << name;
name = QString("wine");
#endif
for (auto arg : cliFlags) {
args << QString::fromStdString(arg);
}
process.start(name, args);
process.waitForFinished(180000);
}