Finally, multiple window message are working

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