/
erhoof
/
telegraf
Обзор
Документация
Войти
/
erhoof
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
qml/components/StickerSetOverlay.qml
157 строк
5 KB
mbarashkov
Версия 0.97.4: ленивая загрузка стикеров; ускорена в 4 раза очередь запросов.
04 июл 2025, 15:26
04 июл 2025, 15:26
2779850
Код
Авторство
О чём код?
import QtQuick 2.6 import Sailfish.Silica 1.0 import "./messageContent" import "../js/functions.js" as Functions import "../js/twemoji.js" as Emoji import "../js/debug.js" as Debug import ru.telegrafaurora.telegraf 1.0 Flickable { id: stickerSetOverlayFlickable anchors.fill: parent boundsBehavior: Flickable.StopAtBounds contentHeight: stickerSetContentColumn.height clip: true property string stickerSetId; property var stickerSet; signal requestClose; Component.onCompleted: { if (!StickerManager.hasStickerSet(stickerSetId)) { TDLibRequestSender.callGetStickerSet(stickerSetId); } else { stickerSet = StickerManager.getStickerSet(stickerSetId); } } Connections { target: TDLibResponseHandler onStickerSetReceived: { if (stickerSet.id === stickerSetOverlayFlickable.stickerSetId) { stickerSetOverlayFlickable.stickerSet = stickerSet; } } onOkReceived: { if (request === "installStickerSet") { appNotification.show(qsTr("Sticker set successfully installed!")); installSetButton.visible = false; TDLibRequestSender.callGetInstalledStickerSets(); } if (request === "removeStickerSet") { appNotification.show(qsTr("Sticker set successfully removed!")); installSetButton.visible = true; TDLibRequestSender.callGetInstalledStickerSets(); } } } Rectangle { id: stickerSetContentBackground color: Theme.overlayBackgroundColor opacity: 0.7 anchors.fill: parent MouseArea { anchors.fill: parent onClicked: { stickerSetOverlayFlickable.requestClose(); } } } Column { id: stickerSetContentColumn spacing: Theme.paddingMedium width: parent.width height: parent.height Row { id: stickerSetTitleRow width: parent.width - ( 2 * Theme.horizontalPageMargin ) height: overlayStickerTitleText.height + ( 2 * Theme.paddingMedium ) anchors.horizontalCenter: parent.horizontalCenter Label { id: overlayStickerTitleText width: parent.width - installSetButton.width - closeSetButton.width text: stickerSet.title font.pixelSize: Theme.fontSizeExtraLarge font.weight: Font.ExtraBold maximumLineCount: 1 truncationMode: TruncationMode.Fade textFormat: Text.StyledText anchors.verticalCenter: parent.verticalCenter } IconButton { id: installSetButton icon.source: "image://theme/icon-m-add" anchors.verticalCenter: parent.verticalCenter visible: !StickerManager.isStickerSetInstalled(stickerSet.id) onClicked: { TDLibRequestSender.callChangeStickerSet(stickerSet.id, true); } } IconButton { id: removeSetButton icon.source: "image://theme/icon-m-remove" anchors.verticalCenter: parent.verticalCenter visible: !installSetButton.visible onClicked: { TDLibRequestSender.callChangeStickerSet(stickerSet.id, false); } } IconButton { id: closeSetButton icon.source: "image://theme/icon-m-clear" anchors.verticalCenter: parent.verticalCenter onClicked: { stickerSetOverlayFlickable.requestClose(); } } } SilicaGridView { id: stickerSetGridView width: parent.width - ( 2 * Theme.horizontalPageMargin ) height: parent.height - stickerSetTitleRow.height - Theme.paddingMedium anchors.horizontalCenter: parent.horizontalCenter cellWidth: chatPage.isLandscape ? (width / 5) : (width / 3); cellHeight: cellWidth visible: count > 0 clip: true model: stickerSet.stickers delegate: Item { width: stickerSetGridView.cellWidth - Theme.paddingSmall height: stickerSetGridView.cellHeight - Theme.paddingSmall TDLibThumbnail { id: singleStickerThumbnail thumbnail: modelData.thumbnail autoDownload: true anchors.fill: parent } Label { font.pixelSize: Theme.fontSizeSmall anchors.right: parent.right anchors.bottom: parent.bottom text: Emoji.emojify(modelData.emoji, font.pixelSize) } } VerticalScrollDecorator {} } } }