mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Windows: Show taskbar progress on browser window in download manager
It will now show progress even when download manager window is not opened, as download manager is no longer automatically opened when starting new download.
This commit is contained in:
parent
ba3563362d
commit
2eeee848b7
@ -156,6 +156,20 @@ void DownloadManager::closeDownloadTab(const QUrl &url) const
|
||||
}
|
||||
}
|
||||
|
||||
QWinTaskbarButton *DownloadManager::taskbarButton()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if (!m_taskbarButton) {
|
||||
BrowserWindow *window = mApp->getWindow();
|
||||
m_taskbarButton = new QWinTaskbarButton(window ? window->windowHandle() : windowHandle());
|
||||
m_taskbarButton->progress()->setRange(0, 100);
|
||||
}
|
||||
return m_taskbarButton;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
void DownloadManager::startExternalManager(const QUrl &url)
|
||||
{
|
||||
QString arguments = m_externalArguments;
|
||||
@ -176,9 +190,7 @@ void DownloadManager::timerEvent(QTimerEvent* e)
|
||||
ui->speedLabel->clear();
|
||||
setWindowTitle(tr("Download Manager"));
|
||||
#ifdef Q_OS_WIN
|
||||
if (m_taskbarButton) {
|
||||
m_taskbarButton->progress()->hide();
|
||||
}
|
||||
taskbarButton()->progress()->hide();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -220,10 +232,8 @@ void DownloadManager::timerEvent(QTimerEvent* e)
|
||||
#endif
|
||||
setWindowTitle(tr("%1% - Download Manager").arg(progress));
|
||||
#ifdef Q_OS_WIN
|
||||
if (m_taskbarButton) {
|
||||
m_taskbarButton->progress()->show();
|
||||
m_taskbarButton->progress()->setValue(progress);
|
||||
}
|
||||
taskbarButton()->progress()->show();
|
||||
taskbarButton()->progress()->setValue(progress);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -407,9 +417,7 @@ void DownloadManager::downloadFinished(bool success)
|
||||
ui->speedLabel->clear();
|
||||
setWindowTitle(tr("Download Manager"));
|
||||
#ifdef Q_OS_WIN
|
||||
if (m_taskbarButton) {
|
||||
m_taskbarButton->progress()->hide();
|
||||
}
|
||||
taskbarButton()->progress()->hide();
|
||||
#endif
|
||||
if (m_closeOnFinish) {
|
||||
close();
|
||||
@ -417,18 +425,6 @@ void DownloadManager::downloadFinished(bool success)
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadManager::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
#ifdef Q_OS_WIN
|
||||
if (!m_taskbarButton) {
|
||||
m_taskbarButton = new QWinTaskbarButton(this);
|
||||
}
|
||||
m_taskbarButton->setWindow(windowHandle());
|
||||
m_taskbarButton->progress()->setRange(0, 100);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DownloadManager::deleteItem(DownloadItem* item)
|
||||
{
|
||||
if (item && !item->isDownloading()) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define DOWNLOADMANAGER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPointer>
|
||||
#include <QBasicTimer>
|
||||
|
||||
#include "qzcommon.h"
|
||||
@ -89,13 +90,13 @@ Q_SIGNALS:
|
||||
void downloadsCountChanged();
|
||||
|
||||
private:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void timerEvent(QTimerEvent* e) override;
|
||||
void closeEvent(QCloseEvent* e) override;
|
||||
void resizeEvent(QResizeEvent* e) override;
|
||||
void keyPressEvent(QKeyEvent* e) override;
|
||||
|
||||
void closeDownloadTab(const QUrl &url) const;
|
||||
QWinTaskbarButton *taskbarButton();
|
||||
|
||||
Ui::DownloadManager* ui;
|
||||
QBasicTimer m_timer;
|
||||
@ -113,7 +114,7 @@ private:
|
||||
|
||||
DownloadOption m_lastDownloadOption;
|
||||
|
||||
QWinTaskbarButton *m_taskbarButton = nullptr;
|
||||
QPointer<QWinTaskbarButton> m_taskbarButton;
|
||||
};
|
||||
|
||||
#endif // DOWNLOADMANAGER_H
|
||||
|
Loading…
Reference in New Issue
Block a user