This commit is contained in:
2026-03-04 23:54:50 +01:00
parent 3a2abf90f6
commit a622739deb
11 changed files with 538 additions and 329 deletions

View File

@@ -43,12 +43,29 @@
webview-value/bool webview-value/bool
webview-value/symbol webview-value/symbol
webview-value/number webview-value/number
;webview-value/date
;webview-value/time
;webview-value/datetime
webview-add-class! webview-add-class!
webview-remove-class! webview-remove-class!
webview-set-style! webview-set-style!
webview-unset-style!
webview-set-attr!
webview-attr
;webview-attr/bool
;webview-attr/symbol
;webview-attr/number
;webview-attr/date
;webview-attr/time
;webview-attr/datetime
;webview-del-attr!
webview-standard-file-getter webview-standard-file-getter
test
) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -242,10 +259,10 @@
(define/contract (webview-close wv) (define/contract (webview-close wv)
(-> wv? symbol?) (-> wv? symbol?)
(let ((r (rkt-webview-close (wv-handle wv)))) (begin
(rkt-webview-close (wv-handle wv))
(kill-thread (wv-webserver-thread wv)) (kill-thread (wv-webserver-thread wv))
r) 'oke))
)
(define/contract (webview-bind! wv selector event) (define/contract (webview-bind! wv selector event)
(-> wv? (or/c symbol? string?) symbol? list?) (-> wv? (or/c symbol? string?) symbol? list?)
@@ -283,9 +300,12 @@
(if (webview-call-js-result? result) (if (webview-call-js-result? result)
(if (eq? (car result) 'oke) (if (eq? (car result) 'oke)
(hash-ref (fromJson (cadr result)) 'result #f) (hash-ref (fromJson (cadr result)) 'result #f)
(error "Error calling javascript. Message: ~a" (hash-ref (fromJson (cadr result)) 'exn result)) (error
(format "Error calling javascript. Message: ~a"
(hash-ref (fromJson (cadr result)) 'exn result)))
) )
(error "Wrong result from webview-call-js: ~a" result) (error
(format "Wrong result from webview-call-js: ~a" result))
) )
) )
) )
@@ -331,12 +351,9 @@
" }\n" " }\n"
"};\n")) "};\n"))
-> "f()")))) -> "f()"))))
(if (eq? (car v) 'oke) (if (eq? v #f)
(let ((h (fromJson (cadr v)))) #f
(hash-ref h 'result #f)) v)))
#f)
)
)
(define/contract (webview-value/number wv id) (define/contract (webview-value/number wv id)
(-> wv? symbol? (or/c number? boolean?)) (-> wv? symbol? (or/c number? boolean?))
@@ -403,8 +420,96 @@
) )
) )
(define/contract (webview-set-style! wv selector style-entries) (define/contract (webview-set-style! wv selector style-entries)
(-> wv? (or/c symbol? string?) (or/c kv? list-of-kv?) hash?)
(let ((sel (if (symbol? selector)
(format "#~a" selector)
selector))
(cl (mk-js-array (if (kv? style-entries)
(list style-entries)
style-entries)))
)
(webview-call-js wv
(with-selector sel
(format
(js-code
"function(id, el) {"
" let cl = ~a;"
" cl.forEach(function(st) {"
" el.style[st[0]] = st[1];"
" });"
" return id;"
"}") cl))
)
)
)
(define/contract (webview-unset-style! wv selector style-entries)
(-> wv? (or/c symbol? string?) (or/c symbol? list-of-symbol?) hash?)
(let ((sel (if (symbol? selector)
(format "#~a" selector)
selector))
(cl (mk-js-array (if (symbol? style-entries)
(list style-entries)
style-entries)))
)
(webview-call-js wv
(with-selector sel
(format
(js-code
"function(id, el) {"
" let cl = ~a;"
" cl.forEach(function(st) {"
" el.style[st] = '';"
" });"
" return id;"
"}") cl)
)
)
)
)
(define/contract (webview-set-attr! wv selector attr-entries)
(-> wv? (or/c symbol? string?) (or/c kv? list-of-kv?) hash?)
(let ((sel (if (symbol? selector)
(format "#~a" selector)
selector))
(cl (mk-js-array (if (kv? attr-entries)
(list attr-entries)
attr-entries)))
)
(webview-call-js wv
(with-selector sel
(format
(js-code
"function(id, el) {"
" let cl = ~a;"
" cl.forEach(function(av) {"
" el.setAttribute(av[0], av[1]);"
" });"
" return id;"
"}") cl))
)
)
)
(define/contract (webview-attr wv id attr)
(-> wv? symbol? (or/c symbol? string?) (or/c string? boolean?))
(let ((v (webview-call-js wv
(with-id id el
-> (format "el.getAttribute('~a');" attr))
)))
(if (eq? v 'null)
#f
v)
)
)
#|(define/contract (webview-set-style! wv selector style-entries)
(-> wv? (or/c symbol? string?) (or/c list? list-of-kv?) hash?) (-> wv? (or/c symbol? string?) (or/c list? list-of-kv?) hash?)
(define (webview-set-style!* wv selector h) (define (webview-set-style!* wv selector h)
@@ -435,7 +540,7 @@
) )
) )
) )
|#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; testing ;; testing

View File

@@ -14,7 +14,10 @@
fromJson fromJson
mk-js-array mk-js-array
js-code js-code
kv?
list-of-kv? list-of-kv?
list-of-symbol?
list-of?
) )
(define-syntax while (define-syntax while
@@ -82,12 +85,14 @@
(with-input-from-string str read-json)) (with-input-from-string str read-json))
(define (mk-js-array l) (define (mk-js-array l)
(if (list-of-kv? l)
(string-append "[ " (string-join (map (λ (e) (mk-js-array e)) l) ", ") " ]")
(if (list? l) (if (list? l)
(string-append "[ " (string-join (map (λ (e) (format "'~a'" (string-append "[ " (string-join (map (λ (e) (format "'~a'"
(esc-quote (format "~a" e)))) l) ", ") " ]") (esc-quote (format "~a" e)))) l) ", ") " ]")
(format "[ '~a' ]" (esc-quote (format "~a" l))) (if (pair? l)
) (format "[ '~a', '~a' ]" (car l) (cdr l))
) (format "[ '~a' ]" (esc-quote (format "~a" l)))))))
(define (js-code . a) (define (js-code . a)
(define (code* l) (define (code* l)
@@ -98,20 +103,25 @@
) )
(code* a)) (code* a))
(define (list-of-kv? l)
(define (kv? e) (define (kv? e)
(let ((e (car l))) (or
(and (list? e) (and (list? e) (= (length e) 2) (symbol? (car e)))
(= (length e) 2) (and (pair? e) (symbol? (car e)))))
(symbol? (car e)))))
(define (all-kv? l) (define (list-of? pred? l)
(define (all-pred? l)
(if (null? l) (if (null? l)
#t #t
(if (kv? (car e)) (if (pred? (car l))
(all-kv? (cdr l)) (all-pred? (cdr l))
#f))) #f)))
(if (list? l) (if (list? l)
(all-kv? l) (all-pred? l)
#f)) #f))
(define (list-of-kv? l)
(list-of? kv? l))
(define (list-of-symbol? l)
(list-of? symbol? l))

View File

@@ -23,6 +23,7 @@ add_library(rktwebview_qt SHARED
webviewwindow.h webviewwindow.cpp webviewwindow.h webviewwindow.cpp
webviewapp.h webviewapp.cpp webviewapp.h webviewapp.cpp
rktutils.h rktutils.cpp rktutils.h rktutils.cpp
command.h command.cpp
) )
target_link_libraries(rktwebview_qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) target_link_libraries(rktwebview_qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)

20
rktwebview_qt/command.cpp Normal file
View File

@@ -0,0 +1,20 @@
#include "command.h"
Command::Command(int _cmd)
{
cmd = _cmd;
done = false;
js_result_ok = true;
}
Command *CommandEvent::cmd()
{
return _cmd;
}
CommandEvent::CommandEvent(Command *c)
: QEvent(COMMAND_EVENT)
{
_cmd = c;
}

54
rktwebview_qt/command.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef COMMAND_H
#define COMMAND_H
#include <QEvent>
#include <QVariant>
#define COMMAND_QUIT 1
#define COMMAND_CLOSE 2
#define COMMAND_CREATE 3
#define COMMAND_SET_URL 4
#define COMMAND_SET_HTML 5
#define COMMAND_RUN_JS 6
#define COMMAND_DEV_TOOLS 7
#define COMMAND_MOVE 8
#define COMMAND_RESIZE 9
#define COMMAND_CALL_JS 10
#define COMMAND_HIDE_WIN 11
#define COMMAND_SHOW_WIN 12
#define COMMAND_MAX_WIN 13
#define COMMAND_MIN_WIN 14
#define COMMAND_PRESENT_WIN 15
#define COMMAND_SHOW_NORMAL_WIN 16
#define COMMAND_WINDOW_STATUS 17
#define COMMAND_SET_TITLE 18
class Command
{
public:
int cmd;
QVector<QVariant> args;
QVariant result;
bool done;
bool js_result_ok;
public:
Command(int _cmd);
};
class CommandEvent : public QEvent
{
private:
Command *_cmd;
public:
Command *cmd();
public:
CommandEvent(Command *c);
};
const QEvent::Type COMMAND_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
#endif // COMMAND_H

View File

@@ -23,10 +23,10 @@ int main(int argc, char *argv[])
wv1 = rkt_webview_create(0, eventCb); wv1 = rkt_webview_create(0, eventCb);
rkt_webview_move(wv1, 200, 300); rkt_webview_move(wv1, 200, 300);
rkt_webview_resize(wv1, 800, 600); rkt_webview_resize(wv1, 800, 600);
rkt_webview_set_url(wv1, "http://127.0.0.1:8083"); rkt_webview_set_url(wv1, "https://wikipedia.org"); //"http://127.0.0.1:8083");
int i = 0; int i = 0;
while(i < 60) { while(i < 35) {
printf("Waiting...%d\n", i); printf("Waiting...%d\n", i);
rkt_webview_process_events(1000); rkt_webview_process_events(1000);

View File

@@ -15,21 +15,7 @@ public:
QString mkEventJson(const EventContainer &kv); QString mkEventJson(const EventContainer &kv);
class Command
{
public:
int cmd;
QVector<QVariant> args;
QVariant result;
bool done;
bool js_result_ok;
public:
Command(int _cmd) {
cmd = _cmd;
done = false;
js_result_ok = true;
}
};
#endif #endif

View File

@@ -9,31 +9,10 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
#include "command.h"
#define COMMAND_QUIT 1 void Rktwebview_qt::processCommand(Command *cmd)
#define COMMAND_CLOSE 2
#define COMMAND_CREATE 3
#define COMMAND_SET_URL 4
#define COMMAND_SET_HTML 5
#define COMMAND_RUN_JS 6
#define COMMAND_DEV_TOOLS 7
#define COMMAND_MOVE 8
#define COMMAND_RESIZE 9
#define COMMAND_CALL_JS 10
#define COMMAND_HIDE_WIN 11
#define COMMAND_SHOW_WIN 12
#define COMMAND_MAX_WIN 13
#define COMMAND_MIN_WIN 14
#define COMMAND_PRESENT_WIN 15
#define COMMAND_SHOW_NORMAL_WIN 16
#define COMMAND_WINDOW_STATUS 17
#define COMMAND_SET_TITLE 18
void Rktwebview_qt::processCommands()
{ {
while(!_command_queue.empty()) {
Command *cmd = _command_queue.dequeue();
switch(cmd->cmd) { switch(cmd->cmd) {
case COMMAND_QUIT: { case COMMAND_QUIT: {
_app->quit(); _app->quit();
@@ -276,7 +255,6 @@ void Rktwebview_qt::processCommands()
break; break;
} }
} }
}
void Rktwebview_qt::processJsEventQueues() void Rktwebview_qt::processJsEventQueues()
{ {
@@ -314,7 +292,7 @@ int Rktwebview_qt::rktWebViewCreate(int parent, event_cb_t js_evt_cb)
QVariant f(QVariant::fromValue(function)); QVariant f(QVariant::fromValue(function));
c.args.push_back(f); c.args.push_back(f);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
@@ -327,7 +305,7 @@ void Rktwebview_qt::rktWebViewClose(int wv)
Command c(COMMAND_CLOSE); Command c(COMMAND_CLOSE);
c.args.push_back(wv); c.args.push_back(wv);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
} }
@@ -338,7 +316,7 @@ result_t Rktwebview_qt::rktSetUrl(rktwebview_t wv, const char *url)
QString _url(url); QString _url(url);
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(_url); c.args.push_back(_url);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
@@ -353,7 +331,7 @@ result_t Rktwebview_qt::rktSetHtml(rktwebview_t wv, const char *html)
QString _html(html); QString _html(html);
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(_html); c.args.push_back(_html);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
@@ -368,7 +346,7 @@ rkt_js_result_t *Rktwebview_qt::rktCallJs(rktwebview_t wv, const char *js)
QString _js(js); QString _js(js);
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(_js); c.args.push_back(_js);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
rkt_js_result_t *r = static_cast<rkt_js_result_t *>(malloc(sizeof(rkt_js_result_t))); rkt_js_result_t *r = static_cast<rkt_js_result_t *>(malloc(sizeof(rkt_js_result_t)));
@@ -384,7 +362,7 @@ result_t Rktwebview_qt::rktRunJs(rktwebview_t wv, const char *js)
QString _js(js); QString _js(js);
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(_js); c.args.push_back(_js);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::eval_js_failed; return r ? result_t::oke : result_t::eval_js_failed;
@@ -396,7 +374,7 @@ result_t Rktwebview_qt::rktMove(rktwebview_t wv, int x, int y)
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(x); c.args.push_back(x);
c.args.push_back(y); c.args.push_back(y);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::move_failed; return r ? result_t::oke : result_t::move_failed;
@@ -408,7 +386,7 @@ result_t Rktwebview_qt::rktResize(rktwebview_t wv, int w, int h)
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(w); c.args.push_back(w);
c.args.push_back(h); c.args.push_back(h);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::resize_failed; return r ? result_t::oke : result_t::resize_failed;
@@ -448,7 +426,7 @@ window_state_t Rktwebview_qt::rktWindowState(rktwebview_t w)
{ {
Command c(COMMAND_WINDOW_STATUS); Command c(COMMAND_WINDOW_STATUS);
c.args.push_back(w); c.args.push_back(w);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
int r = c.result.toInt(); int r = c.result.toInt();
window_state_t ws = static_cast<window_state_t>(r); window_state_t ws = static_cast<window_state_t>(r);
@@ -460,7 +438,7 @@ result_t Rktwebview_qt::rktWindowSetTitle(rktwebview_t wv, const char *title)
Command c(COMMAND_SET_TITLE); Command c(COMMAND_SET_TITLE);
c.args.push_back(wv); c.args.push_back(wv);
c.args.push_back(title); c.args.push_back(title);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::resize_failed; return r ? result_t::oke : result_t::resize_failed;
@@ -470,7 +448,7 @@ result_t Rktwebview_qt::doWindow(rktwebview_t w, int cmd)
{ {
Command c(cmd); Command c(cmd);
c.args.push_back(w); c.args.push_back(w);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::resize_failed; return r ? result_t::oke : result_t::resize_failed;
@@ -485,7 +463,7 @@ result_t Rktwebview_qt::rktOpenDevtools(rktwebview_t wv)
{ {
Command c(COMMAND_DEV_TOOLS); Command c(COMMAND_DEV_TOOLS);
c.args.push_back(wv); c.args.push_back(wv);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
bool r = c.result.toBool(); bool r = c.result.toBool();
return r ? result_t::oke : result_t::eval_js_failed; return r ? result_t::oke : result_t::eval_js_failed;
@@ -544,7 +522,7 @@ void Rktwebview_qt::rktQuit()
} }
Command c(COMMAND_QUIT); Command c(COMMAND_QUIT);
_command_queue.enqueue(&c); postCommand(&c);
while(!c.done) { doEvents(); } while(!c.done) { doEvents(); }
} }
@@ -558,10 +536,45 @@ void Rktwebview_qt::runJs(rktwebview_t wv, const char *js)
} }
} }
void Rktwebview_qt::postCommand(Command *cmd)
{
CommandEvent *e = new CommandEvent(cmd);
QApplication::postEvent(this, e);
}
void Rktwebview_qt::handleCommandEvent(CommandEvent *e)
{
Command *c = e->cmd();
processCommand(c);
}
void Rktwebview_qt::customEvent(QEvent *event)
{
if (event->type() == COMMAND_EVENT) {
handleCommandEvent(static_cast<CommandEvent *>(event));
}
}
void Rktwebview_qt::doEvents() void Rktwebview_qt::doEvents()
{ {
_app->processEvents(); //_app->processEvents();
if (_evt_loop_depth == 0) {
_evt_loop_depth += 1;
_evt_loop_timer.setSingleShot(true);
_evt_loop_timer.start(2);
//_evt_loop.exec();
_app->exec();
} }
}
void Rktwebview_qt::stopEventloop()
{
//_evt_loop.exit(0);
_app->exit(0);
_evt_loop_depth -= 1;
}
Rktwebview_qt::Rktwebview_qt(Rktwebview_qt **handler) : Rktwebview_qt::Rktwebview_qt(Rktwebview_qt **handler) :
QObject() QObject()
@@ -573,19 +586,21 @@ Rktwebview_qt::Rktwebview_qt(Rktwebview_qt **handler) :
_current_handle = 0; _current_handle = 0;
_handler = handler; _handler = handler;
_evt_loop_depth = 0;
_app = new QApplication(_argc, _argv); _app = new QApplication(_argc, _argv);
connect(&_process_commands, &QTimer::timeout, this, &Rktwebview_qt::processCommands);
_process_commands.start(10);
connect(&_process_events, &QTimer::timeout, this, &Rktwebview_qt::processJsEventQueues); connect(&_process_events, &QTimer::timeout, this, &Rktwebview_qt::processJsEventQueues);
_process_events.start(5); _process_events.start(5);
const auto *eventDispatcher = QThread::currentThread()->eventDispatcher(); connect(&_evt_loop_timer, &QTimer::timeout, this, &Rktwebview_qt::stopEventloop);
QObject::connect(eventDispatcher, &QAbstractEventDispatcher::aboutToBlock,
QThread::currentThread(), []{ //const auto *eventDispatcher = QThread::currentThread()->eventDispatcher();
if (QThread::currentThread()->loopLevel() == 0) //QObject::connect(eventDispatcher, &QAbstractEventDispatcher::aboutToBlock,
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); // QThread::currentThread(), []{
} // if (QThread::currentThread()->loopLevel() == 0)
); // QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
// }
// );
*_handler = nullptr; *_handler = nullptr;
} }

View File

@@ -12,11 +12,13 @@
#include <QHash> #include <QHash>
#include <QQueue> #include <QQueue>
#include <QTimer> #include <QTimer>
#include <QEventLoop>
class WebViewQt; class WebViewQt;
class WebviewWindow; class WebviewWindow;
class Command; class Command;
class CommandEvent;
class RKTWEBVIEW_QT_EXPORT Rktwebview_qt : public QObject class RKTWEBVIEW_QT_EXPORT Rktwebview_qt : public QObject
{ {
@@ -27,10 +29,11 @@ private:
QHash<int, WebviewWindow *> _views; QHash<int, WebviewWindow *> _views;
QHash<int, event_cb_t> _view_js_callbacks; QHash<int, event_cb_t> _view_js_callbacks;
QQueue<Command *> _command_queue;
QTimer _process_commands;
QTimer _process_events; QTimer _process_events;
int _evt_loop_depth;
QTimer _evt_loop_timer;
Rktwebview_qt **_handler; Rktwebview_qt **_handler;
int _argc; int _argc;
@@ -41,9 +44,20 @@ private:
result_t doWindow(rktwebview_t w, int cmd); result_t doWindow(rktwebview_t w, int cmd);
public slots: public slots:
void processCommands();
void processJsEventQueues(); void processJsEventQueues();
private slots:
void stopEventloop();
private:
void postCommand(Command *cmd);
void handleCommandEvent(CommandEvent *e);
void processCommand(Command *cmd);
// QObject interface
protected:
void customEvent(QEvent *event);
public: public:
void removeView(int id); void removeView(int id);
@@ -91,6 +105,7 @@ public:
public: public:
Rktwebview_qt(Rktwebview_qt **handler); Rktwebview_qt(Rktwebview_qt **handler);
}; };
#endif // RKTWEBVIEW_QT_H #endif // RKTWEBVIEW_QT_H

View File

@@ -3,15 +3,16 @@
#include "webviewqt.h" #include "webviewqt.h"
#include "rktwebview_qt.h" #include "rktwebview_qt.h"
#include "rktutils.h" #include "rktutils.h"
#include "command.h"
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonParseError> #include <QJsonParseError>
#include <QJsonObject> #include <QJsonObject>
#include <QWebEngineScriptCollection> #include <QWebEngineScriptCollection>
#include <QWebEngineScript> #include <QWebEngineScript>
#include <QMoveEvent> #include <QMoveEvent>
WebviewWindow::WebviewWindow(QWidget *parent) WebviewWindow::WebviewWindow(QWidget *parent)
: QMainWindow{parent} : QMainWindow{parent}
{ {
@@ -194,6 +195,7 @@ void WebviewWindow::moveEvent(QMoveEvent *event)
_move_timer.setSingleShot(true); _move_timer.setSingleShot(true);
_move_timer.start(500); _move_timer.start(500);
_moved += 1; _moved += 1;
//triggerMove();
} }
void WebviewWindow::triggerMove() void WebviewWindow::triggerMove()
@@ -211,6 +213,7 @@ void WebviewWindow::resizeEvent(QResizeEvent *event)
_resize_timer.setSingleShot(true); _resize_timer.setSingleShot(true);
_resize_timer.start(500); _resize_timer.start(500);
_resized += 1; _resized += 1;
//triggerResize();
} }
void WebviewWindow::triggerResize() void WebviewWindow::triggerResize()