Warning, /network/neochat/src/qml/ReactionDelegate.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2019 Black Hat <bhat@encom.eu.org>
0002 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
0003 // SPDX-License-Identifier: GPL-3.0-only
0004 
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 
0008 import org.kde.kirigami as Kirigami
0009 import org.kde.neochat.config
0010 
0011 Flow {
0012     id: root
0013 
0014     /**
0015      * @brief The reaction model to get the reactions from.
0016      */
0017     property alias model: reactionRepeater.model
0018 
0019     /**
0020      * @brief The given reaction has been clicked.
0021      *
0022      * Thrown when one of the reaction buttons in the flow is clicked.
0023      */
0024     signal reactionClicked(string reaction)
0025 
0026     spacing: Kirigami.Units.smallSpacing
0027 
0028     Repeater {
0029         id: reactionRepeater
0030 
0031         delegate: QQC2.AbstractButton {
0032             id: reactionDelegate
0033 
0034             required property string textContent
0035             required property string reaction
0036             required property string toolTip
0037             required property bool hasLocalUser
0038 
0039             width: Math.max(contentItem.implicitWidth + leftPadding + rightPadding, height)
0040             height: Math.round(Kirigami.Units.gridUnit * 1.5)
0041 
0042             contentItem: QQC2.Label {
0043                 id: reactionLabel
0044                 horizontalAlignment: Text.AlignHCenter
0045                 verticalAlignment: Text.AlignVCenter
0046                 text: reactionDelegate.textContent
0047                 background: null
0048                 wrapMode: TextEdit.NoWrap
0049                 textFormat: Text.RichText
0050             }
0051 
0052             padding: Kirigami.Units.smallSpacing
0053 
0054             background: Kirigami.ShadowedRectangle {
0055                 color: reactionDelegate.hasLocalUser ? Kirigami.Theme.positiveBackgroundColor : Kirigami.Theme.backgroundColor
0056                 Kirigami.Theme.inherit: false
0057                 Kirigami.Theme.colorSet: Config.compactLayout ? Kirigami.Theme.Window : Kirigami.Theme.View
0058                 radius: height / 2
0059                 shadow {
0060                     size: Kirigami.Units.smallSpacing
0061                     color: !reactionDelegate.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)
0062                 }
0063             }
0064 
0065             onClicked: reactionClicked(reactionDelegate.reaction)
0066 
0067             hoverEnabled: true
0068 
0069             QQC2.ToolTip.visible: hovered
0070             QQC2.ToolTip.text: reactionDelegate.toolTip
0071         }
0072     }
0073 }