Merge pull request #10153 from druiz17/goto-fix

Ability to toggle goto with the crt-l and enter keys
This commit is contained in:
Chris Collins 2017-04-07 16:36:41 -07:00 committed by GitHub
commit 8e12f62cbb
8 changed files with 84 additions and 13 deletions

View file

@ -243,12 +243,7 @@ Rectangle {
}
}
}
DropShadow {
anchors.fill: actionIcon
radius: 8.0
color: "#80000000"
source: actionIcon
}
MouseArea {
id: messageArea;
width: rectIcon.width;

View file

@ -33,14 +33,25 @@ StackView {
property int cardHeight: 320;
property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/";
property var tablet: null;
property bool isDesktop: false;
Component { id: tabletStoryCard; TabletStoryCard {} }
Component.onCompleted: {
root.currentItem.focus = true;
root.currentItem.forceActiveFocus();
addressLine.focus = true;
addressLine.forceActiveFocus();
fillDestinations();
updateLocationText(false);
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);
@ -108,6 +119,8 @@ StackView {
onClicked: {
addressBarDialog.loadHome();
tabletRoot.shown = false;
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.gotoHomeScreen();
}
anchors {
left: parent.left
@ -294,6 +307,7 @@ StackView {
right: parent.right
leftMargin: 10
}
model: suggestions
orientation: ListView.Vertical
@ -547,6 +561,13 @@ StackView {
if (addressLine.text !== "") {
addressBarDialog.loadAddress(addressLine.text, fromSuggestions)
}
if (isDesktop) {
tablet.gotoHomeScreen();
} else {
HMD.closeTablet();
}
tabletRoot.shown = false;
}

View file

@ -2013,6 +2013,7 @@ void Application::initializeUi() {
rootContext->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
rootContext->setContextProperty("Account", AccountScriptingInterface::getInstance());
rootContext->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
rootContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface);
rootContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance());
rootContext->setContextProperty("FaceTracker", DependencyManager::get<DdeFaceTracker>().data());

View file

@ -31,6 +31,7 @@
#include "TabletScriptingInterface.h"
#include "scripting/HMDScriptingInterface.h"
static const QVariant TABLET_ADDRESS_DIALOG = "TabletAddressDialog.qml";
template<typename T>
void DialogsManager::maybeCreateDialog(QPointer<T>& member) {
if (!member) {
@ -46,12 +47,48 @@ void DialogsManager::maybeCreateDialog(QPointer<T>& member) {
}
void DialogsManager::toggleAddressBar() {
AddressBarDialog::toggle();
emit addressBarToggled();
auto hmd = DependencyManager::get<HMDScriptingInterface>();
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
auto tablet = dynamic_cast<TabletProxy*>(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() {
AddressBarDialog::show();
auto hmd = DependencyManager::get<HMDScriptingInterface>();
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
if (!hmd->getShouldShowTablet()) {
hmd->openTablet();
}
}
void DialogsManager::showFeed() {

View file

@ -79,6 +79,7 @@ private:
QPointer<OctreeStatsDialog> _octreeStatsDialog;
QPointer<TestingDialog> _testingDialog;
QPointer<DomainConnectionDialog> _domainConnectionDialog;
bool _closeAddressBar { false };
};
#endif // hifi_DialogsManager_h

View file

@ -275,6 +275,9 @@ void TabletProxy::emitWebEvent(QVariant msg) {
emit webEventReceived(msg);
}
bool TabletProxy::isPathLoaded(QVariant path) {
return path.toString() == _currentPathLoaded.toString();
}
void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
std::lock_guard<std::mutex> guard(_mutex);
_qmlOffscreenSurface = qmlOffscreenSurface;
@ -322,6 +325,7 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr
removeButtonsFromHomeScreen();
_state = State::Uninitialized;
emit screenChanged(QVariant("Closed"), QVariant(""));
_currentPathLoaded = "";
}
}
@ -345,6 +349,7 @@ void TabletProxy::gotoMenuScreen(const QString& submenu) {
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
_state = State::Menu;
emit screenChanged(QVariant("Menu"), QVariant(VRMENU_SOURCE_URL));
_currentPathLoaded = VRMENU_SOURCE_URL;
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
}
}
@ -364,6 +369,7 @@ void TabletProxy::loadQMLSource(const QVariant& path) {
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, path));
_state = State::QML;
emit screenChanged(QVariant("QML"), path);
_currentPathLoaded = path;
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
}
} else {
@ -426,6 +432,7 @@ void TabletProxy::loadHomeScreen(bool forceOntoHomeScreen) {
}
_state = State::Home;
emit screenChanged(QVariant("Home"), QVariant(TABLET_SOURCE_URL));
_currentPathLoaded = TABLET_SOURCE_URL;
}
}
@ -450,6 +457,7 @@ void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaS
}
_state = State::Web;
emit screenChanged(QVariant("Web"), QVariant(url));
_currentPathLoaded = QVariant(url);
}
QObject* TabletProxy::addButton(const QVariant& properties) {

View file

@ -183,6 +183,8 @@ public:
Q_INVOKABLE void setLandscape(bool landscape) { _landscape = landscape; }
Q_INVOKABLE bool getLandscape() { return _landscape; }
Q_INVOKABLE bool isPathLoaded(QVariant path);
QQuickItem* getTabletRoot() const { return _qmlTabletRoot; }
QObject* getTabletSurface();
@ -235,6 +237,7 @@ protected:
bool _initialScreen { false };
QVariant _initialPath { "" };
QVariant _currentPathLoaded { "" };
QString _name;
std::mutex _mutex;
std::vector<QSharedPointer<TabletButtonProxy>> _tabletButtonProxies;

View file

@ -29,10 +29,15 @@
}
function onScreenChanged(type, url) {
// for toolbar mode: change button to active when window is first openend, false otherwise.
button.editProperties({isActive: shouldActivateButton});
shouldActivateButton = false;
onGotoScreen = false;
if (url === gotoQmlSource) {
onGotoScreen = true;
shouldActivateButton = true;
button.editProperties({isActive: shouldActivateButton});
} else {
shouldActivateButton = false;
onGotoScreen = false;
button.editProperties({isActive: shouldActivateButton});
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");