mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Reaction and Button layout fixes
This commit is contained in:
parent
e55a09906f
commit
a1951056da
2 changed files with 21 additions and 23 deletions
|
@ -1,17 +1,11 @@
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
Button {
|
AbstractButton {
|
||||||
property string image: undefined
|
property string image: undefined
|
||||||
|
|
||||||
id: button
|
id: button
|
||||||
|
|
||||||
flat: true
|
|
||||||
|
|
||||||
// disable background, because we don't want a border on hover
|
|
||||||
background: Item {
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: buttonImg
|
id: buttonImg
|
||||||
// Workaround, can't get icon.source working for now...
|
// Workaround, can't get icon.source working for now...
|
||||||
|
|
|
@ -11,48 +11,53 @@ Flow {
|
||||||
Repeater {
|
Repeater {
|
||||||
id: repeater
|
id: repeater
|
||||||
|
|
||||||
Button {
|
AbstractButton {
|
||||||
id: reaction
|
id: reaction
|
||||||
text: model.key
|
text: model.key
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
implicitWidth: contentItem.childrenRect.width + contentItem.padding*2
|
implicitWidth: contentItem.childrenRect.width + contentItem.leftPadding*2
|
||||||
implicitHeight: contentItem.childrenRect.height + contentItem.padding*2
|
implicitHeight: contentItem.childrenRect.height
|
||||||
|
|
||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: model.users
|
ToolTip.text: model.users
|
||||||
|
|
||||||
|
|
||||||
contentItem: Row {
|
contentItem: Row {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: 2
|
spacing: reactionText.implicitHeight/4
|
||||||
padding: 4
|
leftPadding: reactionText.implicitHeight / 2
|
||||||
|
rightPadding: reactionText.implicitHeight / 2
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics
|
||||||
|
font.family: settings.emoji_font_family
|
||||||
|
elide: Text.ElideRight
|
||||||
|
elideWidth: 150
|
||||||
|
text: reaction.text
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
anchors.baseline: reactionCounter.baseline
|
anchors.baseline: reactionCounter.baseline
|
||||||
id: reactionText
|
id: reactionText
|
||||||
text: reaction.text
|
text: textMetrics.elidedText + (textMetrics.elidedText == textMetrics.text ? "" : "…")
|
||||||
font.family: settings.emoji_font_family
|
font.family: settings.emoji_font_family
|
||||||
opacity: enabled ? 1.0 : 0.3
|
|
||||||
color: reaction.hovered ? colors.highlight : colors.text
|
color: reaction.hovered ? colors.highlight : colors.text
|
||||||
horizontalAlignment: Text.AlignHCenter
|
maximumLineCount: 1
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
height: reactionText.implicitHeight
|
id: divider
|
||||||
|
height: reactionCounter.implicitHeight * 1.4
|
||||||
width: 1
|
width: 1
|
||||||
color: reaction.hovered ? colors.highlight : colors.text
|
color: reaction.hovered ? colors.highlight : colors.text
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
anchors.verticalCenter: divider.verticalCenter
|
||||||
id: reactionCounter
|
id: reactionCounter
|
||||||
text: model.counter
|
text: model.counter
|
||||||
font: reaction.font
|
font: reaction.font
|
||||||
opacity: enabled ? 1.0 : 0.3
|
|
||||||
color: reaction.hovered ? colors.highlight : colors.text
|
color: reaction.hovered ? colors.highlight : colors.text
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +65,6 @@ Flow {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
implicitWidth: reaction.implicitWidth
|
implicitWidth: reaction.implicitWidth
|
||||||
implicitHeight: reaction.implicitHeight
|
implicitHeight: reaction.implicitHeight
|
||||||
opacity: enabled ? 1 : 0.3
|
|
||||||
border.color: (reaction.hovered || model.selfReacted )? colors.highlight : colors.text
|
border.color: (reaction.hovered || model.selfReacted )? colors.highlight : colors.text
|
||||||
color: colors.base
|
color: colors.base
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
Loading…
Reference in a new issue