Warning, /network/tokodon/src/content/ui/Components/Emoji/EmojiDelegate.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls 2 as QQC2
0006 import org.kde.kirigamiaddons.delegates 1 as Delegates
0007 import org.kde.kirigami 2 as Kirigami
0008 
0009 Delegates.RoundedItemDelegate {
0010     id: emojiDelegate
0011 
0012     property string name
0013     property string emoji
0014 
0015     property bool showTones: false
0016     property bool isImage: false
0017 
0018     QQC2.ToolTip.text: emojiDelegate.name
0019     QQC2.ToolTip.visible: hovered && QQC2.ToolTip.text !== ""
0020     QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
0021 
0022     Accessible.name: name
0023 
0024     contentItem: Item {
0025         Loader {
0026             anchors.fill: parent
0027 
0028             active: !emojiDelegate.isImage
0029             sourceComponent: Kirigami.Heading {
0030                 text: emojiDelegate.emoji
0031                 horizontalAlignment: Text.AlignHCenter
0032                 verticalAlignment: Text.AlignVCenter
0033                 font.family: "emoji"
0034 
0035                 Kirigami.Icon {
0036                     width: Kirigami.Units.gridUnit * 0.5
0037                     height: Kirigami.Units.gridUnit * 0.5
0038                     source: "arrow-down"
0039                     anchors.bottom: parent.bottom
0040                     anchors.right: parent.right
0041                     visible: emojiDelegate.showTones
0042                 }
0043             }
0044         }
0045 
0046         Loader {
0047             anchors.fill: parent
0048 
0049             active: emojiDelegate.isImage
0050             sourceComponent: Image {
0051                 source: visible ? emojiDelegate.emoji : ""
0052                 fillMode: Image.PreserveAspectFit
0053                 cache: true
0054             }
0055         }
0056     }
0057 }