mirror of
https://github.com/muesli/telephant
synced 2024-11-10 05:54:19 +00:00
Add font and emoji font settings
This commit is contained in:
parent
a05749a0c6
commit
4c6fc13db0
29 changed files with 129 additions and 91 deletions
|
@ -85,6 +85,8 @@ type ConfigBridge struct {
|
|||
_ int `property:"positionY"`
|
||||
_ int `property:"width"`
|
||||
_ int `property:"height"`
|
||||
_ string `property:"fontfamily"`
|
||||
_ string `property:"emojifont"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
18
config.go
18
config.go
|
@ -17,14 +17,16 @@ type Account struct {
|
|||
|
||||
// Config holds telephant's config settings
|
||||
type Config struct {
|
||||
Account []Account
|
||||
Theme string
|
||||
Style string
|
||||
PositionX int
|
||||
PositionY int
|
||||
Width int
|
||||
Height int
|
||||
FirstRun bool
|
||||
Account []Account
|
||||
Theme string
|
||||
Style string
|
||||
PositionX int
|
||||
PositionY int
|
||||
Width int
|
||||
Height int
|
||||
FirstRun bool
|
||||
FontFamily string
|
||||
EmojiFont string
|
||||
}
|
||||
|
||||
// LoadConfig returns the current config as a Config struct
|
||||
|
|
22
events.go
22
events.go
|
@ -3,10 +3,27 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/muesli/telephant/accounts"
|
||||
"github.com/tachiniererin/bananasplit"
|
||||
)
|
||||
|
||||
func addEmojiFont(body string) string {
|
||||
runeRange := map[string][]bananasplit.RuneRange{"emoji": bananasplit.EmojiRange}
|
||||
bodyParts := bananasplit.SplitByRanges(body, runeRange)
|
||||
var mon strings.Builder
|
||||
for _, part := range bodyParts {
|
||||
if part.Type == "emoji" {
|
||||
mon.WriteString(fmt.Sprintf(`<font face="%s">%s</font>`, config.EmojiFont, part.Text))
|
||||
} else {
|
||||
mon.WriteString(part.Text)
|
||||
}
|
||||
}
|
||||
|
||||
return mon.String()
|
||||
}
|
||||
|
||||
// handleEvents handles incoming events and puts them into the right models
|
||||
func handleEvents(eventsIn chan interface{}, messages *MessageModel) {
|
||||
for {
|
||||
|
@ -22,7 +39,7 @@ func handleEvents(eventsIn chan interface{}, messages *MessageModel) {
|
|||
{
|
||||
log.Println("Account login succeeded:", event.Username, event.Name, event.Avatar)
|
||||
accountBridge.SetUsername(event.Username)
|
||||
accountBridge.SetName(event.Name)
|
||||
accountBridge.SetName(addEmojiFont(event.Name))
|
||||
accountBridge.SetAvatar(event.Avatar)
|
||||
accountBridge.SetProfileURL(event.ProfileURL)
|
||||
accountBridge.SetProfileID(event.ProfileID)
|
||||
|
@ -54,6 +71,9 @@ func handleEvents(eventsIn chan interface{}, messages *MessageModel) {
|
|||
// log.Println("Message received:", spw.Sdump(event))
|
||||
|
||||
p := messageFromEvent(event)
|
||||
p.Name = addEmojiFont(p.Name)
|
||||
p.ActorName = addEmojiFont(p.ActorName)
|
||||
p.Body = addEmojiFont(p.Body)
|
||||
|
||||
// markup links
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
modal: true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
id: accountPopup
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
import "componentCreator.js" as ComponentCreator
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
id: connectDialog
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
id: conversationPopup
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
property var message
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 2.1
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
Image {
|
||||
id: img
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtMultimedia 5.9
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtMultimedia 5.13
|
||||
|
||||
Popup {
|
||||
property var url
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
ColumnLayout {
|
||||
property bool fadeMedia
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
ListView {
|
||||
property bool fadeMedia: true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
ColumnLayout {
|
||||
property int idx
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Dialogs 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Dialogs 1.11
|
||||
|
||||
Popup {
|
||||
id: popup
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
|
||||
import "componentCreator.js" as ComponentCreator
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtGraphicalEffects 1.0
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtGraphicalEffects 1.12
|
||||
|
||||
import "componentCreator.js" as ComponentCreator
|
||||
|
||||
|
@ -33,6 +33,7 @@ ColumnLayout {
|
|||
font.pointSize: 10
|
||||
text: qsTr("%1 shared").arg(message.actorname)
|
||||
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.8 : 0.3
|
||||
textFormat: Text.RichText
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
@ -59,6 +60,7 @@ ColumnLayout {
|
|||
font.pointSize: 10
|
||||
text: qsTr("%1 liked").arg(message.actorname)
|
||||
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.8 : 0.3
|
||||
textFormat: Text.RichText
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
@ -101,7 +103,7 @@ ColumnLayout {
|
|||
font.pointSize: 11
|
||||
font.bold: true
|
||||
text: qsTr("%1 followed you").arg(message.actorname)
|
||||
textFormat: Text.PlainText
|
||||
textFormat: Text.RichText
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
|
||||
|
@ -117,7 +119,7 @@ ColumnLayout {
|
|||
Label {
|
||||
font.pointSize: 11
|
||||
text: message.actor
|
||||
textFormat: Text.PlainText
|
||||
textFormat: Text.RichText
|
||||
Layout.fillWidth: true
|
||||
elide: Text.ElideRight
|
||||
|
||||
|
@ -154,7 +156,7 @@ ColumnLayout {
|
|||
font.pointSize: 11
|
||||
font.bold: true
|
||||
text: message.name
|
||||
textFormat: Text.PlainText
|
||||
textFormat: Text.RichText
|
||||
elide: Text.ElideRight
|
||||
opacity: (accountBridge.username == message.author && (message.like || message.forward)) ? 0.4 : 1.0
|
||||
Layout.fillWidth: true
|
||||
|
@ -174,7 +176,7 @@ ColumnLayout {
|
|||
font.pointSize: 9
|
||||
opacity: 0.4
|
||||
text: "@" + message.author
|
||||
textFormat: Text.PlainText
|
||||
textFormat: Text.RichText
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
Layout.maximumWidth: implicitWidth + 1
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
/*
|
||||
* The MouseArea + interactive: false + maximumFlickVelocity are required
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
modal: true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
Popup {
|
||||
property var message
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import QtQuick 2.5
|
||||
import QtQuick.Controls 2.1
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
Label {
|
||||
id: label
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
QtObject {
|
||||
property string username: "username"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
ListModel {
|
||||
ListElement {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
ListModel {
|
||||
ListElement {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
ListModel {
|
||||
Component.onCompleted: {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
QtObject {
|
||||
property string authURL: "http://example.com/auth"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick 2.13
|
||||
|
||||
QtObject {
|
||||
function connectButton(instance) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.4
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Controls.Material 2.1
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Controls.Material 2.13
|
||||
import QtQuick.Layouts 1.11
|
||||
|
||||
import "componentCreator.js" as ComponentCreator
|
||||
|
||||
|
@ -16,6 +16,8 @@ ApplicationWindow {
|
|||
color: Material.color(Material.Grey, Material.Shade900)
|
||||
}
|
||||
|
||||
font.family: settings.fontfamily
|
||||
|
||||
minimumWidth: 364
|
||||
minimumHeight: 590
|
||||
width: settings.width > 0 ? settings.width : minimumWidth * 2
|
||||
|
|
10
telephant.go
10
telephant.go
|
@ -145,6 +145,12 @@ func main() {
|
|||
if config.Style == "" {
|
||||
config.Style = "Dark"
|
||||
}
|
||||
if config.FontFamily == "" {
|
||||
config.FontFamily = "Noto Sans"
|
||||
}
|
||||
if config.EmojiFont == "" {
|
||||
config.EmojiFont = "Noto Color Emoji"
|
||||
}
|
||||
configBridge.SetTheme(config.Theme)
|
||||
configBridge.SetStyle(config.Style)
|
||||
configBridge.SetFirstRun(config.FirstRun)
|
||||
|
@ -152,6 +158,8 @@ func main() {
|
|||
configBridge.SetPositionY(config.PositionY)
|
||||
configBridge.SetWidth(config.Width)
|
||||
configBridge.SetHeight(config.Height)
|
||||
configBridge.SetFontfamily(config.FontFamily)
|
||||
configBridge.SetEmojifont(config.EmojiFont)
|
||||
|
||||
accountBridge.SetUsername("Not connected...")
|
||||
accountBridge.SetNotifications(notificationModel)
|
||||
|
@ -178,5 +186,7 @@ func main() {
|
|||
config.Width = configBridge.Width()
|
||||
config.Height = configBridge.Height()
|
||||
config.FirstRun = false
|
||||
config.FontFamily = configBridge.Fontfamily()
|
||||
config.EmojiFont = configBridge.Emojifont()
|
||||
SaveConfig(configFile, config)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue