Warning, /office/klevernotes/src/contents/ui/dialogs/emojiDialog/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 as QQC2
0006 import org.kde.kirigami as Kirigami
0007 
0008 import org.kde.neochat
0009 import org.kde.Klever 1.0
0010 
0011 QQC2.Popup {
0012     id: root
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: root.categoryIconSize * tonesList.count + 2 * padding
0025     height: root.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 - root.width, 0).x, -(width - parent.width) / 2)
0032     background: Kirigami.ShadowedRectangle {
0033         color: Kirigami.Theme.backgroundColor
0034         radius: Kirigami.Units.mediumSpacing
0035         shadow {
0036             size: Kirigami.Units.largeSpacing
0037             color: Qt.rgba(0.0, 0.0, 0.0, 0.3)
0038             yOffset: 2
0039         }
0040         border {
0041             color: Kirigami.ColorUtils.tintWithAlpha(color, Kirigami.Theme.textColor, 0.15)
0042             width: 1
0043         }
0044     }
0045 
0046     ListView {
0047         id: tonesList
0048         width: parent.width
0049         height: parent.height
0050         orientation: Qt.Horizontal
0051         model: EmojiModel.tones(root.shortName)
0052         keyNavigationEnabled: true
0053         keyNavigationWraps: true
0054 
0055         delegate: EmojiDelegate {
0056             id: emojiDelegate
0057             checked: tonesList.currentIndex === model.index
0058             emoji: modelData.unicode
0059             name: modelData.shortName
0060 
0061             width: root.categoryIconSize
0062             height: width
0063 
0064             Keys.onEnterPressed: clicked()
0065             Keys.onReturnPressed: clicked()
0066             onClicked: {
0067                 root.chosen(Config.quickEmojiDialogEnabled ? modelData.shortName : modelData.unicode)
0068                 EmojiModel.emojiUsed(modelData)
0069                 root.close()
0070             }
0071         }
0072     }
0073 }