mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Set RS emoji font as default if no emoji native font is detected
This commit is contained in:
parent
1cdb3db548
commit
0a5b3508da
@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.2
|
||||
Rectangle {
|
||||
id: emojiButton
|
||||
|
||||
property var fontName
|
||||
|
||||
Text {
|
||||
id: emojiText
|
||||
@ -11,6 +12,7 @@ Rectangle {
|
||||
text: qsTr(eCatText)
|
||||
font.pixelSize: emojiButton.width - 8
|
||||
anchors.centerIn: parent
|
||||
font.family: fontName
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,8 @@ Rectangle {
|
||||
id: emojiCategoryButton
|
||||
property string categoryName
|
||||
|
||||
property var fontName
|
||||
|
||||
|
||||
function completedHandler() {
|
||||
categoryName = eCatName
|
||||
@ -38,6 +40,7 @@ Rectangle {
|
||||
text: qsTr(eCatText)
|
||||
font.pixelSize: emojiCategoryButton.width - 8
|
||||
anchors.centerIn: parent
|
||||
font.family: fontName
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import "emoji.js" as EmojiJSON
|
||||
//import "../../fonts/."
|
||||
|
||||
Rectangle {
|
||||
id: emojiPicker
|
||||
@ -9,6 +10,10 @@ Rectangle {
|
||||
property int buttonWidth: 40
|
||||
property TextArea textArea
|
||||
|
||||
FontLoader { id: emojiFont; source: "/fonts/OpenSansEmoji.ttf" }
|
||||
property var supportedEmojiFonts: ["Android Emoji"]
|
||||
property var rootFontName: emojiFont.name
|
||||
|
||||
//displays all Emoji of one categroy by modifying the ListModel of emojiGrid
|
||||
function categoryChangedHandler (newCategoryName){
|
||||
emojiByCategory.clear()
|
||||
@ -35,6 +40,22 @@ Rectangle {
|
||||
textArea.insert(textArea.cursorPosition, strAppnd)
|
||||
}
|
||||
|
||||
// If native emoji font exists use it, else use RS emoji font
|
||||
function selectFont ()
|
||||
{
|
||||
var fontFamilies = Qt.fontFamilies()
|
||||
return fontFamilies.some(function (f)
|
||||
{
|
||||
if (supportedEmojiFonts.indexOf(f) !== -1)
|
||||
{
|
||||
console.log("Compatible native emoji font found: " +f)
|
||||
rootFontName = f
|
||||
return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
//parses JSON, publishes button handlers and inits textArea
|
||||
function completedHandler() {
|
||||
// emojiParsedJson = JSON.parse(EmojiJSON.emoji_json)
|
||||
@ -63,7 +84,6 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//all emoji of one category
|
||||
ListModel {
|
||||
id: emojiByCategory
|
||||
@ -81,6 +101,7 @@ Rectangle {
|
||||
width: buttonWidth
|
||||
height: buttonWidth
|
||||
color: emojiPicker.color
|
||||
fontName: rootFontName
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +133,7 @@ Rectangle {
|
||||
width: buttonWidth
|
||||
height: buttonWidth
|
||||
color: emojiPicker.color
|
||||
fontName: rootFontName
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +141,10 @@ Rectangle {
|
||||
id: emojiCategoryButtons
|
||||
}
|
||||
|
||||
Component.onCompleted: completedHandler()
|
||||
Component.onCompleted:
|
||||
{
|
||||
selectFont()
|
||||
completedHandler()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user