mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Switched existing sticker pick to inline dropdown that excludes self.
This commit is contained in:
@@ -378,8 +378,6 @@ PRIVATE
|
||||
boxes/star_gift_resale_box.h
|
||||
boxes/sticker_creator_box.cpp
|
||||
boxes/sticker_creator_box.h
|
||||
boxes/sticker_picker_box.cpp
|
||||
boxes/sticker_picker_box.h
|
||||
boxes/sticker_set_box.cpp
|
||||
boxes/sticker_set_box.h
|
||||
boxes/stickers_box.cpp
|
||||
|
||||
@@ -4509,6 +4509,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"lng_stickers_create_new" = "Create a New Sticker";
|
||||
"lng_stickers_add_existing" = "Add an Existing Sticker";
|
||||
"lng_stickers_pack_choose_emoji_title" = "Choose Emoji";
|
||||
"lng_stickers_pack_choose_emoji_about" = "Pick an emoji that corresponds to this sticker.";
|
||||
"lng_stickers_pick_existing_title" = "Choose Sticker";
|
||||
"lng_stickers_pick_existing_about" = "Pick a sticker from your library to add it to this set.";
|
||||
"lng_stickers_pick_existing_empty" = "You don't have any stickers yet.";
|
||||
|
||||
@@ -447,10 +447,11 @@ void StickerCreatorBox::prepare() {
|
||||
st::boxLabel),
|
||||
st::boxRowPadding);
|
||||
|
||||
_emojiRow = inner->add(
|
||||
const auto emojiRow = inner->add(
|
||||
object_ptr<EmojiPickerRow>(inner, _show),
|
||||
QMargins(0, 0, 0, st::boxRowPadding.left()));
|
||||
_emojiRow->resize(st::boxWideWidth, st::stickersCreatorRowHeight);
|
||||
emojiRow->resize(st::boxWideWidth, st::stickersCreatorRowHeight);
|
||||
_emojiValue = [=] { return emojiRow->value(); };
|
||||
|
||||
const auto addButton = this->addButton(
|
||||
rpl::conditional(
|
||||
@@ -501,7 +502,7 @@ void StickerCreatorBox::startUpload() {
|
||||
if (_uploading.current()) {
|
||||
return;
|
||||
}
|
||||
const auto emoji = _emojiRow->value();
|
||||
const auto emoji = _emojiValue ? _emojiValue() : QString();
|
||||
if (emoji.isEmpty()) {
|
||||
_show->showToast(tr::lng_stickers_create_emoji_required(tr::now));
|
||||
return;
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/sticker_picker_box.h"
|
||||
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
StickerPickerBox::StickerPickerBox(
|
||||
QWidget*,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<void(not_null<DocumentData*>)> chosen)
|
||||
: _show(std::move(show))
|
||||
, _chosen(std::move(chosen)) {
|
||||
}
|
||||
|
||||
void StickerPickerBox::prepare() {
|
||||
setTitle(tr::lng_stickers_pick_existing_title());
|
||||
|
||||
auto descriptor = ChatHelpers::StickersListDescriptor{
|
||||
.show = _show,
|
||||
.mode = ChatHelpers::StickersListMode::UserpicBuilder,
|
||||
.paused = [] { return false; },
|
||||
};
|
||||
auto list = object_ptr<ChatHelpers::StickersListWidget>(
|
||||
this,
|
||||
std::move(descriptor));
|
||||
_list = list.data();
|
||||
|
||||
_list->refreshRecent();
|
||||
_list->refreshStickers();
|
||||
|
||||
_list->chosen(
|
||||
) | rpl::on_next([=](const ChatHelpers::FileChosen &chosen) {
|
||||
const auto document = chosen.document;
|
||||
if (_chosen) {
|
||||
_chosen(document);
|
||||
}
|
||||
closeBox();
|
||||
}, _list->lifetime());
|
||||
|
||||
setInnerWidget(std::move(list));
|
||||
setDimensions(st::boxWideWidth, st::stickersMaxHeight);
|
||||
|
||||
scrolls(
|
||||
) | rpl::on_next([=, this] {
|
||||
if (_list) {
|
||||
const auto top = scrollTop();
|
||||
_list->setVisibleTopBottom(top, top + scrollHeight());
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
}
|
||||
|
||||
void StickerPickerBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
if (_list) {
|
||||
const auto width = this->width();
|
||||
_list->resizeToWidth(width);
|
||||
_list->setMinimalHeight(width, st::stickersMaxHeight);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "ui/layers/box_content.h"
|
||||
|
||||
class DocumentData;
|
||||
|
||||
namespace ChatHelpers {
|
||||
class Show;
|
||||
class StickersListWidget;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
class StickerPickerBox final : public Ui::BoxContent {
|
||||
public:
|
||||
StickerPickerBox(
|
||||
QWidget*,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<void(not_null<DocumentData*>)> chosen);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<ChatHelpers::Show> _show;
|
||||
Fn<void(not_null<DocumentData*>)> _chosen;
|
||||
|
||||
QPointer<ChatHelpers::StickersListWidget> _list;
|
||||
|
||||
};
|
||||
@@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/premium_preview_box.h"
|
||||
#include "boxes/sticker_creator_box.h"
|
||||
#include "boxes/sticker_picker_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
#include "chat_helpers/stickers_lottie.h"
|
||||
@@ -57,6 +56,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/widgets/gradient_round_button.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/inner_dropdown.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "window/window_session_controller.h"
|
||||
@@ -488,6 +488,7 @@ private:
|
||||
bool _previewLocked = false;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
base::unique_qptr<Ui::InnerDropdown> _pickerDropdown;
|
||||
|
||||
rpl::event_stream<uint64> _setInstalled;
|
||||
rpl::event_stream<uint64> _setArchived;
|
||||
@@ -2353,6 +2354,16 @@ void StickerSetBox::Inner::startAddExistingStickerFlow() {
|
||||
if (!hasAddCell()) {
|
||||
return;
|
||||
}
|
||||
auto box = (Ui::BoxContent*)nullptr;
|
||||
for (auto p = parentWidget(); p; p = p->parentWidget()) {
|
||||
if (const auto candidate = dynamic_cast<Ui::BoxContent*>(p)) {
|
||||
box = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!box) {
|
||||
return;
|
||||
}
|
||||
const auto identifier = StickerSetIdentifier{
|
||||
.id = _setId,
|
||||
.accessHash = _setAccessHash,
|
||||
@@ -2360,8 +2371,31 @@ void StickerSetBox::Inner::startAddExistingStickerFlow() {
|
||||
};
|
||||
const auto session = _session;
|
||||
const auto show = _show;
|
||||
const auto onChosen = crl::guard(this, [=, this](
|
||||
not_null<DocumentData*> document) {
|
||||
|
||||
_pickerDropdown = base::make_unique_q<Ui::InnerDropdown>(box);
|
||||
const auto dropdown = _pickerDropdown.get();
|
||||
dropdown->setAutoHiding(false);
|
||||
dropdown->setMaxHeight(st::stickersMaxHeight);
|
||||
|
||||
auto descriptor = ChatHelpers::StickersListDescriptor{
|
||||
.show = _show,
|
||||
.mode = ChatHelpers::StickersListMode::UserpicBuilder,
|
||||
.paused = [] { return false; },
|
||||
.excludeSetId = _setId,
|
||||
};
|
||||
const auto list = dropdown->setOwnedWidget(
|
||||
object_ptr<ChatHelpers::StickersListWidget>(
|
||||
dropdown,
|
||||
std::move(descriptor)));
|
||||
list->refreshRecent();
|
||||
list->refreshStickers();
|
||||
|
||||
list->chosen(
|
||||
) | rpl::on_next([=, this](const ChatHelpers::FileChosen &chosen) {
|
||||
const auto document = chosen.document;
|
||||
if (_pickerDropdown) {
|
||||
_pickerDropdown->hideAnimated();
|
||||
}
|
||||
const auto sticker = document->sticker();
|
||||
const auto fallback = QString::fromUtf8("\xF0\x9F\x99\x82");
|
||||
const auto emoji = (sticker && !sticker->alt.isEmpty())
|
||||
@@ -2382,8 +2416,15 @@ void StickerSetBox::Inner::startAddExistingStickerFlow() {
|
||||
? tr::lng_attach_failed(tr::now)
|
||||
: err);
|
||||
}));
|
||||
});
|
||||
_show->showBox(Box<StickerPickerBox>(_show, onChosen));
|
||||
}, list->lifetime());
|
||||
|
||||
const auto desiredWidth = box->width();
|
||||
list->resizeToWidth(desiredWidth);
|
||||
|
||||
dropdown->resize(desiredWidth, st::stickersMaxHeight);
|
||||
dropdown->move(0, 0);
|
||||
dropdown->setOrigin(Ui::PanelAnimation::Origin::TopLeft);
|
||||
dropdown->showAnimated();
|
||||
}
|
||||
|
||||
void StickerSetBox::Inner::startCreateNewStickerFlow() {
|
||||
|
||||
@@ -213,6 +213,7 @@ StickersListWidget::StickersListWidget(
|
||||
, _section(Section::Stickers)
|
||||
, _isMasks(_mode == Mode::Masks)
|
||||
, _isEffects(_mode == Mode::MessageEffects)
|
||||
, _excludeSetId(descriptor.excludeSetId)
|
||||
, _updateItemsTimer([=] { updateItems(); })
|
||||
, _updateSetsTimer([=] { updateSets(); })
|
||||
, _trendingAddBgOver(
|
||||
@@ -2578,6 +2579,9 @@ bool StickersListWidget::appendSet(
|
||||
uint64 setId,
|
||||
bool externalLayout,
|
||||
AppendSkip skip) {
|
||||
if (_excludeSetId && setId == _excludeSetId) {
|
||||
return false;
|
||||
}
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
auto it = sets.find(setId);
|
||||
if (it == sets.cend()
|
||||
|
||||
@@ -84,6 +84,7 @@ struct StickersListDescriptor {
|
||||
std::vector<StickerCustomRecentDescriptor> customRecentList;
|
||||
const style::EmojiPan *st = nullptr;
|
||||
ComposeFeatures features;
|
||||
uint64 excludeSetId = 0;
|
||||
};
|
||||
|
||||
class StickersListWidget final : public TabbedSelector::Inner {
|
||||
@@ -419,6 +420,7 @@ private:
|
||||
Section _section = Section::Stickers;
|
||||
const bool _isMasks;
|
||||
const bool _isEffects;
|
||||
const uint64 _excludeSetId = 0;
|
||||
|
||||
base::Timer _updateItemsTimer;
|
||||
base::Timer _updateSetsTimer;
|
||||
|
||||
Reference in New Issue
Block a user