r21068 by craig -

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 6 16:38:39 UTC 2016


Author: craig
Date: Sun Mar  6 16:38:39 2016
New Revision: 21068

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21068
Log:
Add byte counter for downloads to Resource Manager

Modified:
    trunk/Scribus/scribus/downloadmanager/scdlmgr.cpp
    trunk/Scribus/scribus/downloadmanager/scdlmgr.h
    trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
    trunk/Scribus/scribus/downloadmanager/scdlthread.h
    trunk/Scribus/scribus/ui/resourcemanager.cpp
    trunk/Scribus/scribus/ui/resourcemanager.h
    trunk/Scribus/scribus/ui/resourcemanagerbase.ui

Modified: trunk/Scribus/scribus/downloadmanager/scdlmgr.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/downloadmanager/scdlmgr.cpp
==============================================================================
--- trunk/Scribus/scribus/downloadmanager/scdlmgr.cpp	(original)
+++ trunk/Scribus/scribus/downloadmanager/scdlmgr.cpp	Sun Mar  6 16:38:39 2016
@@ -19,6 +19,7 @@
 	connect(m_thread, SIGNAL(fileReceived(const QString &)), this, SLOT(dlReceived(const QString&)));
 	connect(m_thread, SIGNAL(fileFailed(const QString &)), this, SLOT(dlFailed(const QString&)));
 	connect(m_thread, SIGNAL(fileStarted(const QString &)), this, SLOT(dlStarted(const QString &)));
+	connect(m_thread, SIGNAL(fileDownloadProgress(qint64, qint64)), this, SIGNAL(fileDownloadProgress(qint64, qint64)));
 	//connect(thread, SIGNAL(finished()), this, SIGNAL(finished()));
 	connect(m_thread, SIGNAL(finished()), this, SLOT(moveFinishedDownloads()));
 }

Modified: trunk/Scribus/scribus/downloadmanager/scdlmgr.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/downloadmanager/scdlmgr.h
==============================================================================
--- trunk/Scribus/scribus/downloadmanager/scdlmgr.h	(original)
+++ trunk/Scribus/scribus/downloadmanager/scdlmgr.h	Sun Mar  6 16:38:39 2016
@@ -40,6 +40,7 @@
 		void finished();
 		void fileReceived(const QString& t);
 		void fileFailed(const QString& t);
+		void fileDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
 
 	private:
 		ScDLThread *m_thread;

Modified: trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
==============================================================================
--- trunk/Scribus/scribus/downloadmanager/scdlthread.cpp	(original)
+++ trunk/Scribus/scribus/downloadmanager/scdlthread.cpp	Sun Mar  6 16:38:39 2016
@@ -128,6 +128,7 @@
 	m_currentDownload = m_manager.get(request);
 	connect(m_currentDownload, SIGNAL(finished()), this, SLOT(downloadFinished()));
 	connect(m_currentDownload, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));
+	connect(m_currentDownload, SIGNAL(downloadProgress(qint64, qint64)), this, SIGNAL(fileDownloadProgress(qint64, qint64)));
 
 	//qDebug()<<"Downloading:"<<urlPair.first.toEncoded().constData();
 }

Modified: trunk/Scribus/scribus/downloadmanager/scdlthread.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/downloadmanager/scdlthread.h
==============================================================================
--- trunk/Scribus/scribus/downloadmanager/scdlthread.h	(original)
+++ trunk/Scribus/scribus/downloadmanager/scdlthread.h	Sun Mar  6 16:38:39 2016
@@ -29,6 +29,7 @@
 		void fileStarted(const QString &);
 		void fileReceived(const QString &);
 		void fileFailed(const QString &);
+		void fileDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
 
 	private slots:
 		void startNextDownload();

Modified: trunk/Scribus/scribus/ui/resourcemanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/ui/resourcemanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/resourcemanager.cpp	(original)
+++ trunk/Scribus/scribus/ui/resourcemanager.cpp	Sun Mar  6 16:38:39 2016
@@ -26,6 +26,7 @@
 #include <QDomDocument>
 #include <QFile>
 #include <QFileInfo>
+#include <QLabel>
 #include <QList>
 #include <QMessageBox>
 #include <QString>
@@ -52,6 +53,7 @@
 	downloadButton->setEnabled(false);
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(false);
+	dataReceivedLabel->setVisible(false);
 	languageChange();
 
 	connect(categoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(categoryChanged()));
@@ -685,6 +687,7 @@
 	downloadButton->setEnabled(false);
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(true);
+	dataReceivedLabel->setVisible(true);
 	downloadProgressBar->setRange(0, dataFiles.count());
 	foreach(QString f, dataFiles)
 		ScQApp->dlManager()->addURL("http://services.scribus.net/"+f, true, ScPaths::downloadDir(), ScPaths::downloadDir());
@@ -693,6 +696,8 @@
 	connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadListFinished()));
 	connect(ScQApp->dlManager(), SIGNAL(fileReceived(const QString&)), this, SLOT(updateProgressBar()));
 	connect(ScQApp->dlManager(), SIGNAL(fileFailed(const QString&)), this, SLOT(updateProgressBar()));
+	connect(ScQApp->dlManager(), SIGNAL(fileFailed(const QString&)), this, SLOT(updateProgressBar()));
+	connect(ScQApp->dlManager(), SIGNAL(fileDownloadProgress(qint64, qint64)), this, SLOT(updateProgressData(qint64, qint64)));
 	ScQApp->dlManager()->startDownloads();
 }
 
@@ -701,6 +706,7 @@
 	disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadListFinished()));
 	disconnect(ScQApp->dlManager(), SIGNAL(fileReceived(const QString&)), this, SLOT(updateProgressBar()));
 	disconnect(ScQApp->dlManager(), SIGNAL(fileFailed(const QString&)), this, SLOT(updateProgressBar()));
+	disconnect(ScQApp->dlManager(), SIGNAL(fileDownloadProgress(qint64, qint64)), this, SLOT(updateProgressData(qint64, qint64)));
 
 	int category = categoryComboBox->currentData().toInt();
 	switch (category)
@@ -734,6 +740,7 @@
 	downloadButton->setEnabled(true);
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(false);
+	dataReceivedLabel->setVisible(false);
 }
 
 void ResourceManager::downloadFilesFinished()
@@ -741,9 +748,11 @@
 	disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadFilesFinished()));
 	disconnect(ScQApp->dlManager(), SIGNAL(fileReceived(const QString&)), this, SLOT(updateProgressBar()));
 	disconnect(ScQApp->dlManager(), SIGNAL(fileFailed(const QString&)), this, SLOT(updateProgressBar()));
+	disconnect(ScQApp->dlManager(), SIGNAL(fileDownloadProgress(qint64, qint64)), this, SLOT(updateProgressData(qint64, qint64)));
 	categoryChanged();
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(false);
+	dataReceivedLabel->setVisible(false);
 	downloadButton->setEnabled(true);
 
 	int category = categoryComboBox->currentData().toInt();
@@ -923,6 +932,20 @@
 	downloadProgressBar->setValue(downloadProgressBar->value() + 1);
 }
 
+void ResourceManager::updateProgressData(qint64 bytesReceived, qint64 bytesTotal)
+{
+	QString totalText;
+	if (bytesTotal == -1)
+		totalText = QString("%1 bytes").arg(bytesReceived);
+	else
+	{
+		totalText = QString("%1 / %2 bytes").arg(bytesReceived).arg(bytesTotal);
+		QString totalTextWidth = QString("%1 / %2 bytes").arg(bytesTotal).arg(bytesTotal);
+		dataReceivedLabel->setMinimumWidth(QWidget::fontMetrics().width(totalTextWidth));
+	}
+	dataReceivedLabel->setText(totalText);
+}
+
 void ResourceManager::startDownload()
 {
 	int rows = availableTableWidget->rowCount();
@@ -941,6 +964,7 @@
 	downloadList.clear();
 	downloadProgressBar->setValue(0);
 	downloadProgressBar->setVisible(true);
+	dataReceivedLabel->setVisible(true);
 //	dlLabel->setVisible(true);
 	int dlCount=0;
 
@@ -1045,6 +1069,7 @@
 		connect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadFilesFinished()));
 		connect(ScQApp->dlManager(), SIGNAL(fileReceived(const QString&)), this, SLOT(updateProgressBar()));
 		connect(ScQApp->dlManager(), SIGNAL(fileFailed(const QString&)), this, SLOT(updateProgressBar()));
+		connect(ScQApp->dlManager(), SIGNAL(fileDownloadProgress(qint64, qint64)), this, SLOT(updateProgressData(qint64, qint64)));
 		ScQApp->dlManager()->startDownloads();
 	}
 }

Modified: trunk/Scribus/scribus/ui/resourcemanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/ui/resourcemanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/resourcemanager.h	(original)
+++ trunk/Scribus/scribus/ui/resourcemanager.h	Sun Mar  6 16:38:39 2016
@@ -99,6 +99,7 @@
 		void downloadLicenseFileFinished(const QString &);
 		void downloadLicenseFileFailed(const QString &);
 		void updateProgressBar();
+		void updateProgressData(qint64 bytesReceived, qint64 bytesTotal);
 		void startDownload();
 		void showLicense();
 

Modified: trunk/Scribus/scribus/ui/resourcemanagerbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21068&path=/trunk/Scribus/scribus/ui/resourcemanagerbase.ui
==============================================================================
Binary files - no diff available.




More information about the scribus-commit mailing list