diff --git a/src/gui/Base/AutoDirectionLayout.qml b/src/gui/Base/AutoDirectionLayout.qml index d14c911b..2cd8ab7b 100644 --- a/src/gui/Base/AutoDirectionLayout.qml +++ b/src/gui/Base/AutoDirectionLayout.qml @@ -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: diff --git a/src/gui/Utils.qml b/src/gui/Utils.qml index d4525b55..e05cc88e 100644 --- a/src/gui/Utils.qml +++ b/src/gui/Utils.qml @@ -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 + } }