Show sticker set on Ctrl+Click in stickers list.

This commit is contained in:
John Preston 2019-09-10 00:48:34 +03:00
parent ca45fb617e
commit 76f0abecfd
5 changed files with 41 additions and 20 deletions

View File

@ -135,16 +135,17 @@ StickerSetBox::StickerSetBox(
, _set(set) { , _set(set) {
} }
void StickerSetBox::Show( QPointer<BoxContent> StickerSetBox::Show(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<DocumentData*> document) { not_null<DocumentData*> document) {
if (const auto sticker = document->sticker()) { if (const auto sticker = document->sticker()) {
if (sticker->set.type() != mtpc_inputStickerSetEmpty) { if (sticker->set.type() != mtpc_inputStickerSetEmpty) {
Ui::show( return Ui::show(
Box<StickerSetBox>(controller, sticker->set), Box<StickerSetBox>(controller, sticker->set),
LayerOption::KeepOther); LayerOption::KeepOther).data();
} }
} }
return nullptr;
} }
void StickerSetBox::prepare() { void StickerSetBox::prepare() {

View File

@ -28,7 +28,7 @@ public:
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
const MTPInputStickerSet &set); const MTPInputStickerSet &set);
static void Show( static QPointer<BoxContent> Show(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<DocumentData*> document); not_null<DocumentData*> document);

View File

@ -1894,7 +1894,18 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
} }
return; return;
} }
_chosen.fire_copy(set.stickers[sticker->index].document); const auto document = set.stickers[sticker->index].document;
if (e->modifiers() & Qt::ControlModifier) {
if (document->sticker()
&& document->sticker()->set.type() != mtpc_inputStickerSetEmpty) {
_displayingSet = true;
checkHideWithBox(StickerSetBox::Show(
controller(),
document));
}
} else {
_chosen.fire_copy(document);
}
} else if (auto set = base::get_if<OverSet>(&pressed)) { } else if (auto set = base::get_if<OverSet>(&pressed)) {
Assert(set->section >= 0 && set->section < sets.size()); Assert(set->section >= 0 && set->section < sets.size());
displaySet(sets[set->section].id); displaySet(sets[set->section].id);
@ -2529,7 +2540,7 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
} }
bool StickersListWidget::preventAutoHide() { bool StickersListWidget::preventAutoHide() {
return _removingSetId != 0 || _displayingSetId != 0; return _removingSetId != 0 || _displayingSet != 0;
} }
void StickersListWidget::updateSelected() { void StickersListWidget::updateSelected() {
@ -2760,12 +2771,10 @@ void StickersListWidget::beforeHiding() {
void StickersListWidget::displaySet(uint64 setId) { void StickersListWidget::displaySet(uint64 setId) {
if (setId == Stickers::MegagroupSetId) { if (setId == Stickers::MegagroupSetId) {
if (_megagroupSet->canEditStickers()) { if (_megagroupSet->canEditStickers()) {
_displayingSetId = setId; _displayingSet = true;
auto box = Ui::show(Box<StickersBox>(_megagroupSet)); checkHideWithBox(Ui::show(
connect(box, &QObject::destroyed, this, [this] { Box<StickersBox>(_megagroupSet),
_displayingSetId = 0; LayerOption::KeepOther).data());
_checkForHide.fire({});
});
return; return;
} else if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) { } else if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) {
setId = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID().vid().v; setId = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID().vid().v;
@ -2776,17 +2785,23 @@ void StickersListWidget::displaySet(uint64 setId) {
auto &sets = session().data().stickerSets(); auto &sets = session().data().stickerSets();
auto it = sets.constFind(setId); auto it = sets.constFind(setId);
if (it != sets.cend()) { if (it != sets.cend()) {
_displayingSetId = setId; _displayingSet = true;
auto box = Ui::show( checkHideWithBox(Ui::show(
Box<StickerSetBox>(controller(), Stickers::inputSetId(*it)), Box<StickerSetBox>(controller(), Stickers::inputSetId(*it)),
LayerOption::KeepOther); LayerOption::KeepOther).data());
connect(box, &QObject::destroyed, this, [this] {
_displayingSetId = 0;
_checkForHide.fire({});
});
} }
} }
void StickersListWidget::checkHideWithBox(QPointer<BoxContent> box) {
if (!box) {
return;
}
connect(box, &QObject::destroyed, this, [=] {
_displayingSet = false;
_checkForHide.fire({});
});
}
void StickersListWidget::installSet(uint64 setId) { void StickersListWidget::installSet(uint64 setId) {
auto &sets = session().data().stickerSets(); auto &sets = session().data().stickerSets();
auto it = sets.constFind(setId); auto it = sets.constFind(setId);

View File

@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/variant.h" #include "base/variant.h"
#include "base/timer.h" #include "base/timer.h"
class BoxContent;
namespace Main { namespace Main {
class Session; class Session;
} // namespace Main } // namespace Main
@ -201,6 +203,7 @@ private:
void setSection(Section section); void setSection(Section section);
void displaySet(uint64 setId); void displaySet(uint64 setId);
void checkHideWithBox(QPointer<BoxContent> box);
void installSet(uint64 setId); void installSet(uint64 setId);
void removeMegagroupSet(bool locally); void removeMegagroupSet(bool locally);
void removeSet(uint64 setId); void removeSet(uint64 setId);
@ -310,7 +313,7 @@ private:
Section _section = Section::Stickers; Section _section = Section::Stickers;
uint64 _displayingSetId = 0; bool _displayingSet = false;
uint64 _removingSetId = 0; uint64 _removingSetId = 0;
Footer *_footer = nullptr; Footer *_footer = nullptr;

View File

@ -3219,6 +3219,8 @@ void MainWidget::start() {
if (const auto availableAt = Local::ReadExportSettings().availableAt) { if (const auto availableAt = Local::ReadExportSettings().availableAt) {
session().data().suggestStartExport(availableAt); session().data().suggestStartExport(availableAt);
} }
session().data().notifyStickersUpdated();
session().data().notifySavedGifsUpdated();
_history->start(); _history->start();