mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show "Unlock emoji" button for premium sets.
This commit is contained in:
parent
bb7249f280
commit
bf286cf175
4 changed files with 70 additions and 35 deletions
|
@ -1159,31 +1159,6 @@ void ReactionPreview::paintEffect(QPainter &p) {
|
||||||
return CreateGradientButton(parent, Ui::Premium::ButtonGradientStops());
|
return CreateGradientButton(parent, Ui::Premium::ButtonGradientStops());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::GradientButton> CreateUnlockButton(
|
|
||||||
QWidget *parent,
|
|
||||||
rpl::producer<QString> text) {
|
|
||||||
auto result = CreatePremiumButton(parent);
|
|
||||||
const auto &st = st::premiumPreviewBox.button;
|
|
||||||
result->resize(result->width(), st.height);
|
|
||||||
|
|
||||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
|
||||||
result.data(),
|
|
||||||
std::move(text),
|
|
||||||
st::premiumPreviewButtonLabel);
|
|
||||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
rpl::combine(
|
|
||||||
result->widthValue(),
|
|
||||||
label->widthValue()
|
|
||||||
) | rpl::start_with_next([=](int outer, int width) {
|
|
||||||
label->moveToLeft(
|
|
||||||
(outer - width) / 2,
|
|
||||||
st::premiumPreviewBox.button.textTop,
|
|
||||||
outer);
|
|
||||||
}, label->lifetime());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::RpWidget> CreateSwitch(
|
[[nodiscard]] object_ptr<Ui::RpWidget> CreateSwitch(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<rpl::variable<PremiumPreview>*> selected) {
|
not_null<rpl::variable<PremiumPreview>*> selected) {
|
||||||
|
@ -1793,3 +1768,28 @@ void DoubledLimitsPreviewBox(
|
||||||
});
|
});
|
||||||
Ui::Premium::ShowListBox(box, std::move(entries));
|
Ui::Premium::ShowListBox(box, std::move(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_ptr<Ui::GradientButton> CreateUnlockButton(
|
||||||
|
QWidget *parent,
|
||||||
|
rpl::producer<QString> text) {
|
||||||
|
auto result = CreatePremiumButton(parent);
|
||||||
|
const auto &st = st::premiumPreviewBox.button;
|
||||||
|
result->resize(result->width(), st.height);
|
||||||
|
|
||||||
|
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
result.data(),
|
||||||
|
std::move(text),
|
||||||
|
st::premiumPreviewButtonLabel);
|
||||||
|
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
rpl::combine(
|
||||||
|
result->widthValue(),
|
||||||
|
label->widthValue()
|
||||||
|
) | rpl::start_with_next([=](int outer, int width) {
|
||||||
|
label->moveToLeft(
|
||||||
|
(outer - width) / 2,
|
||||||
|
st::premiumPreviewBox.button.textTop,
|
||||||
|
outer);
|
||||||
|
}, label->lifetime());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -7,10 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/object_ptr.h"
|
||||||
|
|
||||||
class DocumentData;
|
class DocumentData;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GenericBox;
|
class GenericBox;
|
||||||
|
class GradientButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -60,3 +63,7 @@ void ShowPremiumPreviewToBuy(
|
||||||
Fn<void()> hiddenCallback);
|
Fn<void()> hiddenCallback);
|
||||||
|
|
||||||
void PremiumUnavailableBox(not_null<Ui::GenericBox*> box);
|
void PremiumUnavailableBox(not_null<Ui::GenericBox*> box);
|
||||||
|
|
||||||
|
[[nodiscard]] object_ptr<Ui::GradientButton> CreateUnlockButton(
|
||||||
|
QWidget *parent,
|
||||||
|
rpl::producer<QString> text);
|
||||||
|
|
|
@ -15,12 +15,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "menu/menu_send.h"
|
#include "menu/menu_send.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
#include "boxes/premium_preview_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
#include "ui/widgets/gradient_round_button.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/image/image_location_factory.h"
|
#include "ui/image/image_location_factory.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -35,6 +37,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/clip/media_clip_reader.h"
|
#include "media/clip/media_clip_reader.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
|
#include "settings/settings_premium.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
@ -46,6 +49,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
#include "styles/style_premium.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
@ -113,9 +117,10 @@ public:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
const StickerSetIdentifier &set);
|
const StickerSetIdentifier &set);
|
||||||
|
|
||||||
bool loaded() const;
|
[[nodiscard]] bool loaded() const;
|
||||||
bool notInstalled() const;
|
[[nodiscard]] bool notInstalled() const;
|
||||||
bool official() const;
|
[[nodiscard]] bool premiumEmojiSet() const;
|
||||||
|
[[nodiscard]] bool official() const;
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> title() const;
|
[[nodiscard]] rpl::producer<TextWithEntities> title() const;
|
||||||
[[nodiscard]] QString shortName() const;
|
[[nodiscard]] QString shortName() const;
|
||||||
[[nodiscard]] bool isEmojiSet() const;
|
[[nodiscard]] bool isEmojiSet() const;
|
||||||
|
@ -379,13 +384,29 @@ void StickerSetBox::updateButtons() {
|
||||||
: tr::lng_stickers_copied(tr::now)));
|
: tr::lng_stickers_copied(tr::now)));
|
||||||
};
|
};
|
||||||
if (_inner->notInstalled()) {
|
if (_inner->notInstalled()) {
|
||||||
auto addText = (type == Data::StickersType::Emoji)
|
if (!_controller->session().premium()
|
||||||
? tr::lng_stickers_add_emoji()
|
&& _controller->session().premiumPossible()
|
||||||
: (type == Data::StickersType::Masks)
|
&& _inner->premiumEmojiSet()) {
|
||||||
? tr::lng_stickers_add_masks()
|
setStyle(st::premiumPreviewBox);
|
||||||
: tr::lng_stickers_add_pack();
|
auto button = CreateUnlockButton(
|
||||||
addButton(std::move(addText), [=] { addStickers(); });
|
this,
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
tr::lng_premium_unlock_emoji());
|
||||||
|
button->resizeToWidth(st::boxWideWidth
|
||||||
|
- st::premiumPreviewBox.buttonPadding.left()
|
||||||
|
- st::premiumPreviewBox.buttonPadding.left());
|
||||||
|
button->setClickedCallback([=] {
|
||||||
|
Settings::ShowPremium(_controller, u"animated_emoji"_q);
|
||||||
|
});
|
||||||
|
addButton(std::move(button));
|
||||||
|
} else {
|
||||||
|
auto addText = (type == Data::StickersType::Emoji)
|
||||||
|
? tr::lng_stickers_add_emoji()
|
||||||
|
: (type == Data::StickersType::Masks)
|
||||||
|
? tr::lng_stickers_add_masks()
|
||||||
|
: tr::lng_stickers_add_pack();
|
||||||
|
addButton(std::move(addText), [=] { addStickers(); });
|
||||||
|
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||||
|
}
|
||||||
|
|
||||||
if (!_inner->shortName().isEmpty()) {
|
if (!_inner->shortName().isEmpty()) {
|
||||||
const auto top = addTopButton(st::infoTopBarMenu);
|
const auto top = addTopButton(st::infoTopBarMenu);
|
||||||
|
@ -1119,6 +1140,12 @@ bool StickerSetBox::Inner::loaded() const {
|
||||||
return _loaded && !_pack.isEmpty();
|
return _loaded && !_pack.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StickerSetBox::Inner::premiumEmojiSet() const {
|
||||||
|
return (_setFlags & SetFlag::Emoji)
|
||||||
|
&& !_pack.empty()
|
||||||
|
&& _pack.front()->isPremiumEmoji();
|
||||||
|
}
|
||||||
|
|
||||||
bool StickerSetBox::Inner::notInstalled() const {
|
bool StickerSetBox::Inner::notInstalled() const {
|
||||||
if (!_loaded) {
|
if (!_loaded) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -73,6 +73,7 @@ using Order = std::vector<QString>;
|
||||||
u"no_ads"_q,
|
u"no_ads"_q,
|
||||||
u"unique_reactions"_q,
|
u"unique_reactions"_q,
|
||||||
u"premium_stickers"_q,
|
u"premium_stickers"_q,
|
||||||
|
u"animated_emoji"_q,
|
||||||
u"advanced_chat_management"_q,
|
u"advanced_chat_management"_q,
|
||||||
u"profile_badge"_q,
|
u"profile_badge"_q,
|
||||||
u"animated_userpics"_q,
|
u"animated_userpics"_q,
|
||||||
|
|
Loading…
Add table
Reference in a new issue