mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-19 06:26:55 +00:00
Show sticker set on Ctrl+Click in stickers list.
This commit is contained in:
parent
ca45fb617e
commit
76f0abecfd
@ -135,16 +135,17 @@ StickerSetBox::StickerSetBox(
|
||||
, _set(set) {
|
||||
}
|
||||
|
||||
void StickerSetBox::Show(
|
||||
QPointer<BoxContent> StickerSetBox::Show(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<DocumentData*> document) {
|
||||
if (const auto sticker = document->sticker()) {
|
||||
if (sticker->set.type() != mtpc_inputStickerSetEmpty) {
|
||||
Ui::show(
|
||||
return Ui::show(
|
||||
Box<StickerSetBox>(controller, sticker->set),
|
||||
LayerOption::KeepOther);
|
||||
LayerOption::KeepOther).data();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StickerSetBox::prepare() {
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
not_null<Window::SessionController*> controller,
|
||||
const MTPInputStickerSet &set);
|
||||
|
||||
static void Show(
|
||||
static QPointer<BoxContent> Show(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<DocumentData*> document);
|
||||
|
||||
|
@ -1894,7 +1894,18 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
||||
}
|
||||
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)) {
|
||||
Assert(set->section >= 0 && set->section < sets.size());
|
||||
displaySet(sets[set->section].id);
|
||||
@ -2529,7 +2540,7 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
|
||||
}
|
||||
|
||||
bool StickersListWidget::preventAutoHide() {
|
||||
return _removingSetId != 0 || _displayingSetId != 0;
|
||||
return _removingSetId != 0 || _displayingSet != 0;
|
||||
}
|
||||
|
||||
void StickersListWidget::updateSelected() {
|
||||
@ -2760,12 +2771,10 @@ void StickersListWidget::beforeHiding() {
|
||||
void StickersListWidget::displaySet(uint64 setId) {
|
||||
if (setId == Stickers::MegagroupSetId) {
|
||||
if (_megagroupSet->canEditStickers()) {
|
||||
_displayingSetId = setId;
|
||||
auto box = Ui::show(Box<StickersBox>(_megagroupSet));
|
||||
connect(box, &QObject::destroyed, this, [this] {
|
||||
_displayingSetId = 0;
|
||||
_checkForHide.fire({});
|
||||
});
|
||||
_displayingSet = true;
|
||||
checkHideWithBox(Ui::show(
|
||||
Box<StickersBox>(_megagroupSet),
|
||||
LayerOption::KeepOther).data());
|
||||
return;
|
||||
} else if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) {
|
||||
setId = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID().vid().v;
|
||||
@ -2776,17 +2785,23 @@ void StickersListWidget::displaySet(uint64 setId) {
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
if (it != sets.cend()) {
|
||||
_displayingSetId = setId;
|
||||
auto box = Ui::show(
|
||||
_displayingSet = true;
|
||||
checkHideWithBox(Ui::show(
|
||||
Box<StickerSetBox>(controller(), Stickers::inputSetId(*it)),
|
||||
LayerOption::KeepOther);
|
||||
connect(box, &QObject::destroyed, this, [this] {
|
||||
_displayingSetId = 0;
|
||||
_checkForHide.fire({});
|
||||
});
|
||||
LayerOption::KeepOther).data());
|
||||
}
|
||||
}
|
||||
|
||||
void StickersListWidget::checkHideWithBox(QPointer<BoxContent> box) {
|
||||
if (!box) {
|
||||
return;
|
||||
}
|
||||
connect(box, &QObject::destroyed, this, [=] {
|
||||
_displayingSet = false;
|
||||
_checkForHide.fire({});
|
||||
});
|
||||
}
|
||||
|
||||
void StickersListWidget::installSet(uint64 setId) {
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/variant.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class BoxContent;
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
@ -201,6 +203,7 @@ private:
|
||||
|
||||
void setSection(Section section);
|
||||
void displaySet(uint64 setId);
|
||||
void checkHideWithBox(QPointer<BoxContent> box);
|
||||
void installSet(uint64 setId);
|
||||
void removeMegagroupSet(bool locally);
|
||||
void removeSet(uint64 setId);
|
||||
@ -310,7 +313,7 @@ private:
|
||||
|
||||
Section _section = Section::Stickers;
|
||||
|
||||
uint64 _displayingSetId = 0;
|
||||
bool _displayingSet = false;
|
||||
uint64 _removingSetId = 0;
|
||||
|
||||
Footer *_footer = nullptr;
|
||||
|
@ -3219,6 +3219,8 @@ void MainWidget::start() {
|
||||
if (const auto availableAt = Local::ReadExportSettings().availableAt) {
|
||||
session().data().suggestStartExport(availableAt);
|
||||
}
|
||||
session().data().notifyStickersUpdated();
|
||||
session().data().notifySavedGifsUpdated();
|
||||
|
||||
_history->start();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user