diff options
author | Jonathan Bauer | 2011-03-24 11:12:11 +0100 |
---|---|---|
committer | Jonathan Bauer | 2011-03-24 11:12:11 +0100 |
commit | 43b40a5d98ce36ed094b7e266cb4889aa9f7e0fa (patch) | |
tree | f719978a81b7596c7a3e053c52c0bf7a6231c8d4 /src | |
parent | . (diff) | |
download | fbgui-43b40a5d98ce36ed094b7e266cb4889aa9f7e0fa.tar.gz fbgui-43b40a5d98ce36ed094b7e266cb4889aa9f7e0fa.tar.xz fbgui-43b40a5d98ce36ed094b7e266cb4889aa9f7e0fa.zip |
callback fix
Diffstat (limited to 'src')
-rw-r--r-- | src/fbgui.cpp | 13 | ||||
-rw-r--r-- | src/fbgui.h | 2 | ||||
-rw-r--r-- | src/html/test.html | 16 | ||||
-rw-r--r-- | src/javascriptinterface.cpp | 10 | ||||
-rw-r--r-- | src/javascriptinterface.h | 6 |
5 files changed, 28 insertions, 19 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 210368f..3154551 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -26,10 +26,10 @@ fbgui::fbgui() sil->getInfoAboutNetworkInterface(); sil->getInfoAboutClassNet(); - // setup basic debug + // start basic console debug log qxtLog->disableLoggerEngine("DEFAULT"); qxtLog->enableLogLevels(QxtLogger::DebugLevel); - if (debugMode == 0){ + if (debugMode == 0 || debugMode == 1){ qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); @@ -37,7 +37,6 @@ fbgui::fbgui() } // base of the gui - _webView = new QWebView(this); // debug console split or normal browser if (debugMode == 1) @@ -61,13 +60,12 @@ fbgui::fbgui() QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, SLOT(downloadFile(const QString&))); QObject::connect(dm, SIGNAL(updateProgress(const int&, const double&, const QString&)), jsi, SLOT(updateProgressBar(const int&, const double&, const QString&))); - QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(callbackOnDlQueueFinished())); + QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(callbackOnFinished())); createActions(); _webView->load(QUrl("qrc:/html/loadAbout.html")); - // watch creation of fileToTriggerURL - watchFileTrigger(); + watchForTrigger(); // set properties setWindowTitle("fbgui"); @@ -88,7 +86,7 @@ void fbgui::createActions() //------------------------------------------------------------------------------------------- -void fbgui::watchFileTrigger() +void fbgui::watchForTrigger() { // check if the directory to fileToTriggerURL exists QFileInfo fi(fileToTriggerURL); @@ -194,7 +192,6 @@ void fbgui::setupDebugSplit() pal.setColor(QPalette::Base, Qt::black); _debugConsole->setPalette(pal); _debugConsole->setTextColor(Qt::white); - _debugConsole->insertPlainText("Debug console initialized.\n"); // enable custom logger engine qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); //qxtLog->initLoggerEngine("fb_logger"); diff --git a/src/fbgui.h b/src/fbgui.h index 77b339b..6df76b8 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -53,7 +53,7 @@ private: void setupDebugSplit(); void createActions(); bool checkHost() const; - void watchFileTrigger(); + void watchForTrigger(); void loadURL(); diff --git a/src/html/test.html b/src/html/test.html index ae8aece..0b9a1eb 100644 --- a/src/html/test.html +++ b/src/html/test.html @@ -25,11 +25,18 @@ function quit(){ } function downloadFile(){ var tmp=document.formular.downloadFilename.value; - fbgui.setCallbackOnDlQueueFinished("foo();"); fbgui.startDownload(tmp); + //fbgui.setCallbackOnFinished("foo();"); +} +function setcallback(){ + var tmp=document.formular.callback_fct.value; + fbgui.setCallbackOnFinished(tmp); } function foo(){ - alert("yay"); + alert("foo"); +} +function bar(){ + alert("bar"); } function updateProgress(p, s, u){ if (p >= 0 && p <= 100) @@ -68,6 +75,11 @@ fbgui test page <input type="text" name="fbgui_out_ip"> </p> <p> + <input type="button" name="callback" value="Set callback" + onclick="setcallback()"> + <input type="text" name="callback_fct"> + </p> + <p> <input type="button" name="downloadButton" value="Download file" onclick="downloadFile()"> <input type="text" name="downloadFilename"> diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp index 281a39f..338cb2c 100644 --- a/src/javascriptinterface.cpp +++ b/src/javascriptinterface.cpp @@ -52,13 +52,13 @@ void JavascriptInterface::updateProgressBar(const int& percent, const double& sp _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- -void JavascriptInterface::setCallbackOnDlQueueFinished(QString& jsFunction){ - qxtLog->debug() << "Callback set: " << jsFunction; - _callBackOnDownloadsFinished = jsFunction; +void JavascriptInterface::setCallbackOnFinished(const QString& function){ + qxtLog->debug() << "Callback set: " << function; + _callbackOnDownloadsFinished = QString(function); } //------------------------------------------------------------------------------------------------------- -void JavascriptInterface::callbackOnDlQueueFinished(){ - QString code = QString("\%1").arg(_callBackOnDownloadsFinished); +void JavascriptInterface::callbackOnFinished(){ + QString code = QString("\%1").arg(_callbackOnDownloadsFinished); _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- diff --git a/src/javascriptinterface.h b/src/javascriptinterface.h index 0999ce3..9a6477f 100644 --- a/src/javascriptinterface.h +++ b/src/javascriptinterface.h @@ -25,7 +25,7 @@ class JavascriptInterface : public QObject Q_OBJECT private: QWebFrame* _parent; - QString _callBackOnDownloadsFinished; + QString _callbackOnDownloadsFinished; void loadJQuery(); @@ -41,8 +41,8 @@ public slots: void attachToDOM(); void getSession(const QString& session); void startDownload(const QString& filename); - void setCallbackOnDlQueueFinished(QString& fctOnDownloadsFinished); - void callbackOnDlQueueFinished(); + void setCallbackOnFinished(const QString& function); + void callbackOnFinished(); void updateProgressBar(const int& percent, const double& speed, const QString& unit); void downloadInfo(const QString& filename, const double& filesize); void notify(const QString& msg); |