author | nemo |
Mon, 24 Oct 2022 10:06:52 -0400 | |
branch | 1.0.0 |
changeset 15885 | ed84eb580643 |
parent 13284 | b504131f7405 |
permissions | -rw-r--r-- |
5271 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
5271 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
5271 | 17 |
*/ |
18 |
||
19 |
#include <QGridLayout> |
|
20 |
#include <QPushButton> |
|
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
21 |
#include <QNetworkAccessManager> |
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
22 |
#include <QNetworkRequest> |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
23 |
#include <QNetworkReply> |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
24 |
#include <QFileInfo> |
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
25 |
#include <QFileDialog> |
5754 | 26 |
#include <QDebug> |
27 |
#include <QProgressBar> |
|
5756 | 28 |
#include <QBuffer> |
9829 | 29 |
#include <QDesktopServices> |
5271 | 30 |
|
31 |
#include "pagedata.h" |
|
5755
a079b4dea081
Implement DataBrowser which downloads resources (images, css) on its own.
unc0rr
parents:
5754
diff
changeset
|
32 |
#include "databrowser.h" |
5762 | 33 |
#include "hwconsts.h" |
5754 | 34 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
35 |
QLayout * PageDataDownload::bodyLayoutDefinition() |
5271 | 36 |
{ |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
37 |
QGridLayout * pageLayout = new QGridLayout(); |
5271 | 38 |
pageLayout->setColumnStretch(0, 1); |
39 |
pageLayout->setColumnStretch(1, 1); |
|
40 |
pageLayout->setColumnStretch(2, 1); |
|
41 |
||
5755
a079b4dea081
Implement DataBrowser which downloads resources (images, css) on its own.
unc0rr
parents:
5754
diff
changeset
|
42 |
web = new DataBrowser(this); |
5271 | 43 |
pageLayout->addWidget(web, 0, 0, 1, 3); |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
44 |
|
5769 | 45 |
progressBarsLayout = new QVBoxLayout(); |
5754 | 46 |
pageLayout->addLayout(progressBarsLayout, 1, 0, 1, 3); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
47 |
return pageLayout; |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
48 |
} |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
49 |
|
9829 | 50 |
QLayout * PageDataDownload::footerLayoutDefinition() |
51 |
{ |
|
52 |
QHBoxLayout * bottomLayout = new QHBoxLayout(); |
|
53 |
bottomLayout->setStretch(0, 1); |
|
54 |
||
12234 | 55 |
pbHome = addButton(":/res/home.png", bottomLayout, 1, true, Qt::AlignBottom); |
56 |
pbHome->setMinimumHeight(50); |
|
57 |
pbHome->setMinimumWidth(50); |
|
12238 | 58 |
pbHome->setWhatsThis(tr("Load the start page")); |
12234 | 59 |
|
12482 | 60 |
pbOpenDir = addButton(":/res/folder.png", bottomLayout, 2, true, Qt::AlignBottom); |
12236
a0ed4caa6d35
Apply minimal padding to all text buttons in frontend
Wuzzy <almikes@aol.com>
parents:
12234
diff
changeset
|
61 |
pbOpenDir->setStyleSheet("padding: 5px 10px"); |
12482 | 62 |
pbOpenDir->setWhatsThis(tr("Open packages directory")); |
11819
7642955690bc
Tweak sizes and icons of most footer buttons of frontend
Wuzzy <almikes@aol.com>
parents:
11626
diff
changeset
|
63 |
pbOpenDir->setMinimumHeight(50); |
9829 | 64 |
|
65 |
bottomLayout->setStretch(2, 1); |
|
66 |
||
67 |
return bottomLayout; |
|
68 |
} |
|
69 |
||
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
70 |
void PageDataDownload::connectSignals() |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
71 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
72 |
connect(web, SIGNAL(anchorClicked(QUrl)), this, SLOT(request(const QUrl&))); |
6932 | 73 |
connect(this, SIGNAL(goBack()), this, SLOT(onPageLeave())); |
9829 | 74 |
connect(pbOpenDir, SIGNAL(clicked()), this, SLOT(openPackagesDir())); |
12234 | 75 |
connect(pbHome, SIGNAL(clicked()), this, SLOT(fetchList())); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
76 |
} |
6009 | 77 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
78 |
PageDataDownload::PageDataDownload(QWidget* parent) : AbstractPage(parent) |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
79 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
80 |
initPage(); |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
81 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
82 |
web->setOpenLinks(false); |
6384
8b7e8ff1b16a
Disable loading content.html on startup, it is fetched on pushing to top of stack already.
nemo
parents:
6131
diff
changeset
|
83 |
// fetchList(); |
8876
bd8df772dbe6
reintroduce the notification message in case you access dlc page without internet connection
koda
parents:
8059
diff
changeset
|
84 |
web->setHtml(QString( |
bd8df772dbe6
reintroduce the notification message in case you access dlc page without internet connection
koda
parents:
8059
diff
changeset
|
85 |
"<center><h2>Hedgewars Downloadable Content</h2><br><br>" |
bd8df772dbe6
reintroduce the notification message in case you access dlc page without internet connection
koda
parents:
8059
diff
changeset
|
86 |
"<i>%1</i></center>") |
bd8df772dbe6
reintroduce the notification message in case you access dlc page without internet connection
koda
parents:
8059
diff
changeset
|
87 |
.arg(tr("Loading, please wait."))); |
6932 | 88 |
m_contentDownloaded = false; |
5271 | 89 |
} |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
90 |
|
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
91 |
void PageDataDownload::request(const QUrl &url) |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
92 |
{ |
5768 | 93 |
QUrl finalUrl; |
12234 | 94 |
if(url.isEmpty()) |
95 |
{ |
|
96 |
qWarning() << "Empty URL requested"; |
|
97 |
return; |
|
98 |
} |
|
99 |
else if(url.host().isEmpty()) |
|
11626 | 100 |
finalUrl = QUrl("https://www.hedgewars.org" + url.path()); |
5768 | 101 |
else |
102 |
finalUrl = url; |
|
103 |
||
8059 | 104 |
if(url.path().endsWith(".hwp") || url.path().endsWith(".zip")) |
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
105 |
{ |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
106 |
qWarning() << "Download Request" << url.toString(); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
107 |
QString fileName = QFileInfo(url.toString()).fileName(); |
5754 | 108 |
|
5768 | 109 |
QNetworkRequest newRequest(finalUrl); |
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
110 |
newRequest.setAttribute(QNetworkRequest::User, fileName); |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
111 |
|
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
112 |
QNetworkAccessManager *manager = new QNetworkAccessManager(this); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
113 |
QNetworkReply *reply = manager->get(newRequest); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
114 |
connect(reply, SIGNAL(finished()), this, SLOT(fileDownloaded())); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
115 |
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
116 |
|
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
117 |
QProgressBar *progressBar = new QProgressBar(this); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
118 |
progressBarsLayout->addWidget(progressBar); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
119 |
progressBars.insert(reply, progressBar); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6384
diff
changeset
|
120 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6384
diff
changeset
|
121 |
else |
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
122 |
{ |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
123 |
qWarning() << "Page Request" << url.toString(); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
124 |
|
5768 | 125 |
QNetworkRequest newRequest(finalUrl); |
5765
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
126 |
|
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
127 |
QNetworkAccessManager *manager = new QNetworkAccessManager(this); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
128 |
QNetworkReply *reply = manager->get(newRequest); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
129 |
connect(reply, SIGNAL(finished()), this, SLOT(pageDownloaded())); |
e87f6756773e
Allow surfing, download and extract only .zip files
unc0rr
parents:
5764
diff
changeset
|
130 |
} |
5567
44c9a577b082
Tiny bit of progress on download page - hooked it up to "Info" button for now.
nemo
parents:
5271
diff
changeset
|
131 |
} |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
132 |
|
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
133 |
|
5754 | 134 |
void PageDataDownload::pageDownloaded() |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
135 |
{ |
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
136 |
QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
12674
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
137 |
const char *html = |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
138 |
"<center><h2>Hedgewars Downloadable Content</h2><br><br>" |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
139 |
"<h4><i>%1</i></h4></center>"; |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
140 |
|
12674
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
141 |
if (reply) { |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
142 |
if (reply->error() == QNetworkReply::NoError) |
5768 | 143 |
{ |
12674
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
144 |
QString html = QString::fromUtf8(reply->readAll()); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
145 |
int begin = html.indexOf("<!-- BEGIN -->"); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
146 |
int end = html.indexOf("<!-- END -->"); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
147 |
if(begin != -1 && begin < end) |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
148 |
{ |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
149 |
html.truncate(end); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
150 |
html.remove(0, begin); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
151 |
} |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
152 |
web->setHtml(html); |
5768 | 153 |
} |
12674
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
154 |
else |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
155 |
{ |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
156 |
QString message = reply->error() == QNetworkReply::UnknownNetworkError ? |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
157 |
tr("Unknown network error (possibly missing SSL library).") : |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
158 |
QString(tr("This feature requires an Internet connection, but you don't appear to be online (error code: %1).")).arg(reply->error()); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
159 |
web->setHtml(QString(html).arg(message)); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
160 |
} |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
161 |
} |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
162 |
else { |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
163 |
web->setHtml(QString(html).arg(tr("Internal error: Reply object is invalid."))); |
8d266b2d0f9c
Improve error messages when feedback or DLC fail to reach Internet
alfadur
parents:
12482
diff
changeset
|
164 |
} |
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
165 |
} |
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
166 |
|
5754 | 167 |
void PageDataDownload::fileDownloaded() |
168 |
{ |
|
169 |
QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
|
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
170 |
|
5754 | 171 |
if(reply) |
172 |
{ |
|
173 |
QProgressBar *progressBar = progressBars.value(reply, 0); |
|
174 |
||
175 |
if(progressBar) |
|
176 |
{ |
|
177 |
progressBars.remove(reply); |
|
178 |
progressBar->deleteLater(); |
|
179 |
} |
|
5756 | 180 |
|
8055
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
181 |
QDir extractDir(*cfgdir); |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
182 |
extractDir.cd("Data"); |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
183 |
|
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
184 |
QString fileName = extractDir.filePath(QFileInfo(reply->url().path()).fileName()); |
8059 | 185 |
if(fileName.endsWith(".zip")) |
186 |
fileName = fileName.left(fileName.length() - 4) + ".hwp"; |
|
8055
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
187 |
|
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
188 |
QFile out(fileName); |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
189 |
if(!out.open(QFile::WriteOnly)) |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
190 |
{ |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
191 |
qWarning() << "out.open():" << out.errorString(); |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
192 |
return ; |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
193 |
} |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
194 |
|
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
195 |
out.write(reply->readAll()); |
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
196 |
|
04dd8b7fb605
- Download .hwp files into Data folder and mount them immediately (yes, could cause problems in case of overlapped contents)
unc0rr
parents:
7824
diff
changeset
|
197 |
out.close(); |
5754 | 198 |
} |
199 |
} |
|
200 |
||
201 |
void PageDataDownload::downloadProgress(qint64 bytesRecieved, qint64 bytesTotal) |
|
202 |
{ |
|
203 |
QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
|
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
204 |
|
5754 | 205 |
if(reply) |
206 |
{ |
|
207 |
QProgressBar *progressBar = progressBars.value(reply, 0); |
|
5746
fbc52bb92cad
Use QTextBrowser instead of WebKit for downloadable contents page (currently only shows the page itself)
unc0rr
parents:
5582
diff
changeset
|
208 |
|
5754 | 209 |
if(progressBar) |
210 |
{ |
|
211 |
progressBar->setValue(bytesRecieved); |
|
212 |
progressBar->setMaximum(bytesTotal); |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
void PageDataDownload::fetchList() |
|
218 |
{ |
|
11626 | 219 |
request(QUrl("https://hedgewars.org/content.html")); |
5754 | 220 |
} |
5756 | 221 |
|
6932 | 222 |
void PageDataDownload::onPageLeave() |
223 |
{ |
|
224 |
if (m_contentDownloaded) |
|
225 |
{ |
|
226 |
m_contentDownloaded = false; |
|
227 |
} |
|
228 |
} |
|
9829 | 229 |
|
230 |
void PageDataDownload::openPackagesDir() |
|
231 |
{ |
|
232 |
QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Data"); |
|
233 |
QDesktopServices::openUrl(QUrl("file:///" + path)); |
|
234 |
} |