Showing the changes to interface/src/scripting/WebWindowClass.cpp (1 of 4 files). Show all
Unified · Split
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <QListWidget> |
| 19 | 19 | |
| 20 | 20 | #include "Application.h" |
| 21 | +#include "MainWindow.h" | |
| 21 | 22 | #include "WindowScriptingInterface.h" |
| 22 | 23 | #include "WebWindowClass.h" |
| 23 | 24 | |
| @@ -33,26 +34,40 @@ void ScriptEventBridge::emitScriptEvent(const QString& data) { · 9 unmodified lines | ||
| 33 | 34 | } |
| 34 | 35 | |
| 35 | 36 | |
| 36 | −WebWindowClass::WebWindowClass(const QString& title, const QString& url, int width, int height) | |
| 37 | +WebWindowClass::WebWindowClass(const QString& title, const QString& url, int width, int height, bool isToolWindow) | |
| 37 | 38 | : QObject(NULL), |
| 38 | − _eventBridge(new ScriptEventBridge(this)) { | |
| 39 | + _eventBridge(new ScriptEventBridge(this)), | |
| 40 | + _isToolWindow(isToolWindow) { | |
| 39 | 41 | |
| 40 | − ToolWindow* toolWindow = Application::getInstance()->getToolWindow(); | |
| 42 | + if (_isToolWindow) { | |
| 43 | + ToolWindow* toolWindow = Application::getInstance()->getToolWindow(); | |
| 41 | 44 | |
| 42 | − _dockWidget = new QDockWidget(title, toolWindow); | |
| 43 | − _dockWidget->setFeatures(QDockWidget::DockWidgetMovable); | |
| 45 | + auto dockWidget = new QDockWidget(title, toolWindow); | |
| 46 | + dockWidget->setFeatures(QDockWidget::DockWidgetMovable); | |
| 44 | 47 | |
| 45 | − _webView = new QWebView(_dockWidget); | |
| 46 | − _webView->setUrl(url); | |
| 47 | − addEventBridgeToWindowObject(); | |
| 48 | + _webView = new QWebView(dockWidget); | |
| 49 | + addEventBridgeToWindowObject(); | |
| 50 | + | |
| 51 | + dockWidget->setWidget(_webView); | |
| 52 | + | |
| 53 | + toolWindow->addDockWidget(Qt::RightDockWidgetArea, dockWidget); | |
| 54 | + | |
| 55 | + _windowWidget = dockWidget; | |
| 56 | + } else { | |
| 57 | + _windowWidget = new QWidget(Application::getInstance()->getWindow(), Qt::Window); | |
| 58 | + _windowWidget->setMinimumSize(width, height); | |
| 48 | 59 | |
| 49 | − _dockWidget->setWidget(_webView); | |
| 60 | + _webView = new QWebView(_windowWidget); | |
| 61 | + addEventBridgeToWindowObject(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + _webView->setPage(new InterfaceWebPage()); | |
| 65 | + _webView->setUrl(url); | |
| 50 | 66 | |
| 51 | − toolWindow->addDockWidget(Qt::RightDockWidgetArea, _dockWidget); | |
| 52 | 67 | |
| 68 | + connect(this, &WebWindowClass::destroyed, _windowWidget, &QWidget::deleteLater); | |
| 53 | 69 | connect(_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, |
| 54 | 70 | this, &WebWindowClass::addEventBridgeToWindowObject); |
| 55 | − connect(this, &WebWindowClass::destroyed, _dockWidget, &QWidget::deleteLater); | |
| 56 | 71 | } |
| 57 | 72 | |
| 58 | 73 | WebWindowClass::~WebWindowClass() { |
| @@ -67,7 +82,7 @@ void WebWindowClass::setVisible(bool visible) { · 8 unmodified lines | ||
| 67 | 82 | QMetaObject::invokeMethod( |
| 68 | 83 | Application::getInstance()->getToolWindow(), "setVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); |
| 69 | 84 | } |
| 70 | − QMetaObject::invokeMethod(_dockWidget, "setVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); | |
| 85 | + QMetaObject::invokeMethod(_windowWidget, "setVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); | |
| 71 | 86 | } |
| 72 | 87 | |
| 73 | 88 | QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* engine) { |
| @@ -78,7 +93,8 @@ QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* · 4 unmodified lines | ||
| 78 | 93 | Q_ARG(const QString&, file), |
| 79 | 94 | Q_ARG(QString, context->argument(1).toString()), |
| 80 | 95 | Q_ARG(int, context->argument(2).toInteger()), |
| 81 | − Q_ARG(int, context->argument(3).toInteger())); | |
| 96 | + Q_ARG(int, context->argument(3).toInteger()), | |
| 97 | + Q_ARG(bool, context->argument(4).toBool())); | |
| 82 | 98 | |
| 83 | 99 | connect(engine, &QScriptEngine::destroyed, retVal, &WebWindowClass::deleteLater); |
| 84 | 100 | |