mirror of https://github.com/procxx/kepka.git
Cloud recent sticker sets supported.
This commit is contained in:
parent
bf4acc4e52
commit
95c050081c
|
@ -689,6 +689,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
"lng_stickers_packs" = "Sticker Packs";
|
"lng_stickers_packs" = "Sticker Packs";
|
||||||
"lng_stickers_reorder" = "Click and drag to reorder sticker packs";
|
"lng_stickers_reorder" = "Click and drag to reorder sticker packs";
|
||||||
"lng_stickers_featured" = "Featured Stickers";
|
"lng_stickers_featured" = "Featured Stickers";
|
||||||
|
"lng_stickers_clear_recent" = "Clear";
|
||||||
|
"lng_stickers_clear_recent_sure" = "Are you sure you want to clear your frequently used stickers list?";
|
||||||
"lng_stickers_remove" = "Delete";
|
"lng_stickers_remove" = "Delete";
|
||||||
"lng_stickers_return" = "Undo";
|
"lng_stickers_return" = "Undo";
|
||||||
"lng_stickers_restore" = "Restore";
|
"lng_stickers_restore" = "Restore";
|
||||||
|
|
|
@ -937,7 +937,7 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
|
||||||
it->hash = s.vhash.v;
|
it->hash = s.vhash.v;
|
||||||
it->shortName = qs(s.vshort_name);
|
it->shortName = qs(s.vshort_name);
|
||||||
it->title = stickerSetTitle(s);
|
it->title = stickerSetTitle(s);
|
||||||
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded);
|
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
|
||||||
it->flags = s.vflags.v | clientFlags;
|
it->flags = s.vflags.v | clientFlags;
|
||||||
it->flags &= ~MTPDstickerSet_ClientFlag::f_not_loaded;
|
it->flags &= ~MTPDstickerSet_ClientFlag::f_not_loaded;
|
||||||
|
|
||||||
|
|
|
@ -2012,6 +2012,7 @@ namespace {
|
||||||
Global::SetStickerSets(Stickers::Sets());
|
Global::SetStickerSets(Stickers::Sets());
|
||||||
Global::SetStickerSetsOrder(Stickers::Order());
|
Global::SetStickerSetsOrder(Stickers::Order());
|
||||||
Global::SetLastStickersUpdate(0);
|
Global::SetLastStickersUpdate(0);
|
||||||
|
Global::SetLastRecentStickersUpdate(0);
|
||||||
Global::SetFeaturedStickerSetsOrder(Stickers::Order());
|
Global::SetFeaturedStickerSetsOrder(Stickers::Order());
|
||||||
Global::SetFeaturedStickerSetsUnreadCount(0);
|
Global::SetFeaturedStickerSetsUnreadCount(0);
|
||||||
Global::SetLastFeaturedStickersUpdate(0);
|
Global::SetLastFeaturedStickersUpdate(0);
|
||||||
|
|
|
@ -87,7 +87,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
auto &sets = Global::RefStickerSets();
|
auto &sets = Global::RefStickerSets();
|
||||||
auto it = sets.find(_setId);
|
auto it = sets.find(_setId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_unread);
|
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_special);
|
||||||
_setFlags |= clientFlags;
|
_setFlags |= clientFlags;
|
||||||
it->flags = _setFlags;
|
it->flags = _setFlags;
|
||||||
it->stickers = _pack;
|
it->stickers = _pack;
|
||||||
|
@ -418,6 +418,7 @@ StickersInner::StickersInner(StickersBox::Section section) : TWidget()
|
||||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||||
, _a_shifting(animation(this, &StickersInner::step_shifting))
|
, _a_shifting(animation(this, &StickersInner::step_shifting))
|
||||||
, _itemsTop(st::membersPadding.top())
|
, _itemsTop(st::membersPadding.top())
|
||||||
|
, _clearWidth(st::normalFont->width(lang(lng_stickers_clear_recent)))
|
||||||
, _removeWidth(st::normalFont->width(lang(lng_stickers_remove)))
|
, _removeWidth(st::normalFont->width(lang(lng_stickers_remove)))
|
||||||
, _returnWidth(st::normalFont->width(lang(lng_stickers_return)))
|
, _returnWidth(st::normalFont->width(lang(lng_stickers_return)))
|
||||||
, _restoreWidth(st::normalFont->width(lang(lng_stickers_restore)))
|
, _restoreWidth(st::normalFont->width(lang(lng_stickers_restore)))
|
||||||
|
@ -500,8 +501,8 @@ void StickersInner::paintRow(Painter &p, int32 index) {
|
||||||
} else {
|
} else {
|
||||||
p.setPen(st::btnDefLink.color);
|
p.setPen(st::btnDefLink.color);
|
||||||
}
|
}
|
||||||
int32 remWidth = s->disabled ? (s->official ? _restoreWidth : _returnWidth) : _removeWidth;
|
int32 remWidth = s->recent ? _clearWidth : (s->disabled ? (s->official ? _restoreWidth : _returnWidth) : _removeWidth);
|
||||||
QString remText = lang(s->disabled ? (s->official ? lng_stickers_restore : lng_stickers_return) : lng_stickers_remove);
|
QString remText = lang(s->recent ? lng_stickers_clear_recent : (s->disabled ? (s->official ? lng_stickers_restore : lng_stickers_return) : lng_stickers_remove));
|
||||||
p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), remText, remWidth);
|
p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), remText, remWidth);
|
||||||
|
|
||||||
if (index == _above) {
|
if (index == _above) {
|
||||||
|
@ -581,7 +582,7 @@ void StickersInner::mousePressEvent(QMouseEvent *e) {
|
||||||
if (_actionSel >= 0) {
|
if (_actionSel >= 0) {
|
||||||
_actionDown = _actionSel;
|
_actionDown = _actionSel;
|
||||||
update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight);
|
update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight);
|
||||||
} else if (_selected >= 0 && _section == Section::Installed) {
|
} else if (_selected >= 0 && _section == Section::Installed && !_rows.at(_selected)->recent) {
|
||||||
_above = _dragging = _started = _selected;
|
_above = _dragging = _started = _selected;
|
||||||
_dragStart = mapFromGlobal(_mouse);
|
_dragStart = mapFromGlobal(_mouse);
|
||||||
}
|
}
|
||||||
|
@ -599,8 +600,12 @@ void StickersInner::onUpdateSelected() {
|
||||||
if (_dragging >= 0) {
|
if (_dragging >= 0) {
|
||||||
int32 shift = 0;
|
int32 shift = 0;
|
||||||
uint64 ms = getms();
|
uint64 ms = getms();
|
||||||
|
int firstSetIndex = 0;
|
||||||
|
if (_rows.at(firstSetIndex)->recent) {
|
||||||
|
++firstSetIndex;
|
||||||
|
}
|
||||||
if (_dragStart.y() > local.y() && _dragging > 0) {
|
if (_dragStart.y() > local.y() && _dragging > 0) {
|
||||||
shift = -floorclamp(_dragStart.y() - local.y() + (_rowHeight / 2), _rowHeight, 0, _dragging);
|
shift = -floorclamp(_dragStart.y() - local.y() + (_rowHeight / 2), _rowHeight, 0, _dragging - firstSetIndex);
|
||||||
for (int32 from = _dragging, to = _dragging + shift; from > to; --from) {
|
for (int32 from = _dragging, to = _dragging + shift; from > to; --from) {
|
||||||
qSwap(_rows[from], _rows[from - 1]);
|
qSwap(_rows[from], _rows[from - 1]);
|
||||||
_rows.at(from)->yadd = anim::ivalue(_rows.at(from)->yadd.current() - _rowHeight, 0);
|
_rows.at(from)->yadd = anim::ivalue(_rows.at(from)->yadd.current() - _rowHeight, 0);
|
||||||
|
@ -635,7 +640,7 @@ void StickersInner::onUpdateSelected() {
|
||||||
selected = floorclamp(local.y() - _itemsTop, _rowHeight, 0, _rows.size() - 1);
|
selected = floorclamp(local.y() - _itemsTop, _rowHeight, 0, _rows.size() - 1);
|
||||||
|
|
||||||
if (_section == Section::Installed) {
|
if (_section == Section::Installed) {
|
||||||
int remw = _rows.at(selected)->disabled ? (_rows.at(selected)->official ? _restoreWidth : _returnWidth) : _removeWidth;
|
int remw = _rows.at(selected)->recent ? _clearWidth : (_rows.at(selected)->disabled ? (_rows.at(selected)->official ? _restoreWidth : _returnWidth) : _removeWidth);
|
||||||
QRect rem(myrtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - remw, st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, remw, st::normalFont->height));
|
QRect rem(myrtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - remw, st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, remw, st::normalFont->height));
|
||||||
actionSel = rem.contains(local.x(), local.y() - _itemsTop - selected * _rowHeight) ? selected : -1;
|
actionSel = rem.contains(local.x(), local.y() - _itemsTop - selected * _rowHeight) ? selected : -1;
|
||||||
} else if (_rows.at(selected)->installed) {
|
} else if (_rows.at(selected)->installed) {
|
||||||
|
@ -666,6 +671,34 @@ void StickersInner::onUpdateSelected() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StickersInner::onClearRecent() {
|
||||||
|
if (_clearBox) {
|
||||||
|
_clearBox->onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &sets = Global::RefStickerSets();
|
||||||
|
sets.remove(Stickers::CloudRecentSetId);
|
||||||
|
sets.remove(Stickers::CustomSetId);
|
||||||
|
|
||||||
|
auto &recent = cGetRecentStickers();
|
||||||
|
if (!recent.isEmpty()) {
|
||||||
|
recent.clear();
|
||||||
|
Local::writeUserSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
Local::writeStickers();
|
||||||
|
emit App::main()->updateStickers();
|
||||||
|
rebuild();
|
||||||
|
|
||||||
|
MTP::send(MTPmessages_ClearRecentStickers());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StickersInner::onClearBoxDestroyed(QObject *box) {
|
||||||
|
if (box == _clearBox) {
|
||||||
|
_clearBox = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float64 StickersInner::aboveShadowOpacity() const {
|
float64 StickersInner::aboveShadowOpacity() const {
|
||||||
if (_above < 0) return 0;
|
if (_above < 0) return 0;
|
||||||
|
|
||||||
|
@ -688,7 +721,14 @@ void StickersInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
onUpdateSelected();
|
onUpdateSelected();
|
||||||
if (_actionDown == _actionSel && _actionSel >= 0) {
|
if (_actionDown == _actionSel && _actionSel >= 0) {
|
||||||
if (_section == Section::Installed) {
|
if (_section == Section::Installed) {
|
||||||
_rows[_actionDown]->disabled = !_rows[_actionDown]->disabled;
|
if (_rows[_actionDown]->recent) {
|
||||||
|
_clearBox = new ConfirmBox(lang(lng_stickers_clear_recent_sure), lang(lng_stickers_clear_recent));
|
||||||
|
connect(_clearBox, SIGNAL(confirmed()), this, SLOT(onClearRecent()));
|
||||||
|
connect(_clearBox, SIGNAL(destroyed(QObject*)), this, SLOT(onClearBoxDestroyed(QObject*)));
|
||||||
|
Ui::showLayer(_clearBox, KeepOtherLayers);
|
||||||
|
} else {
|
||||||
|
_rows[_actionDown]->disabled = !_rows[_actionDown]->disabled;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
installSet(_rows[_actionDown]->id);
|
installSet(_rows[_actionDown]->id);
|
||||||
}
|
}
|
||||||
|
@ -876,7 +916,7 @@ void StickersInner::rebuild() {
|
||||||
int namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
|
int namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
|
||||||
int namew = st::boxWideWidth - namex - st::contactsPadding.right() - st::contactsCheckPosition.x();
|
int namew = st::boxWideWidth - namex - st::contactsPadding.right() - st::contactsCheckPosition.x();
|
||||||
if (_section == Section::Installed) {
|
if (_section == Section::Installed) {
|
||||||
namew -= qMax(qMax(_returnWidth, _removeWidth), _restoreWidth);
|
namew -= qMax(qMax(qMax(_returnWidth, _removeWidth), _restoreWidth), _clearWidth);
|
||||||
} else {
|
} else {
|
||||||
namew -= _addWidth - st::defaultActiveButton.width;
|
namew -= _addWidth - st::defaultActiveButton.width;
|
||||||
}
|
}
|
||||||
|
@ -886,12 +926,54 @@ void StickersInner::rebuild() {
|
||||||
_animStartTimes.reserve(order.size());
|
_animStartTimes.reserve(order.size());
|
||||||
|
|
||||||
auto &sets = Global::StickerSets();
|
auto &sets = Global::StickerSets();
|
||||||
|
auto cloudIt = sets.constFind(Stickers::CloudRecentSetId);
|
||||||
|
if (cloudIt != sets.cend() && !cloudIt->stickers.isEmpty()) {
|
||||||
|
DocumentData *sticker = cloudIt->stickers.at(0);
|
||||||
|
int32 pixw = 0, pixh = 0;
|
||||||
|
if (sticker) {
|
||||||
|
pixw = sticker->thumb->width();
|
||||||
|
pixh = sticker->thumb->height();
|
||||||
|
if (pixw > st::contactsPhotoSize) {
|
||||||
|
if (pixw > pixh) {
|
||||||
|
pixh = (pixh * st::contactsPhotoSize) / pixw;
|
||||||
|
pixw = st::contactsPhotoSize;
|
||||||
|
} else {
|
||||||
|
pixw = (pixw * st::contactsPhotoSize) / pixh;
|
||||||
|
pixh = st::contactsPhotoSize;
|
||||||
|
}
|
||||||
|
} else if (pixh > st::contactsPhotoSize) {
|
||||||
|
pixw = (pixw * st::contactsPhotoSize) / pixh;
|
||||||
|
pixh = st::contactsPhotoSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString title = cloudIt->title;
|
||||||
|
int32 titleWidth = st::contactsNameFont->width(title);
|
||||||
|
if (titleWidth > namew) {
|
||||||
|
title = st::contactsNameFont->elided(title, namew);
|
||||||
|
}
|
||||||
|
int count = cloudIt->stickers.size();
|
||||||
|
int added = 0;
|
||||||
|
auto customIt = sets.constFind(Stickers::CustomSetId);
|
||||||
|
if (customIt != sets.cend()) {
|
||||||
|
added = customIt->stickers.size();
|
||||||
|
for_const (auto &sticker, cGetRecentStickers()) {
|
||||||
|
if (customIt->stickers.indexOf(sticker.first) < 0) {
|
||||||
|
++added;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
added = cGetRecentStickers().size();
|
||||||
|
}
|
||||||
|
rows.push_back(new StickerSetRow(cloudIt->id, cloudIt->stickers.front(), count + added, title, true, true, false, false, true, pixw, pixh));
|
||||||
|
_animStartTimes.push_back(0);
|
||||||
|
}
|
||||||
for_const (auto setId, order) {
|
for_const (auto setId, order) {
|
||||||
auto it = sets.constFind(setId);
|
auto it = sets.constFind(setId);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool recent = false;
|
||||||
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
||||||
bool disabled = (_section == Section::Installed) && (it->flags & MTPDstickerSet::Flag::f_disabled);
|
bool disabled = (_section == Section::Installed) && (it->flags & MTPDstickerSet::Flag::f_disabled);
|
||||||
bool official = (it->flags & MTPDstickerSet::Flag::f_official);
|
bool official = (it->flags & MTPDstickerSet::Flag::f_official);
|
||||||
|
@ -924,7 +1006,7 @@ void StickersInner::rebuild() {
|
||||||
if (titleWidth > namew) {
|
if (titleWidth > namew) {
|
||||||
title = st::contactsNameFont->elided(title, namew);
|
title = st::contactsNameFont->elided(title, namew);
|
||||||
}
|
}
|
||||||
(disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, installed, official, unread, disabled, pixw, pixh));
|
(disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, installed, official, unread, disabled, recent, pixw, pixh));
|
||||||
_animStartTimes.push_back(0);
|
_animStartTimes.push_back(0);
|
||||||
if (it->stickers.isEmpty() || (it->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
if (it->stickers.isEmpty() || (it->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||||
App::api()->scheduleStickerSetRequest(it->id, it->access);
|
App::api()->scheduleStickerSetRequest(it->id, it->access);
|
||||||
|
@ -973,6 +1055,9 @@ QVector<uint64> StickersInner::getOrder() const {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_rows.at(i)->recent) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
result.push_back(_rows.at(i)->id);
|
result.push_back(_rows.at(i)->id);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1167,7 +1252,7 @@ void StickersBox::onSave() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeRecent = false;
|
bool writeRecent = false;
|
||||||
RecentStickerPack &recent(cGetRecentStickers());
|
auto &recent = cGetRecentStickers();
|
||||||
auto &sets = Global::RefStickerSets();
|
auto &sets = Global::RefStickerSets();
|
||||||
|
|
||||||
QVector<uint64> reorder = _inner->getOrder(), disabled = _inner->getDisabledSets();
|
QVector<uint64> reorder = _inner->getOrder(), disabled = _inner->getDisabledSets();
|
||||||
|
@ -1191,7 +1276,7 @@ void StickersBox::onSave() {
|
||||||
_disenableRequests.insert(MTP::send(MTPmessages_UninstallStickerSet(setId), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType());
|
_disenableRequests.insert(MTP::send(MTPmessages_UninstallStickerSet(setId), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType());
|
||||||
int removeIndex = Global::StickerSetsOrder().indexOf(it->id);
|
int removeIndex = Global::StickerSetsOrder().indexOf(it->id);
|
||||||
if (removeIndex >= 0) Global::RefStickerSetsOrder().removeAt(removeIndex);
|
if (removeIndex >= 0) Global::RefStickerSetsOrder().removeAt(removeIndex);
|
||||||
if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured)) {
|
if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured) && !(it->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
sets.erase(it);
|
sets.erase(it);
|
||||||
} else {
|
} else {
|
||||||
it->flags &= ~(MTPDstickerSet::Flag::f_installed | MTPDstickerSet::Flag::f_disabled);
|
it->flags &= ~(MTPDstickerSet::Flag::f_installed | MTPDstickerSet::Flag::f_disabled);
|
||||||
|
@ -1221,10 +1306,9 @@ void StickersBox::onSave() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto it = sets.begin(); it != sets.cend();) {
|
for (auto it = sets.begin(); it != sets.cend();) {
|
||||||
if (it->id == Stickers::CustomSetId
|
if ((it->flags & MTPDstickerSet_ClientFlag::f_featured)
|
||||||
|| it->id == Stickers::RecentSetId
|
|| (it->flags & MTPDstickerSet::Flag::f_installed)
|
||||||
|| (it->flags & MTPDstickerSet_ClientFlag::f_featured)
|
|| (it->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
|| (it->flags & MTPDstickerSet::Flag::f_installed)) {
|
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
it = sets.erase(it);
|
it = sets.erase(it);
|
||||||
|
|
|
@ -22,6 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "abstractbox.h"
|
#include "abstractbox.h"
|
||||||
|
|
||||||
|
class ConfirmBox;
|
||||||
|
|
||||||
class StickerSetInner : public TWidget, public RPCSender {
|
class StickerSetInner : public TWidget, public RPCSender {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -221,6 +223,8 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onUpdateSelected();
|
void onUpdateSelected();
|
||||||
|
void onClearRecent();
|
||||||
|
void onClearBoxDestroyed(QObject *box);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void paintFeaturedButton(Painter &p) const;
|
void paintFeaturedButton(Painter &p) const;
|
||||||
|
@ -240,7 +244,7 @@ private:
|
||||||
|
|
||||||
int32 _rowHeight;
|
int32 _rowHeight;
|
||||||
struct StickerSetRow {
|
struct StickerSetRow {
|
||||||
StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool installed, bool official, bool unread, bool disabled, int32 pixw, int32 pixh) : id(id)
|
StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool installed, bool official, bool unread, bool disabled, bool recent, int32 pixw, int32 pixh) : id(id)
|
||||||
, sticker(sticker)
|
, sticker(sticker)
|
||||||
, count(count)
|
, count(count)
|
||||||
, title(title)
|
, title(title)
|
||||||
|
@ -248,6 +252,7 @@ private:
|
||||||
, official(official)
|
, official(official)
|
||||||
, unread(unread)
|
, unread(unread)
|
||||||
, disabled(disabled)
|
, disabled(disabled)
|
||||||
|
, recent(recent)
|
||||||
, pixw(pixw)
|
, pixw(pixw)
|
||||||
, pixh(pixh)
|
, pixh(pixh)
|
||||||
, yadd(0, 0) {
|
, yadd(0, 0) {
|
||||||
|
@ -256,7 +261,7 @@ private:
|
||||||
DocumentData *sticker;
|
DocumentData *sticker;
|
||||||
int32 count;
|
int32 count;
|
||||||
QString title;
|
QString title;
|
||||||
bool installed, official, unread, disabled;
|
bool installed, official, unread, disabled, recent;
|
||||||
int32 pixw, pixh;
|
int32 pixw, pixh;
|
||||||
anim::ivalue yadd;
|
anim::ivalue yadd;
|
||||||
};
|
};
|
||||||
|
@ -274,7 +279,9 @@ private:
|
||||||
int _actionSel = -1;
|
int _actionSel = -1;
|
||||||
int _actionDown = -1;
|
int _actionDown = -1;
|
||||||
|
|
||||||
int _removeWidth, _returnWidth, _restoreWidth;
|
int _clearWidth, _removeWidth, _returnWidth, _restoreWidth;
|
||||||
|
|
||||||
|
ConfirmBox *_clearBox = nullptr;
|
||||||
|
|
||||||
QString _addText;
|
QString _addText;
|
||||||
int _addWidth;
|
int _addWidth;
|
||||||
|
|
|
@ -714,7 +714,7 @@ void EmojiColorPicker::drawVariant(Painter &p, int variant) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EmojiPanInner::EmojiPanInner() : TWidget()
|
EmojiPanInner::EmojiPanInner() : TWidget()
|
||||||
, _maxHeight(int(st::emojiPanMaxHeight))
|
, _maxHeight(int(st::emojiPanMaxHeight) - st::rbEmoji.height)
|
||||||
, _a_selected(animation(this, &EmojiPanInner::step_selected))
|
, _a_selected(animation(this, &EmojiPanInner::step_selected))
|
||||||
, _top(0)
|
, _top(0)
|
||||||
, _selected(-1)
|
, _selected(-1)
|
||||||
|
@ -1230,7 +1230,7 @@ StickerPanInner::StickerPanInner() : TWidget()
|
||||||
, _pressedSel(-1)
|
, _pressedSel(-1)
|
||||||
, _settings(this, lang(lng_stickers_you_have))
|
, _settings(this, lang(lng_stickers_you_have))
|
||||||
, _previewShown(false) {
|
, _previewShown(false) {
|
||||||
setMaxHeight(st::emojiPanMaxHeight);
|
setMaxHeight(st::emojiPanMaxHeight - st::rbEmoji.height);
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
@ -2111,37 +2111,49 @@ void StickerPanInner::refreshRecent() {
|
||||||
void StickerPanInner::refreshRecentStickers(bool performResize) {
|
void StickerPanInner::refreshRecentStickers(bool performResize) {
|
||||||
_custom.clear();
|
_custom.clear();
|
||||||
clearSelection(true);
|
clearSelection(true);
|
||||||
auto customIt = Global::StickerSets().constFind(Stickers::CustomSetId);
|
auto &sets = Global::StickerSets();
|
||||||
if (cGetRecentStickers().isEmpty() && (customIt == Global::StickerSets().cend() || customIt->stickers.isEmpty())) {
|
auto &recent = cGetRecentStickers();
|
||||||
|
auto customIt = sets.constFind(Stickers::CustomSetId);
|
||||||
|
auto cloudIt = sets.constFind(Stickers::CloudRecentSetId);
|
||||||
|
if (recent.isEmpty()
|
||||||
|
&& (customIt == sets.cend() || customIt->stickers.isEmpty())
|
||||||
|
&& (cloudIt == sets.cend() || cloudIt->stickers.isEmpty())) {
|
||||||
if (!_sets.isEmpty() && _sets.at(0).id == Stickers::RecentSetId) {
|
if (!_sets.isEmpty() && _sets.at(0).id == Stickers::RecentSetId) {
|
||||||
_sets.pop_front();
|
_sets.pop_front();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StickerPack recent;
|
StickerPack recentPack;
|
||||||
int32 customCnt = (customIt == Global::StickerSets().cend() ? 0 : customIt->stickers.size());
|
int customCnt = (customIt == sets.cend()) ? 0 : customIt->stickers.size();
|
||||||
QMap<DocumentData*, bool> recentOnly;
|
int cloudCnt = (cloudIt == sets.cend()) ? 0 : cloudIt->stickers.size();
|
||||||
recent.reserve(cGetRecentStickers().size() + customCnt);
|
recentPack.reserve(cloudCnt + recent.size() + customCnt);
|
||||||
_custom.reserve(cGetRecentStickers().size() + customCnt);
|
_custom.reserve(cloudCnt + recent.size() + customCnt);
|
||||||
for (int32 i = 0, l = cGetRecentStickers().size(); i < l; ++i) {
|
if (cloudCnt > 0) {
|
||||||
DocumentData *s = cGetRecentStickers().at(i).first;
|
for_const (auto sticker, cloudIt->stickers) {
|
||||||
recent.push_back(s);
|
recentPack.push_back(sticker);
|
||||||
recentOnly.insert(s, true);
|
_custom.push_back(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for_const (auto &recentSticker, recent) {
|
||||||
|
auto sticker = recentSticker.first;
|
||||||
|
recentPack.push_back(sticker);
|
||||||
_custom.push_back(false);
|
_custom.push_back(false);
|
||||||
}
|
}
|
||||||
for (int32 i = 0; i < customCnt; ++i) {
|
if (customCnt > 0) {
|
||||||
DocumentData *s = customIt->stickers.at(i);
|
for_const (auto &sticker, customIt->stickers) {
|
||||||
if (recentOnly.contains(s)) {
|
auto index = recentPack.indexOf(sticker);
|
||||||
_custom[recent.indexOf(s)] = true;
|
if (index >= cloudCnt) {
|
||||||
} else {
|
_custom[index] = true; // mark stickers from recent as custom
|
||||||
recent.push_back(s);
|
} else {
|
||||||
_custom.push_back(true);
|
recentPack.push_back(sticker);
|
||||||
|
_custom.push_back(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_sets.isEmpty() || _sets.at(0).id != Stickers::RecentSetId) {
|
if (_sets.isEmpty() || _sets.at(0).id != Stickers::RecentSetId) {
|
||||||
_sets.push_back(DisplayedSet(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official, lang(lng_emoji_category0), recent.size() * 2, recent));
|
_sets.push_back(DisplayedSet(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special, lang(lng_emoji_category0), recentPack.size() * 2, recentPack));
|
||||||
} else {
|
} else {
|
||||||
_sets[0].pack = recent;
|
_sets[0].pack = recentPack;
|
||||||
_sets[0].hovers.resize(recent.size() * 2);
|
_sets[0].hovers.resize(recentPack.size() * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3244,7 +3256,7 @@ void EmojiPan::step_icons(uint64 ms, bool timer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_iconsStartAnim) {
|
if (_iconsStartAnim) {
|
||||||
float64 dt = (ms - _iconsStartAnim) / st::stickerIconMove;
|
float64 dt = (ms - _iconsStartAnim) / float64(st::stickerIconMove);
|
||||||
if (dt >= 1) {
|
if (dt >= 1) {
|
||||||
_iconsStartAnim = 0;
|
_iconsStartAnim = 0;
|
||||||
_iconsX.finish();
|
_iconsX.finish();
|
||||||
|
@ -3669,7 +3681,7 @@ void EmojiPan::onRemoveSetSure() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it->flags &= ~MTPDstickerSet::Flag::f_installed;
|
it->flags &= ~MTPDstickerSet::Flag::f_installed;
|
||||||
if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured)) {
|
if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured) && !(it->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
Global::RefStickerSets().erase(it);
|
Global::RefStickerSets().erase(it);
|
||||||
}
|
}
|
||||||
int removeIndex = Global::StickerSetsOrder().indexOf(_removingSetId);
|
int removeIndex = Global::StickerSetsOrder().indexOf(_removingSetId);
|
||||||
|
|
|
@ -564,6 +564,7 @@ struct Data {
|
||||||
Stickers::Sets StickerSets;
|
Stickers::Sets StickerSets;
|
||||||
Stickers::Order StickerSetsOrder;
|
Stickers::Order StickerSetsOrder;
|
||||||
uint64 LastStickersUpdate = 0;
|
uint64 LastStickersUpdate = 0;
|
||||||
|
uint64 LastRecentStickersUpdate = 0;
|
||||||
Stickers::Order FeaturedStickerSetsOrder;
|
Stickers::Order FeaturedStickerSetsOrder;
|
||||||
int FeaturedStickerSetsUnreadCount = 0;
|
int FeaturedStickerSetsUnreadCount = 0;
|
||||||
uint64 LastFeaturedStickersUpdate = 0;
|
uint64 LastFeaturedStickersUpdate = 0;
|
||||||
|
@ -635,6 +636,7 @@ DefineRefVar(Global, PendingItemsMap, PendingRepaintItems);
|
||||||
DefineVar(Global, Stickers::Sets, StickerSets);
|
DefineVar(Global, Stickers::Sets, StickerSets);
|
||||||
DefineVar(Global, Stickers::Order, StickerSetsOrder);
|
DefineVar(Global, Stickers::Order, StickerSetsOrder);
|
||||||
DefineVar(Global, uint64, LastStickersUpdate);
|
DefineVar(Global, uint64, LastStickersUpdate);
|
||||||
|
DefineVar(Global, uint64, LastRecentStickersUpdate);
|
||||||
DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder);
|
DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder);
|
||||||
DefineVar(Global, int, FeaturedStickerSetsUnreadCount);
|
DefineVar(Global, int, FeaturedStickerSetsUnreadCount);
|
||||||
DefineVar(Global, uint64, LastFeaturedStickersUpdate);
|
DefineVar(Global, uint64, LastFeaturedStickersUpdate);
|
||||||
|
|
|
@ -183,8 +183,10 @@ enum Flags {
|
||||||
namespace Stickers {
|
namespace Stickers {
|
||||||
|
|
||||||
static const uint64 DefaultSetId = 0; // for backward compatibility
|
static const uint64 DefaultSetId = 0; // for backward compatibility
|
||||||
static const uint64 CustomSetId = 0xFFFFFFFFFFFFFFFFULL, RecentSetId = 0xFFFFFFFFFFFFFFFEULL;
|
static const uint64 CustomSetId = 0xFFFFFFFFFFFFFFFFULL;
|
||||||
static const uint64 NoneSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel
|
static const uint64 RecentSetId = 0xFFFFFFFFFFFFFFFEULL; // for emoji/stickers panel, should not appear in Sets
|
||||||
|
static const uint64 NoneSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel, should not appear in Sets
|
||||||
|
static const uint64 CloudRecentSetId = 0xFFFFFFFFFFFFFFFCULL; // for cloud-stored recent stickers
|
||||||
struct Set {
|
struct Set {
|
||||||
Set(uint64 id, uint64 access, const QString &title, const QString &shortName, int32 count, int32 hash, MTPDstickerSet::Flags flags)
|
Set(uint64 id, uint64 access, const QString &title, const QString &shortName, int32 count, int32 hash, MTPDstickerSet::Flags flags)
|
||||||
: id(id)
|
: id(id)
|
||||||
|
@ -262,6 +264,7 @@ DeclareRefVar(PendingItemsMap, PendingRepaintItems);
|
||||||
DeclareVar(Stickers::Sets, StickerSets);
|
DeclareVar(Stickers::Sets, StickerSets);
|
||||||
DeclareVar(Stickers::Order, StickerSetsOrder);
|
DeclareVar(Stickers::Order, StickerSetsOrder);
|
||||||
DeclareVar(uint64, LastStickersUpdate);
|
DeclareVar(uint64, LastStickersUpdate);
|
||||||
|
DeclareVar(uint64, LastRecentStickersUpdate);
|
||||||
DeclareVar(Stickers::Order, FeaturedStickerSetsOrder);
|
DeclareVar(Stickers::Order, FeaturedStickerSetsOrder);
|
||||||
DeclareVar(int, FeaturedStickerSetsUnreadCount);
|
DeclareVar(int, FeaturedStickerSetsUnreadCount);
|
||||||
DeclareVar(uint64, LastFeaturedStickersUpdate);
|
DeclareVar(uint64, LastFeaturedStickersUpdate);
|
||||||
|
|
|
@ -4076,10 +4076,10 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
|
||||||
bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
|
bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
|
||||||
|
|
||||||
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width));
|
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width));
|
||||||
QPixmap thumb = loaded ? _data->thumb->pixSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize);
|
QPixmap thumb = loaded ? _data->thumb->pixSingle(ImageRoundRadius::Large, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize);
|
||||||
p.drawPixmap(rthumb.topLeft(), thumb);
|
p.drawPixmap(rthumb.topLeft(), thumb);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlaySmallCorners);
|
App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayLargeCorners);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radial || (!loaded && !_data->loading())) {
|
if (radial || (!loaded && !_data->loading())) {
|
||||||
|
|
|
@ -3530,6 +3530,11 @@ void HistoryWidget::updateStickers() {
|
||||||
_stickersUpdateRequest = MTP::send(MTPmessages_GetAllStickers(MTP_int(Local::countStickersHash(true))), rpcDone(&HistoryWidget::stickersGot), rpcFail(&HistoryWidget::stickersFailed));
|
_stickersUpdateRequest = MTP::send(MTPmessages_GetAllStickers(MTP_int(Local::countStickersHash(true))), rpcDone(&HistoryWidget::stickersGot), rpcFail(&HistoryWidget::stickersFailed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Global::LastRecentStickersUpdate() || now >= Global::LastRecentStickersUpdate() + StickersUpdateTimeout) {
|
||||||
|
if (!_recentStickersUpdateRequest) {
|
||||||
|
_recentStickersUpdateRequest = MTP::send(MTPmessages_GetRecentStickers(MTP_int(Local::countRecentStickersHash())), rpcDone(&HistoryWidget::recentStickersGot), rpcFail(&HistoryWidget::recentStickersFailed));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!Global::LastFeaturedStickersUpdate() || now >= Global::LastFeaturedStickersUpdate() + StickersUpdateTimeout) {
|
if (!Global::LastFeaturedStickersUpdate() || now >= Global::LastFeaturedStickersUpdate() + StickersUpdateTimeout) {
|
||||||
if (!_featuredStickersUpdateRequest) {
|
if (!_featuredStickersUpdateRequest) {
|
||||||
_featuredStickersUpdateRequest = MTP::send(MTPmessages_GetFeaturedStickers(MTP_int(Local::countFeaturedStickersHash())), rpcDone(&HistoryWidget::featuredStickersGot), rpcFail(&HistoryWidget::featuredStickersFailed));
|
_featuredStickersUpdateRequest = MTP::send(MTPmessages_GetFeaturedStickers(MTP_int(Local::countFeaturedStickersHash())), rpcDone(&HistoryWidget::featuredStickersGot), rpcFail(&HistoryWidget::featuredStickersFailed));
|
||||||
|
@ -3671,7 +3676,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
it->access = set.vaccess_hash.v;
|
it->access = set.vaccess_hash.v;
|
||||||
it->title = title;
|
it->title = title;
|
||||||
it->shortName = qs(set.vshort_name);
|
it->shortName = qs(set.vshort_name);
|
||||||
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded);
|
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
|
||||||
it->flags = set.vflags.v | clientFlags;
|
it->flags = set.vflags.v | clientFlags;
|
||||||
if (it->count != set.vcount.v || it->hash != set.vhash.v || it->emoji.isEmpty()) {
|
if (it->count != set.vcount.v || it->hash != set.vhash.v || it->emoji.isEmpty()) {
|
||||||
it->count = set.vcount.v;
|
it->count = set.vcount.v;
|
||||||
|
@ -3692,6 +3697,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
for (Stickers::Sets::iterator it = sets.begin(), e = sets.end(); it != e;) {
|
for (Stickers::Sets::iterator it = sets.begin(), e = sets.end(); it != e;) {
|
||||||
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
||||||
bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured);
|
bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured);
|
||||||
|
bool special = (it->flags & MTPDstickerSet_ClientFlag::f_special);
|
||||||
if (!installed) { // remove not mine sets from recent stickers
|
if (!installed) { // remove not mine sets from recent stickers
|
||||||
for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
|
for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
|
||||||
if (it->stickers.indexOf(i->first) >= 0) {
|
if (it->stickers.indexOf(i->first) >= 0) {
|
||||||
|
@ -3702,7 +3708,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (installed || featured) {
|
if (installed || featured || special) {
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
it = sets.erase(it);
|
it = sets.erase(it);
|
||||||
|
@ -3736,6 +3742,92 @@ bool HistoryWidget::stickersFailed(const RPCError &error) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryWidget::recentStickersGot(const MTPmessages_RecentStickers &stickers) {
|
||||||
|
Global::SetLastRecentStickersUpdate(getms(true));
|
||||||
|
_recentStickersUpdateRequest = 0;
|
||||||
|
|
||||||
|
if (stickers.type() != mtpc_messages_recentStickers) return;
|
||||||
|
auto &d = stickers.c_messages_recentStickers();
|
||||||
|
|
||||||
|
auto &sets = Global::RefStickerSets();
|
||||||
|
auto it = sets.find(Stickers::CloudRecentSetId);
|
||||||
|
|
||||||
|
auto &d_docs = d.vstickers.c_vector().v;
|
||||||
|
if (d_docs.isEmpty()) {
|
||||||
|
if (it != sets.cend()) {
|
||||||
|
sets.erase(it);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (it == sets.cend()) {
|
||||||
|
it = sets.insert(Stickers::CloudRecentSetId, Stickers::Set(Stickers::CloudRecentSetId, 0, lang(lng_emoji_category0), QString(), 0, 0, qFlags(MTPDstickerSet_ClientFlag::f_special)));
|
||||||
|
} else {
|
||||||
|
it->title = lang(lng_emoji_category0);
|
||||||
|
}
|
||||||
|
it->hash = d.vhash.v;
|
||||||
|
|
||||||
|
auto custom = sets.find(Stickers::CustomSetId);
|
||||||
|
|
||||||
|
StickerPack pack;
|
||||||
|
pack.reserve(d_docs.size());
|
||||||
|
for (int32 i = 0, l = d_docs.size(); i != l; ++i) {
|
||||||
|
DocumentData *doc = App::feedDocument(d_docs.at(i));
|
||||||
|
if (!doc || !doc->sticker()) continue;
|
||||||
|
|
||||||
|
pack.push_back(doc);
|
||||||
|
if (custom != sets.cend()) {
|
||||||
|
int32 index = custom->stickers.indexOf(doc);
|
||||||
|
if (index >= 0) {
|
||||||
|
custom->stickers.removeAt(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (custom != sets.cend() && custom->stickers.isEmpty()) {
|
||||||
|
sets.erase(custom);
|
||||||
|
custom = sets.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool writeRecent = false;
|
||||||
|
RecentStickerPack &recent(cGetRecentStickers());
|
||||||
|
for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
|
||||||
|
if (it->stickers.indexOf(i->first) >= 0 && pack.indexOf(i->first) < 0) {
|
||||||
|
i = recent.erase(i);
|
||||||
|
writeRecent = true;
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pack.isEmpty()) {
|
||||||
|
sets.erase(it);
|
||||||
|
} else {
|
||||||
|
it->stickers = pack;
|
||||||
|
it->emoji.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeRecent) {
|
||||||
|
Local::writeUserSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Local::countRecentStickersHash() != d.vhash.v) {
|
||||||
|
LOG(("API Error: received stickers hash %1 while counted hash is %2").arg(d.vhash.v).arg(Local::countRecentStickersHash()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Local::writeStickers();
|
||||||
|
|
||||||
|
if (App::main()) emit App::main()->stickersUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HistoryWidget::recentStickersFailed(const RPCError &error) {
|
||||||
|
if (MTP::isDefaultHandledError(error)) return false;
|
||||||
|
|
||||||
|
LOG(("App Fail: Failed to get recent stickers!"));
|
||||||
|
|
||||||
|
Global::SetLastRecentStickersUpdate(getms(true));
|
||||||
|
_recentStickersUpdateRequest = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stickers) {
|
void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stickers) {
|
||||||
Global::SetLastFeaturedStickersUpdate(getms(true));
|
Global::SetLastFeaturedStickersUpdate(getms(true));
|
||||||
_featuredStickersUpdateRequest = 0;
|
_featuredStickersUpdateRequest = 0;
|
||||||
|
@ -3764,16 +3856,16 @@ void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stic
|
||||||
auto it = sets.find(set.vid.v);
|
auto it = sets.find(set.vid.v);
|
||||||
QString title = stickerSetTitle(set);
|
QString title = stickerSetTitle(set);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
auto clientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded;
|
auto setClientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded;
|
||||||
if (unread.contains(set.vid.v) || !(set.vflags.v & MTPDstickerSet::Flag::f_installed)) {
|
if (unread.contains(set.vid.v) || !(set.vflags.v & MTPDstickerSet::Flag::f_installed)) {
|
||||||
clientFlags |= MTPDstickerSet_ClientFlag::f_unread;
|
setClientFlags |= MTPDstickerSet_ClientFlag::f_unread;
|
||||||
}
|
}
|
||||||
it = sets.insert(set.vid.v, Stickers::Set(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | clientFlags));
|
it = sets.insert(set.vid.v, Stickers::Set(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | setClientFlags));
|
||||||
} else {
|
} else {
|
||||||
it->access = set.vaccess_hash.v;
|
it->access = set.vaccess_hash.v;
|
||||||
it->title = title;
|
it->title = title;
|
||||||
it->shortName = qs(set.vshort_name);
|
it->shortName = qs(set.vshort_name);
|
||||||
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded);
|
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
|
||||||
it->flags = set.vflags.v | clientFlags;
|
it->flags = set.vflags.v | clientFlags;
|
||||||
it->flags |= MTPDstickerSet_ClientFlag::f_featured;
|
it->flags |= MTPDstickerSet_ClientFlag::f_featured;
|
||||||
if (unread.contains(it->id)) {
|
if (unread.contains(it->id)) {
|
||||||
|
@ -3798,7 +3890,8 @@ void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stic
|
||||||
for (auto it = sets.begin(), e = sets.end(); it != e;) {
|
for (auto it = sets.begin(), e = sets.end(); it != e;) {
|
||||||
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
bool installed = (it->flags & MTPDstickerSet::Flag::f_installed);
|
||||||
bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured);
|
bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured);
|
||||||
if (installed || featured) {
|
bool special = (it->flags & MTPDstickerSet_ClientFlag::f_special);
|
||||||
|
if (installed || featured || special) {
|
||||||
if (featured && (it->flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
if (featured && (it->flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
||||||
++unreadCount;
|
++unreadCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1005,6 +1005,10 @@ private:
|
||||||
void stickersGot(const MTPmessages_AllStickers &stickers);
|
void stickersGot(const MTPmessages_AllStickers &stickers);
|
||||||
bool stickersFailed(const RPCError &error);
|
bool stickersFailed(const RPCError &error);
|
||||||
|
|
||||||
|
mtpRequestId _recentStickersUpdateRequest = 0;
|
||||||
|
void recentStickersGot(const MTPmessages_RecentStickers &stickers);
|
||||||
|
bool recentStickersFailed(const RPCError &error);
|
||||||
|
|
||||||
mtpRequestId _featuredStickersUpdateRequest = 0;
|
mtpRequestId _featuredStickersUpdateRequest = 0;
|
||||||
void featuredStickersGot(const MTPmessages_FeaturedStickers &stickers);
|
void featuredStickersGot(const MTPmessages_FeaturedStickers &stickers);
|
||||||
bool featuredStickersFailed(const RPCError &error);
|
bool featuredStickersFailed(const RPCError &error);
|
||||||
|
|
|
@ -3052,7 +3052,7 @@ namespace Local {
|
||||||
quint32 size = sizeof(quint32) + Serialize::bytearraySize(hashToWrite);
|
quint32 size = sizeof(quint32) + Serialize::bytearraySize(hashToWrite);
|
||||||
for_const (auto &set, sets) {
|
for_const (auto &set, sets) {
|
||||||
bool notLoaded = (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded);
|
bool notLoaded = (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded);
|
||||||
if (notLoaded) {
|
if (notLoaded && !(set.flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_disabled)
|
if (!(set.flags & MTPDstickerSet::Flag::f_disabled)
|
||||||
|| (set.flags & MTPDstickerSet::Flag::f_official)
|
|| (set.flags & MTPDstickerSet::Flag::f_official)
|
||||||
|| (set.flags & MTPDstickerSet_ClientFlag::f_featured)) { // waiting to receive
|
|| (set.flags & MTPDstickerSet_ClientFlag::f_featured)) { // waiting to receive
|
||||||
|
@ -3118,8 +3118,8 @@ namespace Local {
|
||||||
auto &recent = cRefRecentStickers();
|
auto &recent = cRefRecentStickers();
|
||||||
recent.clear();
|
recent.clear();
|
||||||
|
|
||||||
auto &def = sets.insert(Stickers::DefaultSetId, Stickers::Set(Stickers::DefaultSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::Flag::f_official | MTPDstickerSet::Flag::f_installed)).value();
|
auto &def = sets.insert(Stickers::DefaultSetId, Stickers::Set(Stickers::DefaultSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::Flag::f_official | MTPDstickerSet::Flag::f_installed | MTPDstickerSet_ClientFlag::f_special)).value();
|
||||||
auto &custom = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed)).value();
|
auto &custom = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed | MTPDstickerSet_ClientFlag::f_special)).value();
|
||||||
|
|
||||||
QMap<uint64, bool> read;
|
QMap<uint64, bool> read;
|
||||||
while (!stickers.stream.atEnd()) {
|
while (!stickers.stream.atEnd()) {
|
||||||
|
@ -3220,12 +3220,16 @@ namespace Local {
|
||||||
|
|
||||||
if (setId == Stickers::DefaultSetId) {
|
if (setId == Stickers::DefaultSetId) {
|
||||||
setTitle = lang(lng_stickers_default_set);
|
setTitle = lang(lng_stickers_default_set);
|
||||||
setFlags |= qFlags(MTPDstickerSet::Flag::f_official);
|
setFlags |= qFlags(MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special);
|
||||||
if (stickers.version < 9058) {
|
if (stickers.version < 9058) {
|
||||||
order.push_front(setId);
|
order.push_front(setId);
|
||||||
}
|
}
|
||||||
} else if (setId == Stickers::CustomSetId) {
|
} else if (setId == Stickers::CustomSetId) {
|
||||||
setTitle = lang(lng_custom_stickers);
|
setTitle = lang(lng_custom_stickers);
|
||||||
|
setFlags |= qFlags(MTPDstickerSet_ClientFlag::f_special);
|
||||||
|
} else if (setId == Stickers::CloudRecentSetId) {
|
||||||
|
setTitle = lang(lng_emoji_category0); // Frequently used
|
||||||
|
setFlags |= qFlags(MTPDstickerSet_ClientFlag::f_special);
|
||||||
} else if (setId) {
|
} else if (setId) {
|
||||||
if (stickers.version < 9058) {
|
if (stickers.version < 9058) {
|
||||||
order.push_back(setId);
|
order.push_back(setId);
|
||||||
|
@ -3328,6 +3332,20 @@ namespace Local {
|
||||||
return (!checkOfficial || (!foundBad && foundOfficial)) ? int32(acc & 0x7FFFFFFF) : 0;
|
return (!checkOfficial || (!foundBad && foundOfficial)) ? int32(acc & 0x7FFFFFFF) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 countRecentStickersHash() {
|
||||||
|
uint32 acc = 0;
|
||||||
|
auto &sets = Global::StickerSets();
|
||||||
|
auto it = sets.constFind(Stickers::CloudRecentSetId);
|
||||||
|
if (it != sets.cend()) {
|
||||||
|
for_const (auto doc, it->stickers) {
|
||||||
|
auto docId = doc->id;
|
||||||
|
acc = (acc * 20261) + uint32(docId >> 32);
|
||||||
|
acc = (acc * 20261) + uint32(docId & 0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return int32(acc & 0x7FFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
int32 countFeaturedStickersHash() {
|
int32 countFeaturedStickersHash() {
|
||||||
uint32 acc = 0;
|
uint32 acc = 0;
|
||||||
auto &sets = Global::StickerSets();
|
auto &sets = Global::StickerSets();
|
||||||
|
@ -3346,10 +3364,9 @@ namespace Local {
|
||||||
|
|
||||||
int32 countSavedGifsHash() {
|
int32 countSavedGifsHash() {
|
||||||
uint32 acc = 0;
|
uint32 acc = 0;
|
||||||
const SavedGifs &saved(cSavedGifs());
|
auto &saved = cSavedGifs();
|
||||||
for (SavedGifs::const_iterator i = saved.cbegin(), e = saved.cend(); i != e; ++i) {
|
for_const (auto doc, saved) {
|
||||||
uint64 docId = (*i)->id;
|
auto docId = doc->id;
|
||||||
|
|
||||||
acc = (acc * 20261) + uint32(docId >> 32);
|
acc = (acc * 20261) + uint32(docId >> 32);
|
||||||
acc = (acc * 20261) + uint32(docId & 0xFFFFFFFF);
|
acc = (acc * 20261) + uint32(docId & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,6 +156,7 @@ namespace Local {
|
||||||
void writeStickers();
|
void writeStickers();
|
||||||
void readStickers();
|
void readStickers();
|
||||||
int32 countStickersHash(bool checkOfficial = false);
|
int32 countStickersHash(bool checkOfficial = false);
|
||||||
|
int32 countRecentStickersHash();
|
||||||
int32 countFeaturedStickersHash();
|
int32 countFeaturedStickersHash();
|
||||||
|
|
||||||
void writeSavedGifs();
|
void writeSavedGifs();
|
||||||
|
|
|
@ -301,11 +301,6 @@ void MainWidget::finishForwarding(History *history, bool silent) {
|
||||||
FullMsgId newId(peerToChannel(history->peer->id), clientMsgId());
|
FullMsgId newId(peerToChannel(history->peer->id), clientMsgId());
|
||||||
HistoryMessage *msg = static_cast<HistoryMessage*>(_toForward.cbegin().value());
|
HistoryMessage *msg = static_cast<HistoryMessage*>(_toForward.cbegin().value());
|
||||||
history->addNewForwarded(newId.msg, flags, date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, msg);
|
history->addNewForwarded(newId.msg, flags, date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, msg);
|
||||||
if (HistoryMedia *media = msg->getMedia()) {
|
|
||||||
if (media->type() == MediaTypeSticker) {
|
|
||||||
App::main()->incrementSticker(media->getDocument());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
}
|
}
|
||||||
if (forwardFrom != i.value()->history()->peer) {
|
if (forwardFrom != i.value()->history()->peer) {
|
||||||
|
@ -3679,71 +3674,60 @@ void MainWidget::updateNotifySetting(PeerData *peer, NotifySettingStatus notify,
|
||||||
|
|
||||||
void MainWidget::incrementSticker(DocumentData *sticker) {
|
void MainWidget::incrementSticker(DocumentData *sticker) {
|
||||||
if (!sticker || !sticker->sticker()) return;
|
if (!sticker || !sticker->sticker()) return;
|
||||||
|
if (sticker->sticker()->set.type() == mtpc_inputStickerSetEmpty) return;
|
||||||
|
|
||||||
RecentStickerPack &recent(cGetRecentStickers());
|
bool writeStickers = false;
|
||||||
RecentStickerPack::iterator i = recent.begin(), e = recent.end();
|
auto &sets = Global::RefStickerSets();
|
||||||
for (; i != e; ++i) {
|
auto it = sets.find(Stickers::CloudRecentSetId);
|
||||||
|
if (it == sets.cend()) {
|
||||||
|
if (it == sets.cend()) {
|
||||||
|
it = sets.insert(Stickers::CloudRecentSetId, Stickers::Set(Stickers::CloudRecentSetId, 0, lang(lng_emoji_category0), QString(), 0, 0, qFlags(MTPDstickerSet_ClientFlag::f_special)));
|
||||||
|
} else {
|
||||||
|
it->title = lang(lng_emoji_category0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto index = it->stickers.indexOf(sticker);
|
||||||
|
if (index > 0) {
|
||||||
|
it->stickers.removeAt(index);
|
||||||
|
}
|
||||||
|
if (index) {
|
||||||
|
it->stickers.push_front(sticker);
|
||||||
|
writeStickers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove that sticker from old recent, now it is in cloud recent stickers.
|
||||||
|
bool writeRecent = false;
|
||||||
|
auto &recent = cGetRecentStickers();
|
||||||
|
for (auto i = recent.begin(), e = recent.end(); i != e; ++i) {
|
||||||
if (i->first == sticker) {
|
if (i->first == sticker) {
|
||||||
i->second = recent.begin()->second; // throw to the first place
|
writeRecent = true;
|
||||||
//++i->second;
|
recent.erase(i);
|
||||||
//if (i->second > 0x8000) {
|
|
||||||
// for (RecentStickerPack::iterator j = recent.begin(); j != e; ++j) {
|
|
||||||
// if (j->second > 1) {
|
|
||||||
// j->second /= 2;
|
|
||||||
// } else {
|
|
||||||
// j->second = 1;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
for (; i != recent.begin(); --i) {
|
|
||||||
if ((i - 1)->second > i->second) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
qSwap(*i, *(i - 1));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == e) {
|
while (!recent.isEmpty() && it->stickers.size() + recent.size() > StickerPanPerRow * StickerPanRowsPerPage) {
|
||||||
while (recent.size() >= StickerPanPerRow * StickerPanRowsPerPage) recent.pop_back();
|
writeRecent = true;
|
||||||
recent.push_front(qMakePair(sticker, recent.isEmpty() ? 1 : recent.begin()->second));
|
recent.pop_back();
|
||||||
//recent.push_back(qMakePair(sticker, 1));
|
|
||||||
//for (i = recent.end() - 1; i != recent.begin(); --i) {
|
|
||||||
// if ((i - 1)->second > i->second) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// qSwap(*i, *(i - 1));
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Local::writeUserSettings();
|
if (writeRecent) {
|
||||||
|
Local::writeUserSettings();
|
||||||
bool found = false;
|
|
||||||
uint64 setId = 0;
|
|
||||||
QString setName;
|
|
||||||
switch (sticker->sticker()->set.type()) {
|
|
||||||
case mtpc_inputStickerSetID: setId = sticker->sticker()->set.c_inputStickerSetID().vid.v; break;
|
|
||||||
case mtpc_inputStickerSetShortName: setName = qs(sticker->sticker()->set.c_inputStickerSetShortName().vshort_name).toLower().trimmed(); break;
|
|
||||||
}
|
}
|
||||||
Stickers::Sets &sets(Global::RefStickerSets());
|
|
||||||
for (auto i = sets.cbegin(); i != sets.cend(); ++i) {
|
// Remove that sticker from custom stickers, now it is in cloud recent stickers.
|
||||||
if (i->id == Stickers::CustomSetId || i->id == Stickers::DefaultSetId || (setId && i->id == setId) || (!setName.isEmpty() && i->shortName.toLower().trimmed() == setName)) {
|
auto custom = sets.find(Stickers::CustomSetId);
|
||||||
for (int32 j = 0, l = i->stickers.size(); j < l; ++j) {
|
if (custom != sets.cend()) {
|
||||||
if (i->stickers.at(j) == sticker) {
|
int removeIndex = custom->stickers.indexOf(sticker);
|
||||||
found = true;
|
if (removeIndex >= 0) {
|
||||||
break;
|
custom->stickers.removeAt(removeIndex);
|
||||||
}
|
if (custom->stickers.isEmpty()) {
|
||||||
|
sets.erase(custom);
|
||||||
}
|
}
|
||||||
if (found) break;
|
writeStickers = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
Stickers::Sets::iterator it = sets.find(Stickers::CustomSetId);
|
if (writeStickers) {
|
||||||
if (it == sets.cend()) {
|
|
||||||
it = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed));
|
|
||||||
}
|
|
||||||
it->stickers.push_back(sticker);
|
|
||||||
++it->count;
|
|
||||||
Local::writeStickers();
|
Local::writeStickers();
|
||||||
}
|
}
|
||||||
_history->updateRecentStickers();
|
_history->updateRecentStickers();
|
||||||
|
@ -4770,6 +4754,11 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
App::main()->updateStickers();
|
App::main()->updateStickers();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case mtpc_updateRecentStickers: {
|
||||||
|
Global::SetLastStickersUpdate(0);
|
||||||
|
App::main()->updateStickers();
|
||||||
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadFeaturedStickers: {
|
case mtpc_updateReadFeaturedStickers: {
|
||||||
for (auto &set : Global::RefStickerSets()) {
|
for (auto &set : Global::RefStickerSets()) {
|
||||||
if (set.flags & MTPDstickerSet_ClientFlag::f_unread) {
|
if (set.flags & MTPDstickerSet_ClientFlag::f_unread) {
|
||||||
|
|
|
@ -1066,8 +1066,11 @@ enum class MTPDstickerSet_ClientFlag : int32 {
|
||||||
// sticker set is an unread featured set
|
// sticker set is an unread featured set
|
||||||
f_unread = (1 << 28),
|
f_unread = (1 << 28),
|
||||||
|
|
||||||
|
// special set like recent or custom stickers
|
||||||
|
f_special = (1 << 27),
|
||||||
|
|
||||||
// update this when adding new client side flags
|
// update this when adding new client side flags
|
||||||
MIN_FIELD = (1 << 28),
|
MIN_FIELD = (1 << 27),
|
||||||
};
|
};
|
||||||
DEFINE_MTP_CLIENT_FLAGS(MTPDstickerSet)
|
DEFINE_MTP_CLIENT_FLAGS(MTPDstickerSet)
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ DocumentData *Document::readFromStreamHelper(int streamAppVersion, QDataStream &
|
||||||
if (typeOfSet == StickerSetTypeEmpty) {
|
if (typeOfSet == StickerSetTypeEmpty) {
|
||||||
attributes.push_back(MTP_documentAttributeSticker(MTP_string(alt), MTP_inputStickerSetEmpty()));
|
attributes.push_back(MTP_documentAttributeSticker(MTP_string(alt), MTP_inputStickerSetEmpty()));
|
||||||
} else if (info) {
|
} else if (info) {
|
||||||
if (info->setId == Stickers::DefaultSetId || info->setId == Stickers::CustomSetId) {
|
if (info->setId == Stickers::DefaultSetId || info->setId == Stickers::CloudRecentSetId || info->setId == Stickers::CustomSetId) {
|
||||||
typeOfSet = StickerSetTypeEmpty;
|
typeOfSet = StickerSetTypeEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -849,16 +849,10 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) {
|
||||||
connect(box.get(), SIGNAL(confirmed()), this, SLOT(onSwitchModerateMode()));
|
connect(box.get(), SIGNAL(confirmed()), this, SLOT(onSwitchModerateMode()));
|
||||||
Ui::showLayer(box.release());
|
Ui::showLayer(box.release());
|
||||||
break;
|
break;
|
||||||
} else if (str == qstr("clearstickers")) {
|
|
||||||
auto box = std_::make_unique<ConfirmBox>(qsl("Clear frequently used stickers list?"));
|
|
||||||
connect(box.get(), SIGNAL(confirmed()), this, SLOT(onClearStickers()));
|
|
||||||
Ui::showLayer(box.release());
|
|
||||||
break;
|
|
||||||
} else if (
|
} else if (
|
||||||
qsl("debugmode").startsWith(str) ||
|
qsl("debugmode").startsWith(str) ||
|
||||||
qsl("testmode").startsWith(str) ||
|
qsl("testmode").startsWith(str) ||
|
||||||
qsl("loadlang").startsWith(str) ||
|
qsl("loadlang").startsWith(str) ||
|
||||||
qsl("clearstickers").startsWith(str) ||
|
|
||||||
qsl("moderate").startsWith(str) ||
|
qsl("moderate").startsWith(str) ||
|
||||||
qsl("debugfiles").startsWith(str) ||
|
qsl("debugfiles").startsWith(str) ||
|
||||||
qsl("workmode").startsWith(str) ||
|
qsl("workmode").startsWith(str) ||
|
||||||
|
@ -1267,24 +1261,6 @@ void SettingsInner::onShowSessions() {
|
||||||
Ui::showLayer(box);
|
Ui::showLayer(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsInner::onClearStickers() {
|
|
||||||
auto &recent(cGetRecentStickers());
|
|
||||||
if (!recent.isEmpty()) {
|
|
||||||
recent.clear();
|
|
||||||
Local::writeUserSettings();
|
|
||||||
}
|
|
||||||
auto &sets(Global::RefStickerSets());
|
|
||||||
auto it = sets.find(Stickers::CustomSetId);
|
|
||||||
if (it != sets.cend()) {
|
|
||||||
sets.erase(it);
|
|
||||||
Local::writeStickers();
|
|
||||||
}
|
|
||||||
if (auto m = App::main()) {
|
|
||||||
emit m->stickersUpdated();
|
|
||||||
}
|
|
||||||
Ui::hideLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsInner::onSwitchModerateMode() {
|
void SettingsInner::onSwitchModerateMode() {
|
||||||
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
|
Global::SetModerateModeEnabled(!Global::ModerateModeEnabled());
|
||||||
Local::writeUserSettings();
|
Local::writeUserSettings();
|
||||||
|
|
|
@ -187,7 +187,6 @@ public slots:
|
||||||
void onUpdateLocalStorage();
|
void onUpdateLocalStorage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onClearStickers();
|
|
||||||
void onSwitchModerateMode();
|
void onSwitchModerateMode();
|
||||||
|
|
||||||
void onAskQuestion();
|
void onAskQuestion();
|
||||||
|
|
Loading…
Reference in New Issue