Move AutoDirectionLayout sum function to Utils

This commit is contained in:
miruka 2020-07-20 21:37:08 -04:00
parent acd02a67a0
commit 93b46dcfee
2 changed files with 15 additions and 12 deletions

View File

@ -4,18 +4,8 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12
HGridLayout {
readonly property real summedImplicitWidth: {
let sum = 0
for (let i = 0; i < visibleChildren.length; i++) {
const item = visibleChildren[i]
if (item)
sum += (item.width > 0 ? item.implicitWidth : 0) +columnSpacing
}
return sum
}
readonly property real summedImplicitWidth:
utils.sumChildrenImplicitWidths(visibleChildren, columnSpacing)
flow:

View File

@ -498,4 +498,17 @@ QtObject {
userId, "send_file", [roomId, path], onSuccess, onError,
)
}
function sumChildrenImplicitWidths(visibleChildren, spacing=0) {
let sum = 0
for (let i = 0; i < visibleChildren.length; i++) {
const item = visibleChildren[i]
if (item)
sum += (item.width > 0 ? item.implicitWidth : 0) + spacing
}
return sum
}
}