blob: 350d8ac0fa665bd6095f10cd42052b9ffe3bb788 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include <QList>
#include <QWidget>
#include <QtCore>
#include "CommandParser.hpp"
#include "InputMediator.hpp"
#include "LuaRuntime.hpp"
#include "widgets/WebViewStack.hpp"
InputMediator::InputMediator(WebViewStack *webViewStack, LuaRuntime *luaRuntime)
: QObject(), webViewStack(webViewStack), luaRuntime(luaRuntime) {
connect(luaRuntime, &LuaRuntime::urlOpened, webViewStack,
&WebViewStack::openUrl);
}
void InputMediator::evaluateCommand(QString command) {
CommandParser parser;
auto cmd = parser.parse(command);
switch (cmd.command) {
case CommandType::LuaEval:
luaRuntime->evaluate(cmd.argsString);
break;
case CommandType::Open:
openUrl(cmd.argsString, OpenType::OpenUrl);
break;
case CommandType::TabOpen:
openUrl(cmd.argsString, OpenType::OpenUrlInTab);
break;
case CommandType::TabNext:
nextWebView();
break;
case CommandType::TabPrev:
previousWebView();
break;
case CommandType::TabSelect:
webViewStack->focusWebView(cmd.argsString.toLong());
break;
case CommandType::Noop:
break;
}
}
|