diff --git a/qml/components/StickerPicker.qml b/qml/components/StickerPicker.qml index 6c38f8f..fb3a30d 100644 --- a/qml/components/StickerPicker.qml +++ b/qml/components/StickerPicker.qml @@ -25,22 +25,32 @@ Item { id: stickerPickerOverlayItem anchors.fill: parent - property var recentStickers: stickerManager.getRecentStickers() - property var installedStickerSets: stickerManager.getInstalledStickerSets() - property bool pickerLoaded: false + property var recentStickers + property var installedStickerSets + property int setInRemoval: -1 - signal stickerPicked(var stickerId) + Component.onCompleted: { + recentStickers = stickerManager.getRecentStickers(); + installedStickerSets = stickerManager.getInstalledStickerSets(); + } - Timer { - id: stickerPickerLoadedTimer - interval: 100 - running: true - repeat: false - onTriggered: { - stickerPickerOverlayItem.pickerLoaded = true; + Connections { + target: tdLibWrapper + onOkReceived: { + if (request === "removeStickerSet") { + appNotification.show(qsTr("Sticker set successfully removed!")); + tdLibWrapper.getInstalledStickerSets(); + console.log("Set in removal: " + setInRemoval); + if (setInRemoval > -1) { + installedStickerSets.splice(setInRemoval, 1); + setInRemoval = -1; + } + } } } + signal stickerPicked(var stickerId) + Rectangle { id: stickerPickerOverlayBackground anchors.fill: parent @@ -54,10 +64,6 @@ Item { anchors.fill: parent anchors.margins: Theme.paddingMedium - opacity: stickerPickerOverlayItem.pickerLoaded ? 1 : 0 - Behavior on opacity { NumberAnimation {} } - visible: stickerPickerOverlayItem.pickerLoaded - contentHeight: stickerPickerColumn.height clip: true @@ -66,7 +72,7 @@ Item { spacing: Theme.paddingMedium width: stickerPickerFlickable.width Label { - font.pixelSize: Theme.fontSizeMedium + font.pixelSize: Theme.fontSizeLarge font.bold: true width: parent.width maximumLineCount: 1 @@ -90,15 +96,16 @@ Item { width: recentStickersGridView.cellWidth height: recentStickersGridView.cellHeight - Image { - source: modelData.thumbnail.file.local.path + TDLibThumbnail { + thumbnail: modelData.thumbnail anchors.fill: parent - asynchronous: true - onStatusChanged: { - if (status === Image.Ready) { - stickerPickerLoadedTimer.restart(); - } - } + } + + Label { + font.pixelSize: Theme.fontSizeSmall + anchors.right: parent.right + anchors.bottom: parent.bottom + text: Emoji.emojify(modelData.emoji, font.pixelSize) } MouseArea { @@ -118,13 +125,32 @@ Item { Column { spacing: Theme.paddingMedium width: parent.width - Label { - font.pixelSize: Theme.fontSizeMedium - font.bold: true + Row { width: parent.width - maximumLineCount: 1 - truncationMode: TruncationMode.Fade - text: modelData.title + height: Math.max(removeSetButton.height, setTitleText.height) + ( 2 * Theme.paddingSmall ) + Label { + id: setTitleText + font.pixelSize: Theme.fontSizeLarge + font.bold: true + width: parent.width - removeSetButton.width + anchors.verticalCenter: parent.verticalCenter + maximumLineCount: 1 + truncationMode: TruncationMode.Fade + text: modelData.title + } + + IconButton { + id: removeSetButton + icon.source: "image://theme/icon-m-remove" + anchors.verticalCenter: parent.verticalCenter + onClicked: { + var stickerSetId = modelData.id; + setInRemoval = index; + Remorse.popupAction(chatPage, qsTr("Removing sticker set"), function() { + tdLibWrapper.changeStickerSet(stickerSetId, false); + }); + } + } } SilicaGridView { @@ -142,25 +168,16 @@ Item { width: installedStickerSetGridView.cellWidth height: installedStickerSetGridView.cellHeight - Image { - id: singleStickerImage - source: modelData.thumbnail.file.local.is_downloading_completed ? modelData.thumbnail.file.local.path : "" + TDLibThumbnail { + thumbnail: modelData.thumbnail anchors.fill: parent - visible: modelData.thumbnail.file.local.is_downloading_completed - asynchronous: true - onStatusChanged: { - if (status === Image.Ready) { - stickerPickerLoadedTimer.restart(); - } - } } + Label { - font.pixelSize: Theme.fontSizeHuge - anchors.fill: parent - maximumLineCount: 1 - truncationMode: TruncationMode.Fade + font.pixelSize: Theme.fontSizeSmall + anchors.right: parent.right + anchors.bottom: parent.bottom text: Emoji.emojify(modelData.emoji, font.pixelSize) - visible: !modelData.thumbnail.file.local.is_downloading_completed } MouseArea { @@ -177,27 +194,5 @@ Item { } } - Column { - anchors.centerIn: parent - width: parent.width - spacing: Theme.paddingMedium - - opacity: stickerPickerOverlayItem.pickerLoaded ? 0 : 1 - Behavior on opacity { NumberAnimation {} } - visible: !stickerPickerOverlayItem.pickerLoaded - - InfoLabel { - id: loadingLabel - text: qsTr("Loading stickers...") - } - - BusyIndicator { - id: loadingBusyIndicator - anchors.horizontalCenter: parent.horizontalCenter - running: !stickerPickerOverlayItem.pickerLoaded - size: BusyIndicatorSize.Large - } - } - } diff --git a/qml/components/StickerSetOverlay.qml b/qml/components/StickerSetOverlay.qml index 0cf65e3..605464d 100644 --- a/qml/components/StickerSetOverlay.qml +++ b/qml/components/StickerSetOverlay.qml @@ -32,7 +32,6 @@ Flickable { property string stickerSetId; property var stickerSet; - property bool setLoaded: false; signal requestClose; Component.onCompleted: { @@ -50,15 +49,17 @@ Flickable { stickerSetOverlayFlickable.stickerSet = stickerSet; } } - } - - Timer { - id: stickerSetLoadedTimer - interval: 100 - running: true - repeat: false - onTriggered: { - stickerSetOverlayFlickable.setLoaded = true; + onOkReceived: { + if (request === "installStickerSet") { + appNotification.show(qsTr("Sticker set successfully installed!")); + installSetButton.visible = false; + tdLibWrapper.getInstalledStickerSets(); + } + if (request === "removeStickerSet") { + appNotification.show(qsTr("Sticker set successfully removed!")); + installSetButton.visible = true; + tdLibWrapper.getInstalledStickerSets(); + } } } @@ -90,7 +91,7 @@ Flickable { Label { id: overlayStickerTitleText - width: parent.width - ( installSetButton.visible ? installSetButton.width : 0 ) - closeSetButton.width + width: parent.width - installSetButton.width - closeSetButton.width text: stickerSet.title font.pixelSize: Theme.fontSizeExtraLarge font.weight: Font.ExtraBold @@ -104,12 +105,22 @@ Flickable { id: installSetButton icon.source: "image://theme/icon-m-add" anchors.verticalCenter: parent.verticalCenter - visible: !stickerSet.is_installed + visible: !stickerManager.isStickerSetInstalled(stickerSet.id) onClicked: { tdLibWrapper.changeStickerSet(stickerSet.id, true); } } + IconButton { + id: removeSetButton + icon.source: "image://theme/icon-m-remove" + anchors.verticalCenter: parent.verticalCenter + visible: !installSetButton.visible + onClicked: { + tdLibWrapper.changeStickerSet(stickerSet.id, false); + } + } + IconButton { id: closeSetButton icon.source: "image://theme/icon-m-clear" @@ -139,25 +150,17 @@ Flickable { width: stickerSetGridView.cellWidth - Theme.paddingSmall height: stickerSetGridView.cellHeight - Theme.paddingSmall - Image { - id: singleStickerImage - source: modelData.thumbnail.file.local.is_downloading_completed ? modelData.thumbnail.file.local.path : "" + TDLibThumbnail { + id: singleStickerThumbnail + thumbnail: modelData.thumbnail anchors.fill: parent - visible: modelData.thumbnail.file.local.is_downloading_completed - asynchronous: true - onStatusChanged: { - if (status === Image.Ready) { - stickerSetLoadedTimer.restart(); - } - } } + Label { - font.pixelSize: Theme.fontSizeHuge - anchors.fill: parent - maximumLineCount: 1 - truncationMode: TruncationMode.Fade + font.pixelSize: Theme.fontSizeSmall + anchors.right: parent.right + anchors.bottom: parent.bottom text: Emoji.emojify(modelData.emoji, font.pixelSize) - visible: !modelData.thumbnail.file.local.is_downloading_completed } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 1740822..1cc24a8 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -699,7 +699,7 @@ Page { contentWidth: width PullDownMenu { - visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active && !voiceNoteOverlayLoader.active && !messageOverlayLoader.active + visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active && !voiceNoteOverlayLoader.active && !messageOverlayLoader.active && !stickerSetOverlayLoader.active MenuItem { id: closeSecretChatMenuItem visible: chatPage.isSecretChat && chatPage.secretChatDetails.state["@type"] !== "secretChatStateClosed" @@ -958,7 +958,7 @@ Page { id: chatView visible: !blurred - property bool blurred: messageOverlayLoader.item || stickerPickerLoader.item || voiceNoteOverlayLoader.item || inlineQuery.hasOverlay + property bool blurred: messageOverlayLoader.item || stickerPickerLoader.item || voiceNoteOverlayLoader.item || inlineQuery.hasOverlay || stickerSetOverlayLoader.item anchors.fill: parent opacity: chatPage.loading ? 0 : 1 @@ -1304,6 +1304,9 @@ Page { } onActiveChanged: { + if (active) { + attachmentOptionsFlickable.isNeeded = false; + } } } @@ -1773,7 +1776,7 @@ Page { icon.source: "image://theme/icon-m-attach?" + (attachmentOptionsFlickable.isNeeded ? Theme.highlightColor : Theme.primaryColor) anchors.bottom: parent.bottom anchors.bottomMargin: Theme.paddingSmall - enabled: !attachmentPreviewRow.visible + enabled: !attachmentPreviewRow.visible && !stickerSetOverlayLoader.item visible: !inlineQuery.userNameIsValid onClicked: { if (attachmentOptionsFlickable.isNeeded) { diff --git a/src/stickermanager.cpp b/src/stickermanager.cpp index 479c672..65e87e1 100644 --- a/src/stickermanager.cpp +++ b/src/stickermanager.cpp @@ -60,6 +60,11 @@ bool StickerManager::hasStickerSet(const QString &stickerSetId) return this->stickerSets.contains(stickerSetId); } +bool StickerManager::isStickerSetInstalled(const QString &stickerSetId) +{ + return this->installedStickerSetIds.contains(stickerSetId); +} + bool StickerManager::needsReload() { return this->reloadNeeded; @@ -105,7 +110,15 @@ void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets) QListIterator stickerSetsIterator(stickerSets); while (stickerSetsIterator.hasNext()) { QVariantMap newStickerSet = stickerSetsIterator.next().toMap(); - this->stickerSets.insert(newStickerSet.value("id").toString(), newStickerSet); + QString newSetId = newStickerSet.value("id").toString(); + bool isInstalled = newStickerSet.value("is_installed").toBool(); + if (isInstalled && !this->installedStickerSetIds.contains(newSetId)) { + this->installedStickerSetIds.append(newSetId); + } + if (!isInstalled && this->installedStickerSetIds.contains(newSetId)) { + this->installedStickerSetIds.removeAll(newSetId); + } + this->stickerSets.insert(newSetId, newStickerSet); } this->installedStickerSets.clear(); diff --git a/src/stickermanager.h b/src/stickermanager.h index e952055..7b26bee 100644 --- a/src/stickermanager.h +++ b/src/stickermanager.h @@ -37,6 +37,7 @@ public: Q_INVOKABLE QVariantList getInstalledStickerSets(); Q_INVOKABLE QVariantMap getStickerSet(const QString &stickerSetId); Q_INVOKABLE bool hasStickerSet(const QString &stickerSetId); + Q_INVOKABLE bool isStickerSetInstalled(const QString &stickerSetId); Q_INVOKABLE bool needsReload(); Q_INVOKABLE void setNeedsReload(const bool &reloadNeeded); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index f1b06ff..1814e6a 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1332,6 +1332,7 @@ void TDLibWrapper::changeStickerSet(const QString &stickerSetId, bool isInstalle QVariantMap requestObject; requestObject.insert(_TYPE, "changeStickerSet"); + requestObject.insert(_EXTRA, isInstalled ? "installStickerSet" : "removeStickerSet"); requestObject.insert("set_id", stickerSetId); requestObject.insert("is_installed", isInstalled); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 7e7d115..1e7fac7 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1666,8 +1666,23 @@ Kürzlich verwendet - Loading stickers... - Lade Sticker... + Removing sticker set + Entferne Sticker-Set + + + Sticker set successfully removed! + Sticker-Set erfolgreich entfernt! + + + + StickerSetOverlay + + Sticker set successfully installed! + Sticker-Set erfolgreich installiert! + + + Sticker set successfully removed! + Sticker-Set erfolgreich entfernt! diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index bf311f4..cbd94b1 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1668,8 +1668,23 @@ messages Recently used - Loading stickers... - Loading stickers... + Removing sticker set + Removing sticker set + + + Sticker set successfully removed! + Sticker set successfully removed! + + + + StickerSetOverlay + + Sticker set successfully installed! + Sticker set successfully installed! + + + Sticker set successfully removed! + Sticker set successfully removed! diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 9272be0..3e216ce 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1666,8 +1666,23 @@ Usado recientemente - Loading stickers... - Cargando pegatinas... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index ebaf0ba..2dbffc2 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1667,8 +1667,23 @@ Viimeksi käytetty - Loading stickers... - Ladataan tarroja... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 80bf027..de21a42 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1639,7 +1639,22 @@ - Loading stickers... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index bacdb6a..63eec71 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1666,8 +1666,23 @@ Usati di recente - Loading stickers... - Carica sticker... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 6386ff1..dfc6fdf 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1693,8 +1693,23 @@ Ostatnio użyty - Loading stickers... - Ładowanie naklejek... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 8785d7c..f054407 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1696,8 +1696,23 @@ Недавно использованные - Loading stickers... - Загрузка стикеров... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 848a31a..5bbc498 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1693,8 +1693,23 @@ Nedávno použité - Loading stickers... - Načítanie nálepiek... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 8dce6d5..fb90049 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1666,8 +1666,23 @@ Nyligen använt - Loading stickers... - Läser in dekaler... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 507f5e0..cc64d84 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1640,8 +1640,23 @@ 最近使用 - Loading stickers... - 正在加载表情贴图… + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! + diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index f640f58..a3c7cdd 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1666,8 +1666,23 @@ Recently used - Loading stickers... - Loading stickers... + Removing sticker set + + + + Sticker set successfully removed! + + + + + StickerSetOverlay + + Sticker set successfully installed! + + + + Sticker set successfully removed! +