mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
sticker packs order now is saved, new packs added to the top, fixed emoji categories icons
This commit is contained in:
parent
cfdacb09ac
commit
18361ce144
9 changed files with 74 additions and 44 deletions
|
@ -1518,12 +1518,12 @@ emojiFoodActive: sprite(266px, 286px, 21px, 22px);
|
|||
emojiCelebration: sprite(84px, 196px, 21px, 22px);
|
||||
emojiCelebrationOver: sprite(287px, 264px, 21px, 22px);
|
||||
emojiCelebrationActive: sprite(287px, 286px, 21px, 22px);
|
||||
emojiActivity: sprite(105px, 196px, 21px, 22px);
|
||||
emojiActivityOver: sprite(308px, 264px, 21px, 22px);
|
||||
emojiActivityActive: sprite(308px, 286px, 21px, 22px);
|
||||
emojiTravel: sprite(126px, 196px, 21px, 22px);
|
||||
emojiTravelOver: sprite(321px, 344px, 21px, 22px);
|
||||
emojiTravelActive: sprite(321px, 366px, 21px, 22px);
|
||||
emojiActivity: sprite(126px, 196px, 21px, 22px);
|
||||
emojiActivityOver: sprite(321px, 344px, 21px, 22px);
|
||||
emojiActivityActive: sprite(321px, 366px, 21px, 22px);
|
||||
emojiTravel: sprite(105px, 196px, 21px, 22px);
|
||||
emojiTravelOver: sprite(308px, 264px, 21px, 22px);
|
||||
emojiTravelActive: sprite(308px, 286px, 21px, 22px);
|
||||
emojiObjects: sprite(147px, 196px, 21px, 22px);
|
||||
emojiObjectsOver: sprite(342px, 344px, 21px, 22px);
|
||||
emojiObjectsActive: sprite(342px, 366px, 21px, 22px);
|
||||
|
|
|
@ -1529,6 +1529,7 @@ namespace App {
|
|||
cSetStickersHash(QByteArray());
|
||||
cSetEmojiStickers(EmojiStickersMap());
|
||||
cSetStickerSets(StickerSets());
|
||||
cSetStickerSetsOrder(StickerSetsOrder());
|
||||
cSetLastStickersUpdate(0);
|
||||
::videoItems.clear();
|
||||
::audioItems.clear();
|
||||
|
|
|
@ -83,14 +83,20 @@ bool StickerSetInner::failedSet(const RPCError &error) {
|
|||
|
||||
void StickerSetInner::installDone(const MTPBool &result) {
|
||||
StickerSets &sets(cRefStickerSets());
|
||||
StickerSets::iterator custom = sets.find(CustomStickerSetId);
|
||||
|
||||
sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName)).value().stickers = _pack;
|
||||
int32 index = cStickerSetsOrder().indexOf(_setId);
|
||||
if (index > 0) {
|
||||
cRefStickerSetsOrder().removeAt(index);
|
||||
cRefStickerSetsOrder().push_front(_setId);
|
||||
} else if (index < 0) {
|
||||
cRefStickerSetsOrder().push_front(_setId);
|
||||
}
|
||||
|
||||
StickerSets::iterator custom = sets.find(CustomStickerSetId);
|
||||
if (custom != sets.cend()) {
|
||||
for (int32 i = 0, l = _pack.size(); i < l; ++i) {
|
||||
int32 index = custom->stickers.indexOf(_pack.at(i));
|
||||
if (index >= 0) {
|
||||
custom->stickers.removeAt(index);
|
||||
}
|
||||
custom->stickers.removeOne(_pack.at(i));
|
||||
}
|
||||
if (custom->stickers.isEmpty()) {
|
||||
sets.erase(custom);
|
||||
|
|
|
@ -1386,13 +1386,10 @@ void StickerPanInner::refreshStickers() {
|
|||
|
||||
refreshRecent(false);
|
||||
|
||||
StickerSets::const_iterator it;
|
||||
|
||||
it = sets.constFind(CustomStickerSetId); if (it != sets.cend()) appendSet(it);
|
||||
it = sets.constFind(DefaultStickerSetId); if (it != sets.cend()) appendSet(it);
|
||||
|
||||
for (it = sets.cbegin(); it != sets.cend(); ++it) {
|
||||
if (it->id != CustomStickerSetId && it->id != DefaultStickerSetId) appendSet(it);
|
||||
appendSet(CustomStickerSetId);
|
||||
appendSet(DefaultStickerSetId);
|
||||
for (StickerSetsOrder::const_iterator i = cStickerSetsOrder().cbegin(), e = cStickerSetsOrder().cend(); i != e; ++i) {
|
||||
appendSet(*i);
|
||||
}
|
||||
|
||||
int32 h = countHeight();
|
||||
|
@ -1431,8 +1428,10 @@ void StickerPanInner::preloadImages() {
|
|||
}
|
||||
}
|
||||
|
||||
void StickerPanInner::appendSet(StickerSets::const_iterator it) {
|
||||
if (it->stickers.isEmpty()) return;
|
||||
void StickerPanInner::appendSet(uint64 setId) {
|
||||
const StickerSets &sets(cStickerSets());
|
||||
StickerSets::const_iterator it = sets.constFind(setId);
|
||||
if (it == sets.cend() || it->stickers.isEmpty()) return;
|
||||
|
||||
StickerPack pack;
|
||||
pack.reserve(it->stickers.size());
|
||||
|
@ -2046,6 +2045,7 @@ void EmojiPan::onRemoveSetSure() {
|
|||
}
|
||||
}
|
||||
cRefStickerSets().erase(it);
|
||||
cRefStickerSetsOrder().removeOne(_removingSetId);
|
||||
cSetStickersHash(QByteArray());
|
||||
refreshStickers();
|
||||
Local::writeStickers();
|
||||
|
|
|
@ -313,7 +313,7 @@ signals:
|
|||
|
||||
private:
|
||||
|
||||
void appendSet(StickerSets::const_iterator it);
|
||||
void appendSet(uint64 setId);
|
||||
|
||||
int32 countHeight();
|
||||
void selectEmoji(EmojiPtr emoji);
|
||||
|
|
|
@ -1829,6 +1829,9 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
|||
QByteArray wasHash = cStickersHash();
|
||||
cSetStickersHash(qba(d.vhash));
|
||||
|
||||
StickerSetsOrder &setsOrder(cRefStickerSetsOrder());
|
||||
setsOrder.clear();
|
||||
|
||||
StickerSets &sets(cRefStickerSets());
|
||||
StickerSets::iterator def = sets.find(DefaultStickerSetId);
|
||||
if (def == sets.cend()) {
|
||||
|
@ -1838,6 +1841,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
|||
if (d_sets.at(i).type() == mtpc_stickerSet) {
|
||||
const MTPDstickerSet &set(d_sets.at(i).c_stickerSet());
|
||||
StickerSets::iterator i = sets.find(set.vid.v);
|
||||
setsOrder.push_back(set.vid.v);
|
||||
if (i == sets.cend()) {
|
||||
i = sets.insert(set.vid.v, StickerSet(set.vid.v, set.vaccess_hash.v, qs(set.vtitle), qs(set.vshort_name)));
|
||||
} else {
|
||||
|
@ -1931,6 +1935,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
|||
++i;
|
||||
}
|
||||
}
|
||||
setsOrder.removeOne(it->id);
|
||||
it = sets.erase(it);
|
||||
removed = true;
|
||||
} else {
|
||||
|
@ -1952,6 +1957,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
|||
}
|
||||
}
|
||||
if (it->stickers.isEmpty()) {
|
||||
setsOrder.removeOne(it->id);
|
||||
it = sets.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
|
|
|
@ -2207,6 +2207,31 @@ namespace Local {
|
|||
return _storageAudiosSize;
|
||||
}
|
||||
|
||||
void _writeStickerSet(QDataStream &stream, uint64 setId) {
|
||||
StickerSets::const_iterator it = cStickerSets().constFind(setId);
|
||||
if (it == cStickerSets().cend() || it->stickers.isEmpty()) return;
|
||||
|
||||
stream << quint64(it->id) << quint64(it->access) << it->title << it->shortName << quint32(it->stickers.size());
|
||||
for (StickerPack::const_iterator j = it->stickers.cbegin(), e = it->stickers.cend(); j != e; ++j) {
|
||||
DocumentData *doc = *j;
|
||||
stream << quint64(doc->id) << quint64(doc->access) << qint32(doc->date) << doc->name << doc->mime << qint32(doc->dc) << qint32(doc->size) << qint32(doc->dimensions.width()) << qint32(doc->dimensions.height()) << qint32(doc->type) << doc->sticker->alt;
|
||||
switch (doc->sticker->set.type()) {
|
||||
case mtpc_inputStickerSetID: {
|
||||
stream << qint32(StickerSetTypeID);
|
||||
} break;
|
||||
case mtpc_inputStickerSetShortName: {
|
||||
stream << qint32(StickerSetTypeShortName);
|
||||
} break;
|
||||
case mtpc_inputStickerSetEmpty:
|
||||
default: {
|
||||
stream << qint32(StickerSetTypeEmpty);
|
||||
} break;
|
||||
}
|
||||
const StorageImageLocation &loc(doc->sticker->loc);
|
||||
stream << qint32(loc.width) << qint32(loc.height) << qint32(loc.dc) << quint64(loc.volume) << qint32(loc.local) << quint64(loc.secret);
|
||||
}
|
||||
}
|
||||
|
||||
void writeStickers() {
|
||||
if (!_working()) return;
|
||||
|
||||
|
@ -2241,29 +2266,11 @@ namespace Local {
|
|||
}
|
||||
}
|
||||
EncryptedDescriptor data(size);
|
||||
data.stream << quint32(sets.size()) << cStickersHash();
|
||||
for (StickerSets::const_iterator i = sets.cbegin(); i != sets.cend(); ++i) {
|
||||
if (i->stickers.isEmpty()) continue;
|
||||
|
||||
data.stream << quint64(i->id) << quint64(i->access) << i->title << i->shortName << quint32(i->stickers.size());
|
||||
for (StickerPack::const_iterator j = i->stickers.cbegin(), e = i->stickers.cend(); j != e; ++j) {
|
||||
DocumentData *doc = *j;
|
||||
data.stream << quint64(doc->id) << quint64(doc->access) << qint32(doc->date) << doc->name << doc->mime << qint32(doc->dc) << qint32(doc->size) << qint32(doc->dimensions.width()) << qint32(doc->dimensions.height()) << qint32(doc->type) << doc->sticker->alt;
|
||||
switch (doc->sticker->set.type()) {
|
||||
case mtpc_inputStickerSetID: {
|
||||
data.stream << qint32(StickerSetTypeID);
|
||||
} break;
|
||||
case mtpc_inputStickerSetShortName: {
|
||||
data.stream << qint32(StickerSetTypeShortName);
|
||||
} break;
|
||||
case mtpc_inputStickerSetEmpty:
|
||||
default: {
|
||||
data.stream << qint32(StickerSetTypeEmpty);
|
||||
} break;
|
||||
}
|
||||
const StorageImageLocation &loc(doc->sticker->loc);
|
||||
data.stream << qint32(loc.width) << qint32(loc.height) << qint32(loc.dc) << quint64(loc.volume) << qint32(loc.local) << quint64(loc.secret);
|
||||
}
|
||||
data.stream << quint32(cStickerSetsOrder().size()) << cStickersHash();
|
||||
_writeStickerSet(data.stream, DefaultStickerSetId);
|
||||
_writeStickerSet(data.stream, CustomStickerSetId);
|
||||
for (StickerSetsOrder::const_iterator i = cStickerSetsOrder().cbegin(), e = cStickerSetsOrder().cend(); i != e; ++i) {
|
||||
_writeStickerSet(data.stream, *i);
|
||||
}
|
||||
FileWriteDescriptor file(_stickersKey);
|
||||
file.writeEncrypted(data);
|
||||
|
@ -2283,6 +2290,8 @@ namespace Local {
|
|||
|
||||
StickerSets &sets(cRefStickerSets());
|
||||
sets.clear();
|
||||
cSetStickerSetsOrder(StickerSetsOrder());
|
||||
|
||||
RecentStickerPack &recent(cRefRecentStickers());
|
||||
recent.clear();
|
||||
|
||||
|
@ -2352,6 +2361,9 @@ namespace Local {
|
|||
StickerSets &sets(cRefStickerSets());
|
||||
sets.clear();
|
||||
|
||||
StickerSetsOrder &order(cRefStickerSetsOrder());
|
||||
order.clear();
|
||||
|
||||
quint32 cnt;
|
||||
QByteArray hash;
|
||||
stickers.stream >> cnt >> hash;
|
||||
|
@ -2365,6 +2377,8 @@ namespace Local {
|
|||
setTitle = lang(lng_stickers_default_set);
|
||||
} else if (setId == CustomStickerSetId) {
|
||||
setTitle = lang(lng_custom_stickers);
|
||||
} else {
|
||||
order.push_back(setId);
|
||||
}
|
||||
StickerSet &set(sets.insert(setId, StickerSet(setId, setAccess, setTitle, setShortName)).value());
|
||||
set.stickers.reserve(scnt);
|
||||
|
|
|
@ -96,6 +96,7 @@ EmojiStickersMap gEmojiStickers;
|
|||
RecentStickerPreload gRecentStickersPreload;
|
||||
RecentStickerPack gRecentStickers;
|
||||
StickerSets gStickerSets;
|
||||
StickerSetsOrder gStickerSetsOrder;
|
||||
|
||||
uint64 gLastStickersUpdate = 0;
|
||||
|
||||
|
|
|
@ -208,6 +208,8 @@ struct StickerSet {
|
|||
};
|
||||
typedef QMap<uint64, StickerSet> StickerSets;
|
||||
DeclareRefSetting(StickerSets, StickerSets);
|
||||
typedef QList<uint64> StickerSetsOrder;
|
||||
DeclareRefSetting(StickerSetsOrder, StickerSetsOrder);
|
||||
|
||||
typedef QList<QPair<QString, ushort> > RecentHashtagPack;
|
||||
DeclareSetting(RecentHashtagPack, RecentWriteHashtags);
|
||||
|
|
Loading…
Add table
Reference in a new issue