diff options
| author | Jonathan Bauer | 2011-03-16 13:17:41 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2011-03-16 13:17:41 +0100 |
| commit | 4f8efa31d054c3fb9de11c740ae8286581765e0c (patch) | |
| tree | ab4aa38f321f076bf33b9a7aad105a6d9c7e3427 /src | |
| parent | DM now appends download index to filename in case file already exists (diff) | |
| download | fbgui-4f8efa31d054c3fb9de11c740ae8286581765e0c.tar.gz fbgui-4f8efa31d054c3fb9de11c740ae8286581765e0c.tar.xz fbgui-4f8efa31d054c3fb9de11c740ae8286581765e0c.zip | |
new fancy console for debugging, open/close with F4
Diffstat (limited to 'src')
| -rw-r--r-- | src/downloadManager.cpp | 4 | ||||
| -rw-r--r-- | src/fbgui.cpp | 43 | ||||
| -rw-r--r-- | src/fbgui.h | 10 |
3 files changed, 44 insertions, 13 deletions
diff --git a/src/downloadManager.cpp b/src/downloadManager.cpp index 9b44a3d..039809a 100644 --- a/src/downloadManager.cpp +++ b/src/downloadManager.cpp @@ -72,7 +72,6 @@ void downloadManager::startNextDownload() /* get temporary filename from URL. */ QString tmp = url.path(); tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1); - if (debug) qDebug() << "Extracted " << tmp << "from " << url.toString(); /* check if filename exists on target file system */ QFileInfo fi(downloadPath + "/" + tmp); @@ -87,8 +86,7 @@ void downloadManager::startNextDownload() if (debug) qDebug() << "Couldn't open file! Skipping..."; return; } - QString qs = QString(fi.absoluteFilePath() + ".\%1").arg(downloaded); - qDebug() << "TEST:" << qs; + /* send the request for the file */ QNetworkRequest request(url); currentDownload = qnam->get(request); diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 7c7ed46..985297a 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -7,7 +7,7 @@ #include <QDir> #include <QHostInfo> #include <QtWebKit> -#include <QApplication> +#include <QPlainTextEdit> // Note: Absolute paths. binPath empty init, set in main() after QApplication instanciated. QString binPath(""); @@ -18,31 +18,58 @@ int updateInterval = DEFAULT_UPDATE_INTERVAL; //------------------------------------------------------------------------------------------- fbgui::fbgui() { - //grabKeyboard(); + /* debug console test */ + if (debug){ + logView = new QTextEdit(this); + logView->resize(QSize(640, 480)); + QPalette qp; + qp.setColor(QPalette::Base, Qt::black); + logView->setPalette(qp); + logView->setTextColor(Qt::green); + logView->setVisible(false); + logView->setPlainText("empty console."); + } - /* Init "browser" */ + /* initialize "browser" */ checkHost(); - QWebView* webView = new QWebView(this); + webView = new QWebView(this); webView->load(baseURL); - /* Init JavaScript interface */ + /* initialize javascript interface */ javascriptInterface* jsi = new javascriptInterface(webView->page()->mainFrame()); QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close())); QObject::connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM())); - /* Init Download Manager */ + /* initialize download manager */ downloadManager* dm = new downloadManager(); QObject::connect(dm, SIGNAL(downloadInfo(QString, double)), jsi, SLOT(downloadInfo(QString, double))); QObject::connect(jsi, SIGNAL(requestFile(QString&)), dm, SLOT(downloadFile(QString&))); QObject::connect(dm, SIGNAL(updateProgress(int, double, QString)), jsi, SLOT(updateProgressBar(int, double, QString))); QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(callbackOnDlQueueFinished())); + setWindowTitle("fbgui"); setAttribute(Qt::WA_QuitOnClose, true); - showFullScreen(); + setWindowFlags(Qt::FramelessWindowHint); + resize(QSize(800, 600)); setCentralWidget(webView); + showFullScreen(); show(); - +} +//------------------------------------------------------------------------------------------- +void fbgui::keyPressEvent(QKeyEvent *event){ + /* test */ + if (event->key() == Qt::Key_F4){ + if (!logView->isVisible()){ + logView->append(QString("check passed.")); + logView->raise(); + logView->setVisible(true); + } + else { + logView->lower(); + logView->setVisible(false); + } + } } //------------------------------------------------------------------------------------------- void fbgui::checkHost() const diff --git a/src/fbgui.h b/src/fbgui.h index 68bb2cf..35f5e69 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -18,8 +18,8 @@ #ifndef FBGUI_H #define FBGUI_H -#include <QtCore> -#include <QMainWindow> +#include <QtGui> +#include <QPlainTextEdit> #include <QtWebKit> #define DEFAULT_URL "http://www.google.com" @@ -40,7 +40,13 @@ public: fbgui(); private: + QWebView* webView; + QTextEdit* logView; void checkHost() const; + + +protected: + void keyPressEvent(QKeyEvent *event); }; #endif // FBGUI_H |
