Finally, multiple window message are working

parent 620e5057
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by Qt Creator 2.6.1, 2013-02-24T21:44:10. --> <!-- Written by Qt Creator 2.6.1, 2013-02-27T02:00:05. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
......
...@@ -91,3 +91,12 @@ SKMessage::SKMessage(const SKMessage &other) ...@@ -91,3 +91,12 @@ SKMessage::SKMessage(const SKMessage &other)
time=other.time; time=other.time;
} }
SKMessage::SKMessage(QString h, SkylivexWin* win)
{
sender= QString("unknown");
handle = h;
webwin = win;
time = QTime::currentTime();
}
...@@ -40,6 +40,10 @@ ...@@ -40,6 +40,10 @@
#include <QHash> #include <QHash>
#include <QString> #include <QString>
// Forward declarations
class SkylivexWin;
/* /*
* SKMessage * SKMessage
* An object representing an IPC message * An object representing an IPC message
...@@ -56,12 +60,14 @@ class SKMessage ...@@ -56,12 +60,14 @@ class SKMessage
QTime time; QTime time;
QString sender; QString sender;
QString handle; QString handle;
SkylivexWin* webwin;
QHash<QString, QString > parameters; QHash<QString, QString > parameters;
SKMessage(QString s, QString h, QHash<QString, QString > p); SKMessage(QString s, QString h, QHash<QString, QString > p);
SKMessage(QString h, QHash<QString, QString > p); SKMessage(QString h, QHash<QString, QString > p);
SKMessage(QString s, QString h); SKMessage(QString s, QString h);
SKMessage(QString h); SKMessage(QString h);
SKMessage(QString h, SkylivexWin* win);
}; };
......
...@@ -73,8 +73,8 @@ int main(int argc, char *argv[]) ...@@ -73,8 +73,8 @@ int main(int argc, char *argv[])
QTimer::singleShot(0, skx, SLOT(initialize())); QTimer::singleShot(0, skx, SLOT(initialize()));
// connect core with the mainwin // connect core with the mainwin
QObject::connect(skx, SIGNAL(msgForMainWin(SKMessage&)), &mainw, SLOT(msgFromCore(SKMessage&))); QObject::connect(skx, SIGNAL(msgForGui(SKMessage&)), &mainw, SLOT(msgFromCore(SKMessage&)));
QObject::connect(&mainw, SIGNAL(putMessage(SKMessage&)), skx, SLOT(receiveFromMainWin(SKMessage&))); QObject::connect(&mainw, SIGNAL(putMessage(SKMessage&)), skx, SLOT(receiveFromGui(SKMessage&)));
// and then.. go! // and then.. go!
return skylivexapp.exec(); return skylivexapp.exec();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "skylivex.h" #include "skylivex.h"
#include "pluginsinterfaces.h" #include "pluginsinterfaces.h"
#include <iostream> #include <iostream>
#include "webwin.h"
#include "ipcmsg.h" #include "ipcmsg.h"
Q_DECLARE_METATYPE(SKMessage) Q_DECLARE_METATYPE(SKMessage)
...@@ -120,15 +121,20 @@ void SkyliveX::initializePlugin(QObject *plugin, QString filename) ...@@ -120,15 +121,20 @@ void SkyliveX::initializePlugin(QObject *plugin, QString filename)
void SkyliveX::sendMessage(SKMessage &msg) void SkyliveX::sendMessage(SKMessage &msg)
{ {
//std::cout << "Send To MainWin: " << msg << std::endl; emit msgForGui(msg);
emit msgForMainWin(msg);
emit msgForPlugins(msg); emit msgForPlugins(msg);
} }
void SkyliveX::receiveFromMainWin(SKMessage &msg) void SkyliveX::receiveFromGui(SKMessage &msg)
{ {
std::cout << "received from MainWin " << msg.handle.toStdString() << std::endl; std::cout << "received from Gui " << msg.handle.toStdString() << std::endl;
if(msg.handle=="newwindow")
{
std::cout << "Connecting new window signals/slots" << std::endl;
connect(msg.webwin, SIGNAL(putMessage(SKMessage&)), this, SLOT(receiveFromGui(SKMessage&)));
connect(this, SIGNAL(msgForGui(SKMessage&)), msg.webwin, SLOT(msgFromCore(SKMessage&)));
}
emit msgForPlugins(msg); emit msgForPlugins(msg);
} }
......
...@@ -66,13 +66,13 @@ class SkyliveX : public QObject ...@@ -66,13 +66,13 @@ class SkyliveX : public QObject
public slots: public slots:
void initialize(); void initialize();
void receiveFromMainWin(SKMessage &msg); void receiveFromGui(SKMessage &msg);
void receiveFromPlugins(SKMessage msg); void receiveFromPlugins(SKMessage msg);
signals: signals:
void finished(); void finished();
void kickPlugins(); void kickPlugins();
void msgForMainWin(SKMessage &msg); void msgForGui(SKMessage &msg);
void msgForPlugins(SKMessage msg); void msgForPlugins(SKMessage msg);
}; };
......
...@@ -97,6 +97,11 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type) ...@@ -97,6 +97,11 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
wv->setAttribute(Qt::WA_DeleteOnClose, true); wv->setAttribute(Qt::WA_DeleteOnClose, true);
if (type == QWebPage::WebModalDialog) if (type == QWebPage::WebModalDialog)
wv->setWindowModality(Qt::ApplicationModal); wv->setWindowModality(Qt::ApplicationModal);
SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv));
sendMessage(msg);
wv->show(); wv->show();
return wv; return wv;
} }
...@@ -261,7 +266,12 @@ SkylivexWin* SkylivexWin::createSkyliveWindow(QString url, QWebPage::WebWindowTy ...@@ -261,7 +266,12 @@ SkylivexWin* SkylivexWin::createSkyliveWindow(QString url, QWebPage::WebWindowTy
std::cout << "transform uri in local file " << url.toStdString() << std::endl; std::cout << "transform uri in local file " << url.toStdString() << std::endl;
} }
wv->setUrl(QUrl(url)); wv->setUrl(QUrl(url));
SKMessage msg("newwindow", qobject_cast<SkylivexWin *>(wv));
sendMessage(msg);
wv->show(); wv->show();
return wv; return wv;
} }
......
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