Merge pull request #2 from Wunderfitz/master

Syncing my fork to the original repository
This commit is contained in:
Matteo 2020-10-17 10:53:02 +02:00 committed by GitHub
commit a0a5c51dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 164 additions and 58 deletions

View file

@ -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) - 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) - Location support, app initialization/registration with Telegram, project dependencies: [jgibbon](https://github.com/jgibbon)
### Logo/Icon
- Designed by [Matteo](https://github.com/iamnomeutente)
### Translations ### Translations
- Chinese: [dashinfantry](https://github.com/dashinfantry) - Chinese: [dashinfantry](https://github.com/dashinfantry)
- Finnish: [jorm1s](https://github.com/jorm1s) - Finnish: [jorm1s](https://github.com/jorm1s)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View file

@ -29,6 +29,17 @@ Item {
property variant recentStickers: stickerManager.getRecentStickers() property variant recentStickers: stickerManager.getRecentStickers()
property variant installedStickerSets: stickerManager.getInstalledStickerSets() property variant installedStickerSets: stickerManager.getInstalledStickerSets()
property bool pickerLoaded: false
Timer {
id: stickerPickerLoadedTimer
interval: 100
running: true
repeat: false
onTriggered: {
stickerPickerOverlayItem.pickerLoaded = true;
}
}
Rectangle { Rectangle {
id: stickerPickerOverlayBackground id: stickerPickerOverlayBackground
@ -37,10 +48,16 @@ Item {
color: Theme.overlayBackgroundColor color: Theme.overlayBackgroundColor
opacity: 0.7 opacity: 0.7
} }
Flickable { Flickable {
id: stickerPickerFlickable id: stickerPickerFlickable
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.paddingMedium anchors.margins: Theme.paddingMedium
opacity: stickerPickerOverlayItem.pickerLoaded ? 1 : 0
Behavior on opacity { NumberAnimation {} }
visible: stickerPickerOverlayItem.pickerLoaded
contentHeight: stickerPickerColumn.height contentHeight: stickerPickerColumn.height
clip: true clip: true
@ -78,18 +95,25 @@ Item {
id: singleRecentStickerRow id: singleRecentStickerRow
spacing: Theme.paddingSmall spacing: Theme.paddingSmall
Image { Image {
source: modelData.sticker.local.path source: modelData.thumbnail.photo.local.path
width: Theme.itemSizeMedium width: Theme.itemSizeExtraLarge
height: Theme.itemSizeMedium height: Theme.itemSizeExtraLarge
asynchronous: true
onStatusChanged: {
if (status === Image.Ready) {
stickerPickerLoadedTimer.restart();
}
}
} }
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.local.path); tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false; stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.visible = false; attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
} }
} }
} }
@ -126,61 +150,69 @@ Item {
model: modelData.stickers model: modelData.stickers
Item { Item {
width: Theme.itemSizeMedium width: Theme.itemSizeExtraLarge
height: Theme.itemSizeMedium height: Theme.itemSizeExtraLarge
Image {
Component.onCompleted: { id: singleStickerImage
if (!modelData.sticker.local.is_downloading_completed) { source: modelData.thumbnail.photo.local.is_downloading_completed ? modelData.thumbnail.photo.local.path : ""
tdLibWrapper.downloadFile(modelData.sticker.id); anchors.fill: parent
} visible: modelData.thumbnail.photo.local.is_downloading_completed
} asynchronous: true
onStatusChanged: {
Connections { if (status === Image.Ready) {
target: tdLibWrapper stickerPickerLoadedTimer.restart();
onFileUpdated : {
if (fileInformation.local.is_downloading_completed) {
if (fileId === modelData.sticker.id) {
singleStickerImage.source = fileInformation.local.path;
}
} }
} }
} }
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 { Text {
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeHuge
color: Theme.primaryColor color: Theme.primaryColor
anchors.fill: parent anchors.fill: parent
maximumLineCount: 1 maximumLineCount: 1
elide: Text.ElideRight elide: Text.ElideRight
text: Emoji.emojify(modelData.emoji, font.pixelSize) text: Emoji.emojify(modelData.emoji, font.pixelSize)
visible: !modelData.sticker.local.is_downloading_completed visible: !modelData.thumbnail.photo.local.is_downloading_completed
} }
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.local.path); tdLibWrapper.sendStickerMessage(chatInformation.id, modelData.sticker.remote.id);
stickerPickerOverlayItem.visible = false; stickerPickerOverlayItem.visible = false;
attachmentOptionsRow.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
}
}
} }

View file

