/
erhoof
/
telegraf
Обзор
Документация
Войти
/
erhoof
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
qml/components/messageContent/MessageGame.qml
109 строк
3 KB
mbarashkov
Рефакторинг зависимости tdLibRequestSender
04 июн 2025, 16:23
04 июн 2025, 16:23
be09f3b
Код
Авторство
О чём код?
import QtQuick 2.6 import Sailfish.Silica 1.0 import ru.telegrafaurora.telegraf 1.0 import "../" import "../../js/functions.js" as Functions import "../../js/twemoji.js" as Emoji MessageContentBase { id: messageContent height: gamePreviewItem.height Column { id: gamePreviewItem width: parent.width height: childrenRect.height Label { width: parent.width font.bold: true font.pixelSize: Theme.fontSizeSmall text: rawMessage.content.game.title || "" truncationMode: TruncationMode.Fade textFormat: Text.StyledText wrapMode: Text.Wrap } Label { width: parent.width font.pixelSize: Theme.fontSizeExtraSmall text: rawMessage.content.game.description truncationMode: TruncationMode.Fade textFormat: Text.StyledText wrapMode: Text.Wrap } Label { width: parent.width font.pixelSize: Theme.fontSizeExtraSmall text: Functions.enhanceMessageText(rawMessage.content.game.text) || "" truncationMode: TruncationMode.Fade wrapMode: Text.Wrap textFormat: Text.StyledText onLinkActivated: { var chatCommand = Functions.handleLink(link); if(chatCommand) { TDLibRequestSender.callSendTextMessage(chatInformation.id, chatCommand); } } } Item { width: parent.width height: Theme.paddingLarge } Image { id: thumbnail source: thumbnailFile.isDownloadingCompleted ? thumbnailFile.path : "" fillMode: Image.PreserveAspectCrop asynchronous: true visible: opacity > 0 opacity: status === Image.Ready ? 1.0 : 0.0 width: parent.width Behavior on opacity { FadeAnimation {} } layer.enabled: messageContent.highlighted layer.effect: PressEffect { source: thumbnail } TDLibFile { id: thumbnailFile autoLoad: true } Rectangle { width: Theme.iconSizeMedium height: width anchors { top: parent.top topMargin: Theme.paddingSmall left: parent.left leftMargin: Theme.paddingSmall } color: Theme.rgba(Theme.overlayBackgroundColor, 0.2) radius: Theme.paddingSmall Icon { id: icon source: "image://theme/icon-m-game-controller" asynchronous: true } } } Component.onCompleted: { if (rawMessage.content.game.photo) { // Check first which size fits best... var photo for (var i = 0; i < rawMessage.content.game.photo.sizes.length; i++) { photo = rawMessage.content.game.photo.sizes[i].photo if (rawMessage.content.game.photo.sizes[i].width >= gamePreviewItem.width) { break } } if (photo) { thumbnailFile.fileInformation = photo } } } } }