diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/DownloadManager.cpp | 23 | ||||
| -rw-r--r-- | src/fbgui.cpp | 9 | ||||
| -rw-r--r-- | src/fbgui.h | 3 | ||||
| -rw-r--r-- | src/javascriptInterface.cpp | 1 |
4 files changed, 25 insertions, 11 deletions
diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index a80ab32..eb9832b 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -1,5 +1,6 @@ #include "DownloadManager.h" //#include <QDir> +#include <QFileInfo> int DownloadManager::downloaded = 0; // ---------------------------------------------------------------------------------------- @@ -7,6 +8,7 @@ DownloadManager::DownloadManager() { qnam = new QNetworkAccessManager(); dip = false; + // the whole QDir thing is questionable.. downloadDir = QDir(downloadPath); // Check if downloadPath exists, if not create it. if (!downloadDir.exists()){ @@ -54,22 +56,23 @@ void DownloadManager::processDownloadRequest(QUrl& url) // ---------------------------------------------------------------------------------------- void DownloadManager::startNextDownload() { - if (debug) qDebug() << "Starting next download: " << dlQ.head().toString() - << "(" << dlQ.size() << "in queue.)"; if (dlQ.isEmpty()) { - if (debug) qDebug() << "Download queue empty! Exiting..."; + if (debug) qDebug() << "Download manager ready."; return; } + if (debug) qDebug() << "Starting next download: " << dlQ.head().toString() + << "(" << dlQ.size() << "in queue.)"; // Dequeue next URL to download. QUrl url = dlQ.dequeue(); + // Get filename from URL. QString tmp = url.path(); tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1); if (debug) qDebug() << "Extracted " << tmp << "from " << url.toString(); // TODO: check for if relative path, if so prepend binPath outfile.setFileName(downloadPath + "/" + tmp); - if (debug) qDebug() << "DM: Absolute path: " << downloadPath + "/" + tmp; + if (debug) qDebug() << "Trying to save to: " << downloadPath + "/" + tmp; if (outfile.exists()){ if (debug) qDebug() << "File already exists. Skipping: " << url.toString(); startNextDownload(); @@ -99,7 +102,7 @@ void DownloadManager::startNextDownload() QObject::connect(currentDownload, SIGNAL(finished()), this, SLOT(downloadFinished())); } // ---------------------------------------------------------------------------------------- -// Private slots for queueing functionality. +// Private slots // ---------------------------------------------------------------------------------------- // This slot listens to readyRead() emmited when data is available for reading. void DownloadManager::downloadReady() @@ -123,18 +126,20 @@ void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) // when all the data from the reply has been read. void DownloadManager::downloadFinished() { - // Second check if the download actually is finished. + // Second check if the download actually is finished just to be sure. if (currentDownload->isFinished()) if (debug) qDebug() << "Download of " << currentDownload->url().toString() << "finished." << endl; // Close output file. outfile.close(); currentDownload->deleteLater(); - ++downloaded; - // If queue is empty, we are done. + downloaded++; dip = false; - if (dlQ.isEmpty()) + // If queue is empty, we are done. + if (dlQ.isEmpty()){ + if (debug) qDebug() << "Download manager ready."; return; + } // Queue not empty: initialise next download. startNextDownload(); } diff --git a/src/fbgui.cpp b/src/fbgui.cpp index dbee71f..5209ad1 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -37,16 +37,21 @@ fbgui::fbgui() QObject::connect(jsi, SIGNAL(requestFile(QString&)), dm, SLOT(downloadFile(QString&))); QObject::connect(dm, SIGNAL(updateProgress(int)), jsi, SLOT(updateProgressBar(int))); - setWindowFlags(Qt::SplashScreen); + //setWindowFlags(Qt::Window); showFullScreen(); + qDebug() << "Width: " << width() << " // Height: " << height(); + QSize size(800, 600); + resize(size); setCentralWidget(webView); show(); + } //------------------------------------------------------------------------------------------- void fbgui::checkHost() const { QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); if (hostInfo.error() != QHostInfo::NoError){ - if (debug) qDebug() << "Lookup of " << baseURL.host() << "failed." << "Exiting..."; + qDebug() << "Lookup of " << baseURL.host() << "failed." << "Exiting..."; exit(EXIT_FAILURE); } } +void fbgui::anim() {} diff --git a/src/fbgui.h b/src/fbgui.h index 0f06551..09cf459 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -21,6 +21,9 @@ public: private: void checkHost() const; + void anim(); + + QSize size; }; diff --git a/src/javascriptInterface.cpp b/src/javascriptInterface.cpp index a0b4254..fc7203a 100644 --- a/src/javascriptInterface.cpp +++ b/src/javascriptInterface.cpp @@ -28,6 +28,7 @@ QString javascriptInterface::getSysInfo(QString info) void javascriptInterface::attachToDOM() { _parent->addToJavaScriptWindowObject(QString("jsObject"), this); + _parent->addToJavaScriptWindowObject(QString("fbgui"), this); } //------------------------------------------------------------------------------------------------------- void javascriptInterface::startDownload(QString filename) |