@ -30,6 +30,7 @@ import "../js/functions.js" as Functions
Page { Page {
id: chatPage id: chatPage
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
backNavigation: !stickerPickerLoader.active
property bool loading: true; property bool loading: true;
property bool isInitialized: false; property bool isInitialized: false;
@ -97,6 +98,12 @@ Page {
isChannel = chatGroupInformation.is_channel; isChannel = chatGroupInformation.is_channel;
updateGroupStatusText(); updateGroupStatusText();
} }
if (stickerManager.needsReload()) {
console.log("Stickers will be reloaded!");
tdLibWrapper.getRecentStickers();
tdLibWrapper.getInstalledStickerSets();
stickerManager.setNeedsReload(false);
}
} }
function getMessageStatusText(message, listItemIndex, lastReadSentIndex) { function getMessageStatusText(message, listItemIndex, lastReadSentIndex) {
@ -279,7 +286,7 @@ Page {
anchors.fill: parent anchors.fill: parent
PullDownMenu { PullDownMenu {
visible: chatInformation.id !== chatPage.myUserId visible: chatInformation.id !== chatPage.myUserId && !stickerPickerLoader.active
MenuItem { MenuItem {
id: muteChatMenuItem id: muteChatMenuItem
onClicked: { onClicked: {
@ -945,10 +952,15 @@ Page {
} }
} }
// StickerPicker { Loader {
// id: stickerPicker id: stickerPickerLoader
// visible: false active: false
// } asynchronous: true
width: parent.width
height: active ? parent.height : 0
source: "../components/StickerPicker.qml"
}
} }
Column { Column {
@ -1050,17 +1062,15 @@ Page {
} }
HighlightImage { HighlightImage {
source: "../../images/icon-m-sticker.png" source: "../../images/icon-m-sticker.png"
width: documentAttachmentButton.width width: Theme.itemSizeSmall
height: documentAttachmentButton.height height: Theme.itemSizeSmall
color: Theme.primaryColor color: Theme.primaryColor
highlightColor: Theme.highlightColor highlightColor: Theme.highlightColor
highlighted: stickerPicker.visible highlighted: stickerPickerLoader.active
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
//console.log("RECENT STICKERS: " + JSON.stringify(stickerManager.getRecentStickers())); stickerPickerLoader.active = !stickerPickerLoader.active;
//console.log("INSTALLED SETS: " + JSON.stringify(stickerManager.getInstalledStickerSets()));
stickerPicker.visible = !stickerPicker.visible;
} }
} }
} }
@ -1198,10 +1208,11 @@ Page {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.paddingSmall anchors.bottomMargin: Theme.paddingSmall
enabled: !(attachmentPreviewRow.visible || stickerPicker.visible) enabled: !attachmentPreviewRow.visible
onClicked: { onClicked: {
if (attachmentOptionsRow.visible) { if (attachmentOptionsRow.visible) {
attachmentOptionsRow.visible = false; attachmentOptionsRow.visible = false;
stickerPickerLoader.active = false;
} else { } else {
attachmentOptionsRow.visible = true; attachmentOptionsRow.visible = true;
} }

View file

@ -12,7 +12,7 @@ Name: harbour-fernschreiber
Summary: Fernschreiber is a Telegram client for Sailfish OS Summary: Fernschreiber is a Telegram client for Sailfish OS
Version: 0.3 Version: 0.3
Release: 1 Release: 2
Group: Qt/Qt Group: Qt/Qt
License: LICENSE License: LICENSE
URL: http://werkwolf.eu/ URL: http://werkwolf.eu/

View file

@ -1,7 +1,7 @@
Name: harbour-fernschreiber Name: harbour-fernschreiber
Summary: Fernschreiber is a Telegram client for Sailfish OS Summary: Fernschreiber is a Telegram client for Sailfish OS
Version: 0.3 Version: 0.3
Release: 1 Release: 2
# The contents of the Group field should be one of the groups listed here: # The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
Group: Qt/Qt Group: Qt/Qt

View file

@ -50,6 +50,16 @@ QVariantList StickerManager::getInstalledStickerSets()
return this->installedStickerSets; return this->installedStickerSets;
} }
bool StickerManager::needsReload()
{
return this->reloadNeeded;
}
void StickerManager::setNeedsReload(const bool &reloadNeeded)
{
this->reloadNeeded = reloadNeeded;
}
void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds) void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds)
{ {
LOG("Receiving recent stickers...." << stickerIds); LOG("Receiving recent stickers...." << stickerIds);
@ -58,7 +68,7 @@ void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds)
void StickerManager::handleStickersReceived(const QVariantList &stickers) void StickerManager::handleStickersReceived(const QVariantList &stickers)
{ {
LOG("Receiving stickers...." << stickers); LOG("Receiving stickers....");
QListIterator<QVariant> stickersIterator(stickers); QListIterator<QVariant> stickersIterator(stickers);
while (stickersIterator.hasNext()) { while (stickersIterator.hasNext()) {
QVariantMap newSticker = stickersIterator.next().toMap(); QVariantMap newSticker = stickersIterator.next().toMap();
@ -81,7 +91,7 @@ void StickerManager::handleInstalledStickerSetsUpdated(const QVariantList &stick
void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets) void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets)
{ {
LOG("Receiving sticker sets...." << stickerSets); LOG("Receiving sticker sets....");
QListIterator<QVariant> stickerSetsIterator(stickerSets); QListIterator<QVariant> stickerSetsIterator(stickerSets);
while (stickerSetsIterator.hasNext()) { while (stickerSetsIterator.hasNext()) {
QVariantMap newStickerSet = stickerSetsIterator.next().toMap(); QVariantMap newStickerSet = stickerSetsIterator.next().toMap();
@ -102,9 +112,20 @@ void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets)
void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet) void StickerManager::handleStickerSetReceived(const QVariantMap &stickerSet)
{ {
LOG("Receiving complete sticker set...." << stickerSet);
QString stickerSetId = stickerSet.value("id").toString(); QString stickerSetId = stickerSet.value("id").toString();
LOG("Receiving complete sticker set...." << stickerSetId);
this->stickerSets.insert(stickerSetId, stickerSet); this->stickerSets.insert(stickerSetId, stickerSet);
int setIndex = this->stickerSetMap.value(stickerSetId).toInt(); int setIndex = this->stickerSetMap.value(stickerSetId).toInt();
this->installedStickerSets.replace(setIndex, stickerSet); this->installedStickerSets.replace(setIndex, stickerSet);
QVariantList stickerList = stickerSet.value("stickers").toList();
QListIterator<QVariant> 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;
}
}
} }

View file

@ -35,6 +35,8 @@ public:
Q_INVOKABLE QVariantList getRecentStickers(); Q_INVOKABLE QVariantList getRecentStickers();
Q_INVOKABLE QVariantList getInstalledStickerSets(); Q_INVOKABLE QVariantList getInstalledStickerSets();
Q_INVOKABLE bool needsReload();
Q_INVOKABLE void setNeedsReload(const bool &reloadNeeded);
signals: signals:
@ -57,6 +59,7 @@ private:
QVariantMap stickers; QVariantMap stickers;
QVariantMap stickerSets; QVariantMap stickerSets;
QVariantMap stickerSetMap; QVariantMap stickerSetMap;
bool reloadNeeded;
}; };

View file

@ -337,9 +337,9 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil
this->sendRequest(requestObject); 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; QVariantMap requestObject;
requestObject.insert(_TYPE, "sendMessage"); requestObject.insert(_TYPE, "sendMessage");
requestObject.insert("chat_id", chatId); requestObject.insert("chat_id", chatId);
@ -350,8 +350,8 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file
inputMessageContent.insert(_TYPE, "inputMessageSticker"); inputMessageContent.insert(_TYPE, "inputMessageSticker");
QVariantMap stickerInputFile; QVariantMap stickerInputFile;
stickerInputFile.insert(_TYPE, "inputFileLocal"); stickerInputFile.insert(_TYPE, "inputFileRemote");
stickerInputFile.insert("path", filePath); stickerInputFile.insert("id", fileId);
inputMessageContent.insert("sticker", stickerInputFile); inputMessageContent.insert("sticker", stickerInputFile);

View file

@ -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 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 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 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 getMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue); Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue);
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings); Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap &notificationSettings);

View file

@ -527,7 +527,11 @@
<name>StickerPicker</name> <name>StickerPicker</name>
<message> <message>
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation>Kürzlich verwendet</translation>
</message>
<message>
<source>Loading stickers...</source>
<translation>Lade Sticker...</translation>
</message> </message>
</context> </context>
<context> <context>

View file

@ -527,7 +527,11 @@
<name>StickerPicker</name> <name>StickerPicker</name>
<message> <message>
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation>Usado recientemente</translation>
</message>
<message>
<source>Loading stickers...</source>
<translation>Cargando pegatinas...</translation>
</message> </message>
</context> </context>
<context> <context>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation>Usati di recente</translation> <translation>Usati di recente</translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>

View file

@ -529,6 +529,10 @@
<source>Recently used</source> <source>Recently used</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Loading stickers...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>VideoPage</name> <name>VideoPage</name>