mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Handle pinned bar clicks.
This commit is contained in:
parent
91a0416037
commit
9b4b15ee6d
5 changed files with 62 additions and 16 deletions
|
@ -135,6 +135,7 @@ void MessagesList::addSlice(
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesList::removeOne(MessagePosition messageId) {
|
void MessagesList::removeOne(MessagePosition messageId) {
|
||||||
|
auto update = MessagesSliceUpdate();
|
||||||
auto slice = ranges::lower_bound(
|
auto slice = ranges::lower_bound(
|
||||||
_slices,
|
_slices,
|
||||||
messageId,
|
messageId,
|
||||||
|
@ -144,10 +145,16 @@ void MessagesList::removeOne(MessagePosition messageId) {
|
||||||
_slices.modify(slice, [&](Slice &slice) {
|
_slices.modify(slice, [&](Slice &slice) {
|
||||||
return slice.messages.remove(messageId);
|
return slice.messages.remove(messageId);
|
||||||
});
|
});
|
||||||
|
update.messages = &slice->messages;
|
||||||
|
update.range = slice->range;
|
||||||
}
|
}
|
||||||
if (_count) {
|
if (_count) {
|
||||||
--*_count;
|
--*_count;
|
||||||
}
|
}
|
||||||
|
update.count = _count;
|
||||||
|
if (update.messages) {
|
||||||
|
_sliceUpdated.fire(std::move(update));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesList::removeAll(ChannelId channelId) {
|
void MessagesList::removeAll(ChannelId channelId) {
|
||||||
|
@ -188,6 +195,8 @@ void MessagesList::removeLessThan(MessagePosition messageId) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (removed && _count) {
|
if (removed && _count) {
|
||||||
|
|
|
@ -4973,9 +4973,6 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
} else {
|
} else {
|
||||||
Ui::showPeerHistory(_peer, _editMsgId ? _editMsgId : replyToId());
|
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();
|
hidePinnedMessage();
|
||||||
}, _pinnedBar->lifetime());
|
}, _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;
|
_pinnedBarHeight = 0;
|
||||||
_pinnedBar->heightValue(
|
_pinnedBar->heightValue(
|
||||||
) | rpl::start_with_next([=](int height) {
|
) | 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();
|
// // 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{
|
return Ui::MessageBarContent{
|
||||||
.id = item->id,
|
.id = item->id,
|
||||||
.title = ((type == PinnedIdType::First)
|
.title = ((type == PinnedIdType::First)
|
||||||
? "First message"
|
? tr::lng_pinned_previous(tr::now) // #TODO pinned first?
|
||||||
: (type == PinnedIdType::Middle)
|
: (type == PinnedIdType::Middle)
|
||||||
? tr::lng_pinned_previous(tr::now)
|
? tr::lng_pinned_previous(tr::now)
|
||||||
: !poll
|
: !poll
|
||||||
|
@ -148,6 +148,24 @@ void PinnedBar::createControls() {
|
||||||
_close->raise();
|
_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()->move(0, 0);
|
||||||
_bar->widget()->show();
|
_bar->widget()->show();
|
||||||
_wrap.entity()->resize(_wrap.entity()->width(), _bar->widget()->height());
|
_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(); }));
|
: (_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]] int height() const;
|
||||||
[[nodiscard]] rpl::producer<int> heightValue() const;
|
[[nodiscard]] rpl::producer<int> heightValue() const;
|
||||||
[[nodiscard]] rpl::producer<> closeClicks() const;
|
[[nodiscard]] rpl::producer<> closeClicks() const;
|
||||||
|
[[nodiscard]] rpl::producer<> barClicks() const;
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime() {
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||||
return _wrap.lifetime();
|
return _wrap.lifetime();
|
||||||
|
@ -64,6 +65,7 @@ private:
|
||||||
std::unique_ptr<Ui::IconButton> _close;
|
std::unique_ptr<Ui::IconButton> _close;
|
||||||
std::unique_ptr<Ui::PlainShadow> _shadow;
|
std::unique_ptr<Ui::PlainShadow> _shadow;
|
||||||
rpl::event_stream<Ui::MessageBarContent> _content;
|
rpl::event_stream<Ui::MessageBarContent> _content;
|
||||||
|
rpl::event_stream<> _barClicks;
|
||||||
bool _shouldBeShown = false;
|
bool _shouldBeShown = false;
|
||||||
bool _forceHidden = false;
|
bool _forceHidden = false;
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,13 @@ MessageBar::BodyAnimation MessageBar::DetectBodyAnimationType(
|
||||||
const auto now = currentAnimation
|
const auto now = currentAnimation
|
||||||
? currentAnimation->bodyAnimation
|
? currentAnimation->bodyAnimation
|
||||||
: BodyAnimation::None;
|
: BodyAnimation::None;
|
||||||
|
const auto somethingChanged = (currentContent.text != nextContent.text)
|
||||||
|
|| (currentContent.id != nextContent.id);
|
||||||
return (now == BodyAnimation::Full
|
return (now == BodyAnimation::Full
|
||||||
|| currentContent.title != nextContent.title)
|
|| currentContent.title != nextContent.title
|
||||||
|
|| (currentContent.title.isEmpty() && somethingChanged))
|
||||||
? BodyAnimation::Full
|
? BodyAnimation::Full
|
||||||
: (now == BodyAnimation::Text
|
: (now == BodyAnimation::Text || somethingChanged)
|
||||||
|| currentContent.text != nextContent.text
|
|
||||||
|| currentContent.id != nextContent.id)
|
|
||||||
? BodyAnimation::Text
|
? BodyAnimation::Text
|
||||||
: BodyAnimation::None;
|
: BodyAnimation::None;
|
||||||
}
|
}
|
||||||
|
@ -275,9 +276,20 @@ void MessageBar::paint(Painter &p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_animation || _animation->bodyAnimation == BodyAnimation::None) {
|
if (!_animation || _animation->bodyAnimation == BodyAnimation::None) {
|
||||||
p.setPen(_st.textFg);
|
if (_title.isEmpty()) {
|
||||||
p.setTextPalette(_st.textPalette);
|
// "Loading..." state.
|
||||||
_text.drawLeftElided(p, body.x(), text.y(), body.width(), width);
|
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) {
|
} else if (_animation->bodyAnimation == BodyAnimation::Text) {
|
||||||
p.setOpacity(1. - progress);
|
p.setOpacity(1. - progress);
|
||||||
p.drawPixmap(
|
p.drawPixmap(
|
||||||
|
|
Loading…
Add table
Reference in a new issue