2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

dev version 0.9.19 sending stickers by emoji

This commit is contained in:
John Preston
2016-01-09 20:51:42 +08:00
parent a72a31e722
commit b13579c7d9
19 changed files with 184 additions and 143 deletions

View File

@@ -43,6 +43,7 @@ _input(set), _installRequest(0) {
void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.clear();
_emoji.clear();
if (set.type() == mtpc_messages_stickerSet) {
const MTPDmessages_stickerSet &d(set.c_messages_stickerSet());
const QVector<MTPDocument> &v(d.vdocuments.c_vector().v);
@@ -53,6 +54,23 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.push_back(doc);
}
const QVector<MTPStickerPack> &packs(d.vpacks.c_vector().v);
for (int32 i = 0, l = packs.size(); i < l; ++i) {
if (packs.at(i).type() != mtpc_stickerPack) continue;
const MTPDstickerPack &pack(packs.at(i).c_stickerPack());
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
DocumentData *doc = App::document(stickers.at(j).v);
if (!doc || !doc->sticker()) continue;
p.push_back(doc);
}
_emoji.insert(e, p);
}
}
if (d.vset.type() == mtpc_stickerSet) {
const MTPDstickerSet &s(d.vset.c_stickerSet());
_setTitle = stickerSetTitle(s);
@@ -91,8 +109,12 @@ void StickerSetInner::installDone(const MTPBool &result) {
StickerSets &sets(cRefStickerSets());
_setFlags &= ~MTPDstickerSet::flag_disabled;
sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags)).value().stickers = _pack;
Global::StickersByEmoji_AddPack(_pack);
StickerSets::iterator it = sets.find(_setId);
if (it == sets.cend()) {
it = sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags));
}
it.value().stickers = _pack;
it.value().emoji = _emoji;
StickerSetsOrder &order(cRefStickerSetsOrder());
int32 insertAtIndex = 0, currentIndex = order.indexOf(_setId);
@@ -868,7 +890,6 @@ void StickersBox::onSave() {
if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex);
sets.erase(it);
}
Global::StickersByEmoji_RemovePack(it->stickers);
}
}
}
@@ -881,7 +902,6 @@ void StickersBox::onSave() {
MTPInputStickerSet setId = (it->id && it->access) ? MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)) : MTP_inputStickerSetShortName(MTP_string(it->shortName));
_disenableRequests.insert(MTP::send(MTPmessages_InstallStickerSet(setId, MTP_boolFalse()), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType());
it->flags &= ~MTPDstickerSet::flag_disabled;
Global::StickersByEmoji_AddPack(it->stickers);
}
order.push_back(reorder.at(i));
}
@@ -890,7 +910,6 @@ void StickersBox::onSave() {
if (it->id == CustomStickerSetId || it->id == RecentStickerSetId || order.contains(it->id)) {
++it;
} else {
Global::StickersByEmoji_RemovePack(it->stickers);
it = sets.erase(it);
}
}

View File

@@ -32,7 +32,7 @@ public:
void init();
void paintEvent(QPaintEvent *e);
bool loaded() const;
int32 notInstalled() const;
bool official() const;
@@ -60,6 +60,7 @@ private:
bool installFailed(const RPCError &error);
StickerPack _pack;
StickersByEmojiMap _emoji;
bool _loaded;
uint64 _setId, _setAccess;
QString _title, _setTitle, _setShortName;
@@ -118,7 +119,7 @@ public:
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void rebuild();
bool savingStart() {
if (_saving) return false;
@@ -201,7 +202,7 @@ public:
StickersBox();
void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e);
void closePressed();
public slots: