From 1e3c717fd4e3f65d30792eba0c18bd128250fb03 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 09:55:47 +1300 Subject: [PATCH 01/35] Method to show appropriate desktop or tablet dialog --- interface/src/Application.cpp | 10 ++++++++++ interface/src/Application.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d659ec0a94..a32acc474b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5862,6 +5862,16 @@ void Application::addAssetToWorldFromURL(QString url) { request->send(); } +void Application::showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const { + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { + DependencyManager::get()->show(desktopURL, name); + } else { + tablet->loadQMLSource(tabletURL); + } +} + void Application::addAssetToWorldFromURLRequestFinished() { auto request = qobject_cast(sender()); auto url = request->getUrl().toString(); diff --git a/interface/src/Application.h b/interface/src/Application.h index c4ba760153..9fab4aef81 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -333,6 +333,8 @@ public slots: void toggleRunningScriptsWidget() const; Q_INVOKABLE void showAssetServerWidget(QString filePath = ""); + void showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const; + // FIXME: Move addAssetToWorld* methods to own class? void addAssetToWorldFromURL(QString url); void addAssetToWorldFromURLRequestFinished(); From 22e52290369fc20358a192d2cb0baf879d2e8005 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 09:57:45 +1300 Subject: [PATCH 02/35] Use existing attachments dialog as base dialog content --- .../{AttachmentsDialog.qml => content/AttachmentsContent.qml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename interface/resources/qml/hifi/dialogs/{AttachmentsDialog.qml => content/AttachmentsContent.qml} (100%) diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml similarity index 100% rename from interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml rename to interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml From 1fc6d824560b47943f360f052c378e6bb37addab Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 13:04:57 +1300 Subject: [PATCH 03/35] Tablet and desktop versions of avatar attachments dialog --- .../qml/hifi/dialogs/AttachmentsDialog.qml | 45 +++++++++++ .../dialogs/content/AttachmentsContent.qml | 43 ++++------- .../hifi/tablet/TabletAttachmentsDialog.qml | 77 +++++++++++++++++++ interface/src/Menu.cpp | 4 +- interface/src/ui/overlays/Web3DOverlay.cpp | 3 + 5 files changed, 141 insertions(+), 31 deletions(-) create mode 100644 interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml create mode 100644 interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml new file mode 100644 index 0000000000..a833c0fe61 --- /dev/null +++ b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml @@ -0,0 +1,45 @@ +// +// AttachmentsDialog.qml +// +// Created by David Rowe on 9 Mar 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import Qt.labs.settings 1.0 + +import "../../styles-uit" +import "../../windows" +import "content" + +ScrollingWindow { + id: root + title: "Attachments" + objectName: "AttachmentsDialog" + width: 600 + height: 600 + resizable: true + destroyOnHidden: true + minSize: Qt.vector2d(400, 500) + + HifiConstants { id: hifi } + + property var settings: Settings { + category: "AttachmentsDialog" + property alias x: root.x + property alias y: root.y + property alias width: root.width + property alias height: root.height + } + + function closeDialog() { + root.destroy(); + } + + AttachmentsContent { } + +} diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index 27d225b58e..b36b7080bc 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -1,47 +1,29 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Dialogs 1.2 as OriginalDialogs -import Qt.labs.settings 1.0 import QtQuick.Controls.Styles 1.4 -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" -import "attachments" +import "../../../styles-uit" +import "../../../controls-uit" as HifiControls +import "../../../windows" +import "../attachments" -ScrollingWindow { - id: root - title: "Attachments" - objectName: "AttachmentsDialog" - width: 600 - height: 600 - resizable: true - destroyOnHidden: true - minSize: Qt.vector2d(400, 500) - - HifiConstants { id: hifi } +Item { + id: content readonly property var originalAttachments: MyAvatar.getAttachmentsVariant(); property var attachments: []; - property var settings: Settings { - category: "AttachmentsDialog" - property alias x: root.x - property alias y: root.y - property alias width: root.width - property alias height: root.height - } - Component.onCompleted: { for (var i = 0; i < originalAttachments.length; ++i) { var attachment = originalAttachments[i]; - root.attachments.push(attachment); + content.attachments.push(attachment); listView.model.append({}); } } Column { - width: pane.contentWidth + width: pane.width Rectangle { width: parent.width @@ -118,7 +100,7 @@ ScrollingWindow { Attachment { id: attachmentView width: scrollView.width - attachment: root.attachments[index] + attachment: content.attachments[index] onDeleteAttachment: { attachments.splice(index, 1); listView.model.remove(index, 1); @@ -190,7 +172,7 @@ ScrollingWindow { text: "Cancel" onTriggered: { MyAvatar.setAttachmentsVariant(originalAttachments); - root.destroy() + closeDialog(); } } @@ -203,12 +185,14 @@ ScrollingWindow { } MyAvatar.setAttachmentsVariant(attachments); - root.destroy() + closeDialog(); } } } } + // FIXME + /* onKeyboardRaisedChanged: { if (keyboardEnabled && keyboardRaised) { // Scroll to item with focus if necessary. @@ -225,5 +209,6 @@ ScrollingWindow { } } } + */ } diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml new file mode 100644 index 0000000000..5dd7e75eed --- /dev/null +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -0,0 +1,77 @@ +// +// TabletAttachmentsDialog.qml +// +// Created by David Rowe on 9 Mar 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import "../../controls-uit" as HifiControls +import "../../styles-uit" +import "../dialogs/content" + +Item { + id: root + objectName: "AttachmentsDialog" + + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + + anchors.fill: parent + + HifiConstants { id: hifi } + + Rectangle { + id: pane // Surrogate for ScrollingWindow's pane. + anchors.fill: parent + color: hifi.colors.baseGray // Match that of dialog so that dialog's rounded corners don't show. + } + + function closeDialog() { + Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); + } + + AttachmentsContent { + id: attachments + + anchors { + top: parent.top + left: parent.left + right: parent.right + bottom: keyboard.top + } + + MouseArea { + // Defocuses any current control so that the keyboard gets hidden. + id: mouseArea + anchors.fill: parent + propagateComposedEvents: true + acceptedButtons: Qt.AllButtons + onPressed: { + parent.forceActiveFocus(); + mouse.accepted = false; + } + } + } + + HifiControls.Keyboard { + id: keyboard + raised: parent.keyboardEnabled && parent.keyboardRaised + numeric: parent.punctuationMode + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + } + + Component.onCompleted: { + keyboardEnabled = HMD.active; + } +} diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index beacbaccab..5fa7c192df 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -171,10 +171,10 @@ Menu::Menu() { // Avatar > Attachments... auto action = addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments); connect(action, &QAction::triggered, [] { - DependencyManager::get()->show(QString("hifi/dialogs/AttachmentsDialog.qml"), "AttachmentsDialog"); + qApp->showDialog(QString("hifi/dialogs/AttachmentsDialog.qml"), + QString("../../hifi/tablet/TabletAttachmentsDialog.qml"), "AttachmentsDialog"); }); - // Avatar > Size MenuWrapper* avatarSizeMenu = avatarMenu->addMenu("Size"); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index d8bead0a07..b2d75a0bbf 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -41,6 +41,7 @@ #include #include "FileDialogHelper.h" #include "AudioClient.h" +#include static const float DPI = 30.47f; @@ -174,7 +175,9 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); + _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); + _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); From 5847f86db8e3598bd6be32bb5110a62991d1adb7 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 8 Mar 2017 16:12:03 -0800 Subject: [PATCH 04/35] fix crash when unpacking too many joints --- libraries/animation/src/Rig.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index b70d28fc30..5573f5c0fe 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -1310,17 +1310,18 @@ void Rig::copyJointsFromJointData(const QVector& jointDataVec) { if (!_animSkeleton) { return; } - if (jointDataVec.size() != (int)_internalPoseSet._relativePoses.size()) { - // animations haven't fully loaded yet. - _internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses(); + int numJoints = jointDataVec.size(); + const AnimPoseVec& absoluteDefaultPoses = _animSkeleton->getAbsoluteDefaultPoses(); + if (numJoints != (int)absoluteDefaultPoses.size()) { + // jointData is incompatible + return; } // make a vector of rotations in absolute-geometry-frame - const AnimPoseVec& absoluteDefaultPoses = _animSkeleton->getAbsoluteDefaultPoses(); std::vector rotations; - rotations.reserve(absoluteDefaultPoses.size()); + rotations.reserve(numJoints); const glm::quat rigToGeometryRot(glmExtractRotation(_rigToGeometryTransform)); - for (int i = 0; i < jointDataVec.size(); i++) { + for (int i = 0; i < numJoints; i++) { const JointData& data = jointDataVec.at(i); if (data.rotationSet) { // JointData rotations are in absolute rig-frame so we rotate them to absolute geometry-frame @@ -1334,8 +1335,11 @@ void Rig::copyJointsFromJointData(const QVector& jointDataVec) { _animSkeleton->convertAbsoluteRotationsToRelative(rotations); // store new relative poses + if (numJoints != _internalPoseSet._relativePoses.size()) { + _internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses(); + } const AnimPoseVec& relativeDefaultPoses = _animSkeleton->getRelativeDefaultPoses(); - for (int i = 0; i < jointDataVec.size(); i++) { + for (int i = 0; i < numJoints; i++) { const JointData& data = jointDataVec.at(i); _internalPoseSet._relativePoses[i].scale() = Vectors::ONE; _internalPoseSet._relativePoses[i].rot() = rotations[i]; From 30d7ffb303925a2f0c7db6ed9e010742ffe43f61 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 8 Mar 2017 17:17:49 -0800 Subject: [PATCH 05/35] fix warning about signed unsigned compare --- libraries/animation/src/Rig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 5573f5c0fe..9ecd0f6352 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -1335,7 +1335,7 @@ void Rig::copyJointsFromJointData(const QVector& jointDataVec) { _animSkeleton->convertAbsoluteRotationsToRelative(rotations); // store new relative poses - if (numJoints != _internalPoseSet._relativePoses.size()) { + if (numJoints != (int)_internalPoseSet._relativePoses.size()) { _internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses(); } const AnimPoseVec& relativeDefaultPoses = _animSkeleton->getRelativeDefaultPoses(); From 66dded5e2888aabc2921d36e3c8486642b146fd7 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 18:13:26 +1300 Subject: [PATCH 06/35] Scroll attachments if necessary when raise keyboard to keep focus --- .../qml/hifi/dialogs/AttachmentsDialog.qml | 10 ++++++++ .../dialogs/content/AttachmentsContent.qml | 20 ++-------------- .../hifi/tablet/TabletAttachmentsDialog.qml | 23 ++++++++++++++++++- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml index a833c0fe61..66338666cf 100644 --- a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml +++ b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml @@ -42,4 +42,14 @@ ScrollingWindow { AttachmentsContent { } + onKeyboardRaisedChanged: { + if (keyboardEnabled && keyboardRaised) { + var buttonHeight = 40; // Allow for New Attachment button. + var keyboardRaisedHeight = 200; + var delta = activator.mouseY - (root.height - keyboardRaisedHeight - buttonHeight); + if (delta > 0) { + content.scrollBy(delta); + } + } + } } diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index b36b7080bc..4793d83e21 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -191,24 +191,8 @@ Item { } } - // FIXME - /* - onKeyboardRaisedChanged: { - if (keyboardEnabled && keyboardRaised) { - // Scroll to item with focus if necessary. - var footerHeight = newAttachmentButton.height + buttonRow.height + 3 * hifi.dimensions.contentSpacing.y; - var delta = activator.mouseY - - (activator.height + activator.y - 200 - footerHeight - hifi.dimensions.controlLineHeight); - - if (delta > 0) { - scrollView.scrollBy(delta); - } else { - // HACK: Work around for case where are 100% scrolled; stops window from erroneously scrolling to 100% when show keyboard. - scrollView.scrollBy(-1); - scrollView.scrollBy(1); - } - } + function scrollBy(delta) { + scrollView.scrollBy(delta); } - */ } diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index 5dd7e75eed..0bb43fccd2 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -49,7 +49,7 @@ Item { MouseArea { // Defocuses any current control so that the keyboard gets hidden. - id: mouseArea + id: defocuser anchors.fill: parent propagateComposedEvents: true acceptedButtons: Qt.AllButtons @@ -71,6 +71,27 @@ Item { } } + onKeyboardRaisedChanged: { + if (keyboardEnabled && keyboardRaised) { + var buttonsHeight = 120; // Allow for New Attachment plus Cancel & OK buttons. + var delta = activator.mouseY - (root.height - keyboard.raisedHeight - buttonsHeight); + if (delta > 0) { + attachments.scrollBy(delta); + } + } + } + + MouseArea { + id: activator + anchors.fill: parent + propagateComposedEvents: true + enabled: true + acceptedButtons: Qt.AllButtons + onPressed: { + mouse.accepted = false; + } + } + Component.onCompleted: { keyboardEnabled = HMD.active; } From 4be106cbae93a57352786a2d55e8cacfc8654de9 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 18:20:26 +1300 Subject: [PATCH 07/35] Remove obsolete rounded border --- .../resources/qml/hifi/dialogs/content/AttachmentsContent.qml | 1 - interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml | 1 - 2 files changed, 2 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index 4793d83e21..47cd633f76 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -28,7 +28,6 @@ Item { Rectangle { width: parent.width height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) - radius: 4 color: hifi.colors.baseGray Rectangle { diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index 0bb43fccd2..743d0305c6 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -30,7 +30,6 @@ Item { Rectangle { id: pane // Surrogate for ScrollingWindow's pane. anchors.fill: parent - color: hifi.colors.baseGray // Match that of dialog so that dialog's rounded corners don't show. } function closeDialog() { From 53dcf80cc0f332af855466c69261732062e81217 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 22:38:49 +1300 Subject: [PATCH 08/35] Add dialog title --- .../hifi/tablet/TabletAttachmentsDialog.qml | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index 743d0305c6..46d285ddb5 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -19,6 +19,8 @@ Item { id: root objectName: "AttachmentsDialog" + property string title: "Avatar Attachments" + property bool keyboardEnabled: false property bool keyboardRaised: false property bool punctuationMode: false @@ -36,11 +38,46 @@ Item { Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); } + anchors.topMargin: 90 // Space for header. + + // FIXME: Refactor with other tablet headers. + Rectangle { + id: header + height: 90 + anchors { + left: parent.left + right: parent.right + bottom: parent.top + } + z: 100 + + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + } + + GradientStop { + position: 1 + color: "#1e1e1e" + } + } + + RalewayBold { + text: title + size: 26 + color: "#34a2c7" + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: hifi.dimensions.contentMargin.x + } + } + AttachmentsContent { id: attachments anchors { - top: parent.top + top: header.bottom left: parent.left right: parent.right bottom: keyboard.top From c7d1aa8ff46e1c34d6bfeca3a612c6e13b61813a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 10 Mar 2017 08:26:00 +1300 Subject: [PATCH 09/35] Make attachments list flickable --- .../dialogs/content/AttachmentsContent.qml | 86 +++++-------------- 1 file changed, 21 insertions(+), 65 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index 47cd633f76..55a5deeb60 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -40,78 +40,34 @@ Item { color: hifi.colors.baseGrayShadow radius: 4 - ScrollView { - id: scrollView + ListView { + id: listView anchors.fill: parent anchors.margins: 4 + clip: true + focus: true - style: ScrollViewStyle { - - padding { - top: 0 - right: 0 - bottom: 0 - } - - decrementControl: Item { - visible: false - } - incrementControl: Item { - visible: false - } - scrollBarBackground: Rectangle{ - implicitWidth: 14 - color: hifi.colors.baseGray - radius: 4 - Rectangle { - // Make top left corner of scrollbar appear square - width: 8 - height: 4 - color: hifi.colors.baseGray - anchors.top: parent.top - anchors.horizontalCenter: parent.left + model: ListModel {} + delegate: Item { + id: attachmentDelegate + implicitHeight: attachmentView.height + 8; + implicitWidth: attachmentView.width + Attachment { + id: attachmentView + width: listView.width + attachment: content.attachments[index] + onDeleteAttachment: { + attachments.splice(index, 1); + listView.model.remove(index, 1); } - - } - handle: - Rectangle { - implicitWidth: 8 - anchors { - left: parent.left - leftMargin: 3 - top: parent.top - topMargin: 3 - bottom: parent.bottom - bottomMargin: 4 - } - radius: 4 - color: hifi.colors.lightGrayText + onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments); } } - - ListView { - id: listView - model: ListModel {} - delegate: Item { - id: attachmentDelegate - implicitHeight: attachmentView.height + 8; - implicitWidth: attachmentView.width - Attachment { - id: attachmentView - width: scrollView.width - attachment: content.attachments[index] - onDeleteAttachment: { - attachments.splice(index, 1); - listView.model.remove(index, 1); - } - onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments); - } - } - onCountChanged: MyAvatar.setAttachmentsVariant(attachments); - } + onCountChanged: MyAvatar.setAttachmentsVariant(attachments); function scrollBy(delta) { - flickableItem.contentY += delta; + // @@@@@@@ + //flickableItem.contentY += delta; } } } @@ -191,7 +147,7 @@ Item { } function scrollBy(delta) { - scrollView.scrollBy(delta); + listView.scrollBy(delta); } } From b539c55c025ea82311c1ce0626093be7ed00d621 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 10 Mar 2017 14:33:51 +1300 Subject: [PATCH 10/35] Scroll and snap to attachment with focus --- .../resources/qml/controls-uit/CheckBox.qml | 2 ++ .../hifi/dialogs/attachments/Attachment.qml | 20 +++++++++++ .../qml/hifi/dialogs/attachments/Vector3.qml | 32 ++++++++++++++++- .../dialogs/content/AttachmentsContent.qml | 35 ++++++++++++++----- .../hifi/tablet/TabletAttachmentsDialog.qml | 10 ------ 5 files changed, 79 insertions(+), 20 deletions(-) diff --git a/interface/resources/qml/controls-uit/CheckBox.qml b/interface/resources/qml/controls-uit/CheckBox.qml index 09a0e04148..9fc484586a 100644 --- a/interface/resources/qml/controls-uit/CheckBox.qml +++ b/interface/resources/qml/controls-uit/CheckBox.qml @@ -25,6 +25,8 @@ Original.CheckBox { readonly property int checkSize: Math.max(boxSize - 8, 10) readonly property int checkRadius: 2 + activeFocusOnPress: true + style: CheckBoxStyle { indicator: Rectangle { id: box diff --git a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml index 6d371741ea..5c11a87d12 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml @@ -17,10 +17,24 @@ Item { HifiConstants { id: hifi } + signal selectAttachment(); signal deleteAttachment(var attachment); signal updateAttachment(); property bool completed: false; + function doSelectAttachment(control, focus) { + if (focus) { + selectAttachment(); + + // Refocus control after possibly changing focus to attachment. + if (control.setControlFocus !== undefined) { + control.setControlFocus(); + } else { + control.focus = true; + } + } + } + Rectangle { color: hifi.colors.baseGray; anchors.fill: parent; radius: 4 } Component.onCompleted: { @@ -50,6 +64,7 @@ Item { updateAttachment(); } } + onFocusChanged: doSelectAttachment(this, focus); } HifiControls.Button { id: modelChooserButton; @@ -91,6 +106,7 @@ Item { updateAttachment(); } } + onFocusChanged: doSelectAttachment(this, focus); } } @@ -108,6 +124,7 @@ Item { updateAttachment(); } } + onControlFocusChanged: doSelectAttachment(this, controlFocus); } } @@ -125,6 +142,7 @@ Item { updateAttachment(); } } + onControlFocusChanged: doSelectAttachment(this, controlFocus); } } @@ -153,6 +171,7 @@ Item { updateAttachment(); } } + onFocusChanged: doSelectAttachment(this, focus); } } @@ -178,6 +197,7 @@ Item { updateAttachment(); } } + onFocusChanged: doSelectAttachment(this, focus); } } } diff --git a/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml b/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml index 3d109cc2a5..29f2c0ebf4 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml @@ -15,9 +15,37 @@ Item { property real stepSize: 1 property real maximumValue: 99 property real minimumValue: 0 + property bool controlFocus: false; // True if one of the ordinate controls has focus. + property var controlFocusControl: undefined signal valueChanged(); + function setControlFocus() { + if (controlFocusControl) { + controlFocusControl.focus = true; + // The controlFocus value is updated via onFocusChanged. + } + } + + function setFocus(control, focus) { + if (focus) { + controlFocusControl = control; + setControlFocusTrue.start(); // After any subsequent false from previous control. + } else { + controlFocus = false; + } + } + + Timer { + id: setControlFocusTrue + interval: 50 + repeat: false + running: false + onTriggered: { + controlFocus = true; + } + } + HifiConstants { id: hifi } HifiControls.SpinBox { @@ -38,6 +66,7 @@ Item { root.valueChanged(); } } + onFocusChanged: setFocus(this, focus); } HifiControls.SpinBox { @@ -58,6 +87,7 @@ Item { root.valueChanged(); } } + onFocusChanged: setFocus(this, focus); } HifiControls.SpinBox { @@ -78,6 +108,6 @@ Item { root.valueChanged(); } } + onFocusChanged: setFocus(this, focus); } } - diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index 55a5deeb60..ac271c5793 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -45,17 +45,32 @@ Item { anchors.fill: parent anchors.margins: 4 clip: true - focus: true + snapMode: ListView.SnapToItem model: ListModel {} delegate: Item { id: attachmentDelegate implicitHeight: attachmentView.height + 8; implicitWidth: attachmentView.width + + MouseArea { + // User can click on whitespace to select item. + anchors.fill: parent + propagateComposedEvents: true + onClicked: { + listView.currentIndex = index; + attachmentsBackground.forceActiveFocus(); // Unfocus from any control. + mouse.accepted = false; + } + } + Attachment { id: attachmentView width: listView.width attachment: content.attachments[index] + onSelectAttachment: { + listView.currentIndex = index; + } onDeleteAttachment: { attachments.splice(index, 1); listView.model.remove(index, 1); @@ -63,11 +78,18 @@ Item { onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments); } } + onCountChanged: MyAvatar.setAttachmentsVariant(attachments); - function scrollBy(delta) { - // @@@@@@@ - //flickableItem.contentY += delta; + /* */ + // DEBUG + highlight: Rectangle { color: "#40ffff00" } + highlightFollowsCurrentItem: true + /* */ + + onHeightChanged: { + // Keyboard has been raised / lowered. + positionViewAtIndex(currentIndex, ListView.SnapPosition); } } } @@ -145,9 +167,4 @@ Item { } } } - - function scrollBy(delta) { - listView.scrollBy(delta); - } } - diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index 46d285ddb5..dac43c9c3c 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -107,16 +107,6 @@ Item { } } - onKeyboardRaisedChanged: { - if (keyboardEnabled && keyboardRaised) { - var buttonsHeight = 120; // Allow for New Attachment plus Cancel & OK buttons. - var delta = activator.mouseY - (root.height - keyboard.raisedHeight - buttonsHeight); - if (delta > 0) { - attachments.scrollBy(delta); - } - } - } - MouseArea { id: activator anchors.fill: parent From 9291d272fe5510a94fad9c7c2e17adac5a61d809 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 10 Mar 2017 18:25:16 +1300 Subject: [PATCH 11/35] Add scrollbar --- .../dialogs/content/AttachmentsContent.qml | 97 ++++++++++++++++++- 1 file changed, 92 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index ac271c5793..bd6a2fecf9 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -42,8 +42,13 @@ Item { ListView { id: listView - anchors.fill: parent - anchors.margins: 4 + anchors { + top: parent.top + left: parent.left + right: scrollBar.left + bottom: parent.bottom + margins: 4 + } clip: true snapMode: ListView.SnapToItem @@ -81,15 +86,97 @@ Item { onCountChanged: MyAvatar.setAttachmentsVariant(attachments); - /* */ + /* // DEBUG highlight: Rectangle { color: "#40ffff00" } highlightFollowsCurrentItem: true - /* */ + */ onHeightChanged: { // Keyboard has been raised / lowered. - positionViewAtIndex(currentIndex, ListView.SnapPosition); + positionViewAtIndex(listView.currentIndex, ListView.SnapPosition); + } + + onCurrentIndexChanged: { + scrollSlider.y = currentIndex * (scrollBar.height - scrollSlider.height) / (listView.count - 1); + } + + onContentYChanged: { + // User may have dragged content up/down. + yScrollTimer.restart(); + } + + Timer { + id: yScrollTimer + interval: 50 + repeat: false + running: false + onTriggered: { + var index = listView.contentY / (scrollBar.height - scrollSlider.height); + index = Math.round(index); + listView.currentIndex = index; + } + } + } + + Rectangle { + id: scrollBar + + property bool scrolling: listView.contentHeight > listView.height + + anchors { + top: parent.top + right: parent.right + bottom: parent.bottom + topMargin: 4 + bottomMargin: 4 + } + width: scrolling ? 18 : 0 + radius: attachmentsBackground.radius + color: hifi.colors.baseGrayShadow + + MouseArea { + anchors.fill: parent + + onClicked: { + var index = listView.currentIndex; + index = index + (mouse.y <= scrollSlider.y ? -1 : 1); + if (index < 0) { + index = 0; + } + if (index > listView.count - 1) { + index = listView.count - 1; + } + listView.currentIndex = index; + } + } + + Rectangle { + id: scrollSlider + anchors { + right: parent.right + rightMargin: 3 + } + width: 16 + height: (listView.height / listView.contentHeight) * listView.height + radius: width / 2 + color: hifi.colors.lightGray + + visible: scrollBar.scrolling; + + onYChanged: { + var index = y * (listView.count - 1) / (scrollBar.height - scrollSlider.height); + index = Math.round(index); + listView.currentIndex = index; + } + + MouseArea { + anchors.fill: parent + drag.target: scrollSlider + drag.axis: Drag.YAxis + drag.minimumY: 0 + drag.maximumY: scrollBar.height - scrollSlider.height + } } } } From 7af9f879dd1f3e3b89ad805ab7e23d01747027bd Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 10 Mar 2017 21:44:20 +1300 Subject: [PATCH 12/35] Fix scrollbar and keyboard behavior --- .../qml/hifi/dialogs/content/AttachmentsContent.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml index bd6a2fecf9..4adb485c2b 100644 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml @@ -98,7 +98,9 @@ Item { } onCurrentIndexChanged: { - scrollSlider.y = currentIndex * (scrollBar.height - scrollSlider.height) / (listView.count - 1); + if (!yScrollTimer.running) { + scrollSlider.y = currentIndex * (scrollBar.height - scrollSlider.height) / (listView.count - 1); + } } onContentYChanged: { @@ -108,13 +110,14 @@ Item { Timer { id: yScrollTimer - interval: 50 + interval: 200 repeat: false running: false onTriggered: { - var index = listView.contentY / (scrollBar.height - scrollSlider.height); + var index = (listView.count - 1) * listView.contentY / (listView.contentHeight - scrollBar.height); index = Math.round(index); listView.currentIndex = index; + scrollSlider.y = index * (scrollBar.height - scrollSlider.height) / (listView.count - 1); } } } From d792559d9abc2b4adca943f994cde9f038ec9853 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Mar 2017 09:59:23 -0800 Subject: [PATCH 13/35] have edit.js resend properties of selected entity to entityProperties.js once it's ready --- scripts/system/edit.js | 7 +++++-- scripts/system/html/js/entityProperties.js | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 74080dbe09..55bd11b286 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1548,7 +1548,7 @@ var PropertiesTool = function (opts) { }); } - selectionManager.addEventListener(function (selectionUpdated) { + function updateSelections(selectionUpdated) { var data = { type: 'update' }; @@ -1589,7 +1589,8 @@ var PropertiesTool = function (opts) { } data.selections = selections; webView.emitScriptEvent(JSON.stringify(data)); - }); + } + selectionManager.addEventListener(updateSelections); webView.webEventReceived.connect(function (data) { try { @@ -1751,6 +1752,8 @@ var PropertiesTool = function (opts) { } } } + } else if (data.type === "propertiesPageReady") { + updateSelections(true); } }); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 4f774e5305..2f109597d7 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1704,4 +1704,8 @@ function loaded() { document.addEventListener("contextmenu", function(event) { event.preventDefault(); }, false); + + setTimeout(function() { + EventBridge.emitWebEvent(JSON.stringify({ type: 'propertiesPageReady' })); + }, 1000); } From 9b3810814e17426ca34786db09b34d43f5190581 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 10 Mar 2017 18:40:18 +0000 Subject: [PATCH 14/35] fiexed putting menu items on the hud when tablet not open when on desktop screen --- interface/src/Application.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 66d138103d..b575cb07b1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5793,12 +5793,12 @@ void Application::toggleRunningScriptsWidget() const { auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + auto hmd = DependencyManager::get(); if (tablet->getToolbarMode()) { static const QUrl url("hifi/dialogs/RunningScripts.qml"); DependencyManager::get()->show(url, "RunningScripts"); } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - if (!tabletRoot && !isHMDMode()) { + if (!hmd->getShouldShowTablet() && !isHMDMode()) { static const QUrl url("hifi/dialogs/RunningScripts.qml"); DependencyManager::get()->show(url, "RunningScripts"); } else { @@ -5835,12 +5835,11 @@ void Application::showAssetServerWidget(QString filePath) { }; auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - + auto hmd = DependencyManager::get(); if (tablet->getToolbarMode()) { DependencyManager::get()->show(url, "AssetServer", startUpload); } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - if (!tabletRoot && !isHMDMode()) { + if (!hmd->getShouldShowTablet() && !isHMDMode()) { DependencyManager::get()->show(url, "AssetServer", startUpload); } else { static const QUrl url("../../hifi/dialogs/TabletAssetServer.qml"); @@ -5873,7 +5872,8 @@ void Application::addAssetToWorldFromURL(QString url) { void Application::showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const { auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { + auto hmd = DependencyManager::get(); + if (tablet->getToolbarMode() || (!hmd->getShouldShowTablet() && !isHMDMode())) { DependencyManager::get()->show(desktopURL, name); } else { tablet->loadQMLSource(tabletURL); From b63ab05eec6495fbb5986f6082b8c72dc8b0cfa2 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 10 Mar 2017 19:33:14 +0000 Subject: [PATCH 15/35] improved general settting coloring --- .../tabletWindows/TabletPreferencesDialog.qml | 46 ++++--------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml index 95ce7f5a1d..e3138e8979 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml @@ -21,8 +21,8 @@ import "../../../controls-uit" as HifiControls Item { id: dialog - width: 480 - height: 720 + width: parent.width + height: parent.height HifiConstants { id: hifi } property var sections: [] @@ -31,6 +31,7 @@ Item { property bool keyboardEnabled: false property bool keyboardRaised: false property bool punctuationMode: false + property var tablet; @@ -68,22 +69,11 @@ Item { } z: 100 - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#1e1e1e" - } - } - + color: hifi.colors.darkGray RalewayBold { text: title size: 26 - color: "#34a2c7" + color: hifi.colors.white anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: hifi.dimensions.contentMargin.x @@ -99,17 +89,8 @@ Item { right: parent.right } - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#0f212e" - } - } + color: hifi.colors.baseGray + Flickable { id: scrollView width: parent.width @@ -203,17 +184,8 @@ Item { left: parent.left right: parent.right } - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#0f212e" - } - } + + color: hifi.colors.baseGray Row { anchors { From 88e74251a160fb8efb6e3b889abba32589bde61b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Mar 2017 12:51:34 -0800 Subject: [PATCH 16/35] cleanups --- scripts/system/tablet-ui/tabletUI.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index 263c8822df..3b15eb4edb 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -75,8 +75,9 @@ function showTabletUI() { tabletShown = true; - if (!tabletRezzed) { - rezTablet(false); + if (!tabletRezzed || !tabletIsValid()) { + closeTabletUI() + rezTablet(); } if (UIWebTablet && tabletRezzed) { @@ -199,7 +200,7 @@ preMakeTime = now; if (!tabletIsValid()) { closeTabletUI(); - rezTablet(false); + rezTablet(); tabletShown = false; } else if (!tabletShown) { hideTabletUI(); From 189eee01a6b2e8994db853886fc2f608bd332789 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 11:02:09 +1300 Subject: [PATCH 17/35] Refactor TabletComboBox.qml into ComboBox.qml --- .../resources/qml/controls-uit/ComboBox.qml | 23 +- .../qml/controls-uit/TabletComboBox.qml | 211 ------------------ .../qml/dialogs/TabletCustomQueryDialog.qml | 2 +- .../qml/dialogs/TabletFileDialog.qml | 2 +- .../qml/dialogs/TabletQueryDialog.qml | 2 +- .../qml/hifi/tablet/NewModelDialog.qml | 2 +- .../tablet/tabletWindows/TabletFileDialog.qml | 2 +- 7 files changed, 22 insertions(+), 222 deletions(-) delete mode 100644 interface/resources/qml/controls-uit/TabletComboBox.qml diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index 573fed4ef9..582e5f6d83 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -14,7 +14,6 @@ import QtQuick.Controls.Styles 1.4 import "../styles-uit" import "../controls-uit" as HifiControls -import "." as VrControls FocusScope { id: root @@ -32,6 +31,8 @@ FocusScope { readonly property ComboBox control: comboBox + property bool isDesktop: true + signal accepted(); implicitHeight: comboBox.height; @@ -119,11 +120,17 @@ FocusScope { } function showList() { - var r = desktop.mapFromItem(root, 0, 0, root.width, root.height); + var r; + if (isDesktop) { + r = desktop.mapFromItem(root, 0, 0, root.width, root.height); + } else { + r = mapFromItem(root, 0, 0, root.width, root.height); + } var y = r.y + r.height; var bottom = y + scrollView.height; - if (bottom > desktop.height) { - y -= bottom - desktop.height + 8; + var height = isDesktop ? desktop.height : tabletRoot.height; + if (bottom > height) { + y -= bottom - height + 8; } scrollView.x = r.x; scrollView.y = y; @@ -141,9 +148,9 @@ FocusScope { FocusScope { id: popup - parent: desktop + parent: isDesktop ? desktop : parent anchors.fill: parent - z: desktop.zLevels.menu + z: isDesktop ? desktop.zLevels.menu : 12 visible: false focus: true @@ -233,4 +240,8 @@ FocusScope { anchors.bottomMargin: 4 visible: label != "" } + + Component.onCompleted: { + isDesktop = (typeof desktop !== "undefined"); + } } diff --git a/interface/resources/qml/controls-uit/TabletComboBox.qml b/interface/resources/qml/controls-uit/TabletComboBox.qml deleted file mode 100644 index 7361833a45..0000000000 --- a/interface/resources/qml/controls-uit/TabletComboBox.qml +++ /dev/null @@ -1,211 +0,0 @@ -// -// ComboBox.qml -// -// Created by Dante Ruiz on 13 Feb 2017 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 - -import "../styles-uit" -import "../controls-uit" as HifiControls - -FocusScope { - id: root - HifiConstants { id: hifi } - - property alias model: comboBox.model; - property alias comboBox: comboBox - readonly property alias currentText: comboBox.currentText; - property alias currentIndex: comboBox.currentIndex; - - property int colorScheme: hifi.colorSchemes.light - readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light - property string label: "" - property real controlHeight: height + (comboBoxLabel.visible ? comboBoxLabel.height + comboBoxLabel.anchors.bottomMargin : 0) - - readonly property ComboBox control: comboBox - - signal accepted(); - - implicitHeight: comboBox.height; - focus: true - - Rectangle { - id: background - gradient: Gradient { - GradientStop { - position: 0.2 - color: popup.visible - ? (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark) - : (isLightColorScheme ? hifi.colors.dropDownLightStart : hifi.colors.dropDownDarkStart) - } - GradientStop { - position: 1.0 - color: popup.visible - ? (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark) - : (isLightColorScheme ? hifi.colors.dropDownLightFinish : hifi.colors.dropDownDarkFinish) - } - } - anchors.fill: parent - } - - SystemPalette { id: palette } - - ComboBox { - id: comboBox - anchors.fill: parent - visible: false - height: hifi.fontSizes.textFieldInput + 13 // Match height of TextField control. - } - - FiraSansSemiBold { - id: textField - anchors { - left: parent.left - leftMargin: hifi.dimensions.textPadding - right: dropIcon.left - verticalCenter: parent.verticalCenter - } - size: hifi.fontSizes.textFieldInput - text: comboBox.currentText - elide: Text.ElideRight - color: controlHover.containsMouse || popup.visible ? hifi.colors.baseGray : (isLightColorScheme ? hifi.colors.lightGray : hifi.colors.lightGrayText ) - } - - Item { - id: dropIcon - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - height: background.height - width: height - Rectangle { - width: 1 - height: parent.height - anchors.top: parent.top - anchors.left: parent.left - color: isLightColorScheme ? hifi.colors.faintGray : hifi.colors.baseGray - } - HiFiGlyphs { - anchors { - top: parent.top - topMargin: -11 - horizontalCenter: parent.horizontalCenter - } - size: hifi.dimensions.spinnerSize - text: hifi.glyphs.caratDn - color: controlHover.containsMouse || popup.visible ? hifi.colors.baseGray : (isLightColorScheme ? hifi.colors.lightGray : hifi.colors.lightGrayText) - } - } - - MouseArea { - id: controlHover - hoverEnabled: true - anchors.fill: parent - onClicked: toggleList(); - } - - function toggleList() { - if (popup.visible) { - hideList(); - } else { - showList(); - } - } - - function showList() { - var r = mapFromItem(root, 0, 0, root.width, root.height); - var y = r.y + r.height; - var bottom = y + scrollView.height; - if (bottom > 720) { - y -= bottom - tabletRoot.height + 8; - } - scrollView.x = r.x; - scrollView.y = y; - popup.visible = true; - popup.forceActiveFocus(); - listView.currentIndex = root.currentIndex; - scrollView.hoverEnabled = true; - } - - function hideList() { - popup.visible = false; - scrollView.hoverEnabled = false; - root.accepted(); - } - - FocusScope { - id: popup - z: 12 - parent: parent - anchors.fill: parent - visible: false - focus: true - - MouseArea { - anchors.fill: parent - onClicked: hideList(); - } - - function previousItem() { listView.currentIndex = (listView.currentIndex + listView.count - 1) % listView.count; } - function nextItem() { listView.currentIndex = (listView.currentIndex + listView.count + 1) % listView.count; } - function selectCurrentItem() { root.currentIndex = listView.currentIndex; hideList(); } - function selectSpecificItem(index) { root.currentIndex = index; hideList(); } - - Keys.onUpPressed: previousItem(); - Keys.onDownPressed: nextItem(); - Keys.onSpacePressed: selectCurrentItem(); - Keys.onRightPressed: selectCurrentItem(); - Keys.onReturnPressed: selectCurrentItem(); - Keys.onEscapePressed: hideList(); - - ScrollView { - id: scrollView - height: 480 - width: root.width + 4 - property bool hoverEnabled: false; - - ListView { - id: listView - height: textField.height * count * 1.4 - model: root.model - delegate: Rectangle { - width: root.width + 4 - height: popupText.implicitHeight * 1.4 - color: (listView.currentIndex === index) ? hifi.colors.primaryHighlight : - (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark) - FiraSansSemiBold { - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.textPadding - anchors.verticalCenter: parent.verticalCenter - id: popupText - text: listView.model[index] ? listView.model[index] : "" - size: hifi.fontSizes.textFieldInput - color: hifi.colors.baseGray - } - MouseArea { - id: popupHover - anchors.fill: parent; - hoverEnabled: scrollView.hoverEnabled; - onEntered: listView.currentIndex = index; - onClicked: popup.selectSpecificItem(index); - } - } - } - } - } - - HifiControls.Label { - id: comboBoxLabel - text: root.label - colorScheme: root.colorScheme - anchors.left: parent.left - anchors.bottom: parent.top - anchors.bottomMargin: 4 - visible: label != "" - } -} diff --git a/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml b/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml index 6e5bc50d32..3f6e07da4f 100644 --- a/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml +++ b/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml @@ -205,7 +205,7 @@ TabletModalWindow { // } } - ControlsUIT.TabletComboBox { + ControlsUIT.ComboBox { id: comboBoxField; label: root.comboBox.label; focus: Boolean(root.comboBox); diff --git a/interface/resources/qml/dialogs/TabletFileDialog.qml b/interface/resources/qml/dialogs/TabletFileDialog.qml index 4fecd4b523..5e33663436 100644 --- a/interface/resources/qml/dialogs/TabletFileDialog.qml +++ b/interface/resources/qml/dialogs/TabletFileDialog.qml @@ -149,7 +149,7 @@ TabletModalWindow { } } - TabletComboBox { + ComboBox { id: pathSelector z: 10 anchors { diff --git a/interface/resources/qml/dialogs/TabletQueryDialog.qml b/interface/resources/qml/dialogs/TabletQueryDialog.qml index 3ff3347ebc..e21677c12c 100644 --- a/interface/resources/qml/dialogs/TabletQueryDialog.qml +++ b/interface/resources/qml/dialogs/TabletQueryDialog.qml @@ -109,7 +109,7 @@ TabletModalWindow { } } - TabletComboBox { + ComboBox { id: comboBox label: root.label focus: true diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml index d57ffdc72f..2fa48cac07 100644 --- a/interface/resources/qml/hifi/tablet/NewModelDialog.qml +++ b/interface/resources/qml/hifi/tablet/NewModelDialog.qml @@ -107,7 +107,7 @@ Rectangle { font.pixelSize: 12 } - TabletComboBox { + ComboBox { id: collisionType width: 200 z: 100 diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml index a3e94152b8..26e35c4dcf 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml @@ -145,7 +145,7 @@ Item { } } - TabletComboBox { + ComboBox { id: pathSelector anchors { top: parent.top From 8a973dae3c077b7c5da386c0deb66a55d5ecf570 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 10 Mar 2017 23:21:29 +0000 Subject: [PATCH 18/35] fixed bring menu dialogs in tablet --- .../resources/qml/hifi/dialogs/TabletRunningScripts.qml | 1 + .../resources/qml/hifi/tablet/TabletAudioPreferences.qml | 2 +- .../resources/qml/hifi/tablet/TabletAvatarPreferences.qml | 2 +- .../resources/qml/hifi/tablet/TabletGeneralPreferences.qml | 5 +++-- interface/resources/qml/hifi/tablet/TabletMenuStack.qml | 2 +- .../qml/hifi/tablet/TabletNetworkingPreferences.qml | 2 +- interface/src/Application.cpp | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml b/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml index e217a6e38e..b4a1ab01b6 100644 --- a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml +++ b/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml @@ -20,6 +20,7 @@ import "../../windows" Rectangle { id: root objectName: "RunningScripts" + property var title: "Running Scripts" HifiConstants { id: hifi } signal sendToScript(var message); property var eventBridge; diff --git a/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml b/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml index efb7b5d50d..1c18c44a97 100644 --- a/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml @@ -19,7 +19,7 @@ StackView { id: profileRoot initialItem: root objectName: "stack" - + property var title: "Audio Preferences" property var eventBridge; signal sendToScript(var message); diff --git a/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml b/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml index f5c1ddf8f7..b29164a30f 100644 --- a/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml @@ -19,7 +19,7 @@ StackView { id: profileRoot initialItem: root objectName: "stack" - + property var title: "Avatar Preferences" property var eventBridge; signal sendToScript(var message); diff --git a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml index 4473a997e6..47e6a05f78 100644 --- a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml @@ -19,10 +19,11 @@ StackView { id: profileRoot initialItem: root objectName: "stack" - + property var title: "General Prefernces" + property var eventBridge; signal sendToScript(var message); - + function pushSource(path) { editRoot.push(Qt.reslovedUrl(path)); } diff --git a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml index a75a9fcd86..64d42acabb 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml @@ -51,7 +51,7 @@ Item { d.push(Qt.resolvedUrl(path)); d.currentItem.eventBridge = tabletMenu.eventBridge d.currentItem.sendToScript.connect(tabletMenu.sendToScript); - breadcrumbText.text = d.currentItem.objectName; + breadcrumbText.text = d.currentItem.title; } function popSource() { diff --git a/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml b/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml index 9b12d3c69e..f48d270646 100644 --- a/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml @@ -19,7 +19,7 @@ StackView { id: profileRoot initialItem: root objectName: "stack" - + property var title: "Network Preferences" property var eventBridge; signal sendToScript(var message); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b575cb07b1..6be36f18ac 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5876,7 +5876,7 @@ void Application::showDialog(const QString& desktopURL, const QString& tabletURL if (tablet->getToolbarMode() || (!hmd->getShouldShowTablet() && !isHMDMode())) { DependencyManager::get()->show(desktopURL, name); } else { - tablet->loadQMLSource(tabletURL); + tablet->pushOntoStack(tabletURL); } } From 713c50f2e860ba7947f7651b589a96a8a437b4cd Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 12:52:22 +1300 Subject: [PATCH 19/35] Fix attachments dialog joint dropdown in tablet --- interface/resources/qml/controls-uit/ComboBox.qml | 5 +++-- .../resources/qml/hifi/dialogs/attachments/Attachment.qml | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index 582e5f6d83..1cb1446658 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -24,6 +24,7 @@ FocusScope { readonly property alias currentText: comboBox.currentText; property alias currentIndex: comboBox.currentIndex; + property int dropdownHeight: 480 property int colorScheme: hifi.colorSchemes.light readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light property string label: "" @@ -148,7 +149,7 @@ FocusScope { FocusScope { id: popup - parent: isDesktop ? desktop : parent + parent: isDesktop ? desktop : root anchors.fill: parent z: isDesktop ? desktop.zLevels.menu : 12 visible: false @@ -173,7 +174,7 @@ FocusScope { ScrollView { id: scrollView - height: 480 + height: root.dropdownHeight width: root.width + 4 property bool hoverEnabled: false; diff --git a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml index 5c11a87d12..d10b8be58f 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml @@ -87,6 +87,7 @@ Item { } Item { + z: 1000 height: jointChooser.height + jointLabel.height + 4 anchors { left: parent.left; right: parent.right; } HifiControls.Label { @@ -97,6 +98,7 @@ Item { } HifiControls.ComboBox { id: jointChooser; + dropdownHeight: (typeof desktop !== "undefined") ? 480 : 206 anchors { bottom: parent.bottom; left: parent.left; right: parent.right } colorScheme: hifi.colorSchemes.dark currentIndex: attachment ? model.indexOf(attachment.jointName) : -1 From 25364c06286af1e9aa8a29bda836899f88ef2a3f Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 12:59:15 +1300 Subject: [PATCH 20/35] Make dropdown scrollbar wider --- interface/resources/qml/controls-uit/ComboBox.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index 1cb1446658..2dea535c06 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -186,18 +186,18 @@ FocusScope { visible: false } scrollBarBackground: Rectangle{ - implicitWidth: 14 + implicitWidth: 20 color: hifi.colors.baseGray } handle: Rectangle { - implicitWidth: 8 + implicitWidth: 16 anchors.left: parent.left anchors.leftMargin: 3 anchors.top: parent.top anchors.bottom: parent.bottom - radius: 3 + radius: 6 color: hifi.colors.lightGrayText } } From d261e48b9d11068865f5e81ca6dc1159dbf56d66 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 14:33:03 +1300 Subject: [PATCH 21/35] Use existing model browser dialog as base content --- .../{ModelBrowserDialog.qml => content/ModelBrowserContent.qml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename interface/resources/qml/hifi/dialogs/{ModelBrowserDialog.qml => content/ModelBrowserContent.qml} (100%) diff --git a/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml b/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml similarity index 100% rename from interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml rename to interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml From ffbb04d3bce5ac0a1d3e120a1c23729268702fc1 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 15:38:21 +1300 Subject: [PATCH 22/35] Tablet and desktop versions of attachment model browser dialog --- .../qml/hifi/dialogs/ModelBrowserDialog.qml | 36 +++++ .../hifi/dialogs/attachments/Attachment.qml | 21 ++- .../dialogs/content/ModelBrowserContent.qml | 124 +++++++----------- .../hifi/tablet/TabletModelBrowserDialog.qml | 78 +++++++++++ 4 files changed, 179 insertions(+), 80 deletions(-) create mode 100644 interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml create mode 100644 interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml diff --git a/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml b/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml new file mode 100644 index 0000000000..c427052904 --- /dev/null +++ b/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml @@ -0,0 +1,36 @@ +// +// ModelBrowserDialog.qml +// +// Created by David Rowe on 11 Mar 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import "../../windows" +import "content" + +ScrollingWindow { + id: root + objectName: "ModelBrowserDialog" + title: "Attachment Model" + resizable: true + width: 600 + height: 480 + closable: false + + //HifiConstants { id: hifi } + + property var result + + signal selected(var modelUrl) + signal canceled() + + ModelBrowserContent { + id: modelBrowserContent + } +} diff --git a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml index d10b8be58f..941d665b18 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml @@ -6,6 +6,7 @@ import Qt.labs.settings 1.0 import "." import ".." +import "../../tablet" import "../../../styles-uit" import "../../../controls-uit" as HifiControls import "../../../windows" @@ -76,12 +77,24 @@ Item { id: modelBrowserBuilder; ModelBrowserDialog {} } + Component { + id: tabletModelBrowserBuilder; + TabletModelBrowserDialog {} + } onClicked: { - var browser = modelBrowserBuilder.createObject(desktop); - browser.selected.connect(function(newModelUrl){ - modelUrl.text = newModelUrl; - }) + var browser; + if (typeof desktop !== "undefined") { + browser = modelBrowserBuilder.createObject(desktop); + browser.selected.connect(function(newModelUrl){ + modelUrl.text = newModelUrl; + }); + } else { + browser = tabletModelBrowserBuilder.createObject(tabletRoot); + browser.selected.connect(function(newModelUrl){ + modelUrl.text = newModelUrl; + }); + } } } } diff --git a/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml b/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml index 7a63c0604c..50fca94ff1 100644 --- a/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml +++ b/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml @@ -1,92 +1,64 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 -import QtQuick.XmlListModel 2.0 -import QtQuick.Controls.Styles 1.4 -import "../../windows" -import "../../js/Utils.js" as Utils -import "../models" +import "../../../controls-uit" as HifiControls -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" +Column { + width: pane.contentWidth -ScrollingWindow { - id: root - resizable: true - width: 600 - height: 480 - closable: false + Rectangle { + width: parent.width + height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) + color: hifi.colors.baseGray - property var result; + HifiControls.TextField { + id: filterEdit + anchors { left: parent.left; right: parent.right; top: parent.top ; margins: 8} + placeholderText: "filter" + onTextChanged: tableView.model.filter = text + colorScheme: hifi.colorSchemes.dark + } - signal selected(var modelUrl); - signal canceled(); - - HifiConstants {id: hifi} - - Column { - width: pane.contentWidth - - Rectangle { - width: parent.width - height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) - radius: 4 - color: hifi.colors.baseGray - - HifiControls.TextField { - id: filterEdit - anchors { left: parent.left; right: parent.right; top: parent.top ; margins: 8} - placeholderText: "filter" - onTextChanged: tableView.model.filter = text - colorScheme: hifi.colorSchemes.dark - } - - HifiControls.AttachmentsTable { - id: tableView - anchors { left: parent.left; right: parent.right; top: filterEdit.bottom; bottom: buttonRow.top; margins: 8; } - colorScheme: hifi.colorSchemes.dark - onCurrentRowChanged: { - if (currentRow == -1) { - root.result = null; - return; - } - result = model.baseUrl + "/" + model.get(tableView.currentRow).key; + HifiControls.AttachmentsTable { + id: tableView + anchors { left: parent.left; right: parent.right; top: filterEdit.bottom; bottom: buttonRow.top; margins: 8; } + colorScheme: hifi.colorSchemes.dark + onCurrentRowChanged: { + if (currentRow == -1) { + root.result = null; + return; } + result = model.baseUrl + "/" + model.get(tableView.currentRow).key; } + } - Row { - id: buttonRow - spacing: 8 - anchors { right: parent.right; rightMargin: 8; bottom: parent.bottom; bottomMargin: 8; } - HifiControls.Button { action: acceptAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } - HifiControls.Button { action: cancelAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } + Row { + id: buttonRow + spacing: 8 + anchors { right: parent.right; rightMargin: 8; bottom: parent.bottom; bottomMargin: 8; } + HifiControls.Button { action: acceptAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } + HifiControls.Button { action: cancelAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } + } + + Action { + id: acceptAction + text: qsTr("OK") + enabled: root.result ? true : false + shortcut: Qt.Key_Return + onTriggered: { + root.selected(root.result); + root.destroy(); } + } - Action { - id: acceptAction - text: qsTr("OK") - enabled: root.result ? true : false - shortcut: Qt.Key_Return - onTriggered: { - root.selected(root.result); - root.destroy(); - } - } - - Action { - id: cancelAction - text: qsTr("Cancel") - shortcut: Qt.Key_Escape - onTriggered: { - root.canceled(); - root.destroy(); - } + Action { + id: cancelAction + text: qsTr("Cancel") + shortcut: Qt.Key_Escape + onTriggered: { + root.canceled(); + root.destroy(); } } } } - - - - diff --git a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml new file mode 100644 index 0000000000..956e175f1e --- /dev/null +++ b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml @@ -0,0 +1,78 @@ +// +// TabletModelBrowserDialog.qml +// +// Created by David Rowe on 11 Mar 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import "../../styles-uit" +import "../dialogs/content" + +Item { + id: root + objectName: "ModelBrowserDialog" + + property string title: "Attachment Model" + + property var result + + signal selected(var modelUrl) + signal canceled() + + anchors.fill: parent + + Rectangle { + id: pane // Surrogate for ScrollingWindow's pane. + anchors.fill: parent + } + + anchors.topMargin: 90 // Space for header. + + // FIXME: Refactor with other tablet headers. + Rectangle { + id: header + height: 90 + anchors { + left: parent.left + right: parent.right + bottom: parent.top + } + z: 100 + + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + } + + GradientStop { + position: 1 + color: "#1e1e1e" + } + } + + RalewayBold { + text: title + size: 26 + color: "#34a2c7" + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: hifi.dimensions.contentMargin.x + } + } + + ModelBrowserContent { + anchors { + top: header.bottom + left: parent.left + right: parent.right + bottom: parent.top + } + } +} From 0a2976deab28aecfde0eef70828abdb727679f3b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 15:43:33 +1300 Subject: [PATCH 23/35] Add tablet keyboard --- .../hifi/tablet/TabletModelBrowserDialog.qml | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml index 956e175f1e..e098c59e4e 100644 --- a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml @@ -11,6 +11,7 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 +import "../../controls-uit" as HifiControls import "../../styles-uit" import "../dialogs/content" @@ -25,6 +26,10 @@ Item { signal selected(var modelUrl) signal canceled() + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + anchors.fill: parent Rectangle { @@ -72,7 +77,33 @@ Item { top: header.bottom left: parent.left right: parent.right - bottom: parent.top + bottom: keyboard.top } } + + HifiControls.Keyboard { + id: keyboard + raised: parent.keyboardEnabled && parent.keyboardRaised + numeric: parent.punctuationMode + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + } + + MouseArea { + id: activator + anchors.fill: parent + propagateComposedEvents: true + enabled: true + acceptedButtons: Qt.AllButtons + onPressed: { + mouse.accepted = false; + } + } + + Component.onCompleted: { + keyboardEnabled = HMD.active; + } } From 327e3c9973ecf8c809231bc51d25cfc676074c45 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 15:46:43 +1300 Subject: [PATCH 24/35] Don't expand height of higlighted row --- interface/resources/qml/controls-uit/AttachmentsTable.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/controls-uit/AttachmentsTable.qml b/interface/resources/qml/controls-uit/AttachmentsTable.qml index 7d0280b72d..8ee9909ab8 100644 --- a/interface/resources/qml/controls-uit/AttachmentsTable.qml +++ b/interface/resources/qml/controls-uit/AttachmentsTable.qml @@ -120,7 +120,7 @@ TableView { } rowDelegate: Rectangle { - height: (styleData.selected ? 1.2 : 1) * hifi.dimensions.tableRowHeight + height: hifi.dimensions.tableRowHeight color: styleData.selected ? hifi.colors.primaryHighlight : tableView.isLightColorScheme From 6a8d0b1064c94dbfa55e2b771be28f53fa1bcfe1 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 16:55:22 +1300 Subject: [PATCH 25/35] Refactor some tablet dialog headers --- .../qml/controls-uit/TabletHeader.qml | 45 +++++++++++++++++++ .../hifi/tablet/TabletAttachmentsDialog.qml | 30 ++----------- .../hifi/tablet/TabletModelBrowserDialog.qml | 30 ++----------- .../tabletWindows/TabletPreferencesDialog.qml | 27 ++--------- 4 files changed, 56 insertions(+), 76 deletions(-) create mode 100644 interface/resources/qml/controls-uit/TabletHeader.qml diff --git a/interface/resources/qml/controls-uit/TabletHeader.qml b/interface/resources/qml/controls-uit/TabletHeader.qml new file mode 100644 index 0000000000..f9482f995f --- /dev/null +++ b/interface/resources/qml/controls-uit/TabletHeader.qml @@ -0,0 +1,45 @@ +// +// TabletHeader.qml +// +// Created by David Rowe on 11 Mar 2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import "../styles-uit" + +Rectangle { + + property string title: "" + + HifiConstants { id: hifi } + + height: hifi.dimensions.tabletMenuHeader + z: 100 + + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + } + + GradientStop { + position: 1 + color: "#1e1e1e" + } + } + + RalewayBold { + text: title + size: 26 + color: "#34a2c7" + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: hifi.dimensions.contentMargin.x + } +} diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index dac43c9c3c..868b35398b 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -38,39 +38,17 @@ Item { Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); } - anchors.topMargin: 90 // Space for header. + anchors.topMargin: hifi.dimensions.tabletMenuHeader // Space for header. - // FIXME: Refactor with other tablet headers. - Rectangle { + HifiControls.TabletHeader { id: header - height: 90 + title: root.title + anchors { left: parent.left right: parent.right bottom: parent.top } - z: 100 - - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#1e1e1e" - } - } - - RalewayBold { - text: title - size: 26 - color: "#34a2c7" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.contentMargin.x - } } AttachmentsContent { diff --git a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml index e098c59e4e..60bd7a88e0 100644 --- a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml @@ -37,39 +37,17 @@ Item { anchors.fill: parent } - anchors.topMargin: 90 // Space for header. + anchors.topMargin: hifi.dimensions.tabletMenuHeader // Space for header. - // FIXME: Refactor with other tablet headers. - Rectangle { + HifiControls.TabletHeader { id: header - height: 90 + title: parent.title + anchors { left: parent.left right: parent.right bottom: parent.top } - z: 100 - - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#1e1e1e" - } - } - - RalewayBold { - text: title - size: 26 - color: "#34a2c7" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.contentMargin.x - } } ModelBrowserContent { diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml index 95ce7f5a1d..c76735cb3c 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml @@ -58,36 +58,15 @@ Item { Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); } - Rectangle { + HifiControls.TabletHeader { id: header - height: 90 + title: parent.title + anchors { top: parent.top left: parent.left right: parent.right } - z: 100 - - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#1e1e1e" - } - } - - RalewayBold { - text: title - size: 26 - color: "#34a2c7" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.contentMargin.x - } } Rectangle { From 0fc45799ed1c8e768124110e8bb1fcd2f0ae4aa6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 11 Mar 2017 17:04:55 +1300 Subject: [PATCH 26/35] Remove redundant keyboard handling code --- .../resources/qml/hifi/dialogs/AttachmentsDialog.qml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml index 66338666cf..12e8de3bfc 100644 --- a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml +++ b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml @@ -41,15 +41,4 @@ ScrollingWindow { } AttachmentsContent { } - - onKeyboardRaisedChanged: { - if (keyboardEnabled && keyboardRaised) { - var buttonHeight = 40; // Allow for New Attachment button. - var keyboardRaisedHeight = 200; - var delta = activator.mouseY - (root.height - keyboardRaisedHeight - buttonHeight); - if (delta > 0) { - content.scrollBy(delta); - } - } - } } From 9f7c5a16033d4341ef13e67e4e8a4f25ae3818cf Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 11 Mar 2017 11:54:44 +0100 Subject: [PATCH 27/35] Add LOD settings to Tablet UI --- .../qml/hifi/tablet/TabletLodPreferences.qml | 34 +++++++++++++++++++ interface/src/Menu.cpp | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 interface/resources/qml/hifi/tablet/TabletLodPreferences.qml diff --git a/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml b/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml new file mode 100644 index 0000000000..8f03bdb0c5 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml @@ -0,0 +1,34 @@ +import QtQuick 2.5 +import Qt.labs.settings 1.0 + +import "tabletWindows" +import "../../dialogs" +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 +import QtGraphicalEffects 1.0 + +StackView { + id: profileRoot + initialItem: root + objectName: "stack" + + property var eventBridge; + signal sendToScript(var message); + + function pushSource(path) { + editRoot.push(Qt.reslovedUrl(path)); + } + + function popSource() { + + } + + TabletPreferencesDialog { + id: root + property string title: "LOD Settings" + objectName: "TabletLodPreferences" + width: parent.width + height: parent.height + showCategories: ["Level of Detail Tuning"] + } +} diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 241f908190..7eb5f4ea60 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -308,7 +308,8 @@ Menu::Menu() { // Settings > LOD... action = addActionToQMenuAndActionHash(settingsMenu, "LOD..."); connect(action, &QAction::triggered, [] { - DependencyManager::get()->toggle(QString("hifi/dialogs/LodPreferencesDialog.qml"), "LodPreferencesDialog"); + qApp->showDialog(QString("hifi/dialogs/LodPreferencesDialog.qml"), + QString("../../hifi/tablet/TabletLodPreferences.qml"), "LodPreferencesDialog"); }); // Settings > Control with Speech [advanced] From 81bc56f124fb0e507e5852c5d9a7b1584bb6b296 Mon Sep 17 00:00:00 2001 From: Vladyslav Stelmakhovskyi Date: Sat, 11 Mar 2017 14:44:33 +0100 Subject: [PATCH 28/35] Fixed slider groove size calculation. Added LOD Tools to Tablet UI --- .../resources/qml/controls-uit/Slider.qml | 2 +- .../qml/hifi/dialogs/TabletLODTools.qml | 119 ++++++++++++++++++ interface/src/Application.cpp | 12 ++ interface/src/Application.h | 1 + interface/src/Menu.cpp | 3 +- interface/src/ui/overlays/Web3DOverlay.cpp | 2 + 6 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 interface/resources/qml/hifi/dialogs/TabletLODTools.qml diff --git a/interface/resources/qml/controls-uit/Slider.qml b/interface/resources/qml/controls-uit/Slider.qml index cf59e1d989..39831546e1 100644 --- a/interface/resources/qml/controls-uit/Slider.qml +++ b/interface/resources/qml/controls-uit/Slider.qml @@ -36,7 +36,7 @@ Slider { Rectangle { width: parent.height - 2 - height: slider.value * slider.width - 1 + height: slider.value * (slider.width/(slider.maximumValue - slider.minimumValue)) - 1 radius: height / 2 anchors { top: parent.top diff --git a/interface/resources/qml/hifi/dialogs/TabletLODTools.qml b/interface/resources/qml/hifi/dialogs/TabletLODTools.qml new file mode 100644 index 0000000000..26e9759e0d --- /dev/null +++ b/interface/resources/qml/hifi/dialogs/TabletLODTools.qml @@ -0,0 +1,119 @@ +// +// TabletLODTools.qml +// +// Created by Vlad Stelmahovsky on 3/11/17 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import Qt.labs.settings 1.0 + +import "../../styles-uit" +import "../../controls-uit" as HifiControls +import "../../windows" + +Rectangle { + id: root + objectName: "LODTools" + + property var eventBridge; + signal sendToScript(var message); + property bool isHMD: false + + color: hifi.colors.baseGray + + property int colorScheme: hifi.colorSchemes.dark + + HifiConstants { id: hifi } + + readonly property real treeScale: 32768; // ~20 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe + readonly property real halfTreeScale: treeScale / 2; + + // This controls the LOD. Larger number will make smaller voxels visible at greater distance. + readonly property real defaultOctreeSizeScale: treeScale * 400.0 + + Column { + anchors.margins: 10 + anchors.left: parent.left + anchors.right: parent.right + y: hifi.dimensions.tabletMenuHeader //-bgNavBar + spacing: 20 + + HifiControls.Label { + size: 20 + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("You can see...") + colorScheme: root.colorScheme + } + HifiControls.Label { + id: whatYouCanSeeLabel + color: "red" + size: 20 + anchors.left: parent.left + anchors.right: parent.right + colorScheme: root.colorScheme + } + Row { + anchors.left: parent.left + anchors.right: parent.right + spacing: 10 + + HifiControls.Label { + size: 20 + text: qsTr("Manually Adjust Level of Detail:") + anchors.verticalCenter: parent.verticalCenter + colorScheme: root.colorScheme + } + + HifiControls.CheckBox { + id: adjustCheckbox + boxSize: 20 + anchors.verticalCenter: parent.verticalCenter + onCheckedChanged: LODManager.setAutomaticLODAdjust(!checked); + } + } + + HifiControls.Label { + size: 20 + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("Level of Detail:") + colorScheme: root.colorScheme + } + HifiControls.Slider { + id: slider + enabled: adjustCheckbox.checked + anchors.left: parent.left + anchors.right: parent.right + minimumValue: 5 + maximumValue: 2000 + value: LODManager.getOctreeSizeScale() / treeScale + tickmarksEnabled: false + onValueChanged: { + LODManager.setOctreeSizeScale(value * treeScale); + whatYouCanSeeLabel.text = LODManager.getLODFeedbackText() + } + } + + HifiControls.Button { + id: uploadButton + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("Reset") + color: hifi.buttons.blue + colorScheme: root.colorScheme + height: 30 + onClicked: { + slider.value = defaultOctreeSizeScale/treeScale + adjustCheckbox.checked = false + LODManager.setAutomaticLODAdjust(adjustCheckbox.checked); + } + } + } +} + diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 27dd65ab8d..94a71e01b0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6363,6 +6363,18 @@ void Application::loadScriptURLDialog() const { } } +void Application::loadLODToolsDialog() { + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { + auto dialogsManager = DependencyManager::get(); + dialogsManager->lodTools(); + } else { + tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml"); + } + +} + void Application::toggleLogDialog() { if (! _logDialog) { _logDialog = new LogDialog(nullptr, getLogger()); diff --git a/interface/src/Application.h b/interface/src/Application.h index 9fab4aef81..5c72f0fa90 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -403,6 +403,7 @@ public slots: void addAssetToWorldMessageClose(); Q_INVOKABLE void toggleMuteAudio(); + void loadLODToolsDialog(); private slots: void showDesktop(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 241f908190..dcbcfed6a0 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -408,7 +408,8 @@ Menu::Menu() { // Developer > Render > LOD Tools - addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, dialogsManager.data(), SLOT(lodTools())); + addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, + qApp, SLOT(loadLODToolsDialog())); // HACK enable texture decimation { diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 32fe26a697..de0218843a 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -43,6 +43,7 @@ #include "FileDialogHelper.h" #include "avatar/AvatarManager.h" #include "AudioClient.h" +#include "LODManager.h" static const float DPI = 30.47f; static const float INCHES_TO_METERS = 1.0f / 39.3701f; @@ -182,6 +183,7 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Assets", DependencyManager::get().data()); + _webSurface->getRootContext()->setContextProperty("LODManager", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); From 05e4c2a1bb32831a4340304e402a06c11e28e718 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 12 Mar 2017 09:59:52 +1300 Subject: [PATCH 29/35] MyAvatar is available in tablet now --- .../resources/qml/dialogs/preferences/AvatarPreference.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml index 53d36b6c79..0c5c5bf630 100644 --- a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml +++ b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml @@ -23,10 +23,7 @@ Preference { Component.onCompleted: { dataTextField.text = preference.value; - // FIXME: MyAvatar object isn't available in HMD mode for some reason. - if (typeof MyAvatar !== "undefined") { - console.log("MyAvatar modelName " + MyAvatar.getFullAvatarModelName()) - } + console.log("MyAvatar modelName " + MyAvatar.getFullAvatarModelName()) console.log("Application : " + ApplicationInterface) ApplicationInterface.fullAvatarURLChanged.connect(processNewAvatar); } From 40b7e34c0be04b4a0c905a2b8734e631a2719775 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 13 Mar 2017 14:23:13 -0700 Subject: [PATCH 30/35] Fix for visible empty toolbar when switching from desktop to HMD mode. --- interface/resources/qml/hifi/toolbars/Toolbar.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/toolbars/Toolbar.qml b/interface/resources/qml/hifi/toolbars/Toolbar.qml index c0d984e822..f80e0f8c14 100644 --- a/interface/resources/qml/hifi/toolbars/Toolbar.qml +++ b/interface/resources/qml/hifi/toolbars/Toolbar.qml @@ -120,8 +120,6 @@ Window { function addButton(properties) { properties = properties || {} - unpinnedAlpha = 1; - // If a name is specified, then check if there's an existing button with that name // and return it if so. This will allow multiple clients to listen to a single button, // and allow scripts to be idempotent so they don't duplicate buttons if they're reloaded @@ -156,7 +154,7 @@ Window { updatePinned(); if (buttons.length === 0) { - unpinnedAlpha = 0; + fadeOut(function () {}); } } From 01c313ad60e253d42920912845ff25e079d81053 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Mar 2017 13:33:20 +1300 Subject: [PATCH 31/35] Fix QML errors --- .../resources/qml/hifi/tablet/TabletAttachmentsDialog.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml index 868b35398b..634c9d41ec 100644 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml @@ -25,6 +25,9 @@ Item { property bool keyboardRaised: false property bool punctuationMode: false + property var eventBridge; + signal sendToScript(var message); + anchors.fill: parent HifiConstants { id: hifi } From 7504c124e40f3d86953951651bd0a7b3a8dfc7d8 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Mar 2017 13:34:06 +1300 Subject: [PATCH 32/35] Make attachment model browser dialog modal --- .../resources/qml/hifi/dialogs/attachments/Attachment.qml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml index 941d665b18..0e98f79216 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml @@ -93,7 +93,14 @@ Item { browser = tabletModelBrowserBuilder.createObject(tabletRoot); browser.selected.connect(function(newModelUrl){ modelUrl.text = newModelUrl; + tabletRoot.openModal = null; }); + browser.canceled.connect(function() { + tabletRoot.openModal = null; + }); + + // Make dialog modal. + tabletRoot.openModal = browser; } } } From f3a99a2437c45cf752c7203fc89d3e1f56fa844d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Mar 2017 15:36:51 +1300 Subject: [PATCH 33/35] Implement avatar browser for tablet avatar settings --- .../dialogs/preferences/AvatarPreference.qml | 26 ++++-- .../preferences/TabletAvatarBrowser.qml | 79 +++++++++++++++++++ 2 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml diff --git a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml index 0c5c5bf630..848dd3c6e9 100644 --- a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml +++ b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml @@ -10,8 +10,8 @@ import QtQuick 2.5 -import "../../dialogs" import "../../controls-uit" +import "../../hifi/tablet/tabletWindows/preferences" Preference { id: root @@ -82,12 +82,26 @@ Preference { verticalCenter: dataTextField.verticalCenter } onClicked: { - // Load dialog via OffscreenUi so that JavaScript EventBridge is available. - root.browser = OffscreenUi.load("dialogs/preferences/AvatarBrowser.qml"); - root.browser.windowDestroyed.connect(function(){ - root.browser = null; - }); + if (typeof desktop !== "undefined") { + // Load dialog via OffscreenUi so that JavaScript EventBridge is available. + root.browser = OffscreenUi.load("dialogs/preferences/AvatarBrowser.qml"); + root.browser.windowDestroyed.connect(function(){ + root.browser = null; + }); + } else { + root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot, { + createGlobalEventBridgeSource: eventBridgeJavaScriptToInject + }); + + // Make dialog modal. + tabletRoot.openModal = root.browser; + } } } + + Component { + id: tabletAvatarBrowserBuilder; + TabletAvatarBrowser { } + } } } diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml new file mode 100644 index 0000000000..57ef7b5933 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml @@ -0,0 +1,79 @@ +// +// TabletAvatarBrowser.qml +// +// Created by David Rowe on 14 Mar 2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import QtQuick.Controls 1.4 +import QtWebChannel 1.0 +import QtWebEngine 1.2 + +import "../../../../windows" +import "../../../../controls-uit" +import "../../../../styles-uit" + +Item { + id: root + objectName: "ModelBrowserDialog" + + property string title: "Attachment Model" + + property var result + + signal selected(var modelUrl) + signal canceled() + + anchors.fill: parent + + /* + Rectangle { + id: pane // Surrogate for ScrollingWindow's pane. + anchors.fill: parent + } + */ + + BaseWebView { + id: webview + url: "https://metaverse.highfidelity.com/marketplace?category=avatars" + focus: true + + anchors { + top: parent.top + left: parent.left + right: parent.right + bottom: footer.top + } + } + + Rectangle { + id: footer + height: 40 + + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + + color: hifi.colors.baseGray + + Row { + anchors { + verticalCenter: parent.verticalCenter + right: parent.right + rightMargin: hifi.dimensions.contentMargin.x + } + + Button { + text: "Cancel" + color: hifi.buttons.white + onClicked: root.destroy(); + } + } + } +} From d141d5b683badfa9492f191333c49e510049a73d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Mar 2017 21:36:57 +1300 Subject: [PATCH 34/35] Add keyboard --- .../dialogs/preferences/AvatarPreference.qml | 8 +-- .../preferences/TabletAvatarBrowser.qml | 58 ++++++++++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml index 848dd3c6e9..7ae4fe6761 100644 --- a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml +++ b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml @@ -89,9 +89,7 @@ Preference { root.browser = null; }); } else { - root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot, { - createGlobalEventBridgeSource: eventBridgeJavaScriptToInject - }); + root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot); // Make dialog modal. tabletRoot.openModal = root.browser; @@ -101,7 +99,9 @@ Preference { Component { id: tabletAvatarBrowserBuilder; - TabletAvatarBrowser { } + TabletAvatarBrowser { + eventBridge: tabletRoot.eventBridge + } } } } diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml index 57ef7b5933..8c415f5ebb 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml @@ -25,17 +25,16 @@ Item { property var result + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + signal selected(var modelUrl) signal canceled() - anchors.fill: parent + property alias eventBridge: eventBridgeWrapper.eventBridge - /* - Rectangle { - id: pane // Surrogate for ScrollingWindow's pane. - anchors.fill: parent - } - */ + anchors.fill: parent BaseWebView { id: webview @@ -48,6 +47,32 @@ Item { right: parent.right bottom: footer.top } + + QtObject { + id: eventBridgeWrapper + WebChannel.id: "eventBridgeWrapper" + property var eventBridge; + } + + webChannel.registeredObjects: [eventBridgeWrapper] + + // Create a global EventBridge object for raiseAndLowerKeyboard. + WebEngineScript { + id: createGlobalEventBridge + sourceCode: eventBridgeJavaScriptToInject + injectionPoint: WebEngineScript.DocumentCreation + worldId: WebEngineScript.MainWorld + } + + // Detect when may want to raise and lower keyboard. + WebEngineScript { + id: raiseAndLowerKeyboard + injectionPoint: WebEngineScript.Deferred + sourceUrl: resourceDirectoryUrl + "html/raiseAndLowerKeyboard.js" + worldId: WebEngineScript.MainWorld + } + + userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ] } Rectangle { @@ -57,7 +82,7 @@ Item { anchors { left: parent.left right: parent.right - bottom: parent.bottom + bottom: keyboard.top } color: hifi.colors.baseGray @@ -76,4 +101,21 @@ Item { } } } + + Keyboard { + id: keyboard + + raised: parent.keyboardEnabled && parent.keyboardRaised + numeric: parent.punctuationMode + + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + } + } + + Component.onCompleted: { + keyboardEnabled = HMD.active; + } } From 43687d4773f4a423ba1c2b3fdca10d8db6ac3557 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 14 Mar 2017 21:41:04 +1300 Subject: [PATCH 35/35] Tidying --- .../tablet/tabletWindows/preferences/TabletAvatarBrowser.qml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml index 8c415f5ebb..029cf7d46b 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml @@ -23,15 +23,10 @@ Item { property string title: "Attachment Model" - property var result - property bool keyboardEnabled: false property bool keyboardRaised: false property bool punctuationMode: false - signal selected(var modelUrl) - signal canceled() - property alias eventBridge: eventBridgeWrapper.eventBridge anchors.fill: parent