mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Implement download integration with Plasma
This commit is contained in:
parent
2091b3d60c
commit
db0584f81e
@ -124,8 +124,10 @@ set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDE Frameworks Integrati
|
|||||||
find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG)
|
find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG)
|
||||||
set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
set_package_properties(KF5CoreAddons PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
||||||
find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG)
|
find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG)
|
||||||
|
find_package(KF5JobWidgets ${KF5_MIN_VERSION} CONFIG)
|
||||||
|
set_package_properties(KF5JobWidgets PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
||||||
set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
set_package_properties(KF5Purpose PROPERTIES DESCRIPTION "KDE Frameworks Integration plugin" TYPE OPTIONAL)
|
||||||
if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND AND KF5Purpose_FOUND)
|
if (KF5Wallet_FOUND AND KF5KIO_FOUND AND KF5Crash_FOUND AND KF5CoreAddons_FOUND AND KF5Purpose_FOUND AND KF5JobWidgets_FOUND)
|
||||||
set(ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN TRUE)
|
set(ENABLE_KDE_FRAMEWORKS_INTEGRATION_PLUGIN TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ set(SRCS ${SRCS}
|
|||||||
cookies/cookiemanager.cpp
|
cookies/cookiemanager.cpp
|
||||||
downloads/downloaditem.cpp
|
downloads/downloaditem.cpp
|
||||||
downloads/downloadmanager.cpp
|
downloads/downloadmanager.cpp
|
||||||
|
downloads/downloadmanagermodel.cpp
|
||||||
downloads/downloadoptionsdialog.cpp
|
downloads/downloadoptionsdialog.cpp
|
||||||
downloads/downloadsbutton.cpp
|
downloads/downloadsbutton.cpp
|
||||||
history/history.cpp
|
history/history.cpp
|
||||||
@ -328,6 +329,7 @@ set(SRCS ${SRCS}
|
|||||||
cookies/cookiemanager.h
|
cookies/cookiemanager.h
|
||||||
downloads/downloaditem.h
|
downloads/downloaditem.h
|
||||||
downloads/downloadmanager.h
|
downloads/downloadmanager.h
|
||||||
|
downloads/downloadmanagermodel.h
|
||||||
downloads/downloadoptionsdialog.h
|
downloads/downloadoptionsdialog.h
|
||||||
downloads/downloadsbutton.h
|
downloads/downloadsbutton.h
|
||||||
history/history.h
|
history/history.h
|
||||||
|
@ -172,6 +172,7 @@ void DownloadItem::downloadProgress(qint64 received, qint64 total)
|
|||||||
m_total = total;
|
m_total = total;
|
||||||
|
|
||||||
updateDownloadInfo(m_currSpeed, m_received, m_total);
|
updateDownloadInfo(m_currSpeed, m_received, m_total);
|
||||||
|
progressChanged(m_currSpeed, m_received, m_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DownloadItem::progress()
|
int DownloadItem::progress()
|
||||||
@ -363,6 +364,21 @@ void DownloadItem::openFolder()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrl DownloadItem::url() const
|
||||||
|
{
|
||||||
|
return m_downUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DownloadItem::path() const
|
||||||
|
{
|
||||||
|
return m_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DownloadItem::fileName() const
|
||||||
|
{
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
DownloadItem::~DownloadItem()
|
DownloadItem::~DownloadItem()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -48,6 +48,9 @@ public:
|
|||||||
QTime remainingTime() const { return m_remTime; }
|
QTime remainingTime() const { return m_remTime; }
|
||||||
double currentSpeed() const { return m_currSpeed; }
|
double currentSpeed() const { return m_currSpeed; }
|
||||||
int progress();
|
int progress();
|
||||||
|
QUrl url() const;
|
||||||
|
QString path() const;
|
||||||
|
QString fileName() const;
|
||||||
~DownloadItem() override;
|
~DownloadItem() override;
|
||||||
void setDownTimer(const QTime &timer) { m_downTimer = timer; }
|
void setDownTimer(const QTime &timer) { m_downTimer = timer; }
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void deleteItem(DownloadItem*);
|
void deleteItem(DownloadItem*);
|
||||||
void downloadFinished(bool success);
|
void downloadFinished(bool success);
|
||||||
|
void progressChanged(double currSpeed, qint64 received, qint64 total);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void parentResized(const QSize &size);
|
void parentResized(const QSize &size);
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
#include "downloadoptionsdialog.h"
|
#include "downloadoptionsdialog.h"
|
||||||
#include "downloaditem.h"
|
#include "downloaditem.h"
|
||||||
|
#include "downloadmanagermodel.h"
|
||||||
|
#ifdef PLASMA_DOWNLOADS
|
||||||
|
#include "downloadkjob.h"
|
||||||
|
#endif
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
#include "desktopnotificationsfactory.h"
|
#include "desktopnotificationsfactory.h"
|
||||||
#include "qztools.h"
|
#include "qztools.h"
|
||||||
@ -52,6 +56,7 @@
|
|||||||
DownloadManager::DownloadManager(QWidget* parent)
|
DownloadManager::DownloadManager(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::DownloadManager)
|
, ui(new Ui::DownloadManager)
|
||||||
|
, m_model(new DownloadManagerModel(this))
|
||||||
, m_isClosing(false)
|
, m_isClosing(false)
|
||||||
, m_lastDownloadOption(NoOption)
|
, m_lastDownloadOption(NoOption)
|
||||||
{
|
{
|
||||||
@ -73,6 +78,8 @@ DownloadManager::DownloadManager(QWidget* parent)
|
|||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
QzTools::setWmClass("Download Manager", this);
|
QzTools::setWmClass("Download Manager", this);
|
||||||
|
|
||||||
|
connect(m_model, &DownloadManagerModel::downloadAdded, this, &DownloadManager::downloadAdded);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::loadSettings()
|
void DownloadManager::loadSettings()
|
||||||
@ -365,8 +372,10 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
|||||||
auto* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), QFileInfo(downloadPath).fileName(), openFile, this);
|
auto* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), QFileInfo(downloadPath).fileName(), openFile, this);
|
||||||
downItem->setDownTimer(downloadTimer);
|
downItem->setDownTimer(downloadTimer);
|
||||||
downItem->startDownloading();
|
downItem->startDownloading();
|
||||||
connect(downItem, &DownloadItem::deleteItem, this, &DownloadManager::deleteItem);
|
connect(downItem, &DownloadItem::deleteItem, m_model, &DownloadManagerModel::removeDownload);
|
||||||
connect(downItem, &DownloadItem::downloadFinished, this, &DownloadManager::downloadFinished);
|
connect(downItem, &DownloadItem::downloadFinished, this, QOverload<bool>::of(&DownloadManager::downloadFinished));
|
||||||
|
connect(downItem, &DownloadItem::downloadFinished, this, QOverload<>::of(&DownloadManager::downloadFinished));
|
||||||
|
m_model->addDownload(downItem);
|
||||||
ui->list->setItemWidget(listItem, downItem);
|
ui->list->setItemWidget(listItem, downItem);
|
||||||
listItem->setSizeHint(downItem->sizeHint());
|
listItem->setSizeHint(downItem->sizeHint());
|
||||||
downItem->show();
|
downItem->show();
|
||||||
@ -377,7 +386,7 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
|||||||
|
|
||||||
int DownloadManager::downloadsCount() const
|
int DownloadManager::downloadsCount() const
|
||||||
{
|
{
|
||||||
return ui->list->count();
|
return m_model->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DownloadManager::activeDownloadsCount() const
|
int DownloadManager::activeDownloadsCount() const
|
||||||
@ -424,13 +433,6 @@ void DownloadManager::downloadFinished(bool success)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::deleteItem(DownloadItem* item)
|
|
||||||
{
|
|
||||||
if (item && !item->isDownloading()) {
|
|
||||||
delete item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadManager::canClose()
|
bool DownloadManager::canClose()
|
||||||
{
|
{
|
||||||
if (m_isClosing) {
|
if (m_isClosing) {
|
||||||
|
@ -36,6 +36,10 @@ class QWebEngineDownloadItem;
|
|||||||
class QWinTaskbarButton;
|
class QWinTaskbarButton;
|
||||||
|
|
||||||
class DownloadItem;
|
class DownloadItem;
|
||||||
|
class DownloadManagerModel;
|
||||||
|
#ifdef PLASMA_DOWNLOADS
|
||||||
|
class DownloadKJob;
|
||||||
|
#endif
|
||||||
class WebPage;
|
class WebPage;
|
||||||
|
|
||||||
class FALKON_EXPORT DownloadManager : public QWidget
|
class FALKON_EXPORT DownloadManager : public QWidget
|
||||||
@ -82,12 +86,14 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void clearList();
|
void clearList();
|
||||||
void deleteItem(DownloadItem* item);
|
|
||||||
void downloadFinished(bool success);
|
void downloadFinished(bool success);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void resized(QSize);
|
void resized(QSize);
|
||||||
void downloadsCountChanged();
|
void downloadsCountChanged();
|
||||||
|
void downloadAdded(DownloadItem *item);
|
||||||
|
void downloadRemoved(DownloadItem *item);
|
||||||
|
void downloadFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void timerEvent(QTimerEvent* e) override;
|
void timerEvent(QTimerEvent* e) override;
|
||||||
@ -99,6 +105,7 @@ private:
|
|||||||
QWinTaskbarButton *taskbarButton();
|
QWinTaskbarButton *taskbarButton();
|
||||||
|
|
||||||
Ui::DownloadManager* ui;
|
Ui::DownloadManager* ui;
|
||||||
|
DownloadManagerModel *m_model;
|
||||||
QBasicTimer m_timer;
|
QBasicTimer m_timer;
|
||||||
|
|
||||||
QString m_lastDownloadPath;
|
QString m_lastDownloadPath;
|
||||||
|
65
src/lib/downloads/downloadmanagermodel.cpp
Normal file
65
src/lib/downloads/downloadmanagermodel.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2019 Javier Llorente <javier@opensuse.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "downloadmanagermodel.h"
|
||||||
|
|
||||||
|
DownloadManagerModel::DownloadManagerModel(QObject *parent)
|
||||||
|
: QAbstractListModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int DownloadManagerModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
return count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DownloadManagerModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (role == Qt::DisplayRole) {
|
||||||
|
const DownloadItem *item = m_downloads.at(index.row());
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManagerModel::addDownload(DownloadItem *item)
|
||||||
|
{
|
||||||
|
m_downloads.append(item);
|
||||||
|
connect(item, &DownloadItem::deleteItem, this, &DownloadManagerModel::removeDownload);
|
||||||
|
emit downloadAdded(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManagerModel::removeDownload(DownloadItem *item)
|
||||||
|
{
|
||||||
|
if (item && !item->isDownloading()) {
|
||||||
|
delete item;
|
||||||
|
emit downloadRemoved(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int DownloadManagerModel::count() const
|
||||||
|
{
|
||||||
|
return m_downloads.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadItem *DownloadManagerModel::at(int index)
|
||||||
|
{
|
||||||
|
return m_downloads.at(index);
|
||||||
|
}
|
||||||
|
|
45
src/lib/downloads/downloadmanagermodel.h
Normal file
45
src/lib/downloads/downloadmanagermodel.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2019 Javier Llorente <javier@opensuse.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef DOWNLOADMANAGERMODEL_H
|
||||||
|
#define DOWNLOADMANAGERMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
#include "downloaditem.h"
|
||||||
|
|
||||||
|
class DownloadManagerModel : public QAbstractListModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DownloadManagerModel(QObject *parent = nullptr);
|
||||||
|
int rowCount(const QModelIndex &parent) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
void addDownload(DownloadItem *item);
|
||||||
|
void removeDownload(DownloadItem *item);
|
||||||
|
int count() const;
|
||||||
|
DownloadItem *at(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<DownloadItem *> m_downloads;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void downloadAdded(DownloadItem *item);
|
||||||
|
void downloadRemoved(DownloadItem *item);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DOWNLOADMANAGERMODEL_H
|
@ -2,9 +2,11 @@ set(KDEFrameworksIntegration_SRCS
|
|||||||
kdeframeworksintegrationplugin.cpp
|
kdeframeworksintegrationplugin.cpp
|
||||||
kwalletpasswordbackend.cpp
|
kwalletpasswordbackend.cpp
|
||||||
kioschemehandler.cpp
|
kioschemehandler.cpp
|
||||||
|
downloadkjob.cpp
|
||||||
kdeframeworksintegrationplugin.h
|
kdeframeworksintegrationplugin.h
|
||||||
kwalletpasswordbackend.h
|
kwalletpasswordbackend.h
|
||||||
kioschemehandler.h
|
kioschemehandler.h
|
||||||
|
downloadkjob.h
|
||||||
)
|
)
|
||||||
|
|
||||||
ecm_create_qm_loader(KDEFrameworksIntegration_SRCS falkon_kdeframeworksintegration_qt)
|
ecm_create_qm_loader(KDEFrameworksIntegration_SRCS falkon_kdeframeworksintegration_qt)
|
||||||
@ -24,4 +26,5 @@ target_link_libraries(KDEFrameworksIntegration
|
|||||||
KF5::Crash
|
KF5::Crash
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
KF5::PurposeWidgets
|
KF5::PurposeWidgets
|
||||||
|
KF5::JobWidgets
|
||||||
)
|
)
|
||||||
|
44
src/plugins/KDEFrameworksIntegration/downloadkjob.cpp
Normal file
44
src/plugins/KDEFrameworksIntegration/downloadkjob.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2019 Javier Llorente <javier@opensuse.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "downloadkjob.h"
|
||||||
|
|
||||||
|
DownloadKJob::DownloadKJob(const QUrl &url, const QString &path, const QString &fileName, QObject *parent)
|
||||||
|
: KJob(parent),
|
||||||
|
m_url(url),
|
||||||
|
m_path(path),
|
||||||
|
m_fileName(fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadKJob::start()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadKJob::updateDescription()
|
||||||
|
{
|
||||||
|
emit description(this, tr("Downloading"),
|
||||||
|
qMakePair<QString, QString>(tr("Source"), m_url.toDisplayString()),
|
||||||
|
qMakePair<QString, QString>(tr("Destination"), QString("%1/%2").arg(m_path, m_fileName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadKJob::progress(double currSpeed, qint64 received, qint64 total)
|
||||||
|
{
|
||||||
|
setProcessedAmount(Bytes, received);
|
||||||
|
setTotalAmount(Bytes, total);
|
||||||
|
emit speed(this, currSpeed);
|
||||||
|
}
|
44
src/plugins/KDEFrameworksIntegration/downloadkjob.h
Normal file
44
src/plugins/KDEFrameworksIntegration/downloadkjob.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* Falkon - Qt web browser
|
||||||
|
* Copyright (C) 2019 Javier Llorente <javier@opensuse.org>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef DOWNLOADKJOB_H
|
||||||
|
#define DOWNLOADKJOB_H
|
||||||
|
|
||||||
|
#include "qzcommon.h"
|
||||||
|
#include <KJob>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class FALKON_EXPORT DownloadKJob : public KJob
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DownloadKJob(const QUrl &url, const QString &path, const QString &fileName, QObject *parent = nullptr);
|
||||||
|
void start();
|
||||||
|
void updateDescription();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void progress(double currSpeed, qint64 received, qint64 total);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUrl m_url;
|
||||||
|
QString m_path;
|
||||||
|
QString m_fileName;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DOWNLOADKJOB_H
|
@ -23,14 +23,18 @@
|
|||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
#include "autofill.h"
|
#include "autofill.h"
|
||||||
#include "passwordmanager.h"
|
#include "passwordmanager.h"
|
||||||
|
#include "downloadmanager.h"
|
||||||
#include "kioschemehandler.h"
|
#include "kioschemehandler.h"
|
||||||
#include "webpage.h"
|
#include "webpage.h"
|
||||||
#include "webview.h"
|
#include "webview.h"
|
||||||
|
#include "downloadkjob.h"
|
||||||
|
#include "downloaditem.h"
|
||||||
|
|
||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KProtocolInfo>
|
#include <KProtocolInfo>
|
||||||
#include <Purpose/AlternativesModel>
|
#include <Purpose/AlternativesModel>
|
||||||
|
#include <KUiServerJobTracker>
|
||||||
|
|
||||||
#include <QWebEngineProfile>
|
#include <QWebEngineProfile>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@ -54,6 +58,22 @@ void KDEFrameworksIntegrationPlugin::init(InitState state, const QString &settin
|
|||||||
mApp->autoFill()->passwordManager()->switchBackend(QSL("KWallet"));
|
mApp->autoFill()->passwordManager()->switchBackend(QSL("KWallet"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_jobTracker = new KUiServerJobTracker(this);
|
||||||
|
|
||||||
|
auto manager = mApp->downloadManager();
|
||||||
|
connect(manager, &DownloadManager::downloadAdded, [=](DownloadItem *item) {
|
||||||
|
auto job = new DownloadKJob(item->url(), item->path(), item->fileName(), this);
|
||||||
|
m_jobTracker->registerJob(job);
|
||||||
|
job->start();
|
||||||
|
job->updateDescription();
|
||||||
|
|
||||||
|
connect(item, &DownloadItem::progressChanged, job, &DownloadKJob::progress);
|
||||||
|
connect(manager, QOverload<>::of(&DownloadManager::downloadFinished), m_jobTracker, [=]() {
|
||||||
|
m_jobTracker->unregisterJob(job);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
const auto protocols = KProtocolInfo::protocols();
|
const auto protocols = KProtocolInfo::protocols();
|
||||||
for (const QString &protocol : protocols) {
|
for (const QString &protocol : protocols) {
|
||||||
if (WebPage::internalSchemes().contains(protocol)) {
|
if (WebPage::internalSchemes().contains(protocol)) {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
class KWalletPasswordBackend;
|
class KWalletPasswordBackend;
|
||||||
class KIOSchemeHandler;
|
class KIOSchemeHandler;
|
||||||
|
class KUiServerJobTracker;
|
||||||
|
|
||||||
class KDEFrameworksIntegrationPlugin : public QObject, public PluginInterface
|
class KDEFrameworksIntegrationPlugin : public QObject, public PluginInterface
|
||||||
{
|
{
|
||||||
@ -42,4 +43,5 @@ private:
|
|||||||
KWalletPasswordBackend *m_backend = nullptr;
|
KWalletPasswordBackend *m_backend = nullptr;
|
||||||
QVector<KIOSchemeHandler*> m_kioSchemeHandlers;
|
QVector<KIOSchemeHandler*> m_kioSchemeHandlers;
|
||||||
Purpose::Menu *m_sharePageMenu = nullptr;
|
Purpose::Menu *m_sharePageMenu = nullptr;
|
||||||
|
KUiServerJobTracker *m_jobTracker = nullptr;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user