Index: sources/gui/qml/compounds/TouchGrid.qml =================================================================== diff -u -r20b286ab574a6b8ad25a51aeb3477506f7dafc5d -r6c6f1f5d466badd9b4fd67be7c907234c342b2a2 --- sources/gui/qml/compounds/TouchGrid.qml (.../TouchGrid.qml) (revision 20b286ab574a6b8ad25a51aeb3477506f7dafc5d) +++ sources/gui/qml/compounds/TouchGrid.qml (.../TouchGrid.qml) (revision 6c6f1f5d466badd9b4fd67be7c907234c342b2a2) @@ -1,13 +1,13 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file TouchGrid.qml * \author (last) Behrouz NematiPour - * \date (last) 14-Apr-2021 + * \date (last) 27-Jun-2022 * \author (original) Behrouz NematiPour * \date (original) 14-Apr-2021 * @@ -35,12 +35,13 @@ property var itemsHasImage : [] property var itemsHasLine : [] property var itemsTouchable : [] + property bool touchable : true property int itemWidth : 350 property int itemHeight : 50 property alias layoutOrder : _grid.flow property alias rowSpacing : _grid.rowSpacing - property alias columnSpacing : _grid.columnSpacing + property alias colSpacing : _grid.columnSpacing property color lineColor : Colors.borderButtonHalfDarker property real lineThickness : 1.5 property real itemsValueLeftMargin : itemWidth / 2 @@ -52,30 +53,48 @@ property int colCount : itemsText.length > rowCount ? Math.ceil(itemsText.length / rowCount) : 1 readonly property int titleTopMargin: 110 + readonly property alias itemsVisibleCount : _private.itemsVisibleCount + signal itemClicked(int vIndex) + QtObject { id: _private + property int itemsVisibleCount : 0 + } + + height: parent.height + onItemsVisibleChanged: { + let count = 0 + for ( let itemVisible of itemsVisible ) { + if ( itemVisible ) { + count++ + } + } + _private.itemsVisibleCount = count + } + function undef(vValue, vOtherwise) { if ( vValue === undefined ) { return vOtherwise } return vValue } + // DEBUG: Rectangle { anchors.fill: _grid } Grid { id: _grid flow: Grid.TopToBottom anchors.centerIn: _root.alignCenter ? parent : undefined anchors.top : ! _root.alignCenter ? _root.top : undefined columns : _root.colCount rows : _root.rowCount rowSpacing : 25 - columnSpacing : 100 + columnSpacing : itemsVisibleCount > rowCount ? 100 : 0 Repeater { model : _root.itemsText TouchRect { id: _touchItem clip : true - touchable : undef( _root.itemsTouchable[index], true ) + touchable : undef( _root.itemsTouchable[index], _root.touchable ) text.anchors.horizontalCenter: undefined text.leftPadding : Variables.minVGap text.text : modelData