diff --git a/README.md b/README.md index 99f29dd..b082a92 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ Fernschreiber wouldn't be the same without all the people helping in making it b - Chat list model, TDLib receiver, project dependencies: [Slava Monich](https://github.com/monich) - Location support, app initialization/registration with Telegram, project dependencies: [jgibbon](https://github.com/jgibbon) +### Logo/Icon +- Designed by [Matteo](https://github.com/iamnomeutente) + ### Translations - Chinese: [dashinfantry](https://github.com/dashinfantry) - Finnish: [jorm1s](https://github.com/jorm1s) diff --git a/icons/108x108/harbour-fernschreiber.png b/icons/108x108/harbour-fernschreiber.png index 83e6153..c480933 100644 Binary files a/icons/108x108/harbour-fernschreiber.png and b/icons/108x108/harbour-fernschreiber.png differ diff --git a/icons/128x128/harbour-fernschreiber.png b/icons/128x128/harbour-fernschreiber.png index 5fd6a2e..7bc4571 100644 Binary files a/icons/128x128/harbour-fernschreiber.png and b/icons/128x128/harbour-fernschreiber.png differ diff --git a/icons/172x172/harbour-fernschreiber.png b/icons/172x172/harbour-fernschreiber.png index bd9b9f4..25ca620 100644 Binary files a/icons/172x172/harbour-fernschreiber.png and b/icons/172x172/harbour-fernschreiber.png differ diff --git a/icons/256x256/harbour-fernschreiber.png b/icons/256x256/harbour-fernschreiber.png index 5778a31..3394217 100644 Binary files a/icons/256x256/harbour-fernschreiber.png and b/icons/256x256/harbour-fernschreiber.png differ diff --git a/icons/86x86/harbour-fernschreiber.png b/icons/86x86/harbour-fernschreiber.png index 30ee140..1aac264 100644 Binary files a/icons/86x86/harbour-fernschreiber.png and b/icons/86x86/harbour-fernschreiber.png differ diff --git a/images/background-black-small.png b/images/background-black-small.png index 7b59b4b..5593eed 100644 Binary files a/images/background-black-small.png and b/images/background-black-small.png differ diff --git a/images/background-black.png b/images/background-black.png index f5a008b..e5279a6 100644 Binary files a/images/background-black.png and b/images/background-black.png differ diff --git a/images/background-white-small.png b/images/background-white-small.png index 250afb0..f8fb318 100644 Binary files a/images/background-white-small.png and b/images/background-white-small.png differ diff --git a/images/background-white.png b/images/background-white.png index 427d19e..b44a78e 100644 Binary files a/images/background-white.png and b/images/background-white.png differ diff --git a/images/fernschreiber-notification.png b/images/fernschreiber-notification.png index bc4e29c..b072150 100644 Binary files a/images/fernschreiber-notification.png and b/images/fernschreiber-notification.png differ diff --git a/images/fernschreiber.png b/images/fernschreiber.png index 4870166..62f2c50 100644 Binary files a/images/fernschreiber.png and b/images/fernschreiber.png differ diff --git a/qml/components/StickerPicker.qml b/qml/components/StickerPicker.qml index 3d95806..1e6e2a8 100644 --- a/qml/components/StickerPicker.qml +++ b/qml/components/StickerPicker.qml @@ -29,6 +29,17 @@ Item { property variant recentStickers: stickerManager.getRecentStickers() property variant installedStickerSets: stickerManager.getInstalledStickerSets() + property bool pickerLoaded: false + + Timer { + id: stickerPickerLoadedTimer + interval: 100 + running: true + repeat: false + onTriggered: { + stickerPickerOverlayItem.pickerLoaded = true; + } + } Rectangle { id: stickerPickerOverlayBackground @@ -37,10 +48,16 @@ Item { color: Theme.overlayBackgroundColor opacity: 0.7 } + Flickable { id: stickerPickerFlickable anchors.fill: parent anchors.margins: Theme.paddingMedium + + opacity: stickerPickerOverlayItem.pickerLoaded ? 1 : 0 + Behavior on opacity { NumberAnimation {} } + visible: stickerPickerOverlayItem.pickerLoaded + contentHeight: stickerPickerColumn.height clip: true @@ -78,18 +95,25 @@ Item { id: singleRecentStickerRow spacing: Theme.paddingSmall Image { - source: modelData.sticker.local.path - width: Theme.itemSizeMedium - height: Theme.itemSizeMedium + source: modelData.thumbnail.photo.local.path + width: Theme.itemSizeExtraLarge + height: Theme.itemSizeExtraLarge + asynchronous: true + onStatusChanged: { + if (status === Image.Ready) { + stickerPickerLoadedTimer.restart(); + } + } } } MouseArea { anchors.fill: parent onClicked: { - tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.local.path); + tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id); stickerPickerOverlayItem.visible = false; attachmentOptionsRow.visible = false; + stickerPickerLoader.active = false; } } } @@ -126,61 +150,69 @@ Item { model: modelData.stickers Item { - width: Theme.itemSizeMedium - height: Theme.itemSizeMedium - - Component.onCompleted: { - if (!modelData.sticker.local.is_downloading_completed) { - tdLibWrapper.downloadFile(modelData.sticker.id); - } - } - - Connections { - target: tdLibWrapper - onFileUpdated : { - if (fileInformation.local.is_downloading_completed) { - if (fileId === modelData.sticker.id) { - singleStickerImage.source = fileInformation.local.path; - } + width: Theme.itemSizeExtraLarge + height: Theme.itemSizeExtraLarge + Image { + id: singleStickerImage + source: modelData.thumbnail.photo.local.is_downloading_completed ? modelData.thumbnail.photo.local.path : "" + anchors.fill: parent + visible: modelData.thumbnail.photo.local.is_downloading_completed + asynchronous: true + onStatusChanged: { + if (status === Image.Ready) { + stickerPickerLoadedTimer.restart(); } } } - - Image { - id: singleStickerImage - source: modelData.sticker.local.is_downloading_completed ? modelData.sticker.local.path : "" - anchors.fill: parent - visible: modelData.sticker.local.is_downloading_completed - } Text { - font.pixelSize: Theme.fontSizeLarge + font.pixelSize: Theme.fontSizeHuge color: Theme.primaryColor anchors.fill: parent maximumLineCount: 1 elide: Text.ElideRight text: Emoji.emojify(modelData.emoji, font.pixelSize) - visible: !modelData.sticker.local.is_downloading_completed + visible: !modelData.thumbnail.photo.local.is_downloading_completed } MouseArea { anchors.fill: parent onClicked: { - tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.local.path); + tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id); stickerPickerOverlayItem.visible = false; attachmentOptionsRow.visible = false; + stickerPickerLoader.active = false; } } } - } } } - - } } - } } + + 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/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 68264d7..fa8d37a 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -30,6 +30,7 @@ import "../js/functions.js" as Functions Page { id: chatPage allowedOrientations: Orientation.All + backNavigation: !stickerPickerLoader.active property bool loading: true; property bool isInitialized: false; @@ -97,6 +98,12 @@ Page { isChannel = chatGroupInformation.is_channel; updateGroupStatusText(); } + if (stickerManager.needsReload()) { + console.log("Stickers will be reloaded!"); + tdLibWrapper.getRecentStickers(); + tdLibWrapper.getInstalledStickerSets(); + stickerManager.setNeedsReload(false); + } } function getMessageStatusText(message, listItemIndex, lastReadSentIndex) { @@ -279,7 +286,7 @@ Page { anchors.fill: parent PullDownMenu { - visible: chatInformation.id !== chatPage.myUserId + visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active MenuItem { id: muteChatMenuItem onClicked: { @@ -945,10 +952,15 @@ Page { } } -// StickerPicker { -// id: stickerPicker -// visible: false -// } + Loader { + id: stickerPickerLoader + active: false + asynchronous: true + width: parent.width + height: active ? parent.height : 0 + source: "../components/StickerPicker.qml" + } + } Column { @@ -1050,17 +1062,15 @@ Page { } HighlightImage { source: "../../images/icon-m-sticker.png" - width: documentAttachmentButton.width - height: documentAttachmentButton.height + width: Theme.itemSizeSmall + height: Theme.itemSizeSmall color: Theme.primaryColor highlightColor: Theme.highlightColor - highlighted: stickerPicker.visible + highlighted: stickerPickerLoader.active MouseArea { anchors.fill: parent onClicked: { - //console.log("RECENT STICKERS: " + JSON.stringify(stickerManager.getRecentStickers())); - //console.log("INSTALLED SETS: " + JSON.stringify(stickerManager.getInstalledStickerSets())); - stickerPicker.visible = !stickerPicker.visible; + stickerPickerLoader.active = !stickerPickerLoader.active; } } } @@ -1198,10 +1208,11 @@ Page { anchors.bottom: parent.bottom anchors.bottomMargin: Theme.paddingSmall - enabled: !(attachmentPreviewRow.visible || stickerPicker.visible) + enabled: !attachmentPreviewRow.visible onClicked: { if (attachmentOptionsRow.visible) { attachmentOptionsRow.visible = false; + stickerPickerLoader.active = false; } else { attachmentOptionsRow.visible = true; } diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 16386aa..fa78aed 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.3 -Release: 1 +Release: 2 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index b5002d4..0524663 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.3 -Release: 1 +Release: 2 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/stickermanager.cpp b/src/stickermanager.cpp index eb0aecd..b27871f 100644 --- a/src/stickermanager.cpp +++ b/src/stickermanager.cpp @@ -50,6 +50,16 @@ QVariantList StickerManager::getInstalledStickerSets() return this->installedStickerSets; } +bool StickerManager::needsReload() +{ + return this->reloadNeeded; +} + +void StickerManager::setNeedsReload(const bool &reloadNeeded) +{ + this->reloadNeeded = reloadNeeded; +} + void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds) { LOG("Receiving recent stickers...." << stickerIds); @@ -58,7 +68,7 @@ void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds) void StickerManager::handleStickersReceived(const QVariantList &stickers) { - LOG("Receiving stickers...." << stickers); + LOG("Receiving stickers...."); QListIterator stickersIterator(stickers); while (stickersIterator.hasNext()) { QVariantMap newSticker = stickersIterator.next().toMap(); @@ -81,7 +91,7 @@ void StickerManager::handleInstalledStickerSetsUpdated(const QVariantList &stick void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets) { - LOG("Receiving sticker sets...." << stickerSets); + LOG("Receiving sticker sets...."); QListIterator stickerSetsIterator(stickerSets); while (stickerSetsIterator.hasNext()) { QVariantMap newStickerSet = stickerSetsIterator.next().toMap(); @@ -102,9 +112,20 @@ void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets) void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet) { - LOG("Receiving complete sticker set...." << stickerSet); QString stickerSetId = stickerSet.value("id").toString(); + LOG("Receiving complete sticker set...." << stickerSetId); this->stickerSets.insert(stickerSetId, stickerSet); int setIndex = this->stickerSetMap.value(stickerSetId).toInt(); this->installedStickerSets.replace(setIndex, stickerSet); + QVariantList stickerList = stickerSet.value("stickers").toList(); + QListIterator stickerIterator(stickerList); + while (stickerIterator.hasNext()) { + QVariantMap singleSticker = stickerIterator.next().toMap(); + QVariantMap thumbnailFile = singleSticker.value("thumbnail").toMap().value("photo").toMap(); + QVariantMap thumbnailLocalFile = thumbnailFile.value("local").toMap(); + if (!thumbnailLocalFile.value("is_downloading_completed").toBool()) { + tdLibWrapper->downloadFile(thumbnailFile.value("id").toString()); + this->reloadNeeded = true; + } + } } diff --git a/src/stickermanager.h b/src/stickermanager.h index 326796d..f4378a3 100644 --- a/src/stickermanager.h +++ b/src/stickermanager.h @@ -35,6 +35,8 @@ public: Q_INVOKABLE QVariantList getRecentStickers(); Q_INVOKABLE QVariantList getInstalledStickerSets(); + Q_INVOKABLE bool needsReload(); + Q_INVOKABLE void setNeedsReload(const bool &reloadNeeded); signals: @@ -57,6 +59,7 @@ private: QVariantMap stickers; QVariantMap stickerSets; QVariantMap stickerSetMap; + bool reloadNeeded; }; diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 94994ca..cf85771 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -337,9 +337,9 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil this->sendRequest(requestObject); } -void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &filePath, const QString &replyToMessageId) +void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId) { - LOG("Sending sticker message" << chatId << filePath << replyToMessageId); + LOG("Sending sticker message" << chatId << fileId << replyToMessageId); QVariantMap requestObject; requestObject.insert(_TYPE, "sendMessage"); requestObject.insert("chat_id", chatId); @@ -350,8 +350,8 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file inputMessageContent.insert(_TYPE, "inputMessageSticker"); QVariantMap stickerInputFile; - stickerInputFile.insert(_TYPE, "inputFileLocal"); - stickerInputFile.insert("path", filePath); + stickerInputFile.insert(_TYPE, "inputFileRemote"); + stickerInputFile.insert("id", fileId); inputMessageContent.insert("sticker", stickerInputFile); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 40b4ba6..a583505 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -118,7 +118,7 @@ public: Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0"); Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0"); Q_INVOKABLE void sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0"); - Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &filePath, const QString &replyToMessageId = "0"); + Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId = "0"); Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId); Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue); Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap ¬ificationSettings); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index f911ccf..2af5735 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -527,7 +527,11 @@ StickerPicker Recently used - + Kürzlich verwendet + + + Loading stickers... + Lade Sticker... diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index a9e5343..7dd6900 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -527,7 +527,11 @@ StickerPicker Recently used - + Usado recientemente + + + Loading stickers... + Cargando pegatinas... diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index ea21750..4eba8f6 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 02c873b..c83c998 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 4712462..24b03ff 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -529,6 +529,10 @@ Recently used Usati di recente + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 19c7fe0..4ec32e7 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index b025095..a5f8c8e 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index d6a7995..59ecb00 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 5e7f494..acce341 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -529,6 +529,10 @@ Recently used + + Loading stickers... + + VideoPage