mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
added pause/resume for downloads
Summary: Added button to pause/resume download from the download manager Reviewers: drosca Reviewed By: drosca Subscribers: falkon Tags: #falkon Differential Revision: https://phabricator.kde.org/D20037
This commit is contained in:
parent
1f1978751f
commit
3150def9fc
|
@ -66,13 +66,15 @@ DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downlo
|
|||
ui->setupUi(this);
|
||||
setMaximumWidth(525);
|
||||
|
||||
ui->button->setPixmap(QIcon::fromTheme(QSL("process-stop")).pixmap(20, 20));
|
||||
ui->cancelButton->setPixmap(QIcon::fromTheme(QSL("process-stop")).pixmap(20, 20));
|
||||
ui->pauseResumeButton->setPixmap(QIcon::fromTheme(QSL("media-playback-pause")).pixmap(20, 20));
|
||||
ui->fileName->setText(m_fileName);
|
||||
ui->downloadInfo->setText(tr("Remaining time unavailable"));
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customContextMenuRequested(QPoint)));
|
||||
connect(ui->button, &ClickableLabel::clicked, this, &DownloadItem::stop);
|
||||
connect(ui->cancelButton, &ClickableLabel::clicked, this, &DownloadItem::stop);
|
||||
connect(ui->pauseResumeButton, &ClickableLabel::clicked, this, &DownloadItem::pauseResume);
|
||||
connect(manager, &DownloadManager::resized, this, &DownloadItem::parentResized);
|
||||
}
|
||||
|
||||
|
@ -138,7 +140,8 @@ void DownloadItem::finished()
|
|||
}
|
||||
|
||||
ui->progressBar->hide();
|
||||
ui->button->hide();
|
||||
ui->cancelButton->hide();
|
||||
ui->pauseResumeButton->hide();
|
||||
ui->frame->hide();
|
||||
|
||||
m_item->setSizeHint(sizeHint());
|
||||
|
@ -231,6 +234,10 @@ void DownloadItem::updateDownloadInfo(double currSpeed, qint64 received, qint64
|
|||
// | m_remTime | |m_currSize| |m_fileSize| |m_speed|
|
||||
// Remaining 26 minutes - 339MB of 693 MB (350kB/s)
|
||||
|
||||
if (m_download->isPaused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int estimatedTime = ((total - received) / 1024) / (currSpeed / 1024);
|
||||
QString speed = currentSpeedToString(currSpeed);
|
||||
// We have QString speed now
|
||||
|
@ -261,7 +268,8 @@ void DownloadItem::stop()
|
|||
}
|
||||
m_downloadStopped = true;
|
||||
ui->progressBar->hide();
|
||||
ui->button->hide();
|
||||
ui->cancelButton->hide();
|
||||
ui->pauseResumeButton->hide();
|
||||
m_item->setSizeHint(sizeHint());
|
||||
ui->downloadInfo->setText(tr("Cancelled - %1").arg(m_download->url().host()));
|
||||
m_download->cancel();
|
||||
|
@ -270,6 +278,18 @@ void DownloadItem::stop()
|
|||
emit downloadFinished(false);
|
||||
}
|
||||
|
||||
void DownloadItem::pauseResume()
|
||||
{
|
||||
if (m_download->isPaused()) {
|
||||
m_download->resume();
|
||||
ui->pauseResumeButton->setPixmap(QIcon::fromTheme(QSL("media-playback-pause")).pixmap(20, 20));
|
||||
} else {
|
||||
m_download->pause();
|
||||
ui->pauseResumeButton->setPixmap(QIcon::fromTheme(QSL("media-playback-start")).pixmap(20, 20));
|
||||
ui->downloadInfo->setText(tr("Paused - %1").arg(m_download->url().host()));
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadItem::mouseDoubleClickEvent(QMouseEvent* e)
|
||||
{
|
||||
openFile();
|
||||
|
@ -286,6 +306,13 @@ void DownloadItem::customContextMenuRequested(const QPoint &pos)
|
|||
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Download Link"), this, &DownloadItem::copyDownloadLink);
|
||||
menu.addSeparator();
|
||||
menu.addAction(QIcon::fromTheme("process-stop"), tr("Cancel downloading"), this, &DownloadItem::stop)->setEnabled(m_downloading);
|
||||
|
||||
if (m_download->isPaused()) {
|
||||
menu.addAction(QIcon::fromTheme("media-playback-start"), tr("Resume downloading"), this, &DownloadItem::pauseResume)->setEnabled(m_downloading);
|
||||
} else {
|
||||
menu.addAction(QIcon::fromTheme("media-playback-pause"), tr("Pause downloading"), this, &DownloadItem::pauseResume)->setEnabled(m_downloading);
|
||||
}
|
||||
|
||||
menu.addAction(QIcon::fromTheme("list-remove"), tr("Remove From List"), this, &DownloadItem::clear)->setEnabled(!m_downloading);
|
||||
|
||||
if (m_downloading || ui->downloadInfo->text().startsWith(tr("Cancelled")) || ui->downloadInfo->text().startsWith(tr("Error"))) {
|
||||
|
|
|
@ -65,6 +65,7 @@ private Q_SLOTS:
|
|||
void finished();
|
||||
void downloadProgress(qint64 received, qint64 total);
|
||||
void stop();
|
||||
void pauseResume();
|
||||
void openFile();
|
||||
void openFolder();
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
|
|
|
@ -33,13 +33,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="SqueezeLabelV2" name="fileName">
|
||||
<property name="text">
|
||||
<string notr="true">A Clockwork Orange.avi</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="SqueezeLabelV2" name="downloadInfo">
|
||||
<property name="text">
|
||||
|
@ -47,6 +40,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="SqueezeLabelV2" name="fileName">
|
||||
<property name="text">
|
||||
<string notr="true">A Clockwork Orange.avi</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="maximumSize">
|
||||
|
@ -56,7 +56,16 @@
|
|||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="progressFrame">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -73,7 +82,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="button">
|
||||
<widget class="ClickableLabel" name="pauseResumeButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ClickableLabel" name="cancelButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -85,16 +101,16 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>clickablelabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SqueezeLabelV2</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>squeezelabelv2.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ClickableLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>clickablelabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user