Showing the changes to interface/src/scripting/WebWindowClass.cpp (1 of 37 files). Show all
Unified · Split
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | 10 | // |
| 11 | 11 | |
| 12 | + | |
| 12 | 13 | #include <QVBoxLayout> |
| 13 | 14 | #include <QApplication> |
| 14 | 15 | #include <QMainWindow> |
| @@ -35,48 +36,25 @@ void ScriptEventBridge::emitScriptEvent(const QString& data) { · 20 unmodified lines | ||
| 35 | 36 | emit scriptEventReceived(data); |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | −WebWindowClass::WebWindowClass(const QString& title, const QString& url, int width, int height, bool isToolWindow) | |
| 39 | − : QObject(NULL), | |
| 40 | − _eventBridge(new ScriptEventBridge(this)), | |
| 41 | − _isToolWindow(isToolWindow) { | |
| 42 | − | |
| 43 | − if (_isToolWindow) { | |
| 44 | − ToolWindow* toolWindow = qApp->getToolWindow(); | |
| 45 | − | |
| 46 | − auto dockWidget = new QDockWidget(title, toolWindow); | |
| 47 | − dockWidget->setFeatures(QDockWidget::DockWidgetMovable); | |
| 48 | − connect(dockWidget, &QDockWidget::visibilityChanged, this, &WebWindowClass::visibilityChanged); | |
| 49 | − | |
| 50 | − _webView = new QWebView(dockWidget); | |
| 51 | − addEventBridgeToWindowObject(); | |
| 39 | +WebWindowClass::WebWindowClass(const QString& title, const QString& url, int width, int height) | |
| 40 | + : QObject(NULL), _eventBridge(new ScriptEventBridge(this)) { | |
| 41 | + auto dialogWidget = new QDialog(qApp->getWindow(), Qt::Window); | |
| 42 | + dialogWidget->setWindowTitle(title); | |
| 43 | + dialogWidget->resize(width, height); | |
| 44 | + dialogWidget->installEventFilter(this); | |
| 45 | + connect(dialogWidget, &QDialog::finished, this, &WebWindowClass::hasClosed); | |
| 52 | 46 | |
| 53 | − dockWidget->setWidget(_webView); | |
| 47 | + auto layout = new QVBoxLayout(dialogWidget); | |
| 48 | + layout->setContentsMargins(0, 0, 0, 0); | |
| 49 | + dialogWidget->setLayout(layout); | |
| 54 | 50 | |
| 55 | − auto titleWidget = new QWidget(dockWidget); | |
| 56 | − dockWidget->setTitleBarWidget(titleWidget); | |
| 57 | − | |
| 58 | − toolWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget, Qt::Horizontal); | |
| 59 | − | |
| 60 | − _windowWidget = dockWidget; | |
| 61 | − } else { | |
| 62 | − auto dialogWidget = new QDialog(qApp->getWindow(), Qt::Window); | |
| 63 | − dialogWidget->setWindowTitle(title); | |
| 64 | − dialogWidget->resize(width, height); | |
| 65 | − dialogWidget->installEventFilter(this); | |
| 66 | − connect(dialogWidget, &QDialog::finished, this, &WebWindowClass::hasClosed); | |
| 51 | + _webView = new QWebView(dialogWidget); | |
| 67 | 52 | |
| 68 | − auto layout = new QVBoxLayout(dialogWidget); | |
| 69 | − layout->setContentsMargins(0, 0, 0, 0); | |
| 70 | − dialogWidget->setLayout(layout); | |
| 53 | + layout->addWidget(_webView); | |
| 71 | 54 | |
| 72 | − _webView = new QWebView(dialogWidget); | |
| 55 | + addEventBridgeToWindowObject(); | |
| 73 | 56 | |
| 74 | − layout->addWidget(_webView); | |
| 75 | − | |
| 76 | − addEventBridgeToWindowObject(); | |
| 77 | − | |
| 78 | − _windowWidget = dialogWidget; | |
| 79 | − } | |
| 57 | + _windowWidget = dialogWidget; | |
| 80 | 58 | |
| 81 | 59 | auto style = QStyleFactory::create("fusion"); |
| 82 | 60 | if (style) { |
| @@ -121,13 +99,8 @@ void WebWindowClass::addEventBridgeToWindowObject() { · 38 unmodified lines | ||
| 121 | 99 | |
| 122 | 100 | void WebWindowClass::setVisible(bool visible) { |
| 123 | 101 | if (visible) { |
| 124 | − if (_isToolWindow) { | |
| 125 | − QMetaObject::invokeMethod( | |
| 126 | − qApp->getToolWindow(), "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); | |
| 127 | − } else { | |
| 128 | − QMetaObject::invokeMethod(_windowWidget, "showNormal", Qt::AutoConnection); | |
| 129 | − QMetaObject::invokeMethod(_windowWidget, "raise", Qt::AutoConnection); | |
| 130 | − } | |
| 102 | + QMetaObject::invokeMethod(_windowWidget, "showNormal", Qt::AutoConnection); | |
| 103 | + QMetaObject::invokeMethod(_windowWidget, "raise", Qt::AutoConnection); | |
| 131 | 104 | } |
| 132 | 105 | QMetaObject::invokeMethod(_windowWidget, "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); |
| 133 | 106 | } |
| @@ -182,13 +155,18 @@ void WebWindowClass::raise() { · 48 unmodified lines | ||
| 182 | 155 | QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* engine) { |
| 183 | 156 | WebWindowClass* retVal; |
| 184 | 157 | QString file = context->argument(0).toString(); |
| 158 | + if (context->argument(4).toBool()) { | |
| 159 | + qWarning() << "ToolWindow views with WebWindow are no longer supported. Use OverlayWebWindow instead"; | |
| 160 | + return QScriptValue(); | |
| 161 | + } else { | |
| 162 | + qWarning() << "WebWindow views are deprecated. Use OverlayWebWindow instead"; | |
| 163 | + } | |
| 185 | 164 | QMetaObject::invokeMethod(DependencyManager::get<WindowScriptingInterface>().data(), "doCreateWebWindow", Qt::BlockingQueuedConnection, |
| 186 | 165 | Q_RETURN_ARG(WebWindowClass*, retVal), |
| 187 | 166 | Q_ARG(const QString&, file), |
| 188 | 167 | Q_ARG(QString, context->argument(1).toString()), |
| 189 | 168 | Q_ARG(int, context->argument(2).toInteger()), |
| 190 | − Q_ARG(int, context->argument(3).toInteger()), | |
| 191 | − Q_ARG(bool, context->argument(4).toBool())); | |
| 169 | + Q_ARG(int, context->argument(3).toInteger())); | |
| 192 | 170 | |
| 193 | 171 | connect(engine, &QScriptEngine::destroyed, retVal, &WebWindowClass::deleteLater); |
| 194 | 172 | |