mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Initial code of attaching effect selector.
This commit is contained in:
parent
92133e7f50
commit
396ba9a984
30 changed files with 163 additions and 83 deletions
|
@ -561,6 +561,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_reaction_invoice" = "{reaction} to your invoice";
|
||||
"lng_reaction_gif" = "{reaction} to your GIF";
|
||||
|
||||
"lng_effect_add_title" = "Add an animated effect";
|
||||
"lng_effect_stickers_title" = "Message Effects";
|
||||
|
||||
"lng_languages" = "Languages";
|
||||
"lng_languages_none" = "No languages found.";
|
||||
"lng_languages_count#one" = "{count} language";
|
||||
|
|
|
@ -1295,6 +1295,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
_controller->show(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
_controller->uiShow(),
|
||||
SendMenu::Type::Scheduled,
|
||||
send));
|
||||
};
|
||||
|
@ -1327,6 +1328,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
};
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
submit.data(),
|
||||
_controller->uiShow(),
|
||||
sendMenuType,
|
||||
sendSilent,
|
||||
sendScheduled,
|
||||
|
|
|
@ -529,6 +529,7 @@ void SendFilesBox::refreshButtons() {
|
|||
if (_sendType == Api::SendType::Normal) {
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send,
|
||||
_show,
|
||||
[=] { return _sendMenuType; },
|
||||
[=] { sendSilent(); },
|
||||
[=] { sendScheduled(); },
|
||||
|
@ -1472,7 +1473,7 @@ void SendFilesBox::sendScheduled() {
|
|||
? SendMenu::Type::ScheduledToUser
|
||||
: _sendMenuType;
|
||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||
auto box = HistoryView::PrepareScheduleBox(this, type, callback);
|
||||
auto box = HistoryView::PrepareScheduleBox(this, _show, type, callback);
|
||||
const auto weak = Ui::MakeWeak(box.data());
|
||||
_show->showBox(std::move(box));
|
||||
if (const auto strong = weak.data()) {
|
||||
|
|
|
@ -616,6 +616,7 @@ void ShareBox::submitScheduled() {
|
|||
uiShow()->showBox(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
this,
|
||||
nullptr, // ChatHelpers::Show for effect attachment.
|
||||
sendMenuType(),
|
||||
callback,
|
||||
HistoryView::DefaultScheduleTime(),
|
||||
|
|
|
@ -351,8 +351,7 @@ HistoryInner::HistoryInner(
|
|||
, _reactionsManager(
|
||||
std::make_unique<HistoryView::Reactions::Manager>(
|
||||
this,
|
||||
[=](QRect updated) { update(updated); },
|
||||
controller->cachedReactionIconFactory().createMethod()))
|
||||
[=](QRect updated) { update(updated); }))
|
||||
, _touchSelectTimer([=] { onTouchSelect(); })
|
||||
, _touchScrollTimer([=] { onTouchScrollTimer(); })
|
||||
, _scrollDateCheck([this] { scrollDateCheck(); })
|
||||
|
@ -2778,8 +2777,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
desiredPosition,
|
||||
reactItem,
|
||||
[=](ChosenReaction reaction) { reactionChosen(reaction); },
|
||||
ItemReactionsAbout(reactItem),
|
||||
_controller->cachedReactionIconFactory().createMethod())
|
||||
ItemReactionsAbout(reactItem))
|
||||
: AttachSelectorResult::Skipped;
|
||||
if (attached == AttachSelectorResult::Failed) {
|
||||
_menu = nullptr;
|
||||
|
|
|
@ -323,6 +323,7 @@ HistoryWidget::HistoryWidget(
|
|||
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send.get(),
|
||||
controller->uiShow(),
|
||||
[=] { return sendButtonMenuType(); },
|
||||
[=] { sendSilent(); },
|
||||
[=] { sendScheduled(); },
|
||||
|
@ -4192,7 +4193,11 @@ void HistoryWidget::sendScheduled() {
|
|||
}
|
||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||
controller()->show(
|
||||
HistoryView::PrepareScheduleBox(_list, sendMenuType(), callback));
|
||||
HistoryView::PrepareScheduleBox(
|
||||
_list,
|
||||
controller()->uiShow(),
|
||||
sendMenuType(),
|
||||
callback));
|
||||
}
|
||||
|
||||
void HistoryWidget::sendWhenOnline() {
|
||||
|
|
|
@ -2197,6 +2197,7 @@ void ComposeControls::initSendButton() {
|
|||
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send.get(),
|
||||
_show,
|
||||
[=] { return sendButtonMenuType(); },
|
||||
SendMenu::DefaultSilentCallback(send),
|
||||
SendMenu::DefaultScheduleCallback(_show, sendMenuType(), send),
|
||||
|
|
|
@ -589,6 +589,7 @@ bool AddRescheduleAction(
|
|||
const auto box = request.navigation->parentController()->show(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
&request.navigation->session(),
|
||||
request.navigation->uiShow(),
|
||||
sendMenuType,
|
||||
callback,
|
||||
date));
|
||||
|
|
|
@ -115,8 +115,7 @@ auto WindowListDelegate::listMakeReactionsManager(
|
|||
-> std::unique_ptr<Reactions::Manager> {
|
||||
return std::make_unique<Reactions::Manager>(
|
||||
wheelEventsTarget,
|
||||
std::move(update),
|
||||
_window->cachedReactionIconFactory().createMethod());
|
||||
std::move(update));
|
||||
}
|
||||
|
||||
void WindowListDelegate::listVisibleAreaUpdated() {
|
||||
|
@ -2780,8 +2779,7 @@ void ListWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
desiredPosition,
|
||||
reactItem,
|
||||
[=](ChosenReaction reaction) { reactionChosen(reaction); },
|
||||
ItemReactionsAbout(reactItem),
|
||||
controller()->cachedReactionIconFactory().createMethod())
|
||||
ItemReactionsAbout(reactItem))
|
||||
: AttachSelectorResult::Skipped;
|
||||
if (attached == AttachSelectorResult::Failed) {
|
||||
_menu = nullptr;
|
||||
|
|
|
@ -69,6 +69,7 @@ bool CanScheduleUntilOnline(not_null<PeerData*> peer) {
|
|||
|
||||
void ScheduleBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
SendMenu::Type type,
|
||||
Fn<void(Api::SendOptions)> done,
|
||||
TimeId time,
|
||||
|
@ -98,6 +99,7 @@ void ScheduleBox(
|
|||
using T = SendMenu::Type;
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
descriptor.submit.data(),
|
||||
show,
|
||||
[t = type == T::Disabled ? T::Disabled : T::SilentOnly] { return t; },
|
||||
[=] { save(true, descriptor.collect()); },
|
||||
nullptr,
|
||||
|
|
|
@ -18,6 +18,10 @@ namespace Api {
|
|||
struct SendOptions;
|
||||
} // namespace Api
|
||||
|
||||
namespace ChatHelpers {
|
||||
class Show;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
|
@ -36,6 +40,7 @@ struct ScheduleBoxStyleArgs {
|
|||
|
||||
void ScheduleBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
SendMenu::Type type,
|
||||
Fn<void(Api::SendOptions)> done,
|
||||
TimeId time,
|
||||
|
@ -44,12 +49,14 @@ void ScheduleBox(
|
|||
template <typename Guard, typename Submit>
|
||||
[[nodiscard]] object_ptr<Ui::GenericBox> PrepareScheduleBox(
|
||||
Guard &&guard,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
SendMenu::Type type,
|
||||
Submit &&submit,
|
||||
TimeId scheduleTime = DefaultScheduleTime(),
|
||||
ScheduleBoxStyleArgs style = ScheduleBoxStyleArgs()) {
|
||||
return Box(
|
||||
ScheduleBox,
|
||||
std::move(show),
|
||||
type,
|
||||
crl::guard(std::forward<Guard>(guard), std::forward<Submit>(submit)),
|
||||
scheduleTime,
|
||||
|
|
|
@ -98,6 +98,7 @@ ScheduledWidget::ScheduledWidget(
|
|||
const Data::ForumTopic *forumTopic)
|
||||
: Window::SectionWidget(parent, controller, history->peer)
|
||||
, WindowListDelegate(controller)
|
||||
, _show(controller->uiShow())
|
||||
, _history(history)
|
||||
, _forumTopic(forumTopic)
|
||||
, _scroll(
|
||||
|
@ -600,7 +601,8 @@ void ScheduledWidget::uploadFile(
|
|||
type,
|
||||
prepareSendAction(options));
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
bool ScheduledWidget::showSendingFilesError(
|
||||
|
@ -678,7 +680,8 @@ void ScheduledWidget::send() {
|
|||
return;
|
||||
}
|
||||
const auto callback = [=](Api::SendOptions options) { send(options); };
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
void ScheduledWidget::send(Api::SendOptions options) {
|
||||
|
@ -709,7 +712,8 @@ void ScheduledWidget::sendVoice(
|
|||
const auto callback = [=](Api::SendOptions options) {
|
||||
sendVoice(bytes, waveform, duration, options);
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
void ScheduledWidget::sendVoice(
|
||||
|
@ -809,7 +813,8 @@ void ScheduledWidget::sendExistingDocument(
|
|||
const auto callback = [=](Api::SendOptions options) {
|
||||
sendExistingDocument(document, options);
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
bool ScheduledWidget::sendExistingDocument(
|
||||
|
@ -838,7 +843,8 @@ void ScheduledWidget::sendExistingPhoto(not_null<PhotoData*> photo) {
|
|||
const auto callback = [=](Api::SendOptions options) {
|
||||
sendExistingPhoto(photo, options);
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
bool ScheduledWidget::sendExistingPhoto(
|
||||
|
@ -872,7 +878,8 @@ void ScheduledWidget::sendInlineResult(
|
|||
const auto callback = [=](Api::SendOptions options) {
|
||||
sendInlineResult(result, bot, options);
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
void ScheduledWidget::sendInlineResult(
|
||||
|
@ -1360,7 +1367,8 @@ void ScheduledWidget::listSendBotCommand(
|
|||
message.textWithTags = { text };
|
||||
session().api().sendMessage(std::move(message));
|
||||
};
|
||||
controller()->show(PrepareScheduleBox(this, sendMenuType(), callback));
|
||||
controller()->show(
|
||||
PrepareScheduleBox(this, _show, sendMenuType(), callback));
|
||||
}
|
||||
|
||||
void ScheduledWidget::listSearch(
|
||||
|
|
|
@ -17,6 +17,10 @@ class History;
|
|||
enum class SendMediaType;
|
||||
struct SendingAlbum;
|
||||
|
||||
namespace ChatHelpers {
|
||||
class Show;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace SendMenu {
|
||||
enum class Type;
|
||||
} // namespace SendMenu
|
||||
|
@ -262,6 +266,7 @@ private:
|
|||
not_null<UserData*> bot,
|
||||
Api::SendOptions options);
|
||||
|
||||
const std::shared_ptr<ChatHelpers::Show> _show;
|
||||
const not_null<History*> _history;
|
||||
const Data::ForumTopic *_forumTopic;
|
||||
std::shared_ptr<Ui::ChatTheme> _theme;
|
||||
|
|
|
@ -138,7 +138,7 @@ public:
|
|||
Manager(
|
||||
QWidget *wheelEventsTarget,
|
||||
Fn<void(QRect)> buttonUpdate,
|
||||
IconFactory iconFactory);
|
||||
IconFactory iconFactory = nullptr);
|
||||
~Manager();
|
||||
|
||||
using ReactionId = ::Data::ReactionId;
|
||||
|
|
|
@ -200,8 +200,8 @@ Selector::Selector(
|
|||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const Data::PossibleItemReactionsRef &reactions,
|
||||
TextWithEntities about,
|
||||
IconFactory iconFactory,
|
||||
Fn<void(bool fast)> close,
|
||||
IconFactory iconFactory,
|
||||
bool child)
|
||||
: Selector(
|
||||
parent,
|
||||
|
@ -261,14 +261,12 @@ Selector::Selector(
|
|||
QSize(2 * st::reactStripSkip + st::reactStripSize, st::reactStripHeight),
|
||||
st::reactionCornerShadow,
|
||||
st::reactStripHeight)
|
||||
, _strip(iconFactory
|
||||
? std::make_unique<Strip>(
|
||||
_st,
|
||||
QRect(0, 0, st::reactStripSize, st::reactStripSize),
|
||||
st::reactStripImage,
|
||||
crl::guard(this, [=] { update(_inner); }),
|
||||
std::move(iconFactory))
|
||||
: nullptr)
|
||||
, _strip(std::make_unique<Strip>(
|
||||
_st,
|
||||
QRect(0, 0, st::reactStripSize, st::reactStripSize),
|
||||
st::reactStripImage,
|
||||
crl::guard(this, [=] { update(_inner); }),
|
||||
std::move(iconFactory)))
|
||||
, _about(about.empty()
|
||||
? nullptr
|
||||
: std::make_unique<Ui::FlatLabel>(
|
||||
|
@ -1221,8 +1219,8 @@ auto AttachSelectorToMenu(
|
|||
std::move(show),
|
||||
std::move(reactions),
|
||||
std::move(about),
|
||||
std::move(iconFactory),
|
||||
[=](bool fast) { menu->hideMenu(fast); },
|
||||
std::move(iconFactory),
|
||||
false); // child
|
||||
if (!AdjustMenuGeometryForSelector(menu, desiredPosition, selector)) {
|
||||
return base::make_unexpected(AttachSelectorResult::Failed);
|
||||
|
|
|
@ -82,8 +82,8 @@ public:
|
|||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const Data::PossibleItemReactionsRef &reactions,
|
||||
TextWithEntities about,
|
||||
IconFactory iconFactory,
|
||||
Fn<void(bool fast)> close,
|
||||
IconFactory iconFactory = nullptr,
|
||||
bool child = false);
|
||||
Selector(
|
||||
not_null<QWidget*> parent,
|
||||
|
@ -253,7 +253,7 @@ AttachSelectorResult AttachSelectorToMenu(
|
|||
not_null<HistoryItem*> item,
|
||||
Fn<void(ChosenReaction)> chosen,
|
||||
TextWithEntities about,
|
||||
IconFactory iconFactory);
|
||||
IconFactory iconFactory = nullptr);
|
||||
|
||||
[[nodiscard]] auto AttachSelectorToMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
|
@ -262,7 +262,7 @@ AttachSelectorResult AttachSelectorToMenu(
|
|||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const Data::PossibleItemReactionsRef &reactions,
|
||||
TextWithEntities about,
|
||||
IconFactory iconFactory
|
||||
IconFactory iconFactory = nullptr
|
||||
) -> base::expected<not_null<Selector*>, AttachSelectorResult>;
|
||||
|
||||
[[nodiscard]] TextWithEntities ItemReactionsAbout(
|
||||
|
|
|
@ -51,7 +51,9 @@ Strip::Strip(
|
|||
Fn<void()> update,
|
||||
IconFactory iconFactory)
|
||||
: _st(st)
|
||||
, _iconFactory(std::move(iconFactory))
|
||||
, _iconFactory(iconFactory
|
||||
? std::move(iconFactory)
|
||||
: DefaultCachingIconFactory)
|
||||
, _inner(inner)
|
||||
, _finalSize(size)
|
||||
, _update(std::move(update)) {
|
||||
|
@ -558,4 +560,11 @@ std::shared_ptr<Ui::AnimatedIcon> DefaultIconFactory(
|
|||
return CreateIcon(media, size);
|
||||
}
|
||||
|
||||
std::shared_ptr<Ui::AnimatedIcon> DefaultCachingIconFactory(
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
int size) {
|
||||
auto &factory = media->owner()->session().cachedReactionIconFactory();
|
||||
return factory.createMethod()(media, size);
|
||||
}
|
||||
|
||||
} // namespace HistoryView::Reactions
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
QRect inner,
|
||||
int size,
|
||||
Fn<void()> update,
|
||||
IconFactory iconFactory);
|
||||
IconFactory iconFactory = nullptr);
|
||||
|
||||
enum class AddedButton : uchar {
|
||||
None,
|
||||
|
@ -173,4 +173,8 @@ private:
|
|||
not_null<Data::DocumentMedia*> media,
|
||||
int size);
|
||||
|
||||
[[nodiscard]] std::shared_ptr<Ui::AnimatedIcon> DefaultCachingIconFactory(
|
||||
not_null<Data::DocumentMedia*> media,
|
||||
int size);
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
#include "chat_helpers/stickers_dice_pack.h"
|
||||
#include "chat_helpers/stickers_gift_box_pack.h"
|
||||
#include "history/view/reactions/history_view_reactions_strip.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "inline_bots/bot_attach_web_view.h"
|
||||
|
@ -104,6 +105,7 @@ Session::Session(
|
|||
, _scheduledMessages(std::make_unique<Data::ScheduledMessages>(this))
|
||||
, _sponsoredMessages(std::make_unique<Data::SponsoredMessages>(this))
|
||||
, _topPeers(std::make_unique<Data::TopPeers>(this))
|
||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
||||
, _supportHelper(Support::Helper::Create(this))
|
||||
, _saveSettingsTimer([=] { saveSettings(); }) {
|
||||
Expects(_settings != nullptr);
|
||||
|
|
|
@ -37,6 +37,10 @@ class SponsoredMessages;
|
|||
class TopPeers;
|
||||
} // namespace Data
|
||||
|
||||
namespace HistoryView::Reactions {
|
||||
class CachedIconFactory;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
||||
namespace Storage {
|
||||
class DownloadManagerMtproto;
|
||||
class Uploader;
|
||||
|
@ -156,6 +160,10 @@ public:
|
|||
[[nodiscard]] InlineBots::AttachWebView &attachWebView() const {
|
||||
return *_attachWebView;
|
||||
}
|
||||
[[nodiscard]] auto cachedReactionIconFactory() const
|
||||
-> HistoryView::Reactions::CachedIconFactory & {
|
||||
return *_cachedReactionIconFactory;
|
||||
}
|
||||
|
||||
void saveSettings();
|
||||
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
||||
|
@ -217,8 +225,6 @@ public:
|
|||
private:
|
||||
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
||||
|
||||
void parseColorIndices(const MTPDhelp_peerColors &data);
|
||||
|
||||
const UserId _userId;
|
||||
const not_null<Account*> _account;
|
||||
|
||||
|
@ -246,6 +252,9 @@ private:
|
|||
const std::unique_ptr<Data::SponsoredMessages> _sponsoredMessages;
|
||||
const std::unique_ptr<Data::TopPeers> _topPeers;
|
||||
|
||||
using ReactionIconFactory = HistoryView::Reactions::CachedIconFactory;
|
||||
const std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
||||
|
||||
const std::unique_ptr<Support::Helper> _supportHelper;
|
||||
|
||||
std::shared_ptr<QImage> _selfUserpicView;
|
||||
|
|
|
@ -679,11 +679,6 @@ auto Controller::stickerOrEmojiChosen() const
|
|||
return _delegate->storiesStickerOrEmojiChosen();
|
||||
}
|
||||
|
||||
auto Controller::cachedReactionIconFactory() const
|
||||
-> HistoryView::Reactions::CachedIconFactory & {
|
||||
return _delegate->storiesCachedReactionIconFactory();
|
||||
}
|
||||
|
||||
void Controller::rebuildFromContext(
|
||||
not_null<PeerData*> peer,
|
||||
FullStoryId storyId) {
|
||||
|
|
|
@ -30,7 +30,6 @@ class DocumentMedia;
|
|||
} // namespace Data
|
||||
|
||||
namespace HistoryView::Reactions {
|
||||
class CachedIconFactory;
|
||||
struct ChosenReaction;
|
||||
enum class AttachSelectorResult;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
@ -137,8 +136,6 @@ public:
|
|||
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow() const;
|
||||
[[nodiscard]] auto stickerOrEmojiChosen() const
|
||||
-> rpl::producer<ChatHelpers::FileChosen>;
|
||||
[[nodiscard]] auto cachedReactionIconFactory() const
|
||||
-> HistoryView::Reactions::CachedIconFactory &;
|
||||
|
||||
void show(not_null<Data::Story*> story, Data::StoriesContext context);
|
||||
void jumpTo(not_null<Data::Story*> story, Data::StoriesContext context);
|
||||
|
|
|
@ -17,10 +17,6 @@ class Story;
|
|||
struct StoriesContext;
|
||||
} // namespace Data
|
||||
|
||||
namespace HistoryView::Reactions {
|
||||
class CachedIconFactory;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
@ -48,8 +44,6 @@ public:
|
|||
-> std::shared_ptr<ChatHelpers::Show> = 0;
|
||||
[[nodiscard]] virtual auto storiesStickerOrEmojiChosen()
|
||||
-> rpl::producer<ChatHelpers::FileChosen> = 0;
|
||||
[[nodiscard]] virtual auto storiesCachedReactionIconFactory()
|
||||
-> HistoryView::Reactions::CachedIconFactory & = 0;
|
||||
virtual void storiesRedisplay(not_null<Data::Story*> story) = 0;
|
||||
virtual void storiesJumpTo(
|
||||
not_null<Main::Session*> session,
|
||||
|
|
|
@ -667,7 +667,6 @@ void Reactions::Panel::create() {
|
|||
TextWithEntities{ (mode == Mode::Message
|
||||
? tr::lng_stories_reaction_as_message(tr::now)
|
||||
: QString()) },
|
||||
_controller->cachedReactionIconFactory().createMethod(),
|
||||
[=](bool fast) { hide(mode); });
|
||||
|
||||
_selector->chosen(
|
||||
|
@ -867,8 +866,7 @@ auto Reactions::attachToMenu(
|
|||
st::storiesReactionsPan,
|
||||
show,
|
||||
LookupPossibleReactions(&show->session()),
|
||||
TextWithEntities(),
|
||||
_controller->cachedReactionIconFactory().createMethod());
|
||||
TextWithEntities());
|
||||
if (!result) {
|
||||
return result.error();
|
||||
}
|
||||
|
|
|
@ -415,7 +415,6 @@ OverlayWidget::OverlayWidget()
|
|||
, _widget(_surface->rpWidget())
|
||||
, _fullscreen(Core::App().settings().mediaViewPosition().maximized == 2)
|
||||
, _windowed(Core::App().settings().mediaViewPosition().maximized == 0)
|
||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
||||
, _layerBg(std::make_unique<Ui::LayerManager>(_body))
|
||||
, _docDownload(_body, tr::lng_media_download(tr::now), st::mediaviewFileLink)
|
||||
, _docSaveAs(_body, tr::lng_mediaview_save_as(tr::now), st::mediaviewFileLink)
|
||||
|
@ -4295,11 +4294,6 @@ auto OverlayWidget::storiesStickerOrEmojiChosen()
|
|||
return _storiesStickerOrEmojiChosen.events();
|
||||
}
|
||||
|
||||
auto OverlayWidget::storiesCachedReactionIconFactory()
|
||||
-> HistoryView::Reactions::CachedIconFactory & {
|
||||
return *_cachedReactionIconFactory;
|
||||
}
|
||||
|
||||
void OverlayWidget::storiesJumpTo(
|
||||
not_null<Main::Session*> session,
|
||||
FullStoryId id,
|
||||
|
|
|
@ -55,10 +55,6 @@ namespace Window::Theme {
|
|||
struct Preview;
|
||||
} // namespace Window::Theme
|
||||
|
||||
namespace HistoryView::Reactions {
|
||||
class CachedIconFactory;
|
||||
} // namespace HistoryView::Reactions
|
||||
|
||||
namespace Media::Player {
|
||||
struct TrackState;
|
||||
} // namespace Media::Player
|
||||
|
@ -251,8 +247,6 @@ private:
|
|||
std::shared_ptr<ChatHelpers::Show> storiesShow() override;
|
||||
auto storiesStickerOrEmojiChosen()
|
||||
-> rpl::producer<ChatHelpers::FileChosen> override;
|
||||
auto storiesCachedReactionIconFactory()
|
||||
-> HistoryView::Reactions::CachedIconFactory & override;
|
||||
void storiesRedisplay(not_null<Data::Story*> story) override;
|
||||
void storiesJumpTo(
|
||||
not_null<Main::Session*> session,
|
||||
|
@ -629,8 +623,6 @@ private:
|
|||
bool _showAsPip = false;
|
||||
|
||||
std::unique_ptr<Stories::View> _stories;
|
||||
using ReactionIconFactory = HistoryView::Reactions::CachedIconFactory;
|
||||
std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
||||
std::shared_ptr<Show> _cachedShow;
|
||||
rpl::event_stream<> _storiesChanged;
|
||||
Main::Session *_storiesSession = nullptr;
|
||||
|
|
|
@ -10,13 +10,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "api/api_common.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "chat_helpers/compose/compose_show.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "history/view/reactions/history_view_reactions_selector.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/data_message_reactions.h"
|
||||
#include "data/data_session.h"
|
||||
#include "main/main_session.h"
|
||||
#include "history/history.h"
|
||||
|
@ -28,19 +31,51 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtWidgets/QApplication>
|
||||
|
||||
namespace SendMenu {
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] Data::PossibleItemReactionsRef LookupPossibleEffects(
|
||||
not_null<Main::Session*> session) {
|
||||
auto result = Data::PossibleItemReactionsRef();
|
||||
const auto reactions = &session->data().reactions();
|
||||
const auto &full = reactions->list(Data::Reactions::Type::Active);
|
||||
const auto &top = reactions->list(Data::Reactions::Type::Top);
|
||||
const auto &recent = reactions->list(Data::Reactions::Type::Recent);
|
||||
const auto premiumPossible = session->premiumPossible();
|
||||
auto added = base::flat_set<Data::ReactionId>();
|
||||
result.recent.reserve(full.size());
|
||||
for (const auto &reaction : ranges::views::concat(top, recent, full)) {
|
||||
if (premiumPossible || !reaction.id.custom()) {
|
||||
if (added.emplace(reaction.id).second) {
|
||||
result.recent.push_back(&reaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
result.customAllowed = premiumPossible;
|
||||
const auto i = ranges::find(
|
||||
result.recent,
|
||||
reactions->favoriteId(),
|
||||
&Data::Reaction::id);
|
||||
if (i != end(result.recent) && i != begin(result.recent)) {
|
||||
std::rotate(begin(result.recent), i, i + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Fn<void()> DefaultSilentCallback(Fn<void(Api::SendOptions)> send) {
|
||||
return [=] { send({ .silent = true }); };
|
||||
}
|
||||
|
||||
Fn<void()> DefaultScheduleCallback(
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Type type,
|
||||
Fn<void(Api::SendOptions)> send) {
|
||||
return [=, weak = Ui::MakeWeak(show->toastParent())] {
|
||||
show->showBox(
|
||||
HistoryView::PrepareScheduleBox(
|
||||
weak,
|
||||
show,
|
||||
type,
|
||||
[=](Api::SendOptions options) { send(options); }),
|
||||
Ui::LayerOption::KeepOther);
|
||||
|
@ -95,6 +130,7 @@ FillMenuResult FillSendMenu(
|
|||
|
||||
void SetupMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<Type()> type,
|
||||
Fn<void()> silent,
|
||||
Fn<void()> schedule,
|
||||
|
@ -107,12 +143,35 @@ void SetupMenuAndShortcuts(
|
|||
*menu = base::make_unique_q<Ui::PopupMenu>(
|
||||
button,
|
||||
st::popupMenuWithIcons);
|
||||
const auto result = FillSendMenu(*menu, type(), silent, schedule, whenOnline);
|
||||
const auto success = (result == FillMenuResult::Success);
|
||||
if (success) {
|
||||
(*menu)->popup(QCursor::pos());
|
||||
const auto result = FillSendMenu(
|
||||
*menu,
|
||||
type(),
|
||||
silent,
|
||||
schedule,
|
||||
whenOnline);
|
||||
if (result != FillMenuResult::Success) {
|
||||
return false;
|
||||
}
|
||||
return success;
|
||||
const auto desiredPosition = QCursor::pos();
|
||||
using namespace HistoryView::Reactions;
|
||||
const auto selector = show
|
||||
? AttachSelectorToMenu(
|
||||
menu->get(),
|
||||
desiredPosition,
|
||||
st::reactPanelEmojiPan,
|
||||
show,
|
||||
LookupPossibleEffects(&show->session()),
|
||||
{ tr::lng_effect_add_title(tr::now) })
|
||||
: base::make_unexpected(AttachSelectorResult::Skipped);
|
||||
if (selector) {
|
||||
//(*selector)->chosen();
|
||||
(*menu)->popupPrepared();
|
||||
} else if (selector.error() == AttachSelectorResult::Failed) {
|
||||
return false;
|
||||
} else {
|
||||
(*menu)->popup(desiredPosition);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
base::install_event_filter(button, [=](not_null<QEvent*> e) {
|
||||
if (e->type() == QEvent::ContextMenu && showMenu()) {
|
||||
|
|
|
@ -15,6 +15,10 @@ namespace Api {
|
|||
struct SendOptions;
|
||||
} // namespace Api
|
||||
|
||||
namespace ChatHelpers {
|
||||
class Show;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace Ui {
|
||||
class PopupMenu;
|
||||
class RpWidget;
|
||||
|
@ -42,7 +46,7 @@ enum class FillMenuResult {
|
|||
|
||||
Fn<void()> DefaultSilentCallback(Fn<void(Api::SendOptions)> send);
|
||||
Fn<void()> DefaultScheduleCallback(
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Type type,
|
||||
Fn<void(Api::SendOptions)> send);
|
||||
Fn<void()> DefaultWhenOnlineCallback(Fn<void(Api::SendOptions)> send);
|
||||
|
@ -57,6 +61,7 @@ FillMenuResult FillSendMenu(
|
|||
|
||||
void SetupMenuAndShortcuts(
|
||||
not_null<Ui::RpWidget*> button,
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
Fn<Type()> type,
|
||||
Fn<void()> silent,
|
||||
Fn<void()> schedule,
|
||||
|
|
|
@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/reactions/history_view_reactions.h"
|
||||
#include "history/view/reactions/history_view_reactions_button.h"
|
||||
//#include "history/view/reactions/history_view_reactions_button.h"
|
||||
#include "history/view/history_view_replies_section.h"
|
||||
#include "history/view/history_view_scheduled_section.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
|
@ -58,6 +58,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/format_values.h" // Ui::FormatPhone.
|
||||
#include "ui/delayed_activation.h"
|
||||
#include "ui/boxes/boost_box.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/chat/chat_theme.h"
|
||||
#include "ui/effects/message_sending_animation_controller.h"
|
||||
#include "ui/style/style_palette_colorizer.h"
|
||||
|
@ -1190,7 +1191,6 @@ SessionController::SessionController(
|
|||
, _activeChatsFilter(session->data().chatsFilters().defaultId())
|
||||
, _defaultChatTheme(std::make_shared<Ui::ChatTheme>())
|
||||
, _chatStyle(std::make_unique<Ui::ChatStyle>(session->colorIndicesValue()))
|
||||
, _cachedReactionIconFactory(std::make_unique<ReactionIconFactory>())
|
||||
, _giftPremiumValidator(this) {
|
||||
init();
|
||||
|
||||
|
|
|
@ -593,11 +593,6 @@ public:
|
|||
return _chatStyle.get();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto cachedReactionIconFactory() const
|
||||
-> HistoryView::Reactions::CachedIconFactory & {
|
||||
return *_cachedReactionIconFactory;
|
||||
}
|
||||
|
||||
[[nodiscard]] QString authedName() const {
|
||||
return _authedName;
|
||||
}
|
||||
|
@ -713,9 +708,6 @@ private:
|
|||
std::deque<std::shared_ptr<Ui::ChatTheme>> _lastUsedCustomChatThemes;
|
||||
rpl::variable<PeerThemeOverride> _peerThemeOverride;
|
||||
|
||||
using ReactionIconFactory = HistoryView::Reactions::CachedIconFactory;
|
||||
std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
||||
|
||||
base::has_weak_ptr _storyOpenGuard;
|
||||
|
||||
GiftPremiumValidator _giftPremiumValidator;
|
||||
|
|
Loading…
Add table
Reference in a new issue