documentation
This commit is contained in:
@@ -352,23 +352,10 @@ void Rktwebview_qt::processCommand(Command *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void Rktwebview_qt::processJsEventQueues()
|
||||
{
|
||||
QList<rktwebview_t> wvs = _views.keys();
|
||||
int i, N;
|
||||
for(i = 0, N = wvs.length(); i < N; i++) {
|
||||
int wv = wvs[i];
|
||||
if (_views.contains(wv)) {
|
||||
WebviewWindow *win = _views[wv];
|
||||
win->processJsEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rktwebview_qt::removeView(int id)
|
||||
{
|
||||
if (_views.contains(id)) {
|
||||
WebviewWindow *win = _views[id];
|
||||
//WebviewWindow *win = _views[id];
|
||||
_views.remove(id);
|
||||
_view_js_callbacks.remove(id);
|
||||
}
|
||||
@@ -394,9 +381,14 @@ rkt_wv_context_t Rktwebview_qt::newContext(const char *boilerplate_js, const cha
|
||||
QString name = QString::asprintf("profile-%d", _context_counter);
|
||||
|
||||
QString code = "if (window.rkt_event_queue === undefined) { window.rkt_event_queue = []; }\n"
|
||||
"window.rkt_evt_frame_el = null;\n"
|
||||
"window.rkt_evt_frame_win = null;\n"
|
||||
"window.rkt_send_event = function(obj) {\n"
|
||||
" console.log('Sending event: ' + obj);\n"
|
||||
" //console.log('Sending event: ' + obj);\n"
|
||||
" window.rkt_event_queue.push(obj);\n"
|
||||
" if (window.rkt_evt_frame_el) {\n"
|
||||
" window.rkt_evt_frame_win.print();\n"
|
||||
" }\n"
|
||||
"};\n"
|
||||
"window.rkt_get_events = function() {\n"
|
||||
" let q = window.rkt_event_queue;\n"
|
||||
@@ -404,6 +396,22 @@ rkt_wv_context_t Rktwebview_qt::newContext(const char *boilerplate_js, const cha
|
||||
" let json_q = JSON.stringify(q);\n"
|
||||
" return json_q;\n"
|
||||
"};\n"
|
||||
"// add hidden hover element to body if necessary\n"
|
||||
"setInterval(function () {\n"
|
||||
" if (window.rkt_evt_frame_el === null || window.rkt_evt_frame_el === undefined) {\n"
|
||||
" window.rkt_evt_frame_el = document.createElement('iframe');\n"
|
||||
" window.rkt_evt_frame_el.style.display = 'none';\n"
|
||||
" window.rkt_evt_frame_el.setAttribute('id', 'rkt-evt-frame');\n"
|
||||
" window.rkt_evt_frame_el.setAttribute('name', 'rkt-evt-frame');\n"
|
||||
" document.body.append(window.rkt_evt_frame_el);\n"
|
||||
" window.rkt_evt_frame_win = window.rkt_evt_frame_el.contentWindow;\n"
|
||||
" } else {"
|
||||
" if (window.rkt_event_queue.length > 0) {\n"
|
||||
" window.rkt_evt_frame_win.print();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"},\n"
|
||||
"10);\n"
|
||||
"";
|
||||
|
||||
QList<QWebEngineScript> scripts;
|
||||
@@ -767,24 +775,14 @@ void Rktwebview_qt::onPageLoad(rktwebview_t w)
|
||||
|
||||
void Rktwebview_qt::pageLoaded(rktwebview_t w, bool ok)
|
||||
{
|
||||
/*runJs(w,
|
||||
"if (window.rkt_event_queue === undefined) { window.rkt_event_queue = []; }\n"
|
||||
"window.rkt_send_event = function(obj) {\n"
|
||||
" console.log('Sending event: ' + obj);\n"
|
||||
" window.rkt_event_queue.push(obj);\n"
|
||||
"};\n"
|
||||
"window.rkt_get_events = function() {\n"
|
||||
" let q = window.rkt_event_queue;\n"
|
||||
" window.rkt_event_queue = [];\n"
|
||||
" let json_q = JSON.stringify(q);\n"
|
||||
" return json_q;\n"
|
||||
"};\n"
|
||||
);
|
||||
*/
|
||||
|
||||
if (!ok) {
|
||||
// Inject code of the profile to this page
|
||||
WebviewWindow *win = _views[w];
|
||||
|
||||
if (win->navigationEventSent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWebEngineProfile *p = win->profile();
|
||||
QWebEngineScriptCollection *col = p->scripts();
|
||||
QList<QWebEngineScript> l = col->toList();
|
||||
@@ -906,9 +904,6 @@ Rktwebview_qt::Rktwebview_qt(Rktwebview_qt **handler) :
|
||||
_evt_loop_depth = 0;
|
||||
_app = new QApplication(_argc, _argv);
|
||||
|
||||
connect(&_process_events, &QTimer::timeout, this, &Rktwebview_qt::processJsEventQueues);
|
||||
_process_events.start(5);
|
||||
|
||||
// See Qt 6.10 remark at doEvents.
|
||||
//connect(&_evt_loop_timer, &QTimer::timeout, this, &Rktwebview_qt::stopEventloop);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user