Warning, /network/tokodon/src/content/ui/Components/Emoji/EmojiTonesPicker.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.kirigami 2 as Kirigami
0007 import org.kde.tokodon
0008 
0009 import ".."
0010 
0011 QQC2.Popup {
0012     id: tones
0013 
0014     signal chosen(string emoji)
0015 
0016     Component.onCompleted: {
0017         tonesList.currentIndex = 0;
0018         tonesList.forceActiveFocus();
0019     }
0020 
0021     required property string shortName
0022     required property string unicode
0023     required property int categoryIconSize
0024     width: tones.categoryIconSize * tonesList.count + 2 * padding
0025     height: tones.categoryIconSize + 2 * padding
0026     y: -height
0027     padding: 2
0028     modal: true
0029     dim: true
0030     clip: false
0031     onOpened: x = Math.min(parent.mapFromGlobal(QQC2.Overlay.overlay.width - tones.width, 0).x, -(width - parent.width) / 2)
0032     background: PopupShadow {}
0033 
0034     ListView {
0035         id: tonesList
0036         width: parent.width
0037         height: parent.height
0038         orientation: Qt.Horizontal
0039         model: EmojiModel.tones(tones.shortName)
0040         keyNavigationEnabled: true
0041         keyNavigationWraps: true
0042 
0043         delegate: EmojiDelegate {
0044             id: emojiDelegate
0045             checked: tonesList.currentIndex === model.index
0046             emoji: modelData.unicode
0047             name: modelData.shortName
0048 
0049             width: tones.categoryIconSize
0050             height: width
0051 
0052             Keys.onEnterPressed: clicked()
0053             Keys.onReturnPressed: clicked()
0054             onClicked: {
0055                 tones.chosen(modelData.unicode)
0056                 EmojiModel.emojiUsed(AccountManager.selectedAccount, name)
0057                 tones.close()
0058             }
0059         }
0060     }
0061 }