Communication between mainwindow and core

established by using signals/slot
parent 64ecb4dc
......@@ -6,7 +6,7 @@ HEADERS = src/skylivex.h \
src/mainwin.h \
src/pluginsinterfaces.h
QT += network webkitwidgets widgets
QT += core network webkitwidgets widgets
OTHER_FILES += \
gui/splash.html \
......
......@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
QObject::connect(skxprocess, SIGNAL(timeout()), skx, SLOT(process()));
skxprocess->start();
// connect core with the mainwin
QObject::connect(skx, SIGNAL(msgForMainWin(std::string&)), &mainw, SLOT(msgFromCore(std::string&)));
// and then.. go!
return skylivexapp.exec();
......
......@@ -33,9 +33,11 @@
*
*/
#include "mainwin.h"
#include <QWebView>
#include <QFile>
#include <QDir>
#include <QPalette>
#include <iostream>
MainWin::MainWin(QFile &htmlfile)
: QWebView(0)
......@@ -54,9 +56,16 @@ MainWin::MainWin(QFile &htmlfile)
setHtml(htmlFileName, baseUrl);
resize(250,200);
}
MainWin::~MainWin()
{
}
void MainWin::msgFromCore(std::string &msg)
{
std::cout << "Message from core: " << msg << std::endl;
}
......@@ -39,6 +39,7 @@
#include <QUrl>
#include <QFile>
#include <QString>
#include <QObject>
/*
* class MainWin
......@@ -47,13 +48,20 @@
*/
class MainWin : public QWebView
{
QUrl baseurl;
QFile htmlfile;
QString htmlFileName;
Q_OBJECT
QUrl baseurl;
QFile htmlfile;
QString htmlFileName;
public:
MainWin(QFile &htmlfile);
~MainWin();
public slots:
void msgFromCore(std::string &msg);
};
......
......@@ -43,6 +43,7 @@
#include <iostream>
// Load and initialize plugins and shared memory communication
void SkyliveX::initialize()
{
......@@ -55,6 +56,8 @@ void SkyliveX::initialize()
void SkyliveX::process()
{
//std::cout << "process" << std::endl;
std::string sarca("ANTANI!");
sendMsgToMainWin(sarca);
}
......@@ -93,3 +96,9 @@ void SkyliveX::initializePlugin(QObject *plugin, QString filename)
// 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 @@
#include <QObject>
#include <QString>
#include "pluginsinterfaces.h"
#include <iostream>
#include <string>
/*
* class SkyliveX
......@@ -61,10 +63,11 @@ class SkyliveX : public QObject
public slots:
void initialize();
void process();
void sendMsgToMainWin(std::string &msg);
signals:
void finished();
void msgForMainWin(std::string &msg);
};
#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