From 56355afd7d4bc9709ddf4e2cb34a51913f039a9d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 8 Mar 2011 00:19:05 +0100 Subject: download directory option preparations (sysInfo: cant test compiling right now... should me mostly correct) --- src/DownloadManager.cpp | 3 +++ src/DownloadManager.h | 2 +- src/fbgui.cpp | 4 ++-- src/main.cpp | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index 61b63d7..b5c11a2 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -1,11 +1,14 @@ #include "DownloadManager.h" + +// ---------------------------------------------------------------------------------------- void DownloadManager::downloadFile(QString& filename){ if (debug) qDebug() << "DM received signal for: " << filename; QUrl fileUrl; fileUrl = baseURL.resolved(QUrl(filename)); this->processDownloadRequest(fileUrl); } +// ---------------------------------------------------------------------------------------- void DownloadManager::downloadFile(QUrl& fileUrl){ if (debug) qDebug() << "Received downloadFile signal for:" << fileUrl; this->processDownloadRequest(fileUrl); diff --git a/src/DownloadManager.h b/src/DownloadManager.h index 0607cf5..0578724 100644 --- a/src/DownloadManager.h +++ b/src/DownloadManager.h @@ -7,7 +7,7 @@ extern bool debug; extern QUrl baseURL; - +extern QDir downloadDirectory; class DownloadManager : public QObject { diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 90eb8f6..97656f5 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -9,6 +9,7 @@ #include QUrl baseURL; +QDir downloadDirectory; bool debug; fbgui::fbgui(QApplication *parent) @@ -18,13 +19,12 @@ fbgui::fbgui(QApplication *parent) QWebView* webView = new QWebView(this); webView->load(baseURL); /* Connect fbb with app for killing the app from browser. */ - + //QObject::connect(jso, SIGNAL(signalQuitAll()), parent, SLOT(quit())); /* Init JavaScript interface */ JSObject* jso = new JSObject(webView->page()->mainFrame()); QObject::connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), jso, SLOT(attachToDOM())); - //QObject::connect(jso, SIGNAL(signalQuitAll()), parent, SLOT(quit())); /* Init Download Manager */ DownloadManager* dm = new DownloadManager(); diff --git a/src/main.cpp b/src/main.cpp index 891f497..cc2729c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include "fbgui.h" extern bool debug; +extern QDir downloadDirectory; extern QUrl baseURL; void printHelp() @@ -36,11 +37,12 @@ int main(int argc, char *argv[]) /* Parse cmdline argus. */ QMap clo; int longIndex = 0; - static const char *optString = "u:hd"; + static const char *optString = "u:hDd"; static const struct option longOpts[] = { {"url", required_argument, NULL, 'u'}, - {"debug", no_argument, NULL, 'd'}, + {"downloadtodir", required_argument, NULL, 'd'}, + {"debug", no_argument, NULL, 'D'}, {"help", no_argument, NULL, 'h'} }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); @@ -52,6 +54,9 @@ int main(int argc, char *argv[]) clo.insert("url", optarg); break; case 'd': + clo.insert("downloadDir", optarg); + break; + case 'D': clo.insert("debug", "debug"); break; case 'h': @@ -77,12 +82,18 @@ int main(int argc, char *argv[]) confFileSettings.setIniCodec("UTF-8"); if (clo.contains("url")) - baseURL = clo.value("url"); + baseURL = clo.value("url").toUrl(); else if (confFileSettings.contains("default/url")) baseURL = confFileSettings.value("default/url").toUrl(); else baseURL = DEFAULT_URL; - + + if (clo.contains("downloadDir")) + downloadDirectory = QDir(clo.value("downloadDir")); + else if (confFileSettings.contains("default/downloadDirectory")) + downloadDirectory = QDir(confFileSettings.value("default/downloadDirectory").toString()); + else + downloadDirectory = QDir("."); // Start fbgui. fbgui gui(&app); gui.show(); -- cgit v1.2.3-55-g7522