mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
Make sure menu items vill be created even its not visible at the moment. Cleanup warnings on app close
This commit is contained in:
parent
daf18156f9
commit
4d530ef173
3 changed files with 22 additions and 21 deletions
|
@ -21,9 +21,9 @@ Item {
|
||||||
property alias text: label.text
|
property alias text: label.text
|
||||||
property var source
|
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
|
implicitWidth: 2 * hifi.dimensions.menuPadding.x + check.width + label.width + tail.width
|
||||||
visible: source.visible
|
visible: source !== null ? source.visible : false
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -42,7 +42,9 @@ Item {
|
||||||
id: checkbox
|
id: checkbox
|
||||||
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
||||||
width: 20
|
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()
|
checked: setChecked()
|
||||||
function setChecked() {
|
function setChecked() {
|
||||||
if (!source || source.type !== 1 || !source.checkable) {
|
if (!source || source.type !== 1 || !source.checkable) {
|
||||||
|
@ -58,7 +60,9 @@ Item {
|
||||||
id: radiobutton
|
id: radiobutton
|
||||||
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
// FIXME: Should use radio buttons if source.exclusiveGroup.
|
||||||
width: 20
|
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()
|
checked: setChecked()
|
||||||
function setChecked() {
|
function setChecked() {
|
||||||
if (!source || source.type !== 1 || !source.checkable) {
|
if (!source || source.type !== 1 || !source.checkable) {
|
||||||
|
@ -80,9 +84,13 @@ Item {
|
||||||
anchors.left: check.right
|
anchors.left: check.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: source.enabled ? hifi.colors.baseGrayShadow : hifi.colors.baseGrayShadow50
|
color: source !== null ?
|
||||||
enabled: source.visible && (source.type !== 0 ? source.enabled : false)
|
source.enabled ? hifi.colors.baseGrayShadow :
|
||||||
visible: source.visible
|
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
|
wrapMode: Text.WordWrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +101,7 @@ Item {
|
||||||
leftMargin: hifi.dimensions.menuPadding.x + check.width
|
leftMargin: hifi.dimensions.menuPadding.x + check.width
|
||||||
rightMargin: hifi.dimensions.menuPadding.x + tail.width
|
rightMargin: hifi.dimensions.menuPadding.x + tail.width
|
||||||
}
|
}
|
||||||
visible: source.type === MenuItemType.Separator
|
visible: source !== null ? source.type === MenuItemType.Separator : false
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors {
|
anchors {
|
||||||
|
@ -117,23 +125,23 @@ Item {
|
||||||
|
|
||||||
RalewayLight {
|
RalewayLight {
|
||||||
id: shortcut
|
id: shortcut
|
||||||
text: source.shortcut ? source.shortcut : ""
|
text: source !== null ? source.shortcut ? source.shortcut : "" : ""
|
||||||
size: hifi.fontSizes.shortcutText
|
size: hifi.fontSizes.shortcutText
|
||||||
color: hifi.colors.baseGrayShadow
|
color: hifi.colors.baseGrayShadow
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 15
|
anchors.rightMargin: 15
|
||||||
visible: source.visible && text != ""
|
visible: source !== null ? source.visible && text != "" : false
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
text: hifi.glyphs.disclosureExpand
|
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
|
size: 70
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
horizontalAlignment: Text.AlignRight
|
horizontalAlignment: Text.AlignRight
|
||||||
visible: source.visible && (source.type === 2)
|
visible: source !== null ? source.visible && (source.type === 2) : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,6 @@ Item {
|
||||||
|
|
||||||
for (var i = 0; i < items.length; ++i) {
|
for (var i = 0; i < items.length; ++i) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
if (!item.visible) continue;
|
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case MenuItemType.Menu:
|
case MenuItemType.Menu:
|
||||||
result.append({"name": item.title, "item": item})
|
result.append({"name": item.title, "item": item})
|
||||||
|
@ -216,5 +215,4 @@ Item {
|
||||||
function nextItem() { d.topMenu.nextItem(); }
|
function nextItem() { d.topMenu.nextItem(); }
|
||||||
function selectCurrentItem() { d.topMenu.selectCurrentItem(); }
|
function selectCurrentItem() { d.topMenu.selectCurrentItem(); }
|
||||||
function previousPage() { d.topMenu.previousPage(); }
|
function previousPage() { d.topMenu.previousPage(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
|
||||||
import QtQuick.Controls.Styles 1.4
|
|
||||||
|
|
||||||
import "../../styles-uit"
|
import "../../styles-uit"
|
||||||
import "."
|
import "."
|
||||||
|
@ -36,7 +34,6 @@ FocusScope {
|
||||||
//color: isSubMenu ? hifi.colors.faintGray : hifi.colors.faintGray80
|
//color: isSubMenu ? hifi.colors.faintGray : hifi.colors.faintGray80
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: listView
|
id: listView
|
||||||
x: 0
|
x: 0
|
||||||
|
@ -68,8 +65,8 @@ FocusScope {
|
||||||
delegate: TabletMenuItem {
|
delegate: TabletMenuItem {
|
||||||
text: name
|
text: name
|
||||||
source: item
|
source: item
|
||||||
onImplicitHeightChanged: listView.recalcSize()
|
onImplicitHeightChanged: listView !== null ? listView.recalcSize() : 0
|
||||||
onImplicitWidthChanged: listView.recalcSize()
|
onImplicitWidthChanged: listView !== null ? listView.recalcSize() : 0
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -124,8 +121,6 @@ FocusScope {
|
||||||
function nextItem() { listView.currentIndex = (listView.currentIndex + listView.count + 1) % listView.count; }
|
function nextItem() { listView.currentIndex = (listView.currentIndex + listView.count + 1) % listView.count; }
|
||||||
function selectCurrentItem() { if (listView.currentIndex != -1) root.selected(currentItem.source); }
|
function selectCurrentItem() { if (listView.currentIndex != -1) root.selected(currentItem.source); }
|
||||||
function previousPage() { root.parent.pop(); }
|
function previousPage() { root.parent.pop(); }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue