mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-31 15:59:54 +00:00
Added ability to set content to bar of pinned messages later.
This commit is contained in:
parent
7600c9bb2f
commit
16f616c5e0
@ -6388,9 +6388,8 @@ void HistoryWidget::checkPinnedBarState() {
|
||||
auto barContent = HistoryView::PinnedBarContent(
|
||||
&session(),
|
||||
_pinnedTracker->shownMessageId());
|
||||
_pinnedBar = std::make_unique<Ui::PinnedBar>(
|
||||
this,
|
||||
std::move(barContent));
|
||||
_pinnedBar = std::make_unique<Ui::PinnedBar>(this);
|
||||
_pinnedBar->setContent(std::move(barContent));
|
||||
Info::Profile::SharedMediaCountValue(
|
||||
_peer,
|
||||
nullptr,
|
||||
|
@ -388,7 +388,8 @@ void RepliesWidget::setupRootView() {
|
||||
) | rpl::map([=](Ui::MessageBarContent &&content, bool shown) {
|
||||
return shown ? std::move(content) : Ui::MessageBarContent();
|
||||
});
|
||||
_rootView = std::make_unique<Ui::PinnedBar>(this, std::move(content));
|
||||
_rootView = std::make_unique<Ui::PinnedBar>(this);
|
||||
_rootView->setContent(std::move(content));
|
||||
|
||||
controller()->adaptive().oneColumnValue(
|
||||
) | rpl::start_with_next([=](bool one) {
|
||||
|
@ -18,9 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Ui {
|
||||
|
||||
PinnedBar::PinnedBar(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<MessageBarContent> content)
|
||||
PinnedBar::PinnedBar(not_null<QWidget*> parent)
|
||||
: _wrap(parent, object_ptr<RpWidget>(parent))
|
||||
, _shadow(std::make_unique<PlainShadow>(_wrap.parentWidget())) {
|
||||
_wrap.hide(anim::type::instant);
|
||||
@ -31,10 +29,18 @@ PinnedBar::PinnedBar(
|
||||
QPainter(_wrap.entity()).fillRect(clip, st::historyPinnedBg);
|
||||
}, lifetime());
|
||||
_wrap.setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
}
|
||||
|
||||
PinnedBar::~PinnedBar() {
|
||||
_right.button.destroy();
|
||||
}
|
||||
|
||||
void PinnedBar::setContent(rpl::producer<Ui::MessageBarContent> content) {
|
||||
_contentLifetime.destroy();
|
||||
|
||||
auto copy = std::move(
|
||||
content
|
||||
) | rpl::start_spawning(_wrap.lifetime());
|
||||
) | rpl::start_spawning(_contentLifetime);
|
||||
|
||||
rpl::duplicate(
|
||||
copy
|
||||
@ -49,7 +55,7 @@ PinnedBar::PinnedBar(
|
||||
if (creating) {
|
||||
_bar->finishAnimating();
|
||||
}
|
||||
}, lifetime());
|
||||
}, _contentLifetime);
|
||||
|
||||
std::move(
|
||||
copy
|
||||
@ -65,11 +71,7 @@ PinnedBar::PinnedBar(
|
||||
}, [=] {
|
||||
_forceHidden = true;
|
||||
_wrap.toggle(false, anim::type::normal);
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
PinnedBar::~PinnedBar() {
|
||||
_right.button.destroy();
|
||||
}, _contentLifetime);
|
||||
}
|
||||
|
||||
void PinnedBar::setRightButton(object_ptr<Ui::RpWidget> button) {
|
||||
|
@ -22,9 +22,7 @@ class RpWidget;
|
||||
|
||||
class PinnedBar final {
|
||||
public:
|
||||
PinnedBar(
|
||||
not_null<QWidget*> parent,
|
||||
rpl::producer<Ui::MessageBarContent> content);
|
||||
PinnedBar(not_null<QWidget*> parent);
|
||||
~PinnedBar();
|
||||
|
||||
void show();
|
||||
@ -34,6 +32,7 @@ public:
|
||||
|
||||
void setShadowGeometryPostprocess(Fn<QRect(QRect)> postprocess);
|
||||
|
||||
void setContent(rpl::producer<Ui::MessageBarContent> content);
|
||||
void setRightButton(object_ptr<Ui::RpWidget> button);
|
||||
|
||||
void move(int x, int y);
|
||||
@ -66,6 +65,8 @@ private:
|
||||
bool _shouldBeShown = false;
|
||||
bool _forceHidden = false;
|
||||
|
||||
rpl::lifetime _contentLifetime;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
|
Loading…
Reference in New Issue
Block a user