Handle pinned bar clicks.
This commit is contained in:
parent
91a0416037
commit
9b4b15ee6d
|
@ -135,6 +135,7 @@ void MessagesList::addSlice(
|
|||
}
|
||||
|
||||
void MessagesList::removeOne(MessagePosition messageId) {
|
||||
auto update = MessagesSliceUpdate();
|
||||
auto slice = ranges::lower_bound(
|
||||
_slices,
|
||||
messageId,
|
||||
|
@ -144,10 +145,16 @@ void MessagesList::removeOne(MessagePosition messageId) {
|
|||
_slices.modify(slice, [&](Slice &slice) {
|
||||
return slice.messages.remove(messageId);
|
||||
});
|
||||
update.messages = &slice->messages;
|
||||
update.range = slice->range;
|
||||
}
|
||||
if (_count) {
|
||||
--*_count;
|
||||
}
|
||||
update.count = _count;
|
||||
if (update.messages) {
|
||||
_sliceUpdated.fire(std::move(update));
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesList::removeAll(ChannelId channelId) {
|
||||
|
@ -188,6 +195,8 @@ void MessagesList::removeLessThan(MessagePosition messageId) {
|
|||
}
|
||||
});
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (removed && _count) {
|
||||
|
|
|
@ -4973,9 +4973,6 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
|
|||
} else {
|
||||
Ui::showPeerHistory(_peer, _editMsgId ? _editMsgId : replyToId());
|
||||
}
|
||||
//} else if (_inPinnedMsg) { // #TODO pinned
|
||||
// Assert(_pinnedBar != nullptr);
|
||||
// Ui::showPeerHistory(_peer, _pinnedBar->msgId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5266,6 +5263,14 @@ void HistoryWidget::checkPinnedBarState() {
|
|||
hidePinnedMessage();
|
||||
}, _pinnedBar->lifetime());
|
||||
|
||||
_pinnedBar->barClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto id = _pinnedTracker->currentMessageId();
|
||||
if (id.message) {
|
||||
Ui::showPeerHistory(_peer, id.message);
|
||||
}
|
||||
}, _pinnedBar->lifetime());
|
||||
|
||||
_pinnedBarHeight = 0;
|
||||
_pinnedBar->heightValue(
|
||||
) | rpl::start_with_next([=](int height) {
|
||||
|
@ -6369,10 +6374,6 @@ void HistoryWidget::drawRecording(Painter &p, float64 recordActive) {
|
|||
// // }
|
||||
// // left += st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x();
|
||||
// // }
|
||||
// //} else {
|
||||
// // p.setFont(st::msgDateFont);
|
||||
// // p.setPen(st::historyComposeAreaFgService);
|
||||
// // p.drawText(left, top + (st::msgReplyBarSize.height() - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(tr::lng_profile_loading(tr::now), width() - left - _pinnedBar->cancel->width() - st::msgReplyPadding.right()));
|
||||
// //}
|
||||
//}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace {
|
|||
return Ui::MessageBarContent{
|
||||
.id = item->id,
|
||||
.title = ((type == PinnedIdType::First)
|
||||
? "First message"
|
||||
? tr::lng_pinned_previous(tr::now) // #TODO pinned first?
|
||||
: (type == PinnedIdType::Middle)
|
||||
? tr::lng_pinned_previous(tr::now)
|
||||
: !poll
|
||||
|
@ -148,6 +148,24 @@ void PinnedBar::createControls() {
|
|||
_close->raise();
|
||||
}
|
||||
|
||||
// Clicks.
|
||||
_bar->widget()->setCursor(style::cur_pointer);
|
||||
_bar->widget()->events(
|
||||
) | rpl::filter([=](not_null<QEvent*> event) {
|
||||
return (event->type() == QEvent::MouseButtonPress);
|
||||
}) | rpl::map([=] {
|
||||
return _bar->widget()->events(
|
||||
) | rpl::filter([=](not_null<QEvent*> event) {
|
||||
return (event->type() == QEvent::MouseButtonRelease);
|
||||
}) | rpl::take(1) | rpl::filter([=](not_null<QEvent*> event) {
|
||||
return _bar->widget()->rect().contains(
|
||||
static_cast<QMouseEvent*>(event.get())->pos());
|
||||
});
|
||||
}) | rpl::flatten_latest(
|
||||
) | rpl::map([] {
|
||||
return rpl::empty_value();
|
||||
}) | rpl::start_to_stream(_barClicks, _bar->widget()->lifetime());
|
||||
|
||||
_bar->widget()->move(0, 0);
|
||||
_bar->widget()->show();
|
||||
_wrap.entity()->resize(_wrap.entity()->width(), _bar->widget()->height());
|
||||
|
@ -233,4 +251,8 @@ rpl::producer<> PinnedBar::closeClicks() const {
|
|||
: (_close->clicks() | rpl::map([] { return rpl::empty_value(); }));
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
rpl::producer<> PinnedBar::barClicks() const {
|
||||
return _barClicks.events();
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
[[nodiscard]] int height() const;
|
||||
[[nodiscard]] rpl::producer<int> heightValue() const;
|
||||
[[nodiscard]] rpl::producer<> closeClicks() const;
|
||||
[[nodiscard]] rpl::producer<> barClicks() const;
|
||||
|
||||
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||
return _wrap.lifetime();
|
||||
|
@ -64,6 +65,7 @@ private:
|
|||
std::unique_ptr<Ui::IconButton> _close;
|
||||
std::unique_ptr<Ui::PlainShadow> _shadow;
|
||||
rpl::event_stream<Ui::MessageBarContent> _content;
|
||||
rpl::event_stream<> _barClicks;
|
||||
bool _shouldBeShown = false;
|
||||
bool _forceHidden = false;
|
||||
|
||||
|
|
|
@ -49,12 +49,13 @@ MessageBar::BodyAnimation MessageBar::DetectBodyAnimationType(
|
|||
const auto now = currentAnimation
|
||||
? currentAnimation->bodyAnimation
|
||||
: BodyAnimation::None;
|
||||
const auto somethingChanged = (currentContent.text != nextContent.text)
|
||||
|| (currentContent.id != nextContent.id);
|
||||
return (now == BodyAnimation::Full
|
||||
|| currentContent.title != nextContent.title)
|
||||
|| currentContent.title != nextContent.title
|
||||
|| (currentContent.title.isEmpty() && somethingChanged))
|
||||
? BodyAnimation::Full
|
||||
: (now == BodyAnimation::Text
|
||||
|| currentContent.text != nextContent.text
|
||||
|| currentContent.id != nextContent.id)
|
||||
: (now == BodyAnimation::Text || somethingChanged)
|
||||
? BodyAnimation::Text
|
||||
: BodyAnimation::None;
|
||||
}
|
||||
|
@ -275,9 +276,20 @@ void MessageBar::paint(Painter &p) {
|
|||
}
|
||||
}
|
||||
if (!_animation || _animation->bodyAnimation == BodyAnimation::None) {
|
||||
p.setPen(_st.textFg);
|
||||
p.setTextPalette(_st.textPalette);
|
||||
_text.drawLeftElided(p, body.x(), text.y(), body.width(), width);
|
||||
if (_title.isEmpty()) {
|
||||
// "Loading..." state.
|
||||
p.setPen(st::historyComposeAreaFgService);
|
||||
_text.drawLeftElided(
|
||||
p,
|
||||
body.x(),
|
||||
body.y() + (body.height() - st::normalFont->height) / 2,
|
||||
body.width(),
|
||||
width);
|
||||
} else {
|
||||
p.setPen(_st.textFg);
|
||||
p.setTextPalette(_st.textPalette);
|
||||
_text.drawLeftElided(p, body.x(), text.y(), body.width(), width);
|
||||
}
|
||||
} else if (_animation->bodyAnimation == BodyAnimation::Text) {
|
||||
p.setOpacity(1. - progress);
|
||||
p.drawPixmap(
|
||||
|
|
Loading…
Reference in New Issue