From 4d530ef17354170b874d12f7e49a24f9d76b44f1 Mon Sep 17 00:00:00 2001 From: vladest Date: Fri, 22 Sep 2017 21:08:34 +0200 Subject: [PATCH] Make sure menu items vill be created even its not visible at the moment. Cleanup warnings on app close --- .../qml/hifi/tablet/TabletMenuItem.qml | 32 ++++++++++++------- .../qml/hifi/tablet/TabletMenuStack.qml | 2 -- .../qml/hifi/tablet/TabletMenuView.qml | 9 ++---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/TabletMenuItem.qml b/interface/resources/qml/hifi/tablet/TabletMenuItem.qml index 71e59e0d01..11d3cab35e 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuItem.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuItem.qml @@ -21,9 +21,9 @@ Item { property alias text: label.text property var source - implicitHeight: source.visible ? 2 * label.implicitHeight : 0 + implicitHeight: source !== null ? source.visible ? 2 * label.implicitHeight : 0 : 0 implicitWidth: 2 * hifi.dimensions.menuPadding.x + check.width + label.width + tail.width - visible: source.visible + visible: source !== null ? source.visible : false width: parent.width Item { @@ -42,7 +42,9 @@ Item { id: checkbox // FIXME: Should use radio buttons if source.exclusiveGroup. width: 20 - visible: source.visible && source.type === 1 && source.checkable && !source.exclusiveGroup + visible: source !== null ? + source.visible && source.type === 1 && source.checkable && !source.exclusiveGroup : + false checked: setChecked() function setChecked() { if (!source || source.type !== 1 || !source.checkable) { @@ -58,7 +60,9 @@ Item { id: radiobutton // FIXME: Should use radio buttons if source.exclusiveGroup. width: 20 - visible: source.visible && source.type === 1 && source.checkable && source.exclusiveGroup + visible: source !== null ? + source.visible && source.type === 1 && source.checkable && source.exclusiveGroup : + false checked: setChecked() function setChecked() { if (!source || source.type !== 1 || !source.checkable) { @@ -80,9 +84,13 @@ Item { anchors.left: check.right anchors.verticalCenter: parent.verticalCenter verticalAlignment: Text.AlignVCenter - color: source.enabled ? hifi.colors.baseGrayShadow : hifi.colors.baseGrayShadow50 - enabled: source.visible && (source.type !== 0 ? source.enabled : false) - visible: source.visible + color: source !== null ? + source.enabled ? hifi.colors.baseGrayShadow : + hifi.colors.baseGrayShadow50 : + "transparent" + + enabled: source !== null ? source.visible && (source.type !== 0 ? source.enabled : false) : false + visible: source !== null ? source.visible : false wrapMode: Text.WordWrap } @@ -93,7 +101,7 @@ Item { leftMargin: hifi.dimensions.menuPadding.x + check.width rightMargin: hifi.dimensions.menuPadding.x + tail.width } - visible: source.type === MenuItemType.Separator + visible: source !== null ? source.type === MenuItemType.Separator : false Rectangle { anchors { @@ -117,23 +125,23 @@ Item { RalewayLight { id: shortcut - text: source.shortcut ? source.shortcut : "" + text: source !== null ? source.shortcut ? source.shortcut : "" : "" size: hifi.fontSizes.shortcutText color: hifi.colors.baseGrayShadow anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 15 - visible: source.visible && text != "" + visible: source !== null ? source.visible && text != "" : false } HiFiGlyphs { text: hifi.glyphs.disclosureExpand - color: source.enabled ? hifi.colors.baseGrayShadow : hifi.colors.baseGrayShadow25 + color: source !== null ? source.enabled ? hifi.colors.baseGrayShadow : hifi.colors.baseGrayShadow25 : "transparent" size: 70 anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right horizontalAlignment: Text.AlignRight - visible: source.visible && (source.type === 2) + visible: source !== null ? source.visible && (source.type === 2) : false } } } diff --git a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml index e7eefbc5e7..ce4fac3bd5 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml @@ -70,7 +70,6 @@ Item { for (var i = 0; i < items.length; ++i) { var item = items[i]; - if (!item.visible) continue; switch (item.type) { case MenuItemType.Menu: result.append({"name": item.title, "item": item}) @@ -216,5 +215,4 @@ Item { function nextItem() { d.topMenu.nextItem(); } function selectCurrentItem() { d.topMenu.selectCurrentItem(); } function previousPage() { d.topMenu.previousPage(); } - } diff --git a/interface/resources/qml/hifi/tablet/TabletMenuView.qml b/interface/resources/qml/hifi/tablet/TabletMenuView.qml index 92e7f59524..ecfb653923 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuView.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuView.qml @@ -9,8 +9,6 @@ // import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 import "../../styles-uit" import "." @@ -36,7 +34,6 @@ FocusScope { //color: isSubMenu ? hifi.colors.faintGray : hifi.colors.faintGray80 } - ListView { id: listView x: 0 @@ -68,8 +65,8 @@ FocusScope { delegate: TabletMenuItem { text: name source: item - onImplicitHeightChanged: listView.recalcSize() - onImplicitWidthChanged: listView.recalcSize() + onImplicitHeightChanged: listView !== null ? listView.recalcSize() : 0 + onImplicitWidthChanged: listView !== null ? listView.recalcSize() : 0 MouseArea { anchors.fill: parent @@ -124,8 +121,6 @@ FocusScope { function nextItem() { listView.currentIndex = (listView.currentIndex + listView.count + 1) % listView.count; } function selectCurrentItem() { if (listView.currentIndex != -1) root.selected(currentItem.source); } function previousPage() { root.parent.pop(); } - - }