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