Redesign sticker picker, fix one sticker reload bug
This commit is contained in:
parent
ef9a999994
commit
8fc499582b
3 changed files with 100 additions and 44 deletions
|
@ -25,14 +25,8 @@ Item {
|
||||||
id: stickerPickerOverlayItem
|
id: stickerPickerOverlayItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
property var recentStickers
|
property var recentStickers: stickerManager.getRecentStickers();
|
||||||
property var installedStickerSets
|
property var installedStickerSets: stickerManager.getInstalledStickerSets();
|
||||||
property int setInRemoval: -1
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
recentStickers = stickerManager.getRecentStickers();
|
|
||||||
installedStickerSets = stickerManager.getInstalledStickerSets();
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: tdLibWrapper
|
target: tdLibWrapper
|
||||||
|
@ -40,13 +34,15 @@ Item {
|
||||||
if (request === "removeStickerSet") {
|
if (request === "removeStickerSet") {
|
||||||
appNotification.show(qsTr("Sticker set successfully removed!"));
|
appNotification.show(qsTr("Sticker set successfully removed!"));
|
||||||
tdLibWrapper.getInstalledStickerSets();
|
tdLibWrapper.getInstalledStickerSets();
|
||||||
console.log("Set in removal: " + setInRemoval);
|
|
||||||
if (setInRemoval > -1) {
|
|
||||||
installedStickerSets.splice(setInRemoval, 1);
|
|
||||||
setInRemoval = -1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: stickerManager
|
||||||
|
onStickerSetsReceived: {
|
||||||
|
installedStickerSets = stickerManager.getInstalledStickerSets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal stickerPicked(var stickerId)
|
signal stickerPicked(var stickerId)
|
||||||
|
@ -123,20 +119,65 @@ Item {
|
||||||
model: stickerPickerOverlayItem.installedStickerSets
|
model: stickerPickerOverlayItem.installedStickerSets
|
||||||
width: stickerPickerFlickable.width
|
width: stickerPickerFlickable.width
|
||||||
Column {
|
Column {
|
||||||
|
id: stickerSetColumn
|
||||||
|
|
||||||
|
property bool isExpanded: false
|
||||||
|
function toggleDisplaySet() {
|
||||||
|
stickerSetColumn.isExpanded = !stickerSetColumn.isExpanded;
|
||||||
|
stickerSetLoader.active = stickerSetColumn.isExpanded;
|
||||||
|
if (stickerSetLoader.active) {
|
||||||
|
stickerSetLoader.myStickerSet = modelData.stickers;
|
||||||
|
} else {
|
||||||
|
stickerSetLoader.myStickerSet = ({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
spacing: Theme.paddingMedium
|
spacing: Theme.paddingMedium
|
||||||
width: parent.width
|
width: parent.width
|
||||||
Row {
|
Row {
|
||||||
|
id: stickerSetTitleRow
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Math.max(removeSetButton.height, setTitleText.height) + ( 2 * Theme.paddingSmall )
|
height: stickerSetThumbnail.height + ( 2 * Theme.paddingSmall )
|
||||||
|
spacing: Theme.paddingMedium
|
||||||
|
|
||||||
|
TDLibThumbnail {
|
||||||
|
id: stickerSetThumbnail
|
||||||
|
thumbnail: modelData.thumbnail
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: Theme.itemSizeMedium
|
||||||
|
height: Theme.itemSizeMedium
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
toggleDisplaySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: setTitleText
|
id: setTitleText
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
font.bold: true
|
font.bold: true
|
||||||
width: parent.width - removeSetButton.width
|
width: parent.width - removeSetButton.width - expandSetButton.width - stickerSetThumbnail.width - ( 3 * Theme.paddingMedium )
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
truncationMode: TruncationMode.Fade
|
truncationMode: TruncationMode.Fade
|
||||||
text: modelData.title
|
text: modelData.title
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
toggleDisplaySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IconButton {
|
||||||
|
id: expandSetButton
|
||||||
|
icon.source: stickerSetColumn.isExpanded ? "image://theme/icon-m-up" : "image://theme/icon-m-down"
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
onClicked: {
|
||||||
|
toggleDisplaySet();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton {
|
IconButton {
|
||||||
|
@ -145,25 +186,34 @@ Item {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var stickerSetId = modelData.id;
|
var stickerSetId = modelData.id;
|
||||||
setInRemoval = index;
|
|
||||||
Remorse.popupAction(chatPage, qsTr("Removing sticker set"), function() {
|
Remorse.popupAction(chatPage, qsTr("Removing sticker set"), function() {
|
||||||
tdLibWrapper.changeStickerSet(stickerSetId, false);
|
tdLibWrapper.changeStickerSet(stickerSetId, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: stickerSetLoader
|
||||||
|
width: parent.width
|
||||||
|
active: false
|
||||||
|
height: active ? Theme.itemSizeExtraLarge : 0
|
||||||
|
|
||||||
|
property var myStickerSet
|
||||||
|
|
||||||
|
sourceComponent: Component {
|
||||||
SilicaGridView {
|
SilicaGridView {
|
||||||
id: installedStickerSetGridView
|
id: installedStickerSetGridView
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Theme.itemSizeExtraLarge
|
height: parent.height
|
||||||
cellWidth: Theme.itemSizeExtraLarge;
|
cellWidth: Theme.itemSizeExtraLarge;
|
||||||
cellHeight: Theme.itemSizeExtraLarge;
|
cellHeight: Theme.itemSizeExtraLarge;
|
||||||
visible: count > 0
|
visible: count > 0
|
||||||
clip: true
|
clip: true
|
||||||
flow: GridView.FlowTopToBottom
|
flow: GridView.FlowTopToBottom
|
||||||
|
|
||||||
model: modelData.stickers
|
model: stickerSetLoader.myStickerSet
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: installedStickerSetGridView.cellWidth
|
width: installedStickerSetGridView.cellWidth
|
||||||
height: installedStickerSetGridView.cellHeight
|
height: installedStickerSetGridView.cellHeight
|
||||||
|
@ -188,6 +238,8 @@ Item {
|
||||||
|
|
||||||
HorizontalScrollDecorator {}
|
HorizontalScrollDecorator {}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,8 +118,10 @@ void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets)
|
||||||
if (!isInstalled && this->installedStickerSetIds.contains(newSetId)) {
|
if (!isInstalled && this->installedStickerSetIds.contains(newSetId)) {
|
||||||
this->installedStickerSetIds.removeAll(newSetId);
|
this->installedStickerSetIds.removeAll(newSetId);
|
||||||
}
|
}
|
||||||
|
if (!this->stickerSets.contains(newSetId)) {
|
||||||
this->stickerSets.insert(newSetId, newStickerSet);
|
this->stickerSets.insert(newSetId, newStickerSet);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->installedStickerSets.clear();
|
this->installedStickerSets.clear();
|
||||||
QListIterator<QVariant> stickerSetIdIterator(this->installedStickerSetIds);
|
QListIterator<QVariant> stickerSetIdIterator(this->installedStickerSetIds);
|
||||||
|
@ -133,6 +135,7 @@ void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emit stickerSetsReceived();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet)
|
void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet)
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
Q_INVOKABLE void setNeedsReload(const bool &reloadNeeded);
|
Q_INVOKABLE void setNeedsReload(const bool &reloadNeeded);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void stickerSetsReceived();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue