diff --git a/interface/resources/qml/hifi/tablet/Tablet.qml b/interface/resources/qml/hifi/tablet/Tablet.qml index c51bb1a598..545ab2fa58 100644 --- a/interface/resources/qml/hifi/tablet/Tablet.qml +++ b/interface/resources/qml/hifi/tablet/Tablet.qml @@ -3,17 +3,15 @@ import QtGraphicalEffects 1.0 FocusScope { id: tablet - objectName: "tablet" focus: true - enabled: true + objectName: "tablet" property double micLevel: 0.8 - property int index: 0 - property int count: flowMain.children.length + property int rowIndex: 0 + property int columnIndex: 0 + property int count: (flowMain.children.length - 1) width: parent.width height: parent.height - //property alias currentItem: flowMain.currentItem - // called by C++ code to keep audio bar updated function setMicLevel(newMicLevel) { tablet.micLevel = newMicLevel; @@ -182,7 +180,6 @@ FocusScope { clip: true Flow { id: flowMain - focus: true spacing: 16 anchors.right: parent.right anchors.rightMargin: 30 @@ -192,50 +189,6 @@ FocusScope { anchors.bottomMargin: 30 anchors.top: parent.top anchors.topMargin: 30 - - function setCurrentItemState(state) { - flowMain.children[index].state = state; - } - function nextItem() { - setCurrentItemState("base state"); - index = (index + count + 1) % count; - setCurrentItemState("hover state"); - console.log("next item at index: " + index); - } - - function previousItem() { - setCurrentItemState("base state"); - index = (index + count - 1 ) % count; - setCurrentItemState("hover state"); - console.log("previous item at index: " + index); - } - - function upItem() { - setCurrentItemState("base state"); - index = (index + count - 3) % count; - setCurrentItemState("hover state"); - console.log("up item at index: " + index); - } - - function downItem() { - setCurrentItemState("base state"); - index = (index + count + 3) % count; - setCurrentItemState("hover state"); - console.log("down item at index :" + index); - } - - function selectItem() { - flowMain.children[index].clicked(); - if(tabletRoot) { - tabletRoot.playButtonClickSound(); - } - } - - Keys.onRightPressed: nextItem(); - Keys.onLeftPressed: previousItem(); - Keys.onDownPressed: downItem(); - Keys.onUpPressed: upItem(); - Keys.onReturnPressed: selectItem(); } } } @@ -260,5 +213,68 @@ FocusScope { } } ] + + function setCurrentItemState(state) { + var index = rowIndex + columnIndex; + + if (index >= 0 && index <= count ) { + flowMain.children[index].state = state; + } + } + function nextItem() { + setCurrentItemState("base state"); + + if((rowIndex + columnIndex) != count) { + columnIndex = (columnIndex + 3 + 1) % 3 + }; + setCurrentItemState("hover state"); + } + + function previousItem() { + setCurrentItemState("base state"); + var prevIndex = (columnIndex + 3 - 1) % 3; + if((rowIndex + prevIndex) <= count){ + columnIndex = prevIndex; + } + setCurrentItemState("hover state"); + } + + function upItem() { + setCurrentItemState("base state"); + rowIndex = rowIndex - 3; + if (rowIndex < 0 ) { + rowIndex = (count - (count % 3)); + var index = rowIndex + columnIndex; + if(index > count) { + rowIndex = rowIndex - 3; + console.log("index: " + (rowIndex +columnIndex)); + } + } + console.log("row index: " + rowIndex); + setCurrentItemState("hover state"); + } + + function downItem() { + setCurrentItemState("base state"); + rowIndex = rowIndex + 3; + var index = rowIndex + columnIndex; + if (index > count ) { + rowIndex = 0; + } + setCurrentItemState("hover state"); + } + + function selectItem() { + flowMain.children[rowIndex + columnIndex].clicked(); + if (tabletRoot) { + tabletRoot.playButtonClickSound(); + } + } + + Keys.onRightPressed: nextItem(); + Keys.onLeftPressed: previousItem(); + Keys.onDownPressed: downItem(); + Keys.onUpPressed: upItem(); + Keys.onReturnPressed: selectItem(); } diff --git a/interface/resources/qml/hifi/tablet/TabletMenu.qml b/interface/resources/qml/hifi/tablet/TabletMenu.qml index a782192b4d..a80ca12d5f 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenu.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenu.qml @@ -87,6 +87,10 @@ FocusScope { } } + function pop() { + menuPopperUpper.closeLastMenu(); + } + function setRootMenu(menu) { tabletMenu.rootMenu = menu buildMenu() diff --git a/interface/resources/qml/hifi/tablet/TabletMenuView.qml b/interface/resources/qml/hifi/tablet/TabletMenuView.qml index dedbfc80ab..da791a8ed2 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuView.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuView.qml @@ -13,12 +13,12 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import "../../styles-uit" - +import "." FocusScope { id: root implicitHeight: background.height implicitWidth: background.width - + property alias currentItem: listView.currentItem property alias model: listView.model property bool isSubMenu: false @@ -111,7 +111,7 @@ FocusScope { function previousItem() { currentIndex = (currentIndex + count - 1) % count; } function nextItem() { currentIndex = (currentIndex + count + 1) % count; } function selectCurrentItem() { if (currentIndex != -1) root.selected(currentItem.source); } - function previousPage() {console.log("going to previous page"); } + function previousPage() { root.parent.pop(); } Keys.onUpPressed: previousItem(); Keys.onDownPressed: nextItem(); diff --git a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml index 1eb5f7cdd1..bf8e72ce8a 100644 --- a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml +++ b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml @@ -91,7 +91,6 @@ Item { breadcrumbText.text = "Menu"; topMenu = null; offscreenFlags.navigationFocused = false; - //menuRoot.enabled = false; } } @@ -100,7 +99,6 @@ Item { topMenu = newMenu; topMenu.focus = true; offscreenFlags.navigationFocused = true; - console.log(offscreenWindow.activeFocusItem); } function clearMenus() { @@ -160,7 +158,6 @@ Item { function popup(parent, items) { d.clearMenus(); - //menuRoot.enabled = true; d.buildMenu(items, point); } diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index 66c22e2843..aa2ce947b8 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import Hifi 1.0 -Item { +FocusScope { id: tabletRoot objectName: "tabletRoot" property var eventBridge; @@ -26,7 +26,11 @@ Item { } function forceFocus() { + console.log(loader.item.objectName); + offscreenWindow.requestActivate(); loader.item.forceActiveFocus(); + console.log("----------> adding focus"); + console.log("------>Current foucs itrm: " + offscreenWindow.activeFocusItem); } Loader { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 2626170bd6..a5727e36ff 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -979,7 +979,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto offscreenUi = DependencyManager::get(); auto tabletScriptingInterface = DependencyManager::get(); if (offscreenUi->navigationFocused()) { - qDebug() << "NavigationFocused"; auto actionEnum = static_cast(action); int key = Qt::Key_unknown; static int lastKey = Qt::Key_unknown; @@ -1025,7 +1024,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto window = tabletScriptingInterface->getTabletWindow(); if (navAxis && window) { - qDebug() << "Sending input to qml"; if (lastKey != Qt::Key_unknown) { QKeyEvent event(QEvent::KeyRelease, lastKey, Qt::NoModifier); sendEvent(window, &event); diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index f15f7da53e..ddf999e5d2 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -215,8 +215,9 @@ void TabletProxy::addButtonsToHomeScreen() { addButtonProxyToQmlTablet(tablet, buttonProxy.data()); } auto loader = _qmlTabletRoot->findChild("loader"); - QObject::disconnect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen())); QMetaObject::invokeMethod(_qmlTabletRoot, "forceFocus"); + qDebug() << "----> INVOKEMETHOD"; + QObject::disconnect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen())); } QObject* TabletProxy::getTabletSurface() {