-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud-install.cpp
102 lines (96 loc) · 3.31 KB
/
cloud-install.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
#include "cloud.h"
#include "ui_cloud.h"
#include "QSettings"
#include "QDebug"
#include "QMenu"
#include <QTimer>
#include <QHttp>
#include <QBuffer>
#include <QList>
#include <QFile>
#include <QtGui>
void Cloud::dl_reinstall()
{
TRACE(5, "");
qDebug() << "reinstall" << currentItem;
int item = currentItem;
if (item == -1)
return;
QString fol = games.at(item).folder.isEmpty() ? games.at(item).name : games.at(item).folder;
QString fil = QString("%1/%2/" + setGlobal->value("Global/DescFile").toString()).arg(setGlobal->value("Global/Folder").toString()).arg(fol);
qDebug() << fil << QFile::remove(fil);
finished.removeAll(item);
installed.removeAll(item);
while (items[item]->childCount())
items[item]->removeChild(items[item]->child(0));
TRACE(5, "");
}
void Cloud::dl_reconfigure()
{
TRACE(5, "");
int item = currentItem;
QString fol = games.at(item).folder.isEmpty() ? games.at(item).name : games.at(item).folder;
QString cmd = QString("%1/%2/%3/%4").arg(QApplication::applicationDirPath(), setGlobal->value("Global/Folder").toString(), fol, "install.cmd");
QString fol2 = QString("%1/%2/%3").arg(QApplication::applicationDirPath(), setGlobal->value("Global/Folder").toString(), fol);
qDebug() << "reconfigure" << cmd << "in" << fol2;
QProcess::startDetached(cmd, QStringList(), fol2);
TRACE(5, "");
}
void Cloud::add_shortcuts(int item)
{
TRACE(5, "");
ui->list->sortItems(1, Qt::AscendingOrder);
QString fol = games.at(item).folder.isEmpty() ? games.at(item).name : games.at(item).folder;
QString desc = QString("%1/%2/" + setGlobal->value("Global/DescFile").toString()).arg(setGlobal->value("Global/Folder").toString(), fol);
installed << item;
QFile file(desc);
file.open(QFile::ReadOnly);
while (!file.atEnd())
{
QString line = file.readLine();
if (line.contains("="))
{
line = line.left(line.size() - 2);
QString name = line.split("=")[0];
QString val = line.mid(line.indexOf("=")+1);
QRegExp re("(.*)[.]exe");
re.setMinimal(true);
val = val.replace(re, "\\1.exe\"");//\"
val = val.replace("\\\\", "\\");
QTreeWidgetItem* lwitem = new QTreeWidgetItem();
items[item]->setForeground(0, QBrush(Qt::white));
lwitem->setText(0, tr("Run %1").arg(name));
lwitem->setData(0, Qt::UserRole, val);
lwitem->setData(0, Qt::UserRole + 1, 2);
QString fol = games.at(item).folder.isEmpty() ? games.at(item).name : games.at(item).folder;
lwitem->setData(0, Qt::UserRole + 2, QString("%1/%2").arg(setGlobal->value("Global/Folder").toString(), fol));
items[item]->addChild(lwitem);
ui->list->expandAll();
}
}
TRACE(5, "");
}
void Cloud::refreshUnzipProgressEnd()
{
TRACE(5, "");
finished << current_v;
current_v = -1;
TRACE(5, "");
}
void Cloud::refreshUnzipProgressMax(unsigned long long int d)
{
TRACE(5, "");
unzip_max = d;
TRACE(5, "");
}
void Cloud::refreshUnzipProgress(unsigned long long int d)
{
TRACE(5, "");
int item = current_v;
if (current_v == -1)
return;
int local_changed;
SET_ITEM(items[item], QString("%1").arg(games.at(item).name), tr("Installing... %2/%3").arg((unsigned long)(d)).arg((unsigned long)unzip_max), 55, Qt::gray);
qDebug() << d;
TRACE(5, "");
}