From 38781502c6d675d8be7c79eb362e07fb3505aa11 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 9 Sep 2019 12:37:01 -0400 Subject: [PATCH] HBox: make buttons a column if not enough width --- TODO.md | 4 +++- src/qml/Base/HBox.qml | 7 +++++-- src/qml/Base/HRepeater.qml | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/qml/Base/HRepeater.qml diff --git a/TODO.md b/TODO.md index c8d75c2a..cd3e78a5 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,6 @@ - Refactoring + - Room header elide detection + - Use HBox for Profile - Banners - Composer @@ -94,7 +96,6 @@ - Server selection - Register/Forgot? for SignIn dialog - Add room - - Logout & leave/forget room warning popup - Prevent using the composer if no permission (power levels) - Prevent using an alias if that user is not in the room or no permission - Spinner when loading past room events or images @@ -132,6 +133,7 @@ - Opening links with keyboard - Client improvements + - More error details - Refetch profile after manual profile change, don't wait for a room event - Prevent starting multiple instances, causes problems with E2E DB (sending new messages from second instances makes them undecryptable to diff --git a/src/qml/Base/HBox.qml b/src/qml/Base/HBox.qml index b56269ff..df4826e8 100644 --- a/src/qml/Base/HBox.qml +++ b/src/qml/Base/HBox.qml @@ -70,10 +70,13 @@ Rectangle { Layout.rightMargin: interfaceBox.horizontalSpacing } - HRowLayout { + HGridLayout { + id: buttonGrid visible: buttonModel.length > 0 + flow: width >= buttonRepeater.childrenImplicitWidth ? + GridLayout.LeftToRight : GridLayout.TopToBottom - Repeater { + HRepeater { id: buttonRepeater model: [] diff --git a/src/qml/Base/HRepeater.qml b/src/qml/Base/HRepeater.qml new file mode 100644 index 00000000..2f4e250e --- /dev/null +++ b/src/qml/Base/HRepeater.qml @@ -0,0 +1,17 @@ +import QtQuick.Controls 2.12 +import QtQuick 2.12 + + +Repeater { + id: repeater + + readonly property int childrenImplicitWidth: { + let total = 0 + + for (let i = 0; i < repeater.count; i++) { + total += repeater.itemAt(i).implicitWidth + } + + return total + } +}