diff --git a/localization/rssguard-cs_CZ.ts b/localization/rssguard-cs_CZ.ts
index 5175edad7..3f91a7d76 100644
--- a/localization/rssguard-cs_CZ.ts
+++ b/localization/rssguard-cs_CZ.ts
@@ -69,7 +69,7 @@
Error: %1
- Chyba: %1. {1?}
+ Chyba: %1
Cannot open folder
@@ -138,6 +138,14 @@
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-de_DE.ts b/localization/rssguard-de_DE.ts
index 7a666fe6e..7c672c003 100644
--- a/localization/rssguard-de_DE.ts
+++ b/localization/rssguard-de_DE.ts
@@ -136,6 +136,13 @@
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-en_GB.ts b/localization/rssguard-en_GB.ts
index 7456b5712..c23ec35b1 100644
--- a/localization/rssguard-en_GB.ts
+++ b/localization/rssguard-en_GB.ts
@@ -136,6 +136,13 @@
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-en_US.ts b/localization/rssguard-en_US.ts
index aa4859cdd..610abe165 100644
--- a/localization/rssguard-en_US.ts
+++ b/localization/rssguard-en_US.ts
@@ -4,7 +4,7 @@
Application
-
+
Application is already running.
@@ -132,7 +132,15 @@
-
+
+ Downloading %n file(s)...
+
+
+
+
+
+
+
%n minutes remaining
@@ -140,7 +148,7 @@
-
+
%n seconds remaining
@@ -148,22 +156,22 @@
-
+
bytes
-
+
kB
-
+
MB
-
+
GB
@@ -3119,12 +3127,12 @@ currently installed one.
StatusBar
-
+
Fullscreen mode
-
+
Switch application between fulscreen/normal states right from this status bar icon.
diff --git a/localization/rssguard-fr_FR.ts b/localization/rssguard-fr_FR.ts
index 8fbae6dca..5473c9184 100644
--- a/localization/rssguard-fr_FR.ts
+++ b/localization/rssguard-fr_FR.ts
@@ -136,6 +136,13 @@
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-it_IT.ts b/localization/rssguard-it_IT.ts
index 1c3c0fc1b..602751559 100644
--- a/localization/rssguard-it_IT.ts
+++ b/localization/rssguard-it_IT.ts
@@ -136,6 +136,13 @@
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-nl_NL.ts b/localization/rssguard-nl_NL.ts
index a967e04cb..fb10c8cf4 100644
--- a/localization/rssguard-nl_NL.ts
+++ b/localization/rssguard-nl_NL.ts
@@ -136,6 +136,13 @@
GB
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/localization/rssguard-sv_SE.ts b/localization/rssguard-sv_SE.ts
index b1de2e431..2f5a40906 100644
--- a/localization/rssguard-sv_SE.ts
+++ b/localization/rssguard-sv_SE.ts
@@ -136,6 +136,13 @@
GB
GB
+
+ Downloading %n file(s)...
+
+
+
+
+
FeedMessageViewer
diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp
index b475768e2..3c8bad623 100755
--- a/src/gui/feedmessageviewer.cpp
+++ b/src/gui/feedmessageviewer.cpp
@@ -164,20 +164,20 @@ void FeedMessageViewer::updateTrayIconStatus(int unread_messages, int total_mess
void FeedMessageViewer::onFeedUpdatesStarted() {
//: Text display in status bar when feed update is started.
- qApp->mainForm()->statusBar()->showProgress(0, tr("Feed update started"));
+ qApp->mainForm()->statusBar()->showProgressFeeds(0, tr("Feed update started"));
}
void FeedMessageViewer::onFeedUpdatesProgress(FeedsModelFeed *feed, int current, int total) {
// Some feed got updated.
m_feedsView->updateCountsOfParticularFeed(feed, true);
- qApp->mainForm()->statusBar()->showProgress((current * 100.0) / total,
+ qApp->mainForm()->statusBar()->showProgressFeeds((current * 100.0) / total,
//: Text display in status bar when particular feed is updated.
tr("Updated feed '%1'").arg(feed->title()));
}
void FeedMessageViewer::onFeedUpdatesFinished() {
qApp->closeLock()->unlock();
- qApp->mainForm()->statusBar()->clearProgress();
+ qApp->mainForm()->statusBar()->clearProgressFeeds();
m_messagesView->reloadSelections(1);
}
diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp
index 7cc3464f9..bb233e791 100755
--- a/src/gui/statusbar.cpp
+++ b/src/gui/statusbar.cpp
@@ -17,11 +17,14 @@
#include "gui/statusbar.h"
+#include "gui/formmain.h"
+#include "gui/tabwidget.h"
#include "miscellaneous/iconfactory.h"
#include
#include
#include
+#include
StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
@@ -36,18 +39,33 @@ StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
m_fullscreenSwitcher->setText(tr("Fullscreen mode"));
m_fullscreenSwitcher->setToolTip(tr("Switch application between fulscreen/normal states right from this status bar icon."));
- m_progressBar = new QProgressBar(this);
- m_progressBar->setTextVisible(false);
- m_progressBar->setFixedWidth(100);
- m_progressBar->setVisible(false);
+ m_barProgressFeeds = new QProgressBar(this);
+ m_barProgressFeeds->setTextVisible(false);
+ m_barProgressFeeds->setFixedWidth(100);
+ m_barProgressFeeds->setVisible(false);
- m_progressLabel = new QLabel(this);
- m_progressLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
- m_progressLabel->setVisible(false);
+ m_lblProgressFeeds = new QLabel(this);
+ m_lblProgressFeeds->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ m_lblProgressFeeds->setVisible(false);
+
+ m_barProgressDownload = new QProgressBar(this);
+ m_barProgressDownload->setTextVisible(true);
+ m_barProgressDownload->setFixedWidth(100);
+ m_barProgressDownload->setVisible(false);
+
+ m_lblProgressDownload = new QLabel(this);
+ m_lblProgressDownload->setText("Downloading files in background");
+ m_lblProgressDownload->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ m_lblProgressDownload->setVisible(false);
+
+ // TODO: nastavit event filter na label a progress aby se po kliku
+ // otevřel download manager
// Add widgets.
- addWidget(m_progressBar);
- addWidget(m_progressLabel);
+ addPermanentWidget(m_lblProgressFeeds);
+ addPermanentWidget(m_barProgressFeeds);
+ addPermanentWidget(m_lblProgressDownload);
+ addPermanentWidget(m_barProgressDownload);
addPermanentWidget(m_fullscreenSwitcher);
}
@@ -55,15 +73,33 @@ StatusBar::~StatusBar() {
qDebug("Destroying StatusBar instance.");
}
-void StatusBar::showProgress(int progress, const QString &label) {
- m_progressLabel->setVisible(true);
- m_progressBar->setVisible(true);
-
- m_progressLabel->setText(label);
- m_progressBar->setValue(progress);
+void StatusBar::displayDownloadManager() {
+ qApp->mainForm()->tabWidget()->showDownloadManager();
}
-void StatusBar::clearProgress() {
- m_progressLabel->setVisible(false);
- m_progressBar->setVisible(false);
+void StatusBar::showProgressFeeds(int progress, const QString &label) {
+ m_lblProgressFeeds->setVisible(true);
+ m_barProgressFeeds->setVisible(true);
+
+ m_lblProgressFeeds->setText(label);
+ m_barProgressFeeds->setValue(progress);
+}
+
+void StatusBar::clearProgressFeeds() {
+ m_lblProgressFeeds->setVisible(false);
+ m_barProgressFeeds->setVisible(false);
+}
+
+void StatusBar::showProgressDownload(int progress, const QString &tooltip) {
+ m_lblProgressDownload->setVisible(true);
+ m_barProgressDownload->setVisible(true);
+ m_barProgressDownload->setValue(progress);
+ m_barProgressDownload->setToolTip(tooltip);
+ m_lblProgressDownload->setToolTip(tooltip);
+}
+
+void StatusBar::clearProgressDownload() {
+ m_lblProgressDownload->setVisible(false);
+ m_barProgressDownload->setVisible(false);
+ m_barProgressDownload->setValue(0);
}
diff --git a/src/gui/statusbar.h b/src/gui/statusbar.h
index e17341a03..24a872cd4 100644
--- a/src/gui/statusbar.h
+++ b/src/gui/statusbar.h
@@ -37,13 +37,19 @@ class StatusBar : public QStatusBar {
return m_fullscreenSwitcher;
}
+ public slots:
// Progress bar operations
- void showProgress(int progress, const QString &label);
- void clearProgress();
+ void showProgressFeeds(int progress, const QString &label);
+ void clearProgressFeeds();
+
+ void showProgressDownload(int progress, const QString &tooltip);
+ void clearProgressDownload();
private:
- QProgressBar *m_progressBar;
- QLabel *m_progressLabel;
+ QProgressBar *m_barProgressFeeds;
+ QLabel *m_lblProgressFeeds;
+ QProgressBar *m_barProgressDownload;
+ QLabel *m_lblProgressDownload;
QToolButton *m_fullscreenSwitcher;
};
diff --git a/src/gui/tabwidget.h b/src/gui/tabwidget.h
index 57e6af3db..a3fa7b90c 100644
--- a/src/gui/tabwidget.h
+++ b/src/gui/tabwidget.h
@@ -118,9 +118,7 @@ class TabWidget : public QTabWidget {
int addLinkedBrowser(const QString &initial_url);
// General method for adding WebBrowsers.
- int addBrowser(bool move_after_current,
- bool make_active,
- const QUrl &initial_url = QUrl());
+ int addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url = QUrl());
private:
PlainToolButton *m_btnAddTab;
diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp
index 09f41591e..a47fa8028 100755
--- a/src/miscellaneous/application.cpp
+++ b/src/miscellaneous/application.cpp
@@ -23,6 +23,7 @@
#include "gui/feedmessageviewer.h"
#include "gui/messagebox.h"
#include "gui/formmain.h"
+#include "gui/statusbar.h"
#include
#include
@@ -59,6 +60,18 @@ IconFactory *Application::icons() {
return m_icons;
}
+DownloadManager *Application::downloadManager() {
+ if (m_downloadManager == NULL) {
+ m_downloadManager = new DownloadManager();
+
+ connect(m_downloadManager, SIGNAL(downloadFinished()), mainForm()->statusBar(), SLOT(clearProgressDownload()));
+ connect(m_downloadManager, SIGNAL(downloadProgress(int,QString)),
+ mainForm()->statusBar(), SLOT(showProgressDownload(int,QString)));
+ }
+
+ return m_downloadManager;
+}
+
bool Application::backupDatabaseSettings(bool backup_database, bool backup_settings,
const QString &target_path, const QString &backup_name) {
if (!QFileInfo(target_path).isWritable()) {
diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h
index 0377b0683..eb54e13e5 100755
--- a/src/miscellaneous/application.h
+++ b/src/miscellaneous/application.h
@@ -88,14 +88,7 @@ class Application : public QtSingleApplication {
}
IconFactory *icons();
-
- inline DownloadManager *downloadManager() {
- if (m_downloadManager == NULL) {
- m_downloadManager = new DownloadManager();
- }
-
- return m_downloadManager;
- }
+ DownloadManager *downloadManager();
inline Settings *settings() {
if (m_settings == NULL) {
diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp
index 149d8c7af..1c91f6ee6 100644
--- a/src/network-web/downloadmanager.cpp
+++ b/src/network-web/downloadmanager.cpp
@@ -452,13 +452,15 @@ DownloadManager::~DownloadManager() {
}
delete m_ui;
+
+ qDebug("Destroying DownloadManager instance.");
}
int DownloadManager::activeDownloads() const {
int count = 0;
- for (int i = 0; i < m_downloads.count(); i++) {
- if (m_downloads.at(i)->m_ui->m_btnStopDownload->isEnabled()) {
+ foreach (DownloadItem *download, m_downloads) {
+ if (download->downloading()) {
count++;
}
}
@@ -466,6 +468,25 @@ int DownloadManager::activeDownloads() const {
return count;
}
+int DownloadManager::downloadProgress() const {
+ qint64 bytes_total = 0;
+ qint64 bytes_received = 0;
+
+ foreach (DownloadItem *download, m_downloads) {
+ if (download->downloading()) {
+ bytes_total += download->bytesTotal();
+ bytes_received += download->bytesReceived();
+ }
+ }
+
+ if (bytes_total <= 0) {
+ return -1;
+ }
+ else {
+ return (bytes_received * 100.0) / bytes_total;
+ }
+}
+
void DownloadManager::download(const QNetworkRequest &request) {
if (!request.url().isEmpty()) {
handleUnsupportedContent(m_networkManager->get(request));
@@ -501,7 +522,8 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply *reply) {
void DownloadManager::addItem(DownloadItem *item) {
connect(item, SIGNAL(statusChanged()), this, SLOT(updateRow()));
- connect(item, SIGNAL(downloadFinished()), this, SLOT(finished()));
+ connect(item, SIGNAL(progress(qint64,qint64)), this, SLOT(itemProgress()));
+ connect(item, SIGNAL(downloadFinished()), this, SLOT(itemFinished()));
int row = m_downloads.count();
m_model->beginInsertRows(QModelIndex(), row, row);
@@ -521,8 +543,8 @@ QNetworkAccessManager *DownloadManager::networkManager() const {
return m_networkManager;
}
-void DownloadManager::finished() {
- // NOTE: Download has finished.
+void DownloadManager::itemFinished() {
+ emit downloadFinished();
}
void DownloadManager::updateRow() {
@@ -531,6 +553,17 @@ void DownloadManager::updateRow() {
}
}
+void DownloadManager::itemProgress() {
+ int progress = downloadProgress();
+
+ if (progress < 0) {
+ emit downloadFinished();
+ }
+ else {
+ emit downloadProgress(progress, tr("Downloading %n file(s)...", "", activeDownloads()));
+ }
+}
+
void DownloadManager::updateRow(DownloadItem *item) {
int row = m_downloads.indexOf(item);
diff --git a/src/network-web/downloadmanager.h b/src/network-web/downloadmanager.h
index 197159b59..699280b73 100644
--- a/src/network-web/downloadmanager.h
+++ b/src/network-web/downloadmanager.h
@@ -109,16 +109,17 @@ class DownloadManager : public TabContent {
QNetworkAccessManager *networkManager() const;
int activeDownloads() const;
+ int downloadProgress() const;
RemovePolicy removePolicy() const;
void setRemovePolicy(RemovePolicy policy);
- static QString timeString(double time_remaining);
- static QString dataString(qint64 size);
-
void setDownloadDirectory(const QString &directory);
QString downloadDirectory();
+ static QString timeString(double time_remaining);
+ static QString dataString(qint64 size);
+
public slots:
void download(const QNetworkRequest &request);
void download(const QUrl &url);
@@ -131,7 +132,12 @@ class DownloadManager : public TabContent {
void updateRow(DownloadItem *item);
void updateRow();
- void finished();
+ void itemProgress();
+ void itemFinished();
+
+ signals:
+ void downloadProgress(int progress, const QString &description);
+ void downloadFinished();
private:
void addItem(DownloadItem *item);