-
This commit is contained in:
@@ -18,20 +18,7 @@
|
||||
#define COMMAND_DEV_TOOLS 7
|
||||
#define COMMAND_MOVE 8
|
||||
#define COMMAND_RESIZE 9
|
||||
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
int cmd;
|
||||
QVector<QVariant> args;
|
||||
QVariant result;
|
||||
bool done;
|
||||
public:
|
||||
Command(int _cmd) {
|
||||
cmd = _cmd;
|
||||
done = false;
|
||||
}
|
||||
};
|
||||
#define COMMAND_CALL_JS 10
|
||||
|
||||
void Rktwebview_qt::processCommands()
|
||||
{
|
||||
@@ -127,6 +114,19 @@ void Rktwebview_qt::processCommands()
|
||||
cmd->done = true;
|
||||
}
|
||||
break;
|
||||
case COMMAND_CALL_JS: {
|
||||
int wv = cmd->args[0].toInt();
|
||||
QString js = cmd->args[1].toString();
|
||||
if (_views.contains(wv)) {
|
||||
WebviewWindow *w = _views[wv];
|
||||
w->callJs(js, cmd);
|
||||
} else {
|
||||
cmd->result = false;
|
||||
cmd->js_result_ok = false;
|
||||
cmd->done = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMMAND_DEV_TOOLS: {
|
||||
int wv = cmd->args[0].toInt();
|
||||
if (_views.contains(wv)) {
|
||||
@@ -260,6 +260,22 @@ result_t Rktwebview_qt::rktSetHtml(rktwebview_t wv, const char *html)
|
||||
return r ? result_t::oke : result_t::set_navigate_failed;
|
||||
}
|
||||
|
||||
rkt_js_result_t *Rktwebview_qt::rktCallJs(rktwebview_t wv, const char *js)
|
||||
{
|
||||
Command c(COMMAND_CALL_JS);
|
||||
QString _js(js);
|
||||
c.args.push_back(wv);
|
||||
c.args.push_back(_js);
|
||||
_command_queue.enqueue(&c);
|
||||
while(!c.done) { doEvents(); }
|
||||
|
||||
rkt_js_result_t *r = static_cast<rkt_js_result_t *>(malloc(sizeof(rkt_js_result_t)));
|
||||
r->result = c.js_result_ok ? result_t::oke : result_t::eval_js_failed;
|
||||
r->value = strdup(c.result.toString().toUtf8());
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
result_t Rktwebview_qt::rktRunJs(rktwebview_t wv, const char *js)
|
||||
{
|
||||
Command c(COMMAND_RUN_JS);
|
||||
|
||||
Reference in New Issue
Block a user