-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.cpp
80 lines (67 loc) · 2.78 KB
/
cloud.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
#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>
/*QBuffer Cloud::httpBuf;
QBuffer Cloud::httpBufStatus;*/
Cloud::Cloud(QSettings* set, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Cloud)
{
torrent = new Torrent(set, &games, &hashes, this);
unzip_max = 0;
current_torrent = 0;
ui->setupUi(this);
ui->list->clear();
ui->list->hideColumn(2);
//ui->webView->setUrl(QUrl("http://www.jeuxvideo.fr/jeux/battlefield-3/preview-test-battlefield-3.html"));
setGlobal = set;
updateContent();
TRACE(5, "");
torrent->startApp();
ui->list->setIconSize(QSize(32, 32));
current_v = -1;
//changed = 10;
ui->list->setColumnWidth(0, 350);
timer_ui = new QTimer();
connect(timer_ui, SIGNAL(timeout()), this, SLOT(ui_refresh()));
timer_ui->start(1000);
statusBar()->showMessage(tr("Loading..."));
ui->list->setItemDelegateForColumn(1, new ItemDelegate(ui->list));
qRegisterMetaType<unsigned long long int>("unsigned long long int");
connect(&unzip, SIGNAL(newState(unsigned long long int)), this, SLOT(refreshUnzipProgress(unsigned long long int)));
connect(&unzip, SIGNAL(max(unsigned long long int)), this, SLOT(refreshUnzipProgressMax(unsigned long long int)));
connect(&unzip, SIGNAL(end()), this, SLOT(refreshUnzipProgressEnd()));
ui->toolBar->setFixedHeight(32);
ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui->toolBar->addAction(QIcon(":/res/play.png"), "", this, SLOT(dl_start_torrent()))->setToolTip(tr("Start all"));
//ui->toolBar->addAction(QIcon(":/res/slow.png"), tr("Slow down"), this, SLOT(show_utorrent()));
ui->toolBar->addAction(QIcon(":/res/stop.png"), "", this, SLOT(dl_stop_torrent()))->setToolTip(tr("Pause all"));
ui->toolBar->addAction(QIcon(":/res/eject.png"), "", this, SLOT(dl_reset()))->setToolTip(tr("Cancel all"));
ui->toolBar->addSeparator();
//ui->toolBar->addAction(QIcon(":/res/add.png"), "", this, SLOT(show_utorrent()));
ui->toolBar->addAction(QIcon(":/res/add-server.png"), tr("Add server"), this, SLOT(newIp()));
//ui->toolBar->addAction(QIcon(":/res/utorrent.png"), "", this, SLOT(show_utorrent()));
ui->toolBar->addSeparator();
ui->toolBar->addAction(QIcon(":/res/shutdown.png"), "", this, SLOT(appExit()))->setToolTip(tr("Exit"));
}
Cloud::~Cloud()
{
delete ui;
}
void Cloud::on_list_itemClicked(QTreeWidgetItem *item, int column)
{
QString url = games[item->data(0, Qt::UserRole).toInt()].url;
qDebug() << url << "-" << ui->webView->url();
if (url == "")
url = "about:blank";
if (ui->webView->url() != url)
ui->webView->setUrl(QUrl(url));
}