From a347936b6884e24574465704a9ae1723e4748422 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 6 Oct 2016 16:47:49 +1300 Subject: [PATCH] Fix location not being updated after using back and forwards buttons --- interface/resources/qml/AddressBarDialog.qml | 23 ++++++++++++++++++++ interface/src/ui/AddressBarDialog.cpp | 1 + interface/src/ui/AddressBarDialog.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 40438804ed..75c16da30b 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -70,11 +70,15 @@ Window { id: addressBarDialog implicitWidth: backgroundImage.width implicitHeight: backgroundImage.height + // The buttons have their button state changed on hover, so we have to manually fix them up here onBackEnabledChanged: backArrow.buttonState = addressBarDialog.backEnabled ? 1 : 0; onForwardEnabledChanged: forwardArrow.buttonState = addressBarDialog.forwardEnabled ? 1 : 0; onReceivedHifiSchemeURL: resetAfterTeleport(); + // Update location after using back and forward buttons. + onMetaverseServerUrlChanged: updateLocationTextTimer.start(); + ListModel { id: suggestions } ListView { @@ -225,6 +229,24 @@ Window { } } + Timer { + // Delay updating location text a bit to avoid flicker of content and so that connection status is valid. + id: updateLocationTextTimer + running: false + interval: 500 // ms + repeat: false + onTriggered: updateLocationText(false); + } + + 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 + onTriggered: addressLine.text = "" + } + Window { width: 938; height: 625; @@ -403,6 +425,7 @@ Window { if (addressLine.text !== "") { addressBarDialog.loadAddress(addressLine.text, fromSuggestions) } + clearAddressLineTimer.start(); isCursorVisible = false; root.shown = false; } diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index 3e84c4c3c5..ac566d68c7 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -38,6 +38,7 @@ AddressBarDialog::AddressBarDialog(QQuickItem* parent) : OffscreenQmlDialog(pare }); _backEnabled = !(DependencyManager::get()->getBackStack().isEmpty()); _forwardEnabled = !(DependencyManager::get()->getForwardStack().isEmpty()); + connect(addressManager.data(), &AddressManager::hostChanged, this, &AddressBarDialog::metaverseServerUrlChanged); connect(DependencyManager::get().data(), &DialogsManager::setUseFeed, this, &AddressBarDialog::setUseFeed); connect(qApp, &Application::receivedHifiSchemeURL, this, &AddressBarDialog::receivedHifiSchemeURL); } diff --git a/interface/src/ui/AddressBarDialog.h b/interface/src/ui/AddressBarDialog.h index 2dad742ebb..921e808abb 100644 --- a/interface/src/ui/AddressBarDialog.h +++ b/interface/src/ui/AddressBarDialog.h @@ -37,7 +37,7 @@ signals: void forwardEnabledChanged(); void useFeedChanged(); void receivedHifiSchemeURL(const QString& url); - void metaverseServerUrlChanged(); // While it is a constant, qml will complain about not seeing a change signal. + void metaverseServerUrlChanged(); protected: void displayAddressOfflineMessage();