Use GridView for sticker picker

This commit is contained in:
Sebastian J. Wolf 2020-10-18 16:29:34 +02:00
parent a9f7a10033
commit e578c6bef3
2 changed files with 78 additions and 79 deletions

View file

@ -74,53 +74,50 @@ Item {
elide: Text.ElideRight elide: Text.ElideRight
text: qsTr("Recently used") text: qsTr("Recently used")
} }
Flickable {
SilicaGridView {
id: recentStickersGridView
width: parent.width width: parent.width
height: recentStickersRow.height + Theme.paddingSmall height: Theme.itemSizeExtraLarge
anchors.horizontalCenter: parent.horizontalCenter cellWidth: Theme.itemSizeExtraLarge;
contentWidth: recentStickersRow.width cellHeight: Theme.itemSizeExtraLarge;
visible: count > 0
clip: true clip: true
flow: GridView.FlowTopToBottom
Row { model: stickerPickerOverlayItem.recentStickers
id: recentStickersRow
spacing: Theme.paddingMedium
Repeater {
model: stickerPickerOverlayItem.recentStickers
Item { delegate: Item {
height: singleRecentStickerRow.height width: recentStickersGridView.cellWidth
width: singleRecentStickerRow.width height: recentStickersGridView.cellHeight
Row { Image {
id: singleRecentStickerRow source: modelData.thumbnail.photo.local.path
spacing: Theme.paddingSmall anchors.fill: parent
Image { asynchronous: true
source: modelData.thumbnail.photo.local.path onStatusChanged: {
width: Theme.itemSizeExtraLarge if (status === Image.Ready) {
height: Theme.itemSizeExtraLarge stickerPickerLoadedTimer.restart();
asynchronous: true
onStatusChanged: {
if (status === Image.Ready) {
stickerPickerLoadedTimer.restart();
}
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
}
} }
} }
} }
MouseArea {
anchors.fill: parent
onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
}
}
} }
HorizontalScrollDecorator {}
} }
Repeater { Repeater {
model: stickerPickerOverlayItem.installedStickerSets model: stickerPickerOverlayItem.installedStickerSets
width: stickerPickerFlickable.width width: stickerPickerFlickable.width
@ -136,57 +133,58 @@ Item {
elide: Text.ElideRight elide: Text.ElideRight
text: modelData.title text: modelData.title
} }
Flickable {
SilicaGridView {
id: installedStickerSetGridView
width: parent.width width: parent.width
height: installedStickerSetRow.height + Theme.paddingSmall height: Theme.itemSizeExtraLarge
anchors.horizontalCenter: parent.horizontalCenter cellWidth: Theme.itemSizeExtraLarge;
contentWidth: installedStickerSetRow.width cellHeight: Theme.itemSizeExtraLarge;
visible: count > 0
clip: true clip: true
Row { flow: GridView.FlowTopToBottom
id: installedStickerSetRow
spacing: Theme.paddingMedium
Repeater { model: modelData.stickers
model: modelData.stickers delegate: Item {
width: installedStickerSetGridView.cellWidth
height: installedStickerSetGridView.cellHeight
Item { Image {
width: Theme.itemSizeExtraLarge id: singleStickerImage
height: Theme.itemSizeExtraLarge source: modelData.thumbnail.photo.local.is_downloading_completed ? modelData.thumbnail.photo.local.path : ""
Image { anchors.fill: parent
id: singleStickerImage visible: modelData.thumbnail.photo.local.is_downloading_completed
source: modelData.thumbnail.photo.local.is_downloading_completed ? modelData.thumbnail.photo.local.path : "" asynchronous: true
anchors.fill: parent onStatusChanged: {
visible: modelData.thumbnail.photo.local.is_downloading_completed if (status === Image.Ready) {
asynchronous: true stickerPickerLoadedTimer.restart();
onStatusChanged: {
if (status === Image.Ready) {
stickerPickerLoadedTimer.restart();
}
}
}
Text {
font.pixelSize: Theme.fontSizeHuge
color: Theme.primaryColor
anchors.fill: parent
maximumLineCount: 1
elide: Text.ElideRight
text: Emoji.emojify(modelData.emoji, font.pixelSize)
visible: !modelData.thumbnail.photo.local.is_downloading_completed
}
MouseArea {
anchors.fill: parent
onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
}
} }
} }
} }
Text {
font.pixelSize: Theme.fontSizeHuge
color: Theme.primaryColor
anchors.fill: parent
maximumLineCount: 1
elide: Text.ElideRight
text: Emoji.emojify(modelData.emoji, font.pixelSize)
visible: !modelData.thumbnail.photo.local.is_downloading_completed
}
MouseArea {
anchors.fill: parent
onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
}
}
} }
HorizontalScrollDecorator {}
} }
} }
} }
} }

View file

@ -846,6 +846,7 @@ void TDLibWrapper::setInitialParameters()
initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString());
initialParameters.insert("system_version", QSysInfo::prettyProductName()); initialParameters.insert("system_version", QSysInfo::prettyProductName());
initialParameters.insert("application_version", "0.3"); initialParameters.insert("application_version", "0.3");
// initialParameters.insert("use_test_dc", true);
requestObject.insert("parameters", initialParameters); requestObject.insert("parameters", initialParameters);
this->sendRequest(requestObject); this->sendRequest(requestObject);
} }