An error occurred while loading the file. Please try again.
-
Jens Bache-Wiig authored
- Removed contentWidth and contentHeight since it is not needed - Exposed contentItem so that it can be designable. - Respect the implicit width or height of the contentItem if it is the only item of the GroupBox. Otherwise childrenRect is used. - Modified the style so that the style takes care of only the padding size and not the entire size of the group box. - Fixed flat and checkable appearance for custom style Change-Id: I2c7ec4cb7d5e6f96863847e8d8d6d6f52428364e Reviewed-by:
J-P Nurmi <jpnurmi@digia.com>
57cb0961
import QtQuick 2.0
import "../components/plugin"
MenuBase {
property ListModel model
property string selectedText: itemTextAt(selectedIndex)
property string hoveredText: itemTextAt(hoveredIndex)
// 'centerSelectedText' means that the menu will be positioned
// so that the selected text' top left corner will be at x, y.
property bool centerSelectedText: true
// Show, or hide, the popup by setting the 'visible' property:
visible: false
onMenuClosed: visible = false
onModelChanged: if (Component.status === Component.Ready) rebuildMenu()
Component.onCompleted: rebuildMenu()
onHoveredIndexChanged: {
if (hoveredIndex < menuItems.length)
menuItems[hoveredIndex].emitHovered()
}
onSelectedIndexChanged: {
if (hoveredIndex < menuItems.length)
menuItems[hoveredIndex].emitSelected()
}
onVisibleChanged: {
if (visible) {
var globalPos = parent.mapToItem(null, x, y)
showPopup(globalPos.x, globalPos.y, centerSelectedText ? selectedIndex : 0)
} else {
closePopup()
}
}
function rebuildMenu()
{
clearMenuItems();
for (var i=0; i<menuItems.length; ++i)
addMenuItem(menuItems[i].text)
if (model != undefined) {
for (var j=0; j<model.count; ++j)
addMenuItem(model.get(j).text)
}
}
}