Skip to content

Commit b56a309

Browse files
committed
修复已经下载的内容会重复下载,增加了aria2c的下载,不全
1 parent 036f82d commit b56a309

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

src/download/downloadmanager.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ void DownloadManager::processDownloadQueue()
4141
DownloadInfo data = downloadQueue.takeFirst();
4242
data.downloadIngTaskCount = downloadQueue.size();
4343
Q_EMIT downloadStarted(data);
44-
44+
#ifdef Q_OS_LINUX
45+
system(data.dowloadCode.toStdString().c_str());
46+
#else
4547
QProcess process;
4648
process.start(data.dowloadCode);
4749
if (!process.waitForStarted()) {
@@ -53,6 +55,7 @@ void DownloadManager::processDownloadQueue()
5355
Q_EMIT downloadError(data, tr("Download failed."));
5456
continue;
5557
}
58+
#endif
5659
data.bDownloaded = true;
5760
Q_EMIT downloadFinished(data);
5861
}

src/listview/onlineclient.cpp

+27-5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ OnlineClient::OnlineClient(QWidget *parent) :
101101
connect(m_downloadManger,&DownloadManager::downloadStarted,this,&OnlineClient::downloadStarted);
102102
connect(m_downloadManger,&DownloadManager::downloadFinished,this,&OnlineClient::downloadFinished);
103103
connect(m_downloadManger,&DownloadManager::downloadError,this,&OnlineClient::downloadError);
104+
105+
ui->label_wTip->setWordWrap(true);
104106
}
105107

106108
OnlineClient::~OnlineClient()
@@ -141,6 +143,10 @@ bool OnlineClient::downloadFileWithCurl(const QString &oldurl, const QString &ou
141143
QString part2 = url.mid(slashIndex + 1);
142144
QString encodedFilename = QUrl::toPercentEncoding(part2);
143145
command = strWget + " -o "+downlog +" -O " + outputFilePath + " " + part1+"/"+encodedFilename;
146+
if(ui->com_tool->currentText() == "aria2")
147+
{
148+
command = "aria2c -d "+outputFilePath+" "+part1+"/"+encodedFilename + " >> " +downlog;
149+
}
144150
} else {
145151
qDebug() << "未找到'/'";
146152
}
@@ -246,7 +252,6 @@ void OnlineClient::slotClickedChange(const QString &md5)
246252

247253
void OnlineClient::slotDoubleClickedChange(const QString &md5)
248254
{
249-
ui->label_DownloadCount->setText(QString::number(ui->label_DownloadCount->text().toInt()+1));
250255
slotClickedChange(md5);
251256
QString name = m_datas.value(m_currentMd5).fileName;
252257
QString newName = name.replace(QRegExp("\\s+"), "");
@@ -258,7 +263,7 @@ void OnlineClient::slotDoubleClickedChange(const QString &md5)
258263
ui->label_DTip->setText(tr("Download Ing....."));
259264
bool isExists = QFileInfo(saveFile).exists();
260265
bool isExistsHtml = QFileInfo(saveHtml).exists();
261-
if(!isExists )
266+
if(isExists )
262267
{
263268
if(QFileInfo(saveFile).size() <10)
264269
{
@@ -267,19 +272,19 @@ void OnlineClient::slotDoubleClickedChange(const QString &md5)
267272
}
268273
}
269274

270-
if(!isExistsHtml )
275+
if(isExistsHtml )
271276
{
272277
if(QFileInfo(saveHtml).size() <10)
273278
{
274279
QFile(saveHtml).remove();
275-
isExists = false;
280+
isExistsHtml = false;
276281
}
277282
}
278283

279284

280285
if(!isExists && !isExistsHtml)
281286
{
282-
287+
ui->label_DownloadCount->setText(QString::number(ui->label_DownloadCount->text().toInt()+1));
283288
//Q_EMIT dApp->sigSetDownloadIng(false);
284289
QString strExtra;
285290
strExtra = m_currentMd5;
@@ -563,3 +568,20 @@ void OnlineClient::downloadError(const DownloadInfo &data, const QString &errorM
563568
Q_EMIT dApp->sigDownloadError();
564569
ui->label_DownloadCount->setText(QString::number(data.downloadIngTaskCount));
565570
}
571+
572+
void OnlineClient::on_com_tool_currentIndexChanged(const QString &arg1)
573+
{
574+
if(arg1 == "wget")
575+
{
576+
ui->label_wTip->setText(tr("If unable to download, please check if 'wget' is installed on the command line."));
577+
}
578+
else if(arg1 == "aria2")
579+
{
580+
ui->label_wTip->setText(tr("If unable to download, please check if 'aria2' is installed on the command line.But download html web wallpaper need 'wget' ."));
581+
}
582+
else
583+
{
584+
ui->label_wTip->setText(tr("If unable to download, please check if 'wget' is installed on the command line."));
585+
}
586+
}
587+

src/listview/onlineclient.h

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ private Q_SLOTS:
5757
void downloadFinished(const DownloadInfo &data);
5858
void downloadError(const DownloadInfo &data, const QString &errorMessage);
5959

60+
void on_com_tool_currentIndexChanged(const QString &arg1);
61+
6062
private:
6163
Ui::OnlineClient *ui;
6264
view *m_viewDowload{nullptr};

src/listview/onlineclient.ui

+34-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,39 @@
4949
</property>
5050
</widget>
5151
</item>
52+
<item>
53+
<widget class="QLabel" name="label_9">
54+
<property name="text">
55+
<string>Download Tool</string>
56+
</property>
57+
</widget>
58+
</item>
59+
<item>
60+
<widget class="QComboBox" name="com_tool">
61+
<property name="minimumSize">
62+
<size>
63+
<width>100</width>
64+
<height>0</height>
65+
</size>
66+
</property>
67+
<property name="maximumSize">
68+
<size>
69+
<width>100</width>
70+
<height>16777215</height>
71+
</size>
72+
</property>
73+
<item>
74+
<property name="text">
75+
<string>wget</string>
76+
</property>
77+
</item>
78+
<item>
79+
<property name="text">
80+
<string>aria2</string>
81+
</property>
82+
</item>
83+
</widget>
84+
</item>
5285
<item>
5386
<spacer name="horizontalSpacer_2">
5487
<property name="orientation">
@@ -65,7 +98,7 @@
6598
</layout>
6699
</item>
67100
<item>
68-
<widget class="QLabel" name="label_8">
101+
<widget class="QLabel" name="label_wTip">
69102
<property name="text">
70103
<string>If unable to download, please check if 'wget' is installed on the command line.</string>
71104
</property>

0 commit comments

Comments
 (0)