From 2ee1f18e065aa5f97df4ca94ea46168716705d6b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Thu, 11 Feb 2016 10:27:24 -0800 Subject: [PATCH] Allow closed tabs to delete properly --- examples/tests/toolWindowStressTest.js | 31 ++ interface/ui/chatWindow.ui | 268 -------------- interface/ui/loginDialog.ui | 494 ------------------------- interface/ui/shareSnapshot.ui | 377 ------------------- interface/ui/temp.qml | 33 -- interface/ui/userLocationsDialog.ui | 130 ------- libraries/ui/src/QmlWindowClass.cpp | 12 +- tests/ui/qml/main.qml | 17 + 8 files changed, 56 insertions(+), 1306 deletions(-) create mode 100644 examples/tests/toolWindowStressTest.js delete mode 100644 interface/ui/chatWindow.ui delete mode 100644 interface/ui/loginDialog.ui delete mode 100644 interface/ui/shareSnapshot.ui delete mode 100644 interface/ui/temp.qml delete mode 100644 interface/ui/userLocationsDialog.ui diff --git a/examples/tests/toolWindowStressTest.js b/examples/tests/toolWindowStressTest.js new file mode 100644 index 0000000000..44b059ebda --- /dev/null +++ b/examples/tests/toolWindowStressTest.js @@ -0,0 +1,31 @@ +var TOGGLE_RATE = 1000; +var RUNTIME = 60 * 1000; + +var webView; +var running = true; + +function toggleWindow() { + if (!running) { + return; + } + + if (webView) { + webView.close(); + webView = null; + } else { + webView = new OverlayWebWindow({ + title: 'Entity Properties', + source: "http://www.google.com", + toolWindow: true + }); + webView.setVisible(true); + } + Script.setTimeout(toggleWindow, TOGGLE_RATE) +} + +toggleWindow(); +print("Creating window?") + +Script.setTimeout(function(){ + print("Shutting down") +}, RUNTIME) diff --git a/interface/ui/chatWindow.ui b/interface/ui/chatWindow.ui deleted file mode 100644 index fa75ea9be8..0000000000 --- a/interface/ui/chatWindow.ui +++ /dev/null @@ -1,268 +0,0 @@ - - - ChatWindow - - - - 0 - 0 - 400 - 440 - - - - - 400 - 238 - - - - Chat - - - font-family: Helvetica, Arial, sans-serif; - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 8 - - - 8 - - - 8 - - - 8 - - - - - - 0 - 0 - - - - Connecting to XMPP... - - - Qt::AlignCenter - - - - - - - - - - 0 - 0 - - - - font-weight: bold; color: palette(shadow); margin-bottom: 4px; - - - online now: - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - QLayout::SetDefaultConstraint - - - 0 - - - 0 - - - 0 - - - 12 - - - - - - - - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 382 - 16 - - - - - 0 - 0 - - - - margin-top: 0px; - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 0 - 0 - - - - - 0 - 78 - - - - #chatFrame { -border-color: palette(dark); border-style: solid; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; -} - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 60 - - - - font-family: Arial; -font-size: 14px; - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContents - - - true - - - false - - - - - - - - - - - - - ChatInputArea - QTextEdit -
ui/ChatInputArea.h
-
-
- - messagesScrollArea - - - -
diff --git a/interface/ui/loginDialog.ui b/interface/ui/loginDialog.ui deleted file mode 100644 index e203699155..0000000000 --- a/interface/ui/loginDialog.ui +++ /dev/null @@ -1,494 +0,0 @@ - - - LoginDialog - - - - 0 - 0 - 1003 - 130 - - - - - 0 - 130 - - - - Dialog - - - font-family: Helvetica, Arial, sans-serif; - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 30 - - - - - 5 - - - 0 - - - 10 - - - 10 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 825 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Helvetica,Arial,sans-serif - 17 - - - - Authenticating... - - - - - - - true - - - - Helvetica,Arial,sans-serif - 17 - - - - color: #992800; - - - <style type="text/css"> - a { text-decoration: none; color: #267077;} -</style> -Invalid username or password. <a href="https://metaverse.highfidelity.com/password/new">Recover?</a> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16 - 16 - - - - - 16 - 16 - - - - SplitHCursor - - - - - - - - - - ../resources/images/close.svg../resources/images/close.svg - - - true - - - - - - - - - - true - - - - 0 - 0 - - - - - 0 - 102 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 30 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - - - 0 - - - 0 - - - 12 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - ../resources/images/hifi-logo.png - - - - - - - - - - - 0 - 0 - - - - - 931 - 60 - - - - QLineEdit { - padding: 10px; -border-width: 1px; border-style: solid; border-radius: 3px; border-color: #aaa; -} - - - - 12 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 300 - 54 - - - - - Helvetica,Arial,sans-serif - 20 - - - - padding-top: 14px; - - - - - - Username or Email - - - - - - - - 0 - 0 - - - - - 300 - 54 - - - - - Helvetica,Arial,sans-serif - 20 - - - - padding-top: 14px; - - - - - - QLineEdit::Password - - - Password - - - - - - - - 0 - 0 - - - - - 141 - 54 - - - - - Helvetica,Arial,sans-serif - 20 - - - - PointingHandCursor - - - -background: #0e7077; -color: #e7eeee; -border-radius: 4px; padding-top: 1px; - - - Login - - - - ../resources/images/login.svg../resources/images/login.svg - - - - 32 - 32 - - - - true - - - true - - - - - - - - Helvetica,Arial,sans-serif - 17 - - - - <style type="text/css"> -a { text-decoration: none; color: #267077; margin:0;padding:0;} -#create {font-weight:bold;} -p {margin:5px 0;} -</style> -<p><a id="create" href="%1">Create account</a></p> -<p><a href="%2">Recover password</a></p> - - - true - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - diff --git a/interface/ui/shareSnapshot.ui b/interface/ui/shareSnapshot.ui deleted file mode 100644 index 19e0772f13..0000000000 --- a/interface/ui/shareSnapshot.ui +++ /dev/null @@ -1,377 +0,0 @@ - - - SnapshotShareDialog - - - Qt::NonModal - - - - 0 - 0 - 502 - 616 - - - - - 0 - 0 - - - - - 500 - 616 - - - - - 502 - 616 - - - - Share with Alphas - - - background-color: rgb(255, 255, 255); - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - QLayout::SetMinAndMaxSize - - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 30 - 2000 - - - - background-color: #ccc; - - - 0 - - - true - - - Qt::AlignCenter - - - 0 - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 9 - - - - - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 0 - - - - - Arial - - - - color: #666 - - - - - - Qt::RichText - - - Qt::AlignCenter - - - true - - - Qt::TextBrowserInteraction - - - - - - - - 0 - 0 - - - - - 0 - 19 - - - - - Helvetica - 14 - 75 - true - - - - color: #666; -padding-left:20px; - - - QFrame::NoFrame - - - 0 - - - Notes about this image - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - 0 - - - 0 - - - - - - - 0 - - - QLayout::SetFixedSize - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 19 - 20 - - - - - - - - - 0 - 0 - - - - - 16777215 - 60 - - - - - Helvetica - 14 - - - - border: 1px solid #c5c5c5; - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Helvetica'; font-size:14px; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 25 - 19 - - - - - - - - background-color: #333333; - border-width: 0; - border-radius: 9px; - border-radius: 9px; - font-family: Arial; - font-size: 18px; - font-weight: 100; - color: #FFFFFF; - width: 120px; - height: 50px; - - - Share - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 25 - 20 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 11 - - - - - - - - - - - - shareButton - clicked() - SnapshotShareDialog - accept() - - - 420 - 565 - - - 250 - 307 - - - - - diff --git a/interface/ui/temp.qml b/interface/ui/temp.qml deleted file mode 100644 index 9617a0a8b7..0000000000 --- a/interface/ui/temp.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 2.4 -import QtQuick.Controls 2.3 -import QtQuick.Controls.Styles 1.3 - - -Item { - implicitHeight: 200 - implicitWidth: 800 - - - TextArea { - id: gutter - anchors.left: parent.left - anchors.top: parent.top - anchors.bottom: parent.bottom - style: TextAreaStyle { - backgroundColor: "grey" - } - width: 16 - text: ">" - font.family: "Lucida Console" - } - TextArea { - anchors.left: gutter.right - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - text: "undefined" - font.family: "Lucida Console" - - } -} - diff --git a/interface/ui/userLocationsDialog.ui b/interface/ui/userLocationsDialog.ui deleted file mode 100644 index 609ce1c8ab..0000000000 --- a/interface/ui/userLocationsDialog.ui +++ /dev/null @@ -1,130 +0,0 @@ - - - UserLocationsDialog - - - - 0 - 0 - 929 - 633 - - - - Form - - - - -1 - - - 12 - - - 12 - - - 12 - - - 12 - - - - - - - - font-size: 16px - - - My Locations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Refresh - - - - - - - - - - 0 - - - false - - - - - - - - -1 - - - 12 - - - 12 - - - 12 - - - 12 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Rename - - - - - - - Delete - - - - - - - - - - - diff --git a/libraries/ui/src/QmlWindowClass.cpp b/libraries/ui/src/QmlWindowClass.cpp index 0e834fa379..1b9880fa3c 100644 --- a/libraries/ui/src/QmlWindowClass.cpp +++ b/libraries/ui/src/QmlWindowClass.cpp @@ -323,10 +323,14 @@ void QmlWindowClass::close() { if (_qmlWindow) { if (_toolWindow) { auto offscreenUi = DependencyManager::get(); - auto toolWindow = offscreenUi->getToolWindow(); - auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection, - Q_ARG(QVariant, _source)); - Q_ASSERT(invokeResult); + auto qmlWindow = _qmlWindow; + offscreenUi->executeOnUiThread([=] { + auto toolWindow = offscreenUi->getToolWindow(); + offscreenUi->getRootContext()->engine()->setObjectOwnership(qmlWindow, QQmlEngine::JavaScriptOwnership); + auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::DirectConnection, + Q_ARG(QVariant, _source)); + Q_ASSERT(invokeResult); + }); } else { _qmlWindow->deleteLater(); } diff --git a/tests/ui/qml/main.qml b/tests/ui/qml/main.qml index a55f042227..02d8841486 100644 --- a/tests/ui/qml/main.qml +++ b/tests/ui/qml/main.qml @@ -115,6 +115,23 @@ ApplicationWindow { } } + Button { + text: "Add Tab" + onClicked: { + console.log(desktop.toolWindow); + desktop.toolWindow.addWebTab({ source: "Foo" }); + desktop.toolWindow.showTabForUrl("Foo", true); + } + } + + Button { + text: "Destroy Tab" + onClicked: { + console.log(desktop.toolWindow); + desktop.toolWindow.removeTabForUrl("Foo"); + } + } + Button { text: "Open File" property var builder: Component {