matrixion/resources/qml/Reactions.qml

73 lines
1.7 KiB
QML
Raw Normal View History

2020-05-04 01:59:05 +03:00
import QtQuick 2.6
import QtQuick.Controls 2.2
Flow {
anchors.left: parent.left
anchors.right: parent.right
spacing: 4
2020-05-04 14:14:54 +03:00
property alias reactions: repeater.model
2020-05-04 01:59:05 +03:00
Repeater {
2020-05-04 14:14:54 +03:00
id: repeater
2020-05-04 01:59:05 +03:00
Button {
id: reaction
text: model.key
hoverEnabled: true
implicitWidth: contentItem.childrenRect.width + contentItem.padding*2
implicitHeight: contentItem.childrenRect.height + contentItem.padding*2
ToolTip.visible: hovered
ToolTip.text: model.users
contentItem: Row {
anchors.centerIn: parent
spacing: 2
padding: 4
Text {
anchors.baseline: reactionCounter.baseline
2020-05-04 01:59:05 +03:00
id: reactionText
text: reaction.text
2020-05-04 14:14:54 +03:00
font.family: settings.emoji_font_family
2020-05-04 01:59:05 +03:00
opacity: enabled ? 1.0 : 0.3
color: reaction.hovered ? colors.highlight : colors.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Rectangle {
height: reactionText.implicitHeight
width: 1
color: reaction.hovered ? colors.highlight : colors.buttonText
}
Text {
id: reactionCounter
2020-05-04 14:14:54 +03:00
text: model.counter
2020-05-04 01:59:05 +03:00
font: reaction.font
opacity: enabled ? 1.0 : 0.3
color: reaction.hovered ? colors.highlight : colors.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
background: Rectangle {
anchors.centerIn: parent
implicitWidth: reaction.implicitWidth
implicitHeight: reaction.implicitHeight
opacity: enabled ? 1 : 0.3
2020-05-04 14:14:54 +03:00
border.color: (reaction.hovered || model.selfReacted )? colors.highlight : colors.buttonText
2020-05-04 01:59:05 +03:00
color: colors.dark
border.width: 1
radius: reaction.height / 2.0
}
}
}
}