2020-09-29 08:37:08 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-09-29 08:37:08 +00:00
|
|
|
import "../../shared"
|
2021-10-14 12:14:11 +00:00
|
|
|
import "../../shared/panels"
|
2020-09-29 08:37:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
Item {
|
2021-07-07 09:32:03 +00:00
|
|
|
id: emojiSection
|
2020-09-29 08:37:08 +00:00
|
|
|
property string searchString: ""
|
|
|
|
property string searchStringLowercase: searchString.toLowerCase()
|
|
|
|
property int imageWidth: 26
|
|
|
|
property int imageMargin: 4
|
|
|
|
property var emojis: []
|
|
|
|
property var allEmojis: modelData
|
|
|
|
property var addEmoji: function () {}
|
|
|
|
|
|
|
|
visible: emojis.length > 0 || !!(modelData && modelData.length && modelData[0].empty && searchString === "")
|
|
|
|
|
|
|
|
anchors.top: index === 0 ? parent.top : parent.children[index - 1].bottom
|
|
|
|
anchors.topMargin: index === 0 ? 0 : Style.current.padding
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
// childrenRect caused a binding loop here
|
|
|
|
height: this.visible ? emojiGrid.height + categoryText.height + noRecentText.height + Style.current.padding : 0
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: categoryText
|
|
|
|
text: modelData && modelData.length ? modelData[0].category.toUpperCase() : ""
|
2021-03-26 21:33:23 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-09-29 08:37:08 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: noRecentText
|
|
|
|
visible: !!(allEmojis && allEmojis.length && allEmojis[0].empty)
|
|
|
|
//% "No recent emojis"
|
|
|
|
text: qsTrId("no-recent-emojis")
|
2021-03-26 21:33:23 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-09-29 08:37:08 +00:00
|
|
|
font.pixelSize: 10
|
|
|
|
anchors.top: categoryText.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
onSearchStringLowercaseChanged: {
|
|
|
|
if (emojiSection.searchStringLowercase === "") {
|
2020-11-19 20:45:18 +00:00
|
|
|
this.emojis = allEmojis
|
2020-09-29 08:37:08 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
this.emojis = modelData.filter(function (emoji) {
|
2020-11-19 20:45:18 +00:00
|
|
|
if (emoji.empty) {
|
|
|
|
return false
|
|
|
|
}
|
2020-09-29 08:37:08 +00:00
|
|
|
return emoji.name.includes(emojiSection.searchStringLowercase) ||
|
|
|
|
emoji.shortname.includes(emojiSection.searchStringLowercase) ||
|
|
|
|
emoji.aliases.some(a => a.includes(emojiSection.searchStringLowercase))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
onAllEmojisChanged: {
|
2021-07-07 09:32:03 +00:00
|
|
|
if (!!emojiSection.allEmojis[0] && this.allEmojis[0].empty) {
|
2020-09-29 08:37:08 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
this.emojis = this.allEmojis
|
|
|
|
}
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
id: emojiGrid
|
|
|
|
anchors.top: categoryText.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
width: parent.width
|
|
|
|
height: childrenRect.height
|
|
|
|
visible: count > 0
|
|
|
|
cellWidth: emojiSection.imageWidth + emojiSection.imageMargin * 2
|
|
|
|
cellHeight: emojiSection.imageWidth + emojiSection.imageMargin * 2
|
|
|
|
model: emojiSection.emojis
|
|
|
|
focus: true
|
|
|
|
clip: true
|
|
|
|
interactive: false
|
|
|
|
|
|
|
|
delegate: Item {
|
|
|
|
id: emojiContainer
|
|
|
|
width: emojiGrid.cellWidth
|
|
|
|
height: emojiGrid.cellHeight
|
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: emojiSection.imageMargin
|
|
|
|
anchors.leftMargin: emojiSection.imageMargin
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
width: emojiSection.imageWidth
|
|
|
|
height: emojiSection.imageWidth
|
2021-09-28 15:04:06 +00:00
|
|
|
//TODO EMOJI SVG?
|
2021-10-14 15:00:51 +00:00
|
|
|
source: "../../imports/assets/twemoji/svg/" + modelData.filename + "?22x22"
|
2020-09-29 08:37:08 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
emojiSection.addEmoji(modelData)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:440;width:360}
|
|
|
|
}
|
|
|
|
##^##*/
|