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
ad8a46b4
Commit
ad8a46b4
authored
Feb 25, 2013
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Permit opening subwindow from js with SkyliveX object working
parent
018ad60b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
17 deletions
+55
-17
SkyliveX.js
gui/SkyliveX.js
+14
-17
webwin.cpp
src/webwin.cpp
+38
-0
webwin.h
src/webwin.h
+3
-0
No files found.
gui/SkyliveX.js
View file @
ad8a46b4
function
skyliveClass
()
{}
skyliveClass
.
prototype
.
method
=
function
(
name
,
func
){
this
.
prototype
[
name
]
=
func
;
return
this
;
}
skyliveClass
.
method
(
'changeContent'
,
function
(
id
,
content
){
skyliveClass
.
prototype
.
changeContent
=
function
(
id
,
content
){
var
n
=
document
.
getElementById
(
id
);
if
(
typeof
(
n
)
!=
"undefined"
)
n
.
innerHTML
=
content
;
}
)
;
skyliveClass
.
method
(
'notify'
,
function
(
content
){
};
skyliveClass
.
prototype
.
notify
=
function
(
content
){
if
(
typeof
(
notifycb
)
==
"function"
)
notifycb
(
content
);
}
)
;
skyliveClass
.
method
(
'msgalert'
,
function
(
content
){
};
skyliveClass
.
prototype
.
msgalert
=
function
(
content
){
if
(
typeof
(
alertcb
)
==
"function"
)
alertcb
(
content
);
//else
// alert(content);
}
)
;
skyliveClass
.
method
(
'publicReceived'
,
function
(
user
,
msg
){
};
skyliveClass
.
prototype
.
publicReceived
=
function
(
user
,
msg
){
if
(
typeof
(
public_received
)
==
"function"
)
{
public_received
(
user
,
msg
);
...
...
@@ -32,9 +28,10 @@ skyliveClass.method('publicReceived', function(user, msg){
n
.
scollTop
=
n
.
scrollHeight
;
}
}
});
SkyliveX
.
page
=
new
SkyliveClass
();
SkyliveX
.
changeContent
.
connect
(
SkyliveX
.
page
.
changeContent
);
SkyliveX
.
notify
.
connect
(
SkyliveX
.
page
.
notify
);
SkyliveX
.
alertmsg
.
connect
(
SkyliveX
.
page
.
msgalert
);
SkyliveX
.
public_received
.
connect
(
SkyliveX
.
page
.
publicReceived
);
};
SkyliveXPage
=
new
skyliveClass
();
SkyliveX
.
changeContent
.
connect
(
SkyliveXPage
.
changeContent
);
SkyliveX
.
notify
.
connect
(
SkyliveXPage
.
notify
);
SkyliveX
.
alertmsg
.
connect
(
SkyliveXPage
.
msgalert
);
SkyliveX
.
public_received
.
connect
(
SkyliveXPage
.
publicReceived
);
src/webwin.cpp
View file @
ad8a46b4
...
...
@@ -34,6 +34,7 @@
*/
#include "webwin.h"
#include <QWebView>
#include <QWebPage>
#include <QWebFrame>
#include <QFile>
#include <QUrl>
...
...
@@ -44,6 +45,7 @@
#include <iostream>
#include "ipcmsg.h"
#include "jsbridge.h"
#include "QWebSettings"
#define SENDER "webwin"
...
...
@@ -52,6 +54,10 @@ WebWin::WebWin(QString &htmlfile)
{
baseUrl
=
QUrl
::
fromLocalFile
(
QDir
::
current
().
absoluteFilePath
(
"gui/dummy.html"
));
settings
()
->
setAttribute
(
QWebSettings
::
JavascriptCanOpenWindows
,
true
);
settings
()
->
setAttribute
(
QWebSettings
::
JavascriptCanCloseWindows
,
true
);
//settings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
QPalette
pal
=
palette
();
pal
.
setBrush
(
QPalette
::
Base
,
Qt
::
transparent
);
...
...
@@ -74,11 +80,43 @@ WebWin::WebWin(QString &htmlfile)
}
WebWin
::
WebWin
()
:
QWebView
()
{
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
;
}
WebWin
::~
WebWin
()
{
}
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
)
wv
->
setWindowModality
(
Qt
::
ApplicationModal
);
wv
->
show
();
return
wv
;
}
// XXX This can be used in future to permit
// to drag a window borderless on the desktop.
/*
...
...
src/webwin.h
View file @
ad8a46b4
...
...
@@ -36,6 +36,7 @@
#define WEBWIN_H
#include <QWebView>
#include <QWebPage>
#include <QUrl>
#include <QFile>
#include <QHash>
...
...
@@ -69,6 +70,7 @@ class WebWin : public QWebView
QHash
<
QString
,
SKHandlerFunction
>
_handlers
;
public
:
WebWin
();
WebWin
(
QString
&
htmlfile
);
~
WebWin
();
void
setHtmlFile
(
QString
&
fname
);
...
...
@@ -78,6 +80,7 @@ class WebWin : public QWebView
void
registerHandler
(
QString
type
,
SKHandlerFunction
handler
);
void
toggleBorders
(
bool
borders
);
void
toggleTransparentBackground
(
bool
transparentbg
);
QWebView
*
createWindow
(
QWebPage
::
WebWindowType
type
);
JSBridge
*
jsbridge
;
QString
msgsender
;
...
...
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