Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
skylivex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
astronomy
skylivex
Commits
620e5057
Commit
620e5057
authored
Feb 26, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SkyliveX js object in the bridge now has SkyliveX.open_window() method
parent
ad8a46b4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
66 deletions
+143
-66
jsbridge.cpp
src/jsbridge.cpp
+10
-0
jsbridge.h
src/jsbridge.h
+3
-2
mainwin.cpp
src/mainwin.cpp
+1
-27
mainwin.h
src/mainwin.h
+1
-4
webwin.cpp
src/webwin.cpp
+104
-28
webwin.h
src/webwin.h
+24
-5
No files found.
src/jsbridge.cpp
View file @
620e5057
...
...
@@ -33,6 +33,7 @@
*
*/
#include <QString>
#include <QWebPage>
#include <iostream>
#include "ipcmsg.h"
#include "jsbridge.h"
...
...
@@ -90,3 +91,12 @@ void JSBridge::change_telescope(QString tele)
wwin
->
sendMessage
(
msg
);
}
SkylivexWin
*
JSBridge
::
open_window
(
QString
url
,
bool
Modal
)
{
if
(
Modal
)
return
wwin
->
createSkyliveWindow
(
url
,
QWebPage
::
WebModalDialog
);
else
return
wwin
->
createSkyliveWindow
(
url
,
QWebPage
::
WebBrowserWindow
);
}
src/jsbridge.h
View file @
620e5057
...
...
@@ -39,7 +39,7 @@
#include <QString>
#include "webwin.h"
class
Web
Win
;
// forward declaration for typedef
class
Skylivex
Win
;
// forward declaration for typedef
/*
* class JSBridge
...
...
@@ -51,7 +51,7 @@ class JSBridge : public QObject
Q_OBJECT
public
:
Web
Win
*
wwin
;
Skylivex
Win
*
wwin
;
void
changePageContent
(
QString
elementid
,
QString
content
);
signals
:
...
...
@@ -68,6 +68,7 @@ class JSBridge : public QObject
void
chat_message_send
(
QString
dest
,
QString
message
);
void
chat_message_send
(
QString
message
);
void
change_telescope
(
QString
tele
);
SkylivexWin
*
open_window
(
QString
url
,
bool
Modal
);
};
...
...
src/mainwin.cpp
View file @
620e5057
...
...
@@ -48,17 +48,14 @@
#define SENDER "maingui"
MainWin
::
MainWin
(
QString
&
htmlfile
)
:
Web
Win
(
htmlfile
)
:
Skylivex
Win
(
htmlfile
)
{
registerHandler
((
QString
)
"coreStarted"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_corestarted
);
registerHandler
((
QString
)
"telescopeConnected"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_connected
);
registerHandler
((
QString
)
"asklogin"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_asklogin
);
registerHandler
((
QString
)
"alert"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_alert
);
registerHandler
((
QString
)
"notify"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_notify
);
registerHandler
((
QString
)
"loginok"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_loginres
);
registerHandler
((
QString
)
"loginfailed"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_loginres
);
registerHandler
((
QString
)
"publicchatrcv"
,
(
SKHandlerFunction
)
&
MainWin
::
handle_chatreceived
);
msgsender
=
SENDER
;
...
...
@@ -95,18 +92,6 @@ void MainWin::handle_asklogin(SKMessage &msg)
}
void
MainWin
::
handle_alert
(
SKMessage
&
msg
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
))
jsbridge
->
alertmsg
(
msg
.
parameters
[
"msg"
]);
}
void
MainWin
::
handle_notify
(
SKMessage
&
msg
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
))
jsbridge
->
notify
(
msg
.
parameters
[
"msg"
]);
}
void
MainWin
::
handle_loginres
(
SKMessage
&
msg
)
{
if
(
msg
.
handle
==
"loginok"
)
...
...
@@ -121,14 +106,3 @@ void MainWin::handle_loginres(SKMessage &msg)
}
}
void
MainWin
::
handle_chatreceived
(
SKMessage
&
msg
)
{
if
(
msg
.
handle
==
"publicchatrcv"
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
)
&&
msg
.
parameters
.
contains
(
"username"
))
{
jsbridge
->
public_received
(
msg
.
parameters
[
"username"
],
msg
.
parameters
[
"msg"
]);
}
}
}
src/mainwin.h
View file @
620e5057
...
...
@@ -49,7 +49,7 @@
* This is just a little webkit transparent window
* to show the splash screen
*/
class
MainWin
:
public
Web
Win
class
MainWin
:
public
Skylivex
Win
{
Q_OBJECT
...
...
@@ -61,10 +61,7 @@ class MainWin : public WebWin
void
handle_corestarted
(
SKMessage
&
msg
);
void
handle_connected
(
SKMessage
&
msg
);
void
handle_asklogin
(
SKMessage
&
msg
);
void
handle_alert
(
SKMessage
&
msg
);
void
handle_notify
(
SKMessage
&
msg
);
void
handle_loginres
(
SKMessage
&
msg
);
void
handle_chatreceived
(
SKMessage
&
msg
);
};
...
...
src/webwin.cpp
View file @
620e5057
...
...
@@ -38,6 +38,7 @@
#include <QWebFrame>
#include <QFile>
#include <QUrl>
#include <QList>
#include <QDir>
#include <QString>
#include <QPalette>
...
...
@@ -68,12 +69,6 @@ WebWin::WebWin(QString &htmlfile)
setHtmlFile
(
htmlfile
);
resize
(
250
,
200
);
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
WebWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
connect
(
page
()
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
this
,
SLOT
(
refreshJsObject
()));
msgsender
=
SENDER
;
...
...
@@ -86,11 +81,6 @@ WebWin::WebWin()
baseUrl
=
QUrl
::
fromLocalFile
(
QDir
::
current
().
absoluteFilePath
(
"gui/dummy.html"
));
settings
()
->
setAttribute
(
QWebSettings
::
JavascriptCanOpenWindows
,
true
);
settings
()
->
setAttribute
(
QWebSettings
::
JavascriptCanCloseWindows
,
true
);
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
WebWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
connect
(
page
()
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
this
,
SLOT
(
refreshJsObject
()));
msgsender
=
SENDER
;
}
...
...
@@ -103,11 +93,6 @@ QWebView* WebWin::createWindow(QWebPage::WebWindowType type)
{
WebWin
*
wv
=
new
WebWin
;
QWebPage
*
newWeb
=
new
QWebPage
(
wv
);
wv
->
jsbridge
=
new
JSBridge
();
newWeb
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
wv
->
jsbridge
);
connect
(
newWeb
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
wv
,
SLOT
(
refreshJsObject
()));
wv
->
setPage
(
newWeb
);
wv
->
setAttribute
(
Qt
::
WA_DeleteOnClose
,
true
);
if
(
type
==
QWebPage
::
WebModalDialog
)
...
...
@@ -126,15 +111,6 @@ void WebWin::dragMoveEvent(QDragMoveEvent *ev)
}
*/
void
WebWin
::
refreshJsObject
()
{
//page()->mainFrame()->addToJavaScriptWindowObject("SkyliveX", &jsbridge);
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
WebWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
}
void
WebWin
::
setHtmlFile
(
QString
&
fname
)
{
...
...
@@ -142,8 +118,6 @@ void WebWin::setHtmlFile(QString &fname)
filename
.
open
(
QIODevice
::
ReadOnly
);
htmlFileCont
=
QString
::
fromUtf8
(
filename
.
readAll
().
constData
());
setHtml
(
htmlFileCont
,
baseUrl
);
//page()->mainFrame()->addToJavaScriptWindowObject("SkyliveX", &jsbridge);
//jsbridge.mwin=qobject_cast<WebWin *>(this);
}
void
WebWin
::
setHtmlFile
(
QString
&
fname
,
bool
borders
,
bool
transparentbg
)
...
...
@@ -218,7 +192,6 @@ void WebWin::toggleTransparentBackground(bool transparentbg)
void
WebWin
::
sendMessage
(
SKMessage
&
msg
)
{
//msg.sender=SENDER;
msg
.
sender
=
msgsender
;
emit
putMessage
(
msg
);
}
...
...
@@ -229,3 +202,106 @@ void WebWin::registerHandler(QString type, SKHandlerFunction handler)
}
SkylivexWin
::
SkylivexWin
(
QString
&
htmlfile
)
:
WebWin
(
htmlfile
)
{
msgsender
=
"SkylivexWin"
;
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
SkylivexWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
connect
(
page
()
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
this
,
SLOT
(
refreshJsObject
()));
registerHandler
((
QString
)
"alert"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_alert
);
registerHandler
((
QString
)
"notify"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_notify
);
registerHandler
((
QString
)
"publicchatrcv"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_chatreceived
);
}
SkylivexWin
::
SkylivexWin
()
:
WebWin
()
{
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
SkylivexWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
connect
(
page
()
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
this
,
SLOT
(
refreshJsObject
()));
msgsender
=
SENDER
;
registerHandler
((
QString
)
"alert"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_alert
);
registerHandler
((
QString
)
"notify"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_notify
);
registerHandler
((
QString
)
"publicchatrcv"
,
(
SKHandlerFunction
)
&
SkylivexWin
::
handle_chatreceived
);
}
SkylivexWin
*
SkylivexWin
::
createSkyliveWindow
(
QString
url
,
QWebPage
::
WebWindowType
type
)
{
SkylivexWin
*
wv
=
new
SkylivexWin
;
QWebPage
*
newWeb
=
new
QWebPage
(
wv
);
wv
->
jsbridge
=
new
JSBridge
();
wv
->
jsbridge
->
wwin
=
qobject_cast
<
SkylivexWin
*>
(
wv
);
newWeb
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
wv
->
jsbridge
);
connect
(
newWeb
->
mainFrame
(),
SIGNAL
(
javaScriptWindowObjectCleared
()),
wv
,
SLOT
(
refreshJsObject
()));
wv
->
setPage
(
newWeb
);
wv
->
setAttribute
(
Qt
::
WA_DeleteOnClose
,
true
);
if
(
type
==
QWebPage
::
WebModalDialog
)
wv
->
setWindowModality
(
Qt
::
ApplicationModal
);
QList
<
QString
>
urilist
=
url
.
split
(
"://"
);
if
(
urilist
.
size
()
<=
1
)
{
QString
uristring
=
baseUrl
.
toString
().
replace
(
"dummy.html"
,
""
);
url
.
prepend
(
uristring
);
std
::
cout
<<
"transform uri in local file "
<<
url
.
toStdString
()
<<
std
::
endl
;
}
wv
->
setUrl
(
QUrl
(
url
));
wv
->
show
();
return
wv
;
}
SkylivexWin
::~
SkylivexWin
()
{
}
void
SkylivexWin
::
refreshJsObject
()
{
jsbridge
=
new
JSBridge
();
jsbridge
->
wwin
=
qobject_cast
<
SkylivexWin
*>
(
this
);
page
()
->
mainFrame
()
->
addToJavaScriptWindowObject
(
"SkyliveX"
,
jsbridge
);
}
void
SkylivexWin
::
handle_alert
(
SKMessage
&
msg
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
))
jsbridge
->
alertmsg
(
msg
.
parameters
[
"msg"
]);
}
void
SkylivexWin
::
handle_notify
(
SKMessage
&
msg
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
))
jsbridge
->
notify
(
msg
.
parameters
[
"msg"
]);
}
void
SkylivexWin
::
handle_chatreceived
(
SKMessage
&
msg
)
{
if
(
msg
.
handle
==
"publicchatrcv"
)
{
if
(
msg
.
parameters
.
contains
(
"msg"
)
&&
msg
.
parameters
.
contains
(
"username"
))
{
jsbridge
->
public_received
(
msg
.
parameters
[
"username"
],
msg
.
parameters
[
"msg"
]);
}
}
}
src/webwin.h
View file @
620e5057
...
...
@@ -62,7 +62,6 @@ class WebWin : public QWebView
Q_OBJECT
QUrl
baseUrl
;
QString
htmlfile
;
QString
htmlFileCont
;
...
...
@@ -81,11 +80,8 @@ class WebWin : public QWebView
void
toggleBorders
(
bool
borders
);
void
toggleTransparentBackground
(
bool
transparentbg
);
QWebView
*
createWindow
(
QWebPage
::
WebWindowType
type
);
JSBridge
*
jsbridge
;
QString
msgsender
;
private
slots
:
void
refreshJsObject
();
QUrl
baseUrl
;
public
slots
:
void
msgFromCore
(
SKMessage
&
msg
);
...
...
@@ -99,4 +95,27 @@ class WebWin : public QWebView
};
class
SkylivexWin
:
public
WebWin
{
Q_OBJECT
public
:
SkylivexWin
();
SkylivexWin
(
QString
&
htmlfile
);
~
SkylivexWin
();
SkylivexWin
*
createSkyliveWindow
(
QString
url
,
QWebPage
::
WebWindowType
type
);
JSBridge
*
jsbridge
;
QString
msgsender
;
void
handle_alert
(
SKMessage
&
msg
);
void
handle_notify
(
SKMessage
&
msg
);
void
handle_chatreceived
(
SKMessage
&
msg
);
private
slots
:
void
refreshJsObject
();
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment