init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
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 "info/peer_gifts/info_peer_gifts_collections.h"
|
||||
|
||||
#include "api/api_credits.h"
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_star_gift.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info::PeerGifts {
|
||||
namespace {
|
||||
|
||||
constexpr auto kCollectionNameLimit = 12;
|
||||
|
||||
void EditCollectionBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
int id,
|
||||
Data::SavedStarGiftId addId,
|
||||
QString currentName,
|
||||
Fn<void(MTPStarGiftCollection)> finished) {
|
||||
box->setTitle(id
|
||||
? tr::lng_gift_collection_edit()
|
||||
: tr::lng_gift_collection_new_title());
|
||||
|
||||
if (!id) {
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_gift_collection_new_text(),
|
||||
st::collectionAbout));
|
||||
}
|
||||
const auto title = box->addRow(
|
||||
object_ptr<Ui::InputField>(
|
||||
box,
|
||||
st::collectionNameField,
|
||||
tr::lng_gift_collection_new_ph(),
|
||||
currentName));
|
||||
title->setMaxLength(kCollectionNameLimit * 2);
|
||||
box->setFocusCallback([=] {
|
||||
title->setFocusFast();
|
||||
});
|
||||
|
||||
Ui::AddLengthLimitLabel(title, kCollectionNameLimit);
|
||||
|
||||
const auto show = navigation->uiShow();
|
||||
const auto session = &peer->session();
|
||||
|
||||
const auto creating = std::make_shared<bool>(false);
|
||||
const auto submit = [=] {
|
||||
if (*creating) {
|
||||
return;
|
||||
}
|
||||
const auto text = title->getLastText().trimmed();
|
||||
if (text.isEmpty() || text.size() > kCollectionNameLimit) {
|
||||
title->showError();
|
||||
return;
|
||||
}
|
||||
|
||||
*creating = true;
|
||||
auto ids = QVector<MTPInputSavedStarGift>();
|
||||
if (addId) {
|
||||
ids.push_back(Api::InputSavedStarGiftId(addId));
|
||||
}
|
||||
const auto weak = base::make_weak(box);
|
||||
const auto done = [=](const MTPStarGiftCollection &result) {
|
||||
*creating = false;
|
||||
if (const auto onstack = finished) {
|
||||
onstack(result);
|
||||
}
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
};
|
||||
const auto fail = [=](const MTP::Error &error) {
|
||||
*creating = false;
|
||||
const auto &type = error.type();
|
||||
if (type == u"COLLECTIONS_TOO_MANY"_q) {
|
||||
show->show(Ui::MakeInformBox({
|
||||
.text = tr::lng_gift_collection_limit_text(),
|
||||
.confirmText = tr::lng_box_ok(),
|
||||
.title = tr::lng_gift_collection_limit_title(),
|
||||
}));
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->closeBox();
|
||||
}
|
||||
} else {
|
||||
show->showToast(error.type());
|
||||
}
|
||||
};
|
||||
if (id) {
|
||||
using Flag = MTPpayments_UpdateStarGiftCollection::Flag;
|
||||
session->api().request(MTPpayments_UpdateStarGiftCollection(
|
||||
MTP_flags(Flag::f_title),
|
||||
peer->input(),
|
||||
MTP_int(id),
|
||||
MTP_string(text),
|
||||
MTPVector<MTPInputSavedStarGift>(),
|
||||
MTPVector<MTPInputSavedStarGift>(),
|
||||
MTPVector<MTPInputSavedStarGift>()
|
||||
)).done(done).fail(fail).send();
|
||||
} else {
|
||||
session->api().request(MTPpayments_CreateStarGiftCollection(
|
||||
peer->input(),
|
||||
MTP_string(text),
|
||||
MTP_vector<MTPInputSavedStarGift>(ids)
|
||||
)).done(done).fail(fail).send();
|
||||
}
|
||||
};
|
||||
title->submits() | rpl::on_next(submit, title->lifetime());
|
||||
auto text = id
|
||||
? tr::lng_settings_save()
|
||||
: tr::lng_gift_collection_new_create();
|
||||
box->addButton(std::move(text), submit);
|
||||
|
||||
box->addButton(tr::lng_cancel(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NewCollectionBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
Data::SavedStarGiftId addId,
|
||||
Fn<void(MTPStarGiftCollection)> added) {
|
||||
EditCollectionBox(box, navigation, peer, 0, addId, QString(), added);
|
||||
}
|
||||
|
||||
void EditCollectionNameBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
int id,
|
||||
QString current,
|
||||
Fn<void(QString)> done) {
|
||||
EditCollectionBox(box, navigation, peer, id, {}, current, [=](
|
||||
const MTPStarGiftCollection &result) {
|
||||
done(qs(result.data().vtitle()));
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Info::PeerGifts
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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
|
||||
|
||||
namespace Data {
|
||||
class SavedStarGiftId;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
} // namespace Window
|
||||
|
||||
namespace Info::PeerGifts {
|
||||
|
||||
void NewCollectionBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
Data::SavedStarGiftId addId,
|
||||
Fn<void(MTPStarGiftCollection)> added);
|
||||
|
||||
void EditCollectionNameBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer,
|
||||
int id,
|
||||
QString current,
|
||||
Fn<void(QString)> done);
|
||||
|
||||
} // namespace Info::PeerGifts
|
||||
1402
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp
Normal file
1402
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp
Normal file
File diff suppressed because it is too large
Load Diff
308
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h
Normal file
308
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.h
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
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 "base/qt/qt_compare.h"
|
||||
#include "base/timer.h"
|
||||
#include "data/data_star_gift.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "ui/effects/premium_stars_colored.h"
|
||||
#include "ui/text/custom_emoji_helper.h"
|
||||
#include "ui/text/text.h"
|
||||
|
||||
class StickerPremiumMark;
|
||||
|
||||
namespace ChatHelpers {
|
||||
class Show;
|
||||
} // namespace ChatHelpers
|
||||
|
||||
namespace Data {
|
||||
struct UniqueGift;
|
||||
struct CreditsHistoryEntry;
|
||||
class SavedStarGiftId;
|
||||
} // namespace Data
|
||||
|
||||
namespace HistoryView {
|
||||
class StickerPlayer;
|
||||
} // namespace HistoryView
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Overview::Layout {
|
||||
class Checkbox;
|
||||
} // namespace Overview::Layout
|
||||
|
||||
namespace Ui {
|
||||
class DynamicImage;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui::Text {
|
||||
class CustomEmoji;
|
||||
} // namespace Ui::Text
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Info::PeerGifts {
|
||||
|
||||
struct Tag {
|
||||
explicit Tag(not_null<PeerData*> peer, int collectionId = 0)
|
||||
: peer(peer)
|
||||
, collectionId(collectionId) {
|
||||
}
|
||||
|
||||
not_null<PeerData*> peer;
|
||||
int collectionId = 0;
|
||||
};
|
||||
|
||||
struct GiftTypePremium {
|
||||
int64 cost = 0;
|
||||
QString currency;
|
||||
int stars = 0;
|
||||
int months = 0;
|
||||
int discountPercent = 0;
|
||||
|
||||
[[nodiscard]] friend inline bool operator==(
|
||||
const GiftTypePremium &,
|
||||
const GiftTypePremium &) = default;
|
||||
};
|
||||
|
||||
struct GiftTypeStars {
|
||||
Data::SavedStarGiftId transferId;
|
||||
Data::StarGift info;
|
||||
PeerData *from = nullptr;
|
||||
TimeId date = 0;
|
||||
bool pinnedSelection : 1 = false;
|
||||
bool forceTon : 1 = false;
|
||||
bool userpic : 1 = false;
|
||||
bool pinned : 1 = false;
|
||||
bool hidden : 1 = false;
|
||||
bool resale : 1 = false;
|
||||
bool mine : 1 = false;
|
||||
|
||||
[[nodiscard]] friend inline bool operator==(
|
||||
const GiftTypeStars&,
|
||||
const GiftTypeStars&) = default;
|
||||
};
|
||||
|
||||
[[nodiscard]] rpl::producer<std::vector<GiftTypeStars>> GiftsStars(
|
||||
not_null<Main::Session*> session,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
struct GiftDescriptor : std::variant<GiftTypePremium, GiftTypeStars> {
|
||||
using variant::variant;
|
||||
|
||||
[[nodiscard]] friend inline bool operator==(
|
||||
const GiftDescriptor&,
|
||||
const GiftDescriptor&) = default;
|
||||
};
|
||||
|
||||
struct GiftSendDetails {
|
||||
GiftDescriptor descriptor;
|
||||
TextWithEntities text;
|
||||
uint64 randomId = 0;
|
||||
bool anonymous = false;
|
||||
bool upgraded = false;
|
||||
bool byStars = false;
|
||||
};
|
||||
|
||||
struct GiftBadge {
|
||||
QString text;
|
||||
QColor bg1;
|
||||
QColor bg2 = QColor(0, 0, 0, 0);
|
||||
QColor border = QColor(0, 0, 0, 0);
|
||||
QColor fg;
|
||||
bool gradient = false;
|
||||
bool small = false;
|
||||
|
||||
explicit operator bool() const {
|
||||
return !text.isEmpty();
|
||||
}
|
||||
|
||||
friend std::strong_ordering operator<=>(
|
||||
const GiftBadge &a,
|
||||
const GiftBadge &b);
|
||||
|
||||
friend inline bool operator==(
|
||||
const GiftBadge &,
|
||||
const GiftBadge &) = default;
|
||||
};
|
||||
|
||||
enum class GiftButtonMode : uint8 {
|
||||
Full,
|
||||
Minimal,
|
||||
Selection,
|
||||
};
|
||||
|
||||
enum class GiftSelectionMode : uint8 {
|
||||
Border,
|
||||
Inset,
|
||||
Check,
|
||||
};
|
||||
|
||||
class GiftButtonDelegate {
|
||||
public:
|
||||
[[nodiscard]] virtual TextWithEntities star() = 0;
|
||||
[[nodiscard]] virtual TextWithEntities monostar() = 0;
|
||||
[[nodiscard]] virtual TextWithEntities monoton() = 0;
|
||||
[[nodiscard]] virtual TextWithEntities ministar() = 0;
|
||||
[[nodiscard]] virtual Ui::Text::MarkedContext textContext() = 0;
|
||||
[[nodiscard]] virtual QSize buttonSize() = 0;
|
||||
[[nodiscard]] virtual QMargins buttonExtend() const = 0;
|
||||
[[nodiscard]] virtual auto buttonPatternEmoji(
|
||||
not_null<Data::UniqueGift*> unique,
|
||||
Fn<void()> repaint)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> = 0;
|
||||
[[nodiscard]] virtual QImage background() = 0;
|
||||
[[nodiscard]] virtual rpl::producer<not_null<DocumentData*>> sticker(
|
||||
const GiftDescriptor &descriptor) = 0;
|
||||
[[nodiscard]] virtual not_null<StickerPremiumMark*> hiddenMark() = 0;
|
||||
[[nodiscard]] virtual QImage cachedBadge(const GiftBadge &badge) = 0;
|
||||
[[nodiscard]] virtual bool amPremium() = 0;
|
||||
virtual void invalidateCache() = 0;
|
||||
};
|
||||
|
||||
class GiftButton final : public Ui::AbstractButton {
|
||||
public:
|
||||
GiftButton(QWidget *parent, not_null<GiftButtonDelegate*> delegate);
|
||||
~GiftButton();
|
||||
|
||||
using Mode = GiftButtonMode;
|
||||
void setDescriptor(const GiftDescriptor &descriptor, Mode mode);
|
||||
void setGeometry(QRect inner, QMargins extend);
|
||||
|
||||
void toggleSelected(
|
||||
bool selected,
|
||||
GiftSelectionMode selectionMode = GiftSelectionMode::Border,
|
||||
anim::type animated = anim::type::normal);
|
||||
|
||||
[[nodiscard]] rpl::producer<QPoint> contextMenuRequests() const;
|
||||
[[nodiscard]] rpl::producer<QMouseEvent*> mouseEvents();
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
void mousePressEvent(QMouseEvent *e) override;
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
|
||||
void paintBackground(QPainter &p, const QImage &background);
|
||||
void cacheUniqueBackground(
|
||||
not_null<Data::UniqueGift*> unique,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
void refreshLocked();
|
||||
void setDocument(not_null<DocumentData*> document);
|
||||
[[nodiscard]] QMargins currentExtend() const;
|
||||
[[nodiscard]] bool small() const;
|
||||
|
||||
void onStateChanged(State was, StateChangeSource source) override;
|
||||
void unsubscribe();
|
||||
|
||||
const not_null<GiftButtonDelegate*> _delegate;
|
||||
rpl::event_stream<QPoint> _contextMenuRequests;
|
||||
rpl::event_stream<QMouseEvent*> _mouseEvents;
|
||||
QImage _hiddenBgCache;
|
||||
GiftDescriptor _descriptor;
|
||||
Ui::Text::String _text;
|
||||
Ui::Text::String _price;
|
||||
Ui::Text::String _byStars;
|
||||
std::shared_ptr<Ui::DynamicImage> _userpic;
|
||||
QImage _uniqueBackgroundCache;
|
||||
QImage _tonIcon;
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> _uniquePatternEmoji;
|
||||
base::flat_map<float64, QImage> _uniquePatternCache;
|
||||
std::optional<Ui::Premium::ColoredMiniStars> _stars;
|
||||
Ui::Animations::Simple _selectedAnimation;
|
||||
std::unique_ptr<Overview::Layout::Checkbox> _check;
|
||||
int _resalePrice = 0;
|
||||
GiftButtonMode _mode = GiftButtonMode::Full;
|
||||
GiftSelectionMode _selectionMode = GiftSelectionMode::Border;
|
||||
bool _subscribed : 1 = false;
|
||||
bool _patterned : 1 = false;
|
||||
bool _selected : 1 = false;
|
||||
bool _locked : 1 = false;
|
||||
|
||||
bool _mouseEventsAreListening = false;
|
||||
|
||||
base::Timer _lockedTimer;
|
||||
TimeId _lockedUntilDate = 0;
|
||||
|
||||
QRect _button;
|
||||
QMargins _extend;
|
||||
|
||||
DocumentData *_resolvedDocument = nullptr;
|
||||
|
||||
std::unique_ptr<HistoryView::StickerPlayer> _player;
|
||||
DocumentData *_playerDocument = nullptr;
|
||||
rpl::lifetime _mediaLifetime;
|
||||
rpl::lifetime _documentLifetime;
|
||||
|
||||
};
|
||||
|
||||
class Delegate final : public GiftButtonDelegate {
|
||||
public:
|
||||
Delegate(not_null<Main::Session*> session, GiftButtonMode mode);
|
||||
Delegate(Delegate &&other);
|
||||
~Delegate();
|
||||
|
||||
TextWithEntities star() override;
|
||||
TextWithEntities monostar() override;
|
||||
TextWithEntities monoton() override;
|
||||
TextWithEntities ministar() override;
|
||||
Ui::Text::MarkedContext textContext() override;
|
||||
QSize buttonSize() override;
|
||||
QMargins buttonExtend() const override;
|
||||
auto buttonPatternEmoji(
|
||||
not_null<Data::UniqueGift*> unique,
|
||||
Fn<void()> repaint)
|
||||
-> std::unique_ptr<Ui::Text::CustomEmoji> override;
|
||||
QImage background() override;
|
||||
rpl::producer<not_null<DocumentData*>> sticker(
|
||||
const GiftDescriptor &descriptor) override;
|
||||
not_null<StickerPremiumMark*> hiddenMark() override;
|
||||
QImage cachedBadge(const GiftBadge &badge) override;
|
||||
bool amPremium() override;
|
||||
void invalidateCache() override;
|
||||
|
||||
private:
|
||||
const not_null<Main::Session*> _session;
|
||||
std::unique_ptr<StickerPremiumMark> _hiddenMark;
|
||||
base::flat_map<GiftBadge, QImage> _badges;
|
||||
QSize _single;
|
||||
QImage _bg;
|
||||
GiftButtonMode _mode = GiftButtonMode::Full;
|
||||
Ui::Text::CustomEmojiHelper _emojiHelper;
|
||||
TextWithEntities _ministarEmoji;
|
||||
TextWithEntities _starEmoji;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] DocumentData *LookupGiftSticker(
|
||||
not_null<Main::Session*> session,
|
||||
const GiftDescriptor &descriptor);
|
||||
|
||||
[[nodiscard]] rpl::producer<not_null<DocumentData*>> GiftStickerValue(
|
||||
not_null<Main::Session*> session,
|
||||
const GiftDescriptor &descriptor);
|
||||
|
||||
[[nodiscard]] QImage ValidateRotatedBadge(
|
||||
const GiftBadge &badge,
|
||||
QMargins padding);
|
||||
|
||||
void SelectGiftToUnpin(
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const std::vector<Data::CreditsHistoryEntry> &pinned,
|
||||
Fn<void(Data::SavedStarGiftId)> chosen);
|
||||
|
||||
} // namespace Info::PeerGifts
|
||||
2669
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp
Normal file
2669
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp
Normal file
File diff suppressed because it is too large
Load Diff
127
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h
Normal file
127
Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
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 "data/data_star_gift.h"
|
||||
#include "info/info_content_widget.h"
|
||||
|
||||
class UserData;
|
||||
struct PeerListState;
|
||||
|
||||
namespace Ui {
|
||||
class RpWidget;
|
||||
template <typename Widget>
|
||||
class SlideWrap;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Info::PeerGifts {
|
||||
|
||||
struct ListState {
|
||||
std::vector<Data::SavedStarGift> list;
|
||||
QString offset;
|
||||
};
|
||||
|
||||
struct Filter {
|
||||
bool sortByValue : 1 = false;
|
||||
bool skipUnlimited : 1 = false;
|
||||
bool skipLimited : 1 = false;
|
||||
bool skipUpgradable : 1 = false;
|
||||
bool skipUnique : 1 = false;
|
||||
bool skipSaved : 1 = false;
|
||||
bool skipUnsaved : 1 = false;
|
||||
|
||||
[[nodiscard]] bool skipsSomething() const {
|
||||
return skipLimited
|
||||
|| skipUnlimited
|
||||
|| skipSaved
|
||||
|| skipUnsaved
|
||||
|| skipUpgradable
|
||||
|| skipUnique;
|
||||
}
|
||||
|
||||
friend inline bool operator==(Filter, Filter) = default;
|
||||
};
|
||||
|
||||
struct Descriptor {
|
||||
Filter filter;
|
||||
int collectionId = 0;
|
||||
|
||||
friend inline bool operator==(
|
||||
const Descriptor &,
|
||||
const Descriptor &) = default;
|
||||
};
|
||||
|
||||
class InnerWidget;
|
||||
|
||||
class Memento final : public ContentMemento {
|
||||
public:
|
||||
Memento(not_null<Controller*> controller);
|
||||
Memento(not_null<PeerData*> peer, int collectionId);
|
||||
~Memento();
|
||||
|
||||
object_ptr<ContentWidget> createWidget(
|
||||
QWidget *parent,
|
||||
not_null<Controller*> controller,
|
||||
const QRect &geometry) override;
|
||||
|
||||
Section section() const override;
|
||||
|
||||
void setListState(std::unique_ptr<ListState> state);
|
||||
std::unique_ptr<ListState> listState();
|
||||
|
||||
private:
|
||||
std::unique_ptr<ListState> _listState;
|
||||
|
||||
};
|
||||
|
||||
class Widget final : public ContentWidget {
|
||||
public:
|
||||
Widget(QWidget *parent, not_null<Controller*> controller);
|
||||
|
||||
[[nodiscard]] not_null<PeerData*> peer() const;
|
||||
|
||||
bool showInternal(
|
||||
not_null<ContentMemento*> memento) override;
|
||||
|
||||
void setInternalState(
|
||||
const QRect &geometry,
|
||||
not_null<Memento*> memento);
|
||||
|
||||
void fillTopBarMenu(const Ui::Menu::MenuCallback &addAction) override;
|
||||
|
||||
rpl::producer<QString> title() override;
|
||||
|
||||
rpl::producer<bool> desiredBottomShadowVisibility() override;
|
||||
|
||||
void showFinished() override;
|
||||
|
||||
private:
|
||||
void saveState(not_null<Memento*> memento);
|
||||
void restoreState(not_null<Memento*> memento);
|
||||
|
||||
std::shared_ptr<ContentMemento> doCreateMemento() override;
|
||||
|
||||
void setupNotifyCheckbox(int wasBottomHeight, bool enabled);
|
||||
void setupBottomButton(int wasBottomHeight);
|
||||
void refreshBottom();
|
||||
|
||||
InnerWidget *_inner = nullptr;
|
||||
QPointer<Ui::SlideWrap<Ui::RpWidget>> _pinnedToBottom;
|
||||
rpl::variable<bool> _hasPinnedToBottom;
|
||||
rpl::variable<bool> _emptyCollectionShown;
|
||||
rpl::variable<Descriptor> _descriptor;
|
||||
std::optional<bool> _notifyEnabled;
|
||||
bool _shown = false;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] std::shared_ptr<Info::Memento> Make(
|
||||
not_null<PeerData*> peer,
|
||||
int collectionId = 0);
|
||||
|
||||
} // namespace Info::PeerGifts
|
||||
Reference in New Issue
Block a user