Port to declarative type registration

This commit is contained in:
Tobias Fella
2023-09-23 14:05:50 +00:00
parent 4ed4f3f628
commit 3a4f71de7f
202 changed files with 604 additions and 532 deletions

View File

@@ -0,0 +1,67 @@
// SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: GPL-3.0-only
import QtQuick
import QtQuick.Controls as QQC2
import org.kde.kirigami as Kirigami
Flow {
id: root
/**
* @brief The reaction model to get the reactions from.
*/
property alias model: reactionRepeater.model
/**
* @brief The given reaction has been clicked.
*
* Thrown when one of the reaction buttons in the flow is clicked.
*/
signal reactionClicked(string reaction)
spacing: Kirigami.Units.smallSpacing
Repeater {
id: reactionRepeater
delegate: QQC2.AbstractButton {
width: Math.max(reactionTextMetrics.advanceWidth + Kirigami.Units.smallSpacing * 4, height)
contentItem: QQC2.Label {
id: reactionLabel
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: model.text
TextMetrics {
id: reactionTextMetrics
text: reactionLabel.text
}
}
padding: Kirigami.Units.smallSpacing
background: Kirigami.ShadowedRectangle {
color: model.hasLocalUser ? Kirigami.Theme.positiveBackgroundColor : Kirigami.Theme.backgroundColor
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
radius: height / 2
shadow {
size: Kirigami.Units.smallSpacing
color: !model.hasLocalUser ? Qt.rgba(0.0, 0.0, 0.0, 0.10) : Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.10)
}
}
onClicked: reactionClicked(model.reaction)
hoverEnabled: true
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.text: model.toolTip
}
}
}