Page MenuHomePhorge

StickerPicker.qml
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

StickerPicker.qml

/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2020-2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import org.kde.kirigami 2.13 as Kirigami
import moe.kazv.mxc.kazv 0.0 as MK
import '.' as Kazv
ColumnLayout {
id: stickerPicker
property var stickerPackList
spacing: 0
signal sendMessageRequested(var eventJson)
ScrollView {
id: packListScrollView
Layout.fillWidth: true
Layout.minimumHeight: Kirigami.Units.gridUnit * 2
Layout.preferredHeight: packListView.height
ListView {
id: packListView
orientation: ListView.Horizontal
height: contentHeight
anchors.fill: parent
currentIndex: 0
model: stickerPackList
delegate: ToolButton {
objectName: `stickerPack${index}`
property var pack: stickerPackList.at(index)
icon.name: 'smiley'
text: l10n.get('sticker-picker-user-stickers')
checked: ListView.currentIndex === index
onClicked: ListView.currentIndex = index
}
}
}
property var currentPack: packListView.currentItem && packListView.currentItem.pack
property var stickerSize: Kirigami.Units.iconSizes.enormous
property var stickerMargin: Kirigami.Units.smallSpacing
GridView {
id: stickersGridView
Layout.fillWidth: true
Layout.minimumHeight: stickerPicker.stickerSize * 5
Layout.preferredHeight: stickersGridView.height
model: currentPack
cellWidth: stickerPicker.stickerSize + stickerPicker.stickerMargin
cellHeight: stickerPicker.stickerSize + stickerPicker.stickerMargin
delegate: Item {
objectName: `sticker${index}`
property var sticker: currentPack.at(index)
height: stickerPicker.stickerSize + stickerPicker.stickerMargin
width: stickerPicker.stickerSize + stickerPicker.stickerMargin
Kirigami.Icon {
anchors.centerIn: parent
height: stickerPicker.stickerSize
width: stickerPicker.stickerSize
source: matrixSdk.mxcUriToHttp(sticker.mxcUri)
}
Rectangle {
visible: hoverHandler.hovered
z: -1
anchors.fill: parent
color: Kirigami.Theme.activeBackgroundColor
}
HoverHandler {
id: hoverHandler
}
TapHandler {
onTapped: stickerPicker.sendMessageRequested(sticker.makeEventJson())
}
}
}
Component.onCompleted: {
console.log('stickerpicker finished', stickerPackList.count);
}
}

File Metadata

Mime Type
text/plain
Expires
Tue, Jun 24, 2:04 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
234894
Default Alt Text
StickerPicker.qml (2 KB)

Event Timeline