Communication between mainwindow and core

established by using signals/slot
parent 64ecb4dc
...@@ -6,7 +6,7 @@ HEADERS = src/skylivex.h \ ...@@ -6,7 +6,7 @@ HEADERS = src/skylivex.h \
src/mainwin.h \ src/mainwin.h \
src/pluginsinterfaces.h src/pluginsinterfaces.h
QT += network webkitwidgets widgets QT += core network webkitwidgets widgets
OTHER_FILES += \ OTHER_FILES += \
gui/splash.html \ gui/splash.html \
......
...@@ -76,6 +76,9 @@ int main(int argc, char *argv[]) ...@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
QObject::connect(skxprocess, SIGNAL(timeout()), skx, SLOT(process())); QObject::connect(skxprocess, SIGNAL(timeout()), skx, SLOT(process()));
skxprocess->start(); skxprocess->start();
// connect core with the mainwin
QObject::connect(skx, SIGNAL(msgForMainWin(std::string&)), &mainw, SLOT(msgFromCore(std::string&)));
// and then.. go! // and then.. go!
return skylivexapp.exec(); return skylivexapp.exec();
......
...@@ -33,9 +33,11 @@ ...@@ -33,9 +33,11 @@
* *
*/ */
#include "mainwin.h" #include "mainwin.h"
#include <QWebView>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QPalette> #include <QPalette>
#include <iostream>
MainWin::MainWin(QFile &htmlfile) MainWin::MainWin(QFile &htmlfile)
: QWebView(0) : QWebView(0)
...@@ -54,9 +56,16 @@ MainWin::MainWin(QFile &htmlfile) ...@@ -54,9 +56,16 @@ MainWin::MainWin(QFile &htmlfile)
setHtml(htmlFileName, baseUrl); setHtml(htmlFileName, baseUrl);
resize(250,200); resize(250,200);
} }
MainWin::~MainWin() MainWin::~MainWin()
{ {
} }
void MainWin::msgFromCore(std::string &msg)
{
std::cout << "Message from core: " << msg << std::endl;
}
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QUrl> #include <QUrl>
#include <QFile> #include <QFile>
#include <QString> #include <QString>
#include <QObject>
/* /*
* class MainWin * class MainWin
...@@ -47,13 +48,20 @@ ...@@ -47,13 +48,20 @@
*/ */
class MainWin : public QWebView class MainWin : public QWebView
{ {
QUrl baseurl;
QFile htmlfile; Q_OBJECT
QString htmlFileName;
QUrl baseurl;
QFile htmlfile;
QString htmlFileName;
public: public:
MainWin(QFile &htmlfile); MainWin(QFile &htmlfile);
~MainWin(); ~MainWin();
public slots:
void msgFromCore(std::string &msg);
}; };
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <iostream> #include <iostream>
// Load and initialize plugins and shared memory communication // Load and initialize plugins and shared memory communication
void SkyliveX::initialize() void SkyliveX::initialize()
{ {
...@@ -55,6 +56,8 @@ void SkyliveX::initialize() ...@@ -55,6 +56,8 @@ void SkyliveX::initialize()
void SkyliveX::process() void SkyliveX::process()
{ {
//std::cout << "process" << std::endl; //std::cout << "process" << std::endl;
std::string sarca("ANTANI!");
sendMsgToMainWin(sarca);
} }
...@@ -93,3 +96,9 @@ void SkyliveX::initializePlugin(QObject *plugin, QString filename) ...@@ -93,3 +96,9 @@ void SkyliveX::initializePlugin(QObject *plugin, QString filename)
// now the plugin can be initialized and used // now the plugin can be initialized and used
} }
} }
void SkyliveX::sendMsgToMainWin(std::string &msg)
{
//std::cout << "Send To MainWin: " << msg << std::endl;
emit msgForMainWin(msg);
}
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include "pluginsinterfaces.h" #include "pluginsinterfaces.h"
#include <iostream>
#include <string>
/* /*
* class SkyliveX * class SkyliveX
...@@ -61,10 +63,11 @@ class SkyliveX : public QObject ...@@ -61,10 +63,11 @@ class SkyliveX : public QObject
public slots: public slots:
void initialize(); void initialize();
void process(); void process();
void sendMsgToMainWin(std::string &msg);
signals: signals:
void finished(); void finished();
void msgForMainWin(std::string &msg);
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment