mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Added support of custom emoji to top bar suggestion.
This commit is contained in:
parent
ba31bbace8
commit
97c0e3d4a9
3 changed files with 38 additions and 18 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/star_gift_box.h" // ShowStarGiftBox.
|
#include "boxes/star_gift_box.h" // ShowStarGiftBox.
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
#include "core/ui_integration.h"
|
||||||
#include "data/data_birthday.h"
|
#include "data/data_birthday.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -28,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_credits_graphics.h"
|
#include "settings/settings_credits_graphics.h"
|
||||||
#include "settings/settings_premium.h"
|
#include "settings/settings_premium.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
#include "ui/effects/credits_graphics.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -136,7 +138,11 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||||
promo->dismiss(custom->suggestion);
|
promo->dismiss(custom->suggestion);
|
||||||
repeat(repeat);
|
repeat(repeat);
|
||||||
});
|
});
|
||||||
content->setContent(custom->title, custom->description);
|
|
||||||
|
content->setContent(
|
||||||
|
custom->title,
|
||||||
|
custom->description,
|
||||||
|
Core::TextContext({ .session = session }));
|
||||||
state->desiredWrapToggle.force_assign(
|
state->desiredWrapToggle.force_assign(
|
||||||
Toggle{ true, anim::type::normal });
|
Toggle{ true, anim::type::normal });
|
||||||
return;
|
return;
|
||||||
|
@ -194,6 +200,19 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||||
promo->dismiss(kSugLowCreditsSubs.utf8());
|
promo->dismiss(kSugLowCreditsSubs.utf8());
|
||||||
repeat(repeat);
|
repeat(repeat);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const auto fontH = content->contentTitleSt().font->height;
|
||||||
|
auto customEmojiFactory = [=](
|
||||||
|
QStringView data,
|
||||||
|
const Ui::Text::MarkedContext &context
|
||||||
|
) -> std::unique_ptr<Ui::Text::CustomEmoji> {
|
||||||
|
return Ui::MakeCreditsIconEmoji(fontH, 1);
|
||||||
|
};
|
||||||
|
using namespace Ui::Text;
|
||||||
|
auto context = MarkedContext{
|
||||||
|
.customEmojiFactory = std::move(customEmojiFactory),
|
||||||
|
};
|
||||||
|
|
||||||
content->setContent(
|
content->setContent(
|
||||||
tr::lng_dialogs_suggestions_credits_sub_low_title(
|
tr::lng_dialogs_suggestions_credits_sub_low_title(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
@ -207,7 +226,7 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||||
tr::lng_dialogs_suggestions_credits_sub_low_about(
|
tr::lng_dialogs_suggestions_credits_sub_low_about(
|
||||||
tr::now,
|
tr::now,
|
||||||
TextWithEntities::Simple),
|
TextWithEntities::Simple),
|
||||||
true);
|
std::move(context));
|
||||||
state->desiredWrapToggle.force_assign(
|
state->desiredWrapToggle.force_assign(
|
||||||
Toggle{ true, anim::type::normal });
|
Toggle{ true, anim::type::normal });
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/ui/dialogs_top_bar_suggestion_content.h"
|
#include "dialogs/ui/dialogs_top_bar_suggestion_content.h"
|
||||||
#include "ui/effects/credits_graphics.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_custom_emoji.h"
|
#include "ui/text/text_custom_emoji.h"
|
||||||
#include "ui/ui_rpl_filter.h"
|
#include "ui/ui_rpl_filter.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
@ -141,28 +141,19 @@ void TopBarSuggestionContent::draw(QPainter &p) {
|
||||||
void TopBarSuggestionContent::setContent(
|
void TopBarSuggestionContent::setContent(
|
||||||
TextWithEntities title,
|
TextWithEntities title,
|
||||||
TextWithEntities description,
|
TextWithEntities description,
|
||||||
bool makeContext) {
|
std::optional<Ui::Text::MarkedContext> context) {
|
||||||
if (makeContext) {
|
if (context) {
|
||||||
auto customEmojiFactory = [=, h = _contentTitleSt.font->height](
|
context->repaint = [=] { update(); };
|
||||||
QStringView data,
|
|
||||||
const Ui::Text::MarkedContext &context
|
|
||||||
) -> std::unique_ptr<Ui::Text::CustomEmoji> {
|
|
||||||
return Ui::MakeCreditsIconEmoji(h, 1);
|
|
||||||
};
|
|
||||||
const auto context = Ui::Text::MarkedContext{
|
|
||||||
.repaint = [=] { update(); },
|
|
||||||
.customEmojiFactory = std::move(customEmojiFactory),
|
|
||||||
};
|
|
||||||
_contentTitle.setMarkedText(
|
_contentTitle.setMarkedText(
|
||||||
_contentTitleSt,
|
_contentTitleSt,
|
||||||
std::move(title),
|
std::move(title),
|
||||||
kMarkupTextOptions,
|
kMarkupTextOptions,
|
||||||
context);
|
*context);
|
||||||
_contentText.setMarkedText(
|
_contentText.setMarkedText(
|
||||||
_contentTextSt,
|
_contentTextSt,
|
||||||
std::move(description),
|
std::move(description),
|
||||||
kMarkupTextOptions,
|
kMarkupTextOptions,
|
||||||
context);
|
base::take(*context));
|
||||||
} else {
|
} else {
|
||||||
_contentTitle.setMarkedText(_contentTitleSt, std::move(title));
|
_contentTitle.setMarkedText(_contentTitleSt, std::move(title));
|
||||||
_contentText.setMarkedText(_contentTextSt, std::move(description));
|
_contentText.setMarkedText(_contentTextSt, std::move(description));
|
||||||
|
@ -203,4 +194,8 @@ void TopBarSuggestionContent::setLeftPadding(int value) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const style::TextStyle & TopBarSuggestionContent::contentTitleSt() const {
|
||||||
|
return _contentTitleSt;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Dialogs
|
} // namespace Dialogs
|
||||||
|
|
|
@ -14,6 +14,10 @@ class DynamicImage;
|
||||||
class IconButton;
|
class IconButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Ui::Text {
|
||||||
|
struct MarkedContext;
|
||||||
|
} // namespace Ui::Text
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
|
||||||
class TopBarSuggestionContent : public Ui::RippleButton {
|
class TopBarSuggestionContent : public Ui::RippleButton {
|
||||||
|
@ -29,7 +33,7 @@ public:
|
||||||
void setContent(
|
void setContent(
|
||||||
TextWithEntities title,
|
TextWithEntities title,
|
||||||
TextWithEntities description,
|
TextWithEntities description,
|
||||||
bool makeContext = false);
|
std::optional<Ui::Text::MarkedContext> context = std::nullopt);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<int> desiredHeightValue() const override;
|
[[nodiscard]] rpl::producer<int> desiredHeightValue() const override;
|
||||||
|
|
||||||
|
@ -37,6 +41,8 @@ public:
|
||||||
void setRightIcon(RightIcon);
|
void setRightIcon(RightIcon);
|
||||||
void setLeftPadding(int);
|
void setLeftPadding(int);
|
||||||
|
|
||||||
|
[[nodiscard]] const style::TextStyle &contentTitleSt() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *) override;
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue