diff --git a/interface/resources/images/backward.svg b/interface/resources/images/backward.svg index e4502fa80e..a913ad9cd0 100644 --- a/interface/resources/images/backward.svg +++ b/interface/resources/images/backward.svg @@ -1,6 +1,6 @@ - - - - - - - + + + + diff --git a/interface/resources/images/forward.svg b/interface/resources/images/forward.svg index 0c5cbe3d0c..dde9322b9e 100644 --- a/interface/resources/images/forward.svg +++ b/interface/resources/images/forward.svg @@ -1,6 +1,6 @@ - - - - - - - + + + + diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index ab28b84a3d..ece00bd0dd 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -20,8 +20,10 @@ import "../toolbars" import "../../styles-uit" as HifiStyles import "../../controls-uit" as HifiControls +// references HMD, AddressManager, AddressBarDialog from root context + StackView { - id: root + id: root; HifiConstants { id: hifi } HifiStyles.HifiConstants { id: hifiStyleConstants } initialItem: addressBarDialog @@ -34,24 +36,16 @@ StackView { property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/"; property var tablet: null; - property bool isDesktop: false; Component { id: tabletWebView; TabletWebView {} } Component.onCompleted: { - root.currentItem.focus = true; - root.currentItem.forceActiveFocus(); - addressLine.focus = true; - addressLine.forceActiveFocus(); fillDestinations(); updateLocationText(false); + fillDestinations(); + addressLine.focus = !HMD.active; root.parentChanged.connect(center); center(); - isDesktop = (typeof desktop !== "undefined"); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - - if (desktop) { - root.title = "GOTO"; - } } Component.onDestruction: { root.parentChanged.disconnect(center); @@ -78,8 +72,6 @@ StackView { toggleOrGo(true, targetString); clearAddressLineTimer.start(); } - - property bool isCursorVisible: false // Override default cursor visibility. AddressBarDialog { @@ -102,16 +94,11 @@ StackView { onMetaverseServerUrlChanged: updateLocationTextTimer.start(); Rectangle { id: navBar - width: 480 - height: 70 + width: parent.width + height: 50; color: hifiStyleConstants.colors.white - anchors { - top: parent.top - right: parent.right - rightMargin: 0 - left: parent.left - leftMargin: 0 - } + anchors.top: parent.top; + anchors.left: parent.left; ToolbarButton { id: homeButton @@ -129,8 +116,14 @@ StackView { } ToolbarButton { id: backArrow; + buttonState: addressBarDialog.backEnabled; imageURL: "../../../images/backward.svg"; - onClicked: addressBarDialog.loadBack(); + buttonEnabled: addressBarDialog.backEnabled; + onClicked: { + if (buttonEnabled) { + addressBarDialog.loadBack(); + } + } anchors { left: homeButton.right verticalCenter: parent.verticalCenter @@ -138,8 +131,14 @@ StackView { } ToolbarButton { id: forwardArrow; + buttonState: addressBarDialog.forwardEnabled; imageURL: "../../../images/forward.svg"; - onClicked: addressBarDialog.loadForward(); + buttonEnabled: addressBarDialog.forwardEnabled; + onClicked: { + if (buttonEnabled) { + addressBarDialog.loadForward(); + } + } anchors { left: backArrow.right verticalCenter: parent.verticalCenter @@ -149,85 +148,80 @@ StackView { Rectangle { id: addressBar - width: 480 + width: parent.width height: 70 color: hifiStyleConstants.colors.white anchors { - top: navBar.bottom - right: parent.right - rightMargin: 16 - left: parent.left - leftMargin: 16 + top: navBar.bottom; + left: parent.left; } - property int inputAreaHeight: 70 - property int inputAreaStep: (height - inputAreaHeight) / 2 - HifiStyles.RalewayLight { id: notice; - font.pixelSize: hifi.fonts.pixelSize * 0.50; + font.pixelSize: hifi.fonts.pixelSize * 0.7; anchors { - top: parent.top - topMargin: parent.inputAreaStep + 12 - left: addressLine.left - right: addressLine.right + top: parent.top; + left: addressLineContainer.left; + right: addressLineContainer.right; } } + HifiStyles.FiraSansRegular { id: location; + anchors { + left: addressLineContainer.left; + leftMargin: 8; + verticalCenter: addressLineContainer.verticalCenter; + } font.pixelSize: addressLine.font.pixelSize; color: "gray"; clip: true; - anchors.fill: addressLine; visible: addressLine.text.length === 0 } TextInput { id: addressLine - focus: true + width: addressLineContainer.width - addressLineContainer.anchors.leftMargin - addressLineContainer.anchors.rightMargin; anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - leftMargin: 16 - rightMargin: 16 - topMargin: parent.inputAreaStep + (2 * hifi.layout.spacing) - bottomMargin: parent.inputAreaStep + left: addressLineContainer.left; + leftMargin: 8; + verticalCenter: addressLineContainer.verticalCenter; } font.pixelSize: hifi.fonts.pixelSize * 0.75 - cursorVisible: false onTextChanged: { filterChoicesByText(); updateLocationText(text.length > 0); - if (!isCursorVisible && text.length > 0) { - isCursorVisible = true; - cursorVisible = true; - } } onAccepted: { addressBarDialog.keyboardEnabled = false; - } - onActiveFocusChanged: { - cursorVisible = isCursorVisible && focus; - } - MouseArea { - // If user clicks in address bar show cursor to indicate ability to enter address. - anchors.fill: parent - onClicked: { - isCursorVisible = true; - parent.cursorVisible = true; - parent.focus = true; - parent.forceActiveFocus(); - addressBarDialog.keyboardEnabled = HMD.active - tabletRoot.playButtonClickSound(); - } + toggleOrGo(); } } Rectangle { - anchors.fill: addressLine + id: addressLineContainer; + height: 40; + anchors { + top: notice.bottom; + topMargin: 2; + left: parent.left; + leftMargin: 16; + right: parent.right; + rightMargin: 16; + } color: hifiStyleConstants.colors.lightGray opacity: 0.1 + MouseArea { + anchors.fill: parent; + onClicked: { + if (!addressLine.focus || !HMD.active) { + addressLine.focus = true; + addressLine.forceActiveFocus(); + addressBarDialog.keyboardEnabled = HMD.active; + } + tabletRoot.playButtonClickSound(); + } + } } } Rectangle { @@ -347,13 +341,12 @@ StackView { Timer { // Delay clearing address line so as to avoid flicker of "not connected" being displayed after entering an address. - id: clearAddressLineTimer - running: false - interval: 100 // ms - repeat: false + id: clearAddressLineTimer; + running: false; + interval: 100; // ms + repeat: false; onTriggered: { addressLine.text = ""; - isCursorVisible = false; } } @@ -535,7 +528,7 @@ StackView { function updateLocationText(enteringAddress) { if (enteringAddress) { - notice.text = "Go to a place, @user, path or network address"; + notice.text = "Go To a place, @user, path, or network address:"; notice.color = hifiStyleConstants.colors.baseGrayHighlight; } else { notice.text = AddressManager.isConnected ? "Your location:" : "Not Connected"; @@ -545,46 +538,14 @@ StackView { } } - onVisibleChanged: { - updateLocationText(false); - if (visible) { - addressLine.forceActiveFocus(); - fillDestinations(); - } - } - function toggleOrGo(fromSuggestions, address) { if (address !== undefined && address !== "") { - addressBarDialog.loadAddress(address, fromSuggestions) - } - - if (addressLine.text !== "") { - addressBarDialog.loadAddress(addressLine.text, fromSuggestions) - } - - if (isDesktop) { - tablet.gotoHomeScreen(); - } else { - HMD.closeTablet(); - } - - tabletRoot.shown = false; - } - - Keys.onPressed: { - switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - tabletRoot.shown = false - clearAddressLineTimer.start(); - event.accepted = true - break - case Qt.Key_Enter: - case Qt.Key_Return: - toggleOrGo() - clearAddressLineTimer.start(); - event.accepted = true - break + addressBarDialog.loadAddress(address, fromSuggestions); + clearAddressLineTimer.start(); + } else if (addressLine.text !== "") { + addressBarDialog.loadAddress(addressLine.text, fromSuggestions); + clearAddressLineTimer.start(); } + DialogsManager.hideAddressBar(); } } diff --git a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml index cab5b14d5c..3d4231ced7 100644 --- a/interface/resources/qml/hifi/toolbars/ToolbarButton.qml +++ b/interface/resources/qml/hifi/toolbars/ToolbarButton.qml @@ -3,6 +3,8 @@ import QtQuick.Controls 1.4 StateImage { id: button + + property bool buttonEnabled: true property bool isActive: false property bool isEntered: false @@ -39,30 +41,37 @@ StateImage { } function updateState() { - if (!button.isEntered && !button.isActive) { - buttonState = imageOffOut; - } else if (!button.isEntered && button.isActive) { - buttonState = imageOnOut; - } else if (button.isEntered && !button.isActive) { - buttonState = imageOffIn; + if (buttonEnabled) { + if (!button.isEntered && !button.isActive) { + buttonState = imageOffOut; + } else if (!button.isEntered && button.isActive) { + buttonState = imageOnOut; + } else if (button.isEntered && !button.isActive) { + buttonState = imageOffIn; + } else { + buttonState = imageOnIn; + } } else { - buttonState = imageOnIn; + buttonState = 0; } } onIsActiveChanged: updateState(); + onButtonEnabledChanged: updateState(); Timer { id: asyncClickSender interval: 10 repeat: false running: false - onTriggered: button.clicked(); + onTriggered: { + button.clicked(); + } } MouseArea { id: mouseArea - hoverEnabled: true + hoverEnabled: buttonEnabled anchors.fill: parent onClicked: asyncClickSender.start(); onEntered: { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index c6cd185034..88278034d0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1420,11 +1420,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(DependencyManager::get().data(), &AudioClient::mutedByMixer, this, onMutedByMixer); // Track when the address bar is opened - auto onAddressBarToggled = [this]() { + auto onAddressBarShown = [this]() { // Record time UserActivityLogger::getInstance().logAction("opened_address_bar", { { "uptime_ms", _sessionRunTimer.elapsed() } }); }; - connect(DependencyManager::get().data(), &DialogsManager::addressBarToggled, this, onAddressBarToggled); + connect(DependencyManager::get().data(), &DialogsManager::addressBarShown, this, onAddressBarShown); // Make sure we don't time out during slow operations at startup updateHeartbeat(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 23d689e339..2451f42bca 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -254,7 +254,7 @@ Menu::Menu() { // Navigate > Show Address Bar addActionToQMenuAndActionHash(navigateMenu, MenuOption::AddressBar, Qt::CTRL | Qt::Key_L, - dialogsManager.data(), SLOT(toggleAddressBar())); + dialogsManager.data(), SLOT(showAddressBar())); // Navigate > Bookmark related menus -- Note: the Bookmark class adds its own submenus here. qApp->getBookmarks()->setupMenus(this, navigateMenu); diff --git a/interface/src/scripting/DialogsManagerScriptingInterface.cpp b/interface/src/scripting/DialogsManagerScriptingInterface.cpp index 1604c45593..0fb6078290 100644 --- a/interface/src/scripting/DialogsManagerScriptingInterface.cpp +++ b/interface/src/scripting/DialogsManagerScriptingInterface.cpp @@ -16,15 +16,24 @@ #include "ui/DialogsManager.h" DialogsManagerScriptingInterface::DialogsManagerScriptingInterface() { - connect(DependencyManager::get().data(), &DialogsManager::addressBarToggled, - this, &DialogsManagerScriptingInterface::addressBarToggled); connect(DependencyManager::get().data(), &DialogsManager::addressBarShown, this, &DialogsManagerScriptingInterface::addressBarShown); } -void DialogsManagerScriptingInterface::toggleAddressBar() { + +DialogsManagerScriptingInterface* DialogsManagerScriptingInterface::getInstance() { + static DialogsManagerScriptingInterface sharedInstance; + return &sharedInstance; +} + +void DialogsManagerScriptingInterface::showAddressBar() { QMetaObject::invokeMethod(DependencyManager::get().data(), - "toggleAddressBar", Qt::QueuedConnection); + "showAddressBar", Qt::QueuedConnection); +} + +void DialogsManagerScriptingInterface::hideAddressBar() { + QMetaObject::invokeMethod(DependencyManager::get().data(), + "hideAddressBar", Qt::QueuedConnection); } void DialogsManagerScriptingInterface::showFeed() { diff --git a/interface/src/scripting/DialogsManagerScriptingInterface.h b/interface/src/scripting/DialogsManagerScriptingInterface.h index 86cd22af1c..e4dd18aedf 100644 --- a/interface/src/scripting/DialogsManagerScriptingInterface.h +++ b/interface/src/scripting/DialogsManagerScriptingInterface.h @@ -18,13 +18,14 @@ class DialogsManagerScriptingInterface : public QObject { Q_OBJECT public: DialogsManagerScriptingInterface(); + static DialogsManagerScriptingInterface* getInstance(); Q_INVOKABLE void showFeed(); public slots: - void toggleAddressBar(); + void showAddressBar(); + void hideAddressBar(); signals: - void addressBarToggled(); void addressBarShown(bool visible); }; diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index a95ac8d91f..96b5da3a55 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -46,49 +46,32 @@ void DialogsManager::maybeCreateDialog(QPointer& member) { } } -void DialogsManager::toggleAddressBar() { - auto hmd = DependencyManager::get(); - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode()) { - if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) { - tablet->gotoHomeScreen(); - emit addressBarToggled(); - } else { - tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); - emit addressBarToggled(); - } - } else { - if (hmd->getShouldShowTablet()) { - if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG) && _closeAddressBar) { - tablet->gotoHomeScreen(); - hmd->closeTablet(); - _closeAddressBar = false; - emit addressBarToggled(); - } else { - tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); - _closeAddressBar = true; - emit addressBarToggled(); - } - } else { - tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); - hmd->openTablet(); - _closeAddressBar = true; - emit addressBarToggled(); - } - - } -} - void DialogsManager::showAddressBar() { auto hmd = DependencyManager::get(); auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + if (!tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) { + tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); + } if (!hmd->getShouldShowTablet()) { hmd->openTablet(); } + qApp->setKeyboardFocusOverlay(hmd->getCurrentTabletScreenID()); + emit addressBarShown(true); +} + +void DialogsManager::hideAddressBar() { + auto hmd = DependencyManager::get(); + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + + if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) { + tablet->gotoHomeScreen(); + hmd->closeTablet(); + } + qApp->setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID); + emit addressBarShown(false); } void DialogsManager::showFeed() { diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 24b9078baf..3a40b15a3b 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -41,8 +41,8 @@ public: void emitAddressBarShown(bool visible) { emit addressBarShown(visible); } public slots: - void toggleAddressBar(); void showAddressBar(); + void hideAddressBar(); void showFeed(); void setDomainConnectionFailureVisibility(bool visible); void toggleLoginDialog(); @@ -57,7 +57,6 @@ public slots: void showUpdateDialog(); signals: - void addressBarToggled(); void addressBarShown(bool visible); void setUseFeed(bool useFeed); diff --git a/interface/src/ui/SnapshotUploader.cpp b/interface/src/ui/SnapshotUploader.cpp index 5826c8bd38..411e892de5 100644 --- a/interface/src/ui/SnapshotUploader.cpp +++ b/interface/src/ui/SnapshotUploader.cpp @@ -40,6 +40,9 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) { QJsonObject userStoryObject; QJsonObject detailsObject; detailsObject.insert("image_url", imageUrl); + if (dataObject.contains("shareable_url")) { + detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString()); + } QString pickledDetails = QJsonDocument(detailsObject).toJson(); userStoryObject.insert("details", pickledDetails); userStoryObject.insert("thumbnail_url", thumbnailUrl); diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 502006c862..f80589e5a1 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -198,6 +198,7 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); _webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); _webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get().data()); + _webSurface->getRootContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); diff --git a/libraries/avatars/src/AvatarHashMap.h b/libraries/avatars/src/AvatarHashMap.h index 87bedf8d51..e944c7c887 100644 --- a/libraries/avatars/src/AvatarHashMap.h +++ b/libraries/avatars/src/AvatarHashMap.h @@ -41,7 +41,7 @@ public: Q_INVOKABLE QVector getAvatarIdentifiers(); // Null/Default-constructed QUuids will return MyAvatar - virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); } + Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); } virtual AvatarSharedPointer getAvatarBySessionID(const QUuid& sessionID) const { return findAvatar(sessionID); } int numberOfAvatarsInRange(const glm::vec3& position, float rangeMeters);