StickerSetBox::StickerSetBox(const MTPInputStickerSet &set) : ScrollableBox(st::stickersScroll), _inner(set), _close(this, st::btnStickersClose), _addStickers(this, lng_stickers_add_pack(lt_count, 0), st::btnStickersAdd), _shareStickers(this, lang(lng_stickers_share_pack), st::btnStickersAdd), _closeStickers(this, lang(lng_close), st::btnStickersAdd) { resize(st::stickersWidth, height()); setMaxHeight(st::stickersMaxHeight); connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated())); init(&_inner, 0, st::boxFont->height + st::newGroupNamePadding.top() + st::newGroupNamePadding.bottom()); connect(&_close, SIGNAL(clicked()), this, SLOT(onClose())); connect(&_addStickers, SIGNAL(clicked()), this, SLOT(onAddStickers())); connect(&_shareStickers, SIGNAL(clicked()), this, SLOT(onShareStickers())); connect(&_closeStickers, SIGNAL(clicked()), this, SLOT(onClose())); connect(&_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons())); connect(&_scroll, SIGNAL(scrolled()), this, SLOT(onScroll())); connect(&_inner, SIGNAL(installed(uint64)), this, SIGNAL(installed(uint64))); onStickersUpdated(); onScroll(); prepare(); }
void StickersBox::prepare() { if (_section == Section::Installed) { Local::readArchivedStickers(); } else if (_section == Section::Archived) { requestArchivedSets(); } else if (_section == Section::ArchivedPart) { setTitle(lang(lng_stickers_archived)); } if (Global::ArchivedStickerSetsOrder().isEmpty()) { preloadArchivedSets(); } if (_tabs) { setNoContentMargin(true); _tabs->setSectionActivatedCallback([this] { switchTab(); }); refreshTabs(); } if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide(); if (_featured.widget() && _section != Section::Featured) _featured.widget()->hide(); if (_section != Section::Archived && _section != Section::ArchivedPart) _archived.widget()->hide(); if (_featured.widget()) { _featured.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); }); } _archived.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); }); _archived.widget()->setLoadMoreCallback([this] { loadMoreArchived(); }); addButton(lang(lng_about_done), [this] { closeBox(); }); if (_section == Section::Installed) { _tab = &_installed; } else if (_section == Section::ArchivedPart) { _aboutHeight = st::stickersReorderPadding.top() + _about.countHeight(_aboutWidth) + st::stickersReorderPadding.bottom(); _titleShadow.create(this); _tab = &_archived; } else if (_section == Section::Archived) { _tab = &_archived; } else { // _section == Section::Featured _tab = &_featured; } setInnerWidget(_tab->takeWidget(), getTopSkip()); setDimensions(st::boxWideWidth, (_section == Section::ArchivedPart) ? st::sessionsHeight : st::boxMaxListHeight); connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated())); App::main()->updateStickers(); if (_installed.widget()) { connect(_installed.widget(), SIGNAL(draggingScrollDelta(int)), this, SLOT(onDraggingScrollDelta(int))); }