2020-07-02 17:48:06 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../ChatColumn/samples"
|
|
|
|
|
|
|
|
import "./emojiList.js" as EmojiJSON
|
|
|
|
|
|
|
|
Popup {
|
2020-07-02 18:49:02 +00:00
|
|
|
property var addToChat: function () {}
|
|
|
|
|
2020-07-02 17:48:06 +00:00
|
|
|
id: popup
|
|
|
|
modal: false
|
|
|
|
property int selectedPackId
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
background: Rectangle {
|
2020-07-22 20:16:06 +00:00
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
2020-07-02 17:48:06 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow{
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: emojiModel
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
EmojiJSON.emoji_json.forEach(function (emoji) {
|
2020-07-27 20:03:42 +00:00
|
|
|
emojiModel.append({filename: emoji.unicode + '.png'})
|
2020-07-02 17:48:06 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
Layout.rightMargin: 4
|
|
|
|
Layout.topMargin: 4
|
|
|
|
Layout.bottomMargin: 0
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: 400 - 4
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
property int imageWidth: 26
|
|
|
|
property int imageMargin: 4
|
|
|
|
|
|
|
|
id: emojiGrid
|
|
|
|
visible: count > 0
|
|
|
|
anchors.fill: parent
|
|
|
|
cellWidth: imageWidth + emojiGrid.imageMargin * 2
|
|
|
|
cellHeight: imageWidth + emojiGrid.imageMargin * 2
|
|
|
|
model: emojiModel
|
|
|
|
focus: true
|
|
|
|
clip: true
|
|
|
|
delegate: Item {
|
|
|
|
width: emojiGrid.cellWidth
|
|
|
|
height: emojiGrid.cellHeight
|
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: emojiGrid.imageMargin
|
|
|
|
anchors.leftMargin: emojiGrid.imageMargin
|
2020-07-06 17:54:41 +00:00
|
|
|
SVGImage {
|
2020-07-02 17:48:06 +00:00
|
|
|
width: emojiGrid.imageWidth
|
|
|
|
height: emojiGrid.imageWidth
|
|
|
|
source: "../../../../imports/twemoji/26x26/" + filename
|
2020-07-06 17:54:41 +00:00
|
|
|
// fillMode: Image.PreserveAspectFit
|
2020-07-02 17:48:06 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
2020-07-06 15:03:41 +00:00
|
|
|
const extenstionIndex = filename.lastIndexOf('.');
|
|
|
|
let iconCodePoint = filename
|
|
|
|
if (extenstionIndex > -1) {
|
|
|
|
iconCodePoint = iconCodePoint.substring(0, extenstionIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Split the filename to get all the parts and then encode them from hex to utf8
|
|
|
|
const splitCodePoint = iconCodePoint.split('-')
|
|
|
|
let codePointParts = []
|
|
|
|
splitCodePoint.forEach(function (codePoint) {
|
|
|
|
codePointParts.push(`0x${codePoint}`)
|
|
|
|
})
|
|
|
|
const encodedIcon = String.fromCodePoint(...codePointParts);
|
|
|
|
popup.addToChat(encodedIcon + ' ') // Adding a space because otherwise, some emojis would fuse since it's just an emoji is just a string
|
2020-07-02 17:48:06 +00:00
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:440;width:360}
|
|
|
|
}
|
|
|
|
##^##*/
|