Showing the changes to interface/src/ui/InteractiveWindow.cpp (1 of 3 files). Show all
Unified · Split
| @@ -85,13 +85,13 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) { · 84 unmodified lines | |||
| 85 | * @property {string} [title="InteractiveWindow] - The title of the window. | 85 | * @property {string} [title="InteractiveWindow] - The title of the window. |
| 86 | * @property {Vec2} [position] - The initial position of the window, in pixels. | 86 | * @property {Vec2} [position] - The initial position of the window, in pixels. |
| 87 | * @property {Vec2} [size] - The initial size of the window, in pixels | 87 | * @property {Vec2} [size] - The initial size of the window, in pixels |
| 88 | * @property {boolean} [visible=true] - <code>true</code> to make the window visible when created, <code>false</code> to make | 88 | * @property {boolean} [visible=true] - <code>true</code> to make the window visible when created, <code>false</code> to make |
| 89 | * it invisible. | 89 | * it invisible. |
| 90 | * @property {InteractiveWindow.PresentationMode} [presentationMode=Desktop.PresentationMode.VIRTUAL] - | 90 | * @property {InteractiveWindow.PresentationMode} [presentationMode=Desktop.PresentationMode.VIRTUAL] - |
| 91 | * <code>Desktop.PresentationMode.VIRTUAL</code> to display the window inside Interface, <code>.NATIVE</code> to display it | 91 | * <code>Desktop.PresentationMode.VIRTUAL</code> to display the window inside Interface, <code>.NATIVE</code> to display it |
| 92 | * as its own separate window. | 92 | * as its own separate window. |
| 93 | * @property {InteractiveWindow.PresentationWindowInfo} [presentationWindowInfo] - Controls how a <code>NATIVE</code> window is | 93 | * @property {InteractiveWindow.PresentationWindowInfo} [presentationWindowInfo] - Controls how a <code>NATIVE</code> window is |
| 94 | * displayed. If used, the window is docked to the specified edge of the Interface window, otherwise the window is | 94 | * displayed. If used, the window is docked to the specified edge of the Interface window, otherwise the window is |
| 95 | * displayed as its own separate window. | 95 | * displayed as its own separate window. |
| 96 | * @property {InteractiveWindow.AdditionalFlags} [additionalFlags=0] - Window behavior flags in addition to "native window flags" (minimize/maximize/close), | 96 | * @property {InteractiveWindow.AdditionalFlags} [additionalFlags=0] - Window behavior flags in addition to "native window flags" (minimize/maximize/close), |
| 97 | * set at window creation. Possible flag values are provided as {@link Desktop|Desktop.ALWAYS_ON_TOP} and {@link Desktop|Desktop.CLOSE_BUTTON_HIDES}. | 97 | * set at window creation. Possible flag values are provided as {@link Desktop|Desktop.ALWAYS_ON_TOP} and {@link Desktop|Desktop.CLOSE_BUTTON_HIDES}. |
| @@ -124,7 +124,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 26 unmodified lines | |||
| 124 | auto mainWindow = qApp->getWindow(); | 124 | auto mainWindow = qApp->getWindow(); |
| 125 | _dockWidget = std::shared_ptr<DockWidget>(new DockWidget(title, mainWindow), dockWidgetDeleter); | 125 | _dockWidget = std::shared_ptr<DockWidget>(new DockWidget(title, mainWindow), dockWidgetDeleter); |
| 126 | auto quickView = _dockWidget->getQuickView(); | 126 | auto quickView = _dockWidget->getQuickView(); |
| 127 | 127 | ||
| 128 | Application::setupQmlSurface(quickView->rootContext() , true); | 128 | Application::setupQmlSurface(quickView->rootContext() , true); |
| 129 | 129 | ||
| 130 | //add any whitelisted callbacks | 130 | //add any whitelisted callbacks |
| @@ -176,7 +176,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap · 45 unmodified lines | |||
| 176 | }); | 176 | }); |
| 177 | 177 | ||
| 178 | _dockWidget->setSource(QUrl(sourceUrl)); | 178 | _dockWidget->setSource(QUrl(sourceUrl)); |
| 179 | |||
| 180 | mainWindow->addDockWidget(dockArea, _dockWidget.get()); | 179 | mainWindow->addDockWidget(dockArea, _dockWidget.get()); |
| 181 | } else { | 180 | } else { |
| 182 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 181 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| @@ -254,55 +253,35 @@ void InteractiveWindow::sendToQml(const QVariant& message) { · 71 unmodified lines | |||
| 254 | } | 253 | } |
| 255 | 254 | ||
| 256 | void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { | 255 | void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { |
| 257 | if (QThread::currentThread() != thread()) { | 256 | emit scriptEventReceived(scriptMessage); |
| 258 | QMetaObject::invokeMethod(this, "emitScriptEvent", Qt::QueuedConnection, Q_ARG(QVariant, scriptMessage)); | ||
| 259 | } else { | ||
| 260 | emit scriptEventReceived(scriptMessage); | ||
| 261 | } | ||
| 262 | } | 257 | } |
| 263 | 258 | ||
| 264 | void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { | 259 | void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { |
| 265 | if (QThread::currentThread() != thread()) { | 260 | emit webEventReceived(webMessage); |
| 266 | QMetaObject::invokeMethod(this, "emitWebEvent", Qt::QueuedConnection, Q_ARG(QVariant, webMessage)); | ||
| 267 | } else { | ||
| 268 | emit webEventReceived(webMessage); | ||
| 269 | } | ||
| 270 | } | 261 | } |
| 271 | 262 | ||
| 272 | void InteractiveWindow::close() { | 263 | void InteractiveWindow::close() { |
| 273 | if (QThread::currentThread() != thread()) { | ||
| 274 | QMetaObject::invokeMethod(this, "close"); | ||
| 275 | return; | ||
| 276 | } | ||
| 277 | |||
| 278 | if (_qmlWindow) { | 264 | if (_qmlWindow) { |
| 279 | _qmlWindow->deleteLater(); | 265 | _qmlWindow->deleteLater(); |
| 280 | } | 266 | } |
| 281 | 267 | ||
| 282 | qApp->getWindow()->removeDockWidget(_dockWidget.get()); | 268 | if (_dockWidget) { |
| 269 | auto window = qApp->getWindow(); | ||
| 270 | BLOCKING_INVOKE_METHOD(window, "removeDockWidget", Q_ARG(QDockWidget*, _dockWidget.get())); | ||
| 271 | } | ||
| 283 | _dockWidget = nullptr; | 272 | _dockWidget = nullptr; |
| 284 | _qmlWindow = nullptr; | 273 | _qmlWindow = nullptr; |
| 285 | } | 274 | } |
| 286 | 275 | ||
| 287 | void InteractiveWindow::show() { | 276 | void InteractiveWindow::show() { |
| 288 | if (QThread::currentThread() != thread()) { | ||
| 289 | QMetaObject::invokeMethod(this, "show"); | ||
| 290 | return; | ||
| 291 | } | ||
| 292 | |||
| 293 | if (_qmlWindow) { | 277 | if (_qmlWindow) { |
| 294 | QMetaObject::invokeMethod(_qmlWindow, "show", Qt::DirectConnection); | 278 | QMetaObject::invokeMethod(_qmlWindow, "show"); |
| 295 | } | 279 | } |
| 296 | } | 280 | } |
| 297 | 281 | ||
| 298 | void InteractiveWindow::raise() { | 282 | void InteractiveWindow::raise() { |
| 299 | if (QThread::currentThread() != thread()) { | ||
| 300 | QMetaObject::invokeMethod(this, "raise"); | ||
| 301 | return; | ||
| 302 | } | ||
| 303 | |||
| 304 | if (_qmlWindow) { | 283 | if (_qmlWindow) { |
| 305 | QMetaObject::invokeMethod(_qmlWindow, "raiseWindow", Qt::DirectConnection); | 284 | QMetaObject::invokeMethod(_qmlWindow, "raiseWindow"); |
| 306 | } | 285 | } |
| 307 | } | 286 | } |
| 308 | 287 | ||
| @@ -323,17 +302,12 @@ void InteractiveWindow::setVisible(bool visible) { · 14 unmodified lines | |||
| 323 | } | 302 | } |
| 324 | 303 | ||
| 325 | if (!_qmlWindow.isNull()) { | 304 | if (!_qmlWindow.isNull()) { |
| 326 | _qmlWindow->setProperty(INTERACTIVE_WINDOW_VISIBLE_PROPERTY, visible); | 305 | QMetaObject::invokeMethod(_qmlWindow, "setProperty", Q_ARG(const char*, INTERACTIVE_WINDOW_VISIBLE_PROPERTY), |
| 306 | Q_ARG(bool, visible)); | ||
| 327 | } | 307 | } |
| 328 | } | 308 | } |
| 329 | 309 | ||
| 330 | bool InteractiveWindow::isVisible() const { | 310 | bool InteractiveWindow::isVisible() const { |
| 331 | if (QThread::currentThread() != thread()) { | ||
| 332 | bool result = false; | ||
| 333 | BLOCKING_INVOKE_METHOD(const_cast<InteractiveWindow*>(this), "isVisible", Q_RETURN_ARG(bool, result)); | ||
| 334 | return result; | ||
| 335 | } | ||
| 336 | |||
| 337 | if (_qmlWindow.isNull()) { | 311 | if (_qmlWindow.isNull()) { |
| 338 | return false; | 312 | return false; |
| 339 | } | 313 | } |
| @@ -342,12 +316,6 @@ bool InteractiveWindow::isVisible() const { · 2 unmodified lines | |||
| 342 | } | 316 | } |
| 343 | 317 | ||
| 344 | glm::vec2 InteractiveWindow::getPosition() const { | 318 | glm::vec2 InteractiveWindow::getPosition() const { |
| 345 | if (QThread::currentThread() != thread()) { | ||
| 346 | glm::vec2 result; | ||
| 347 | BLOCKING_INVOKE_METHOD(const_cast<InteractiveWindow*>(this), "getPosition", Q_RETURN_ARG(glm::vec2, result)); | ||
| 348 | return result; | ||
| 349 | } | ||
| 350 | |||
| 351 | if (_qmlWindow.isNull()) { | 319 | if (_qmlWindow.isNull()) { |
| 352 | return {}; | 320 | return {}; |
| 353 | } | 321 | } |
| @@ -362,18 +330,13 @@ void InteractiveWindow::setPosition(const glm::vec2& position) { · 8 unmodified lines | |||
| 362 | } | 330 | } |
| 363 | 331 | ||
| 364 | if (!_qmlWindow.isNull()) { | 332 | if (!_qmlWindow.isNull()) { |
| 365 | _qmlWindow->setProperty(INTERACTIVE_WINDOW_POSITION_PROPERTY, QPointF(position.x, position.y)); | 333 | QMetaObject::invokeMethod(_qmlWindow, "setProperty", Q_ARG(const char*, INTERACTIVE_WINDOW_POSITION_PROPERTY), |
| 366 | QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowPositionForMode", Qt::DirectConnection); | 334 | Q_ARG(QPointF, QPointF(position.x, position.y))); |
| 335 | QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowPositionForMode"); | ||
| 367 | } | 336 | } |
| 368 | } | 337 | } |
| 369 | 338 | ||
| 370 | glm::vec2 InteractiveWindow::getSize() const { | 339 | glm::vec2 InteractiveWindow::getSize() const { |
| 371 | if (QThread::currentThread() != thread()) { | ||
| 372 | glm::vec2 result; | ||
| 373 | BLOCKING_INVOKE_METHOD(const_cast<InteractiveWindow*>(this), "getSize", Q_RETURN_ARG(glm::vec2, result)); | ||
| 374 | return result; | ||
| 375 | } | ||
| 376 | |||
| 377 | if (_qmlWindow.isNull()) { | 340 | if (_qmlWindow.isNull()) { |
| 378 | return {}; | 341 | return {}; |
| 379 | } | 342 | } |
| @@ -381,24 +344,14 @@ glm::vec2 InteractiveWindow::getSize() const { · 1 unmodified line | |||
| 381 | } | 344 | } |
| 382 | 345 | ||
| 383 | void InteractiveWindow::setSize(const glm::vec2& size) { | 346 | void InteractiveWindow::setSize(const glm::vec2& size) { |
| 384 | if (QThread::currentThread() != thread()) { | ||
| 385 | QMetaObject::invokeMethod(this, "setSize", Q_ARG(const glm::vec2&, size)); | ||
| 386 | return; | ||
| 387 | } | ||
| 388 | |||
| 389 | if (!_qmlWindow.isNull()) { | 347 | if (!_qmlWindow.isNull()) { |
| 390 | _qmlWindow->setProperty(INTERACTIVE_WINDOW_SIZE_PROPERTY, QSize(size.x, size.y)); | 348 | QMetaObject::invokeMethod(_qmlWindow, "setProperty", Q_ARG(const char*, INTERACTIVE_WINDOW_SIZE_PROPERTY), |
| 391 | QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowSizeForMode", Qt::DirectConnection); | 349 | Q_ARG(QSize, QSize(size.x, size.y))); |
| 350 | QMetaObject::invokeMethod(_qmlWindow, "updateInteractiveWindowSizeForMode"); | ||
| 392 | } | 351 | } |
| 393 | } | 352 | } |
| 394 | 353 | ||
| 395 | QString InteractiveWindow::getTitle() const { | 354 | QString InteractiveWindow::getTitle() const { |
| 396 | if (QThread::currentThread() != thread()) { | ||
| 397 | QString result; | ||
| 398 | BLOCKING_INVOKE_METHOD(const_cast<InteractiveWindow*>(this), "getTitle", Q_RETURN_ARG(QString, result)); | ||
| 399 | return result; | ||
| 400 | } | ||
| 401 | |||
| 402 | if (_qmlWindow.isNull()) { | 355 | if (_qmlWindow.isNull()) { |
| 403 | return QString(); | 356 | return QString(); |
| 404 | } | 357 | } |
| @@ -406,24 +359,13 @@ QString InteractiveWindow::getTitle() const { · 1 unmodified line | |||
| 406 | } | 359 | } |
| 407 | 360 | ||
| 408 | void InteractiveWindow::setTitle(const QString& title) { | 361 | void InteractiveWindow::setTitle(const QString& title) { |
| 409 | if (QThread::currentThread() != thread()) { | ||
| 410 | QMetaObject::invokeMethod(this, "setTitle", Q_ARG(const QString&, title)); | ||
| 411 | return; | ||
| 412 | } | ||
| 413 | |||
| 414 | if (!_qmlWindow.isNull()) { | 362 | if (!_qmlWindow.isNull()) { |
| 415 | _qmlWindow->setProperty(TITLE_PROPERTY, title); | 363 | QMetaObject::invokeMethod(_qmlWindow, "setProperty", Q_ARG(const char*, TITLE_PROPERTY), |
| 364 | Q_ARG(QString, title)); | ||
| 416 | } | 365 | } |
| 417 | } | 366 | } |
| 418 | 367 | ||
| 419 | int InteractiveWindow::getPresentationMode() const { | 368 | int InteractiveWindow::getPresentationMode() const { |
| 420 | if (QThread::currentThread() != thread()) { | ||
| 421 | int result; | ||
| 422 | BLOCKING_INVOKE_METHOD(const_cast<InteractiveWindow*>(this), "getPresentationMode", | ||
| 423 | Q_RETURN_ARG(int, result)); | ||
| 424 | return result; | ||
| 425 | } | ||
| 426 | |||
| 427 | if (_qmlWindow.isNull()) { | 369 | if (_qmlWindow.isNull()) { |
| 428 | return Virtual; | 370 | return Virtual; |
| 429 | } | 371 | } |
| @@ -449,12 +391,8 @@ void InteractiveWindow::parentNativeWindowToMainWindow() { · 19 unmodified lines | |||
| 449 | } | 391 | } |
| 450 | 392 | ||
| 451 | void InteractiveWindow::setPresentationMode(int presentationMode) { | 393 | void InteractiveWindow::setPresentationMode(int presentationMode) { |
| 452 | if (QThread::currentThread() != thread()) { | ||
| 453 | QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode)); | ||
| 454 | return; | ||
| 455 | } | ||
| 456 | |||
| 457 | if (!_qmlWindow.isNull()) { | 394 | if (!_qmlWindow.isNull()) { |
| 458 | _qmlWindow->setProperty(PRESENTATION_MODE_PROPERTY, presentationMode); | 395 | QMetaObject::invokeMethod(_qmlWindow, "setProperty", Q_ARG(const char*, PRESENTATION_MODE_PROPERTY), |
| 396 | Q_ARG(int, presentationMode)); | ||
| 459 | } | 397 | } |
| 460 | } | 398 | } |