Update checkbox of PollComponent

Use FormCheckDelegate instead of a CheckBox inside a RowLayout. This
increase the click area particularly on mobile.
This commit is contained in:
Carl Schwan
2024-10-10 16:43:16 +02:00
committed by Joshua Goins
parent d2e11bb3bb
commit b044358970

View File

@@ -6,6 +6,8 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
import org.kde.neochat import org.kde.neochat
/** /**
@@ -40,33 +42,39 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: root.maxContentWidth Layout.maximumWidth: root.maxContentWidth
spacing: 0
Label { Label {
id: questionLabel id: questionLabel
text: root.pollHandler.question text: root.pollHandler.question
wrapMode: Text.Wrap wrapMode: Text.Wrap
Layout.fillWidth: true Layout.fillWidth: true
visible: text.length > 0
} }
Repeater { Repeater {
model: root.pollHandler.options model: root.pollHandler.options
delegate: RowLayout { delegate: FormCard.FormCheckDelegate {
Layout.fillWidth: true Layout.fillWidth: true
CheckBox { Layout.leftMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
checked: root.pollHandler.answers[root.room.localMember.id] ? root.pollHandler.answers[root.room.localMember.id].includes(modelData["id"]) : false Layout.rightMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
enabled: !root.pollHandler.hasEnded checked: root.pollHandler.answers[root.room.localMember.id] ? root.pollHandler.answers[root.room.localMember.id].includes(modelData["id"]) : false
} onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
Label { enabled: !root.pollHandler.hasEnded
text: modelData["org.matrix.msc1767.text"] text: modelData["org.matrix.msc1767.text"]
Layout.fillWidth: true
wrapMode: Text.Wrap topPadding: Kirigami.Units.smallSpacing
} bottomPadding: Kirigami.Units.smallSpacing
Label {
trailing: Label {
visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || pollHandler.hasEnded visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || pollHandler.hasEnded
Layout.preferredWidth: contentWidth Layout.preferredWidth: contentWidth
text: root.pollHandler.counts[modelData["id"]] ?? "0" text: root.pollHandler.counts[modelData["id"]] ?? "0"
} }
} }
} }
Label { Label {
visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || root.pollHandler.hasEnded visible: root.pollHandler.kind == "org.matrix.msc3381.poll.disclosed" || root.pollHandler.hasEnded
text: i18np("Based on votes by %1 user", "Based on votes by %1 users", root.pollHandler.answerCount) + (root.pollHandler.hasEnded ? (" " + i18nc("as in 'this vote has ended'", "(Ended)")) : "") text: i18np("Based on votes by %1 user", "Based on votes by %1 users", root.pollHandler.answerCount) + (root.pollHandler.hasEnded ? (" " + i18nc("as in 'this vote has ended'", "(Ended)")) : "")