1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Download manager -> Go to download page + Copy download link option

This commit is contained in:
nowrep 2011-04-08 18:52:14 +02:00
parent ceccb7a4e0
commit c68518d134
6 changed files with 126 additions and 61 deletions

Binary file not shown.

View File

@ -17,6 +17,10 @@
* ============================================================ */
#include "downloaditem.h"
#include "ui_downloaditem.h"
#include "mainapplication.h"
#include "qupzilla.h"
#include "tabwidget.h"
#include "webpage.h"
//#define DOWNMANAGER_DEBUG
@ -27,6 +31,8 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, QString
,m_reply(reply)
,m_path(path)
,m_fileName(fileName)
,m_downUrl(reply->url())
,m_downloadPage(QUrl())
,m_downloading(false)
,m_openAfterFinish(openAfterFinishedDownload)
{
@ -76,6 +82,17 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, QString
error(m_reply->error());
}
show();
//Get Download Page
QNetworkRequest request = m_reply->request();
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
WebPage* webPage = (WebPage*)(v.value<void*>());
if (webPage) {
if (!webPage->mainFrame()->url().isEmpty())
m_downloadPage = webPage->mainFrame()->url();
else if (webPage->history()->canGoBack())
m_downloadPage = webPage->history()->backItem().url();
}
}
void DownloadItem::metaDataChanged()
@ -247,24 +264,33 @@ void DownloadItem::customContextMenuRequested(QPoint pos)
menu.addAction(tr("Open Folder"), this, SLOT(openFolder()));
menu.addSeparator();
menu.addAction(tr("Go to Download Page"), this, SLOT(goToDownloadPage()))->setEnabled(!m_downloadPage.isEmpty());
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Download Link"), this, SLOT(copyDownloadLink()));
menu.addSeparator();
menu.addAction(
#ifdef Q_WS_X11
style()->standardIcon(QStyle::SP_BrowserStop)
#else
QIcon(":/icons/faenza/stop.png")
#endif
,tr("Cancel downloading"), this, SLOT(stop()));
menu.addAction(QIcon::fromTheme("window-close"), tr("Clear"), this, SLOT(clear()));
,tr("Cancel downloading"), this, SLOT(stop()))->setEnabled(m_downloading);
menu.addAction(QIcon::fromTheme("window-close"), tr("Clear"), this, SLOT(clear()))->setEnabled(!m_downloading);
if (m_downloading || ui->downloadInfo->text().startsWith(tr("Cancelled")) || ui->downloadInfo->text().startsWith(tr("Error")))
menu.actions().at(0)->setEnabled(false);
if (!m_downloading)
menu.actions().at(3)->setEnabled(false);
if (m_downloading)
menu.actions().at(4)->setEnabled(false);
menu.exec(mapToGlobal(pos));
}
void DownloadItem::goToDownloadPage()
{
mApp->getWindow()->tabWidget()->addView(m_downloadPage, tr("New tab"), TabWidget::NewSelectedTab);
}
void DownloadItem::copyDownloadLink()
{
qApp->clipboard()->setText(m_downUrl.toString());
}
void DownloadItem::clear()
{
emit deleteItem(this);

View File

@ -70,6 +70,9 @@ private slots:
void customContextMenuRequested(QPoint pos);
void clear();
void goToDownloadPage();
void copyDownloadLink();
private:
void timerEvent(QTimerEvent* event);
void updateDownloadInfo(double currSpeed, qint64 received, qint64 total);
@ -84,6 +87,8 @@ private:
QTime m_remTime;
QBasicTimer m_timer;
QFile m_outputFile;
QUrl m_downUrl;
QUrl m_downloadPage;
bool m_downloading;
bool m_openAfterFinish;

View File

@ -90,6 +90,10 @@ void DownloadManager::timerEvent(QTimerEvent* event)
if (remTimes.isEmpty()) {
ui->speedLabel->clear();
setWindowTitle(tr("Download Manager"));
#ifdef W7API
win7.setProgressValue(0, 0);
win7.setProgressState(win7.Normal);
#endif
return;
}

View File

@ -719,93 +719,108 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="54"/>
<location filename="../src/downloads/downloaditem.cpp" line="60"/>
<source>Remaining time unavailable</source>
<translation>Neznámý zbývající čas</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="99"/>
<location filename="../src/downloads/downloaditem.cpp" line="116"/>
<source>Done - %1</source>
<translation>Hotovo - %1</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="149"/>
<location filename="../src/downloads/downloaditem.cpp" line="259"/>
<location filename="../src/downloads/downloaditem.cpp" line="166"/>
<location filename="../src/downloads/downloaditem.cpp" line="279"/>
<source>Cancelled</source>
<translation>Zrušeno</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="155"/>
<location filename="../src/downloads/downloaditem.cpp" line="172"/>
<source>few seconds</source>
<translation>několik sekund</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="157"/>
<location filename="../src/downloads/downloaditem.cpp" line="174"/>
<source>seconds</source>
<translation>sekund</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="159"/>
<location filename="../src/downloads/downloaditem.cpp" line="176"/>
<source>minutes</source>
<translation>minut</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="161"/>
<location filename="../src/downloads/downloaditem.cpp" line="178"/>
<source>hours</source>
<translation>hodin</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="205"/>
<location filename="../src/downloads/downloaditem.cpp" line="222"/>
<source>Remaining %1 - %2 of %3 (%4)</source>
<translation>Zbývá %1 - %2 z %3 (%4)</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="218"/>
<location filename="../src/downloads/downloaditem.cpp" line="235"/>
<source>Cancelled - %1</source>
<translation>Zrušeno - %1</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="230"/>
<location filename="../src/downloads/downloaditem.cpp" line="247"/>
<source>Delete file</source>
<translation>Smazat soubor</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="230"/>
<location filename="../src/downloads/downloaditem.cpp" line="247"/>
<source>Do you want to also delete dowloaded file?</source>
<translation>Chcete také smazat stahovaný soubor?</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="246"/>
<location filename="../src/downloads/downloaditem.cpp" line="263"/>
<source>Open File</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="248"/>
<location filename="../src/downloads/downloaditem.cpp" line="265"/>
<source>Open Folder</source>
<translation>Otevřít složku</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="256"/>
<location filename="../src/downloads/downloaditem.cpp" line="267"/>
<source>Go to Download Page</source>
<translation>Přejít na stránku stahování</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="268"/>
<source>Copy Download Link</source>
<translation>Kopírovat stahovaný odkaz</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="276"/>
<source>Cancel downloading</source>
<translation>Zrušit stahování</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="257"/>
<location filename="../src/downloads/downloaditem.cpp" line="277"/>
<source>Clear</source>
<translation>Vyčistit</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="259"/>
<location filename="../src/downloads/downloaditem.cpp" line="279"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="281"/>
<location filename="../src/downloads/downloaditem.cpp" line="286"/>
<source>New tab</source>
<translation>Nový panel</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="307"/>
<source>Not found</source>
<translation>Soubor neexistuje</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="281"/>
<location filename="../src/downloads/downloaditem.cpp" line="307"/>
<source>Sorry, the file
%1
was not found!</source>
@ -814,12 +829,12 @@ p, li { white-space: pre-wrap; }
nebyl nalezen!</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="296"/>
<location filename="../src/downloads/downloaditem.cpp" line="322"/>
<source>Error: Cannot write to file!</source>
<translation>Chyba: Nelze zapisovat do souboru!</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="308"/>
<location filename="../src/downloads/downloaditem.cpp" line="334"/>
<source>Error: </source>
<translation>Chyba:</translation>
</message>
@ -827,32 +842,32 @@ nebyl nalezen!</translation>
<context>
<name>DownloadManager</name>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="111"/>
<location filename="../src/downloads/downloadmanager.cpp" line="115"/>
<source>%1% of %2 files (%3) %4 remaining</source>
<translation>%1% z %2 souborů (%3) %4 zbyvá</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="114"/>
<location filename="../src/downloads/downloadmanager.cpp" line="118"/>
<source>% - Download Manager</source>
<translation>% - Správce stahování</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="173"/>
<location filename="../src/downloads/downloadmanager.cpp" line="177"/>
<source>Save file as...</source>
<translation>Uložit soubor jako...</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="273"/>
<location filename="../src/downloads/downloadmanager.cpp" line="277"/>
<source>Warning</source>
<translation>Varování</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="274"/>
<location filename="../src/downloads/downloadmanager.cpp" line="278"/>
<source>Are you sure to quit? All uncompleted downloads will be cancelled!</source>
<translation>Jste si jistý že chcete skončit? Všechna nedokončená stahování budou zrušena!</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="235"/>
<location filename="../src/downloads/downloadmanager.cpp" line="239"/>
<source>NoNameDownload</source>
<translation>BezNazvu</translation>
</message>

View File

@ -722,93 +722,108 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="54"/>
<location filename="../src/downloads/downloaditem.cpp" line="60"/>
<source>Remaining time unavailable</source>
<translation>Neznámy zostávajúci čas</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="99"/>
<location filename="../src/downloads/downloaditem.cpp" line="116"/>
<source>Done - %1</source>
<translation>Dokončené - %1</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="149"/>
<location filename="../src/downloads/downloaditem.cpp" line="259"/>
<location filename="../src/downloads/downloaditem.cpp" line="166"/>
<location filename="../src/downloads/downloaditem.cpp" line="279"/>
<source>Cancelled</source>
<translation>Zrušené</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="155"/>
<location filename="../src/downloads/downloaditem.cpp" line="172"/>
<source>few seconds</source>
<translation>pár sekúnd</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="157"/>
<location filename="../src/downloads/downloaditem.cpp" line="174"/>
<source>seconds</source>
<translation>sekúnd</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="159"/>
<location filename="../src/downloads/downloaditem.cpp" line="176"/>
<source>minutes</source>
<translation>minút</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="161"/>
<location filename="../src/downloads/downloaditem.cpp" line="178"/>
<source>hours</source>
<translation>hodín</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="205"/>
<location filename="../src/downloads/downloaditem.cpp" line="222"/>
<source>Remaining %1 - %2 of %3 (%4)</source>
<translation>Zostáva %1 - %2 z %3 (%4)</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="218"/>
<location filename="../src/downloads/downloaditem.cpp" line="235"/>
<source>Cancelled - %1</source>
<translation>Zrušene - %1</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="230"/>
<location filename="../src/downloads/downloaditem.cpp" line="247"/>
<source>Delete file</source>
<translation>Vymazať súbor</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="230"/>
<location filename="../src/downloads/downloaditem.cpp" line="247"/>
<source>Do you want to also delete dowloaded file?</source>
<translation>Chcete zmazať sťahovaný súbor?</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="246"/>
<location filename="../src/downloads/downloaditem.cpp" line="263"/>
<source>Open File</source>
<translation>Otvoriť súbor</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="248"/>
<location filename="../src/downloads/downloaditem.cpp" line="265"/>
<source>Open Folder</source>
<translation>Otvoriť priečinok</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="256"/>
<location filename="../src/downloads/downloaditem.cpp" line="267"/>
<source>Go to Download Page</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="268"/>
<source>Copy Download Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="276"/>
<source>Cancel downloading</source>
<translation>Zrušiť sťahovanie</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="257"/>
<location filename="../src/downloads/downloaditem.cpp" line="277"/>
<source>Clear</source>
<translation>Vyčistiť</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="259"/>
<location filename="../src/downloads/downloaditem.cpp" line="279"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="281"/>
<location filename="../src/downloads/downloaditem.cpp" line="286"/>
<source>New tab</source>
<translation type="unfinished">Nový panel</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="307"/>
<source>Not found</source>
<translation>Súbor neexistuje</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="281"/>
<location filename="../src/downloads/downloaditem.cpp" line="307"/>
<source>Sorry, the file
%1
was not found!</source>
@ -817,12 +832,12 @@ p, li { white-space: pre-wrap; }
nebol nájdený!</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="296"/>
<location filename="../src/downloads/downloaditem.cpp" line="322"/>
<source>Error: Cannot write to file!</source>
<translation>Chyba: Nejde zapisovať do súboru!</translation>
</message>
<message>
<location filename="../src/downloads/downloaditem.cpp" line="308"/>
<location filename="../src/downloads/downloaditem.cpp" line="334"/>
<source>Error: </source>
<translation>Chyba: </translation>
</message>
@ -830,32 +845,32 @@ p, li { white-space: pre-wrap; }
<context>
<name>DownloadManager</name>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="111"/>
<location filename="../src/downloads/downloadmanager.cpp" line="115"/>
<source>%1% of %2 files (%3) %4 remaining</source>
<translation>%1% z %2 súborov (%3) %4 zostávajú</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="114"/>
<location filename="../src/downloads/downloadmanager.cpp" line="118"/>
<source>% - Download Manager</source>
<translation>% - Správca sťahovania</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="173"/>
<location filename="../src/downloads/downloadmanager.cpp" line="177"/>
<source>Save file as...</source>
<translation>Uložiť súbor ako...</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="273"/>
<location filename="../src/downloads/downloadmanager.cpp" line="277"/>
<source>Warning</source>
<translation>Upozornenie</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="274"/>
<location filename="../src/downloads/downloadmanager.cpp" line="278"/>
<source>Are you sure to quit? All uncompleted downloads will be cancelled!</source>
<translation>Ste si istý, že chcete skončiť? Všetky nedokončené sťahovania budú zrušene!</translation>
</message>
<message>
<location filename="../src/downloads/downloadmanager.cpp" line="235"/>
<location filename="../src/downloads/downloadmanager.cpp" line="239"/>
<source>NoNameDownload</source>
<translation>BezNázvu</translation>
</message>