From 1fc6d824560b47943f360f052c378e6bb37addab Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 9 Mar 2017 13:04:57 +1300 Subject: [PATCH] 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());