mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added support of profile color to profile top bar for stories outline.
This commit is contained in:
@@ -1780,19 +1780,27 @@ void TopBar::setupStoryOutline(const QRect &geometry) {
|
||||
style::PaletteChanged(),
|
||||
user->session().changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::StoriesState
|
||||
| Data::PeerUpdate::Flag::ColorProfile
|
||||
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||
return update.peer == user;
|
||||
}) | rpl::to_empty)
|
||||
) | rpl::start_with_next([=](
|
||||
std::optional<QColor> edgeColor,
|
||||
rpl::empty_value) {
|
||||
const auto geometry = userpicGeometry();
|
||||
_storyOutlineBrush = Ui::UnreadStoryOutlineGradient(
|
||||
QRectF(
|
||||
geometry.x(),
|
||||
geometry.y(),
|
||||
geometry.width(),
|
||||
geometry.height()));
|
||||
const auto geometry = QRectF(userpicGeometry());
|
||||
const auto colorProfile
|
||||
= user->session().api().peerColors().colorProfileFor(user);
|
||||
const auto hasProfileColor = colorProfile
|
||||
&& colorProfile->story.size() > 1;
|
||||
if (hasProfileColor) {
|
||||
edgeColor = std::nullopt;
|
||||
}
|
||||
_storyOutlineBrush = hasProfileColor
|
||||
? Ui::UnreadStoryOutlineGradient(
|
||||
geometry,
|
||||
colorProfile->story[0],
|
||||
colorProfile->story[1])
|
||||
: Ui::UnreadStoryOutlineGradient(geometry);
|
||||
updateStoryOutline(edgeColor);
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
@@ -85,13 +85,20 @@ void PaintOutlineSegments(
|
||||
}
|
||||
}
|
||||
|
||||
QLinearGradient UnreadStoryOutlineGradient(QRectF rect) {
|
||||
QLinearGradient UnreadStoryOutlineGradient(
|
||||
QRectF rect,
|
||||
const QColor &c1,
|
||||
const QColor &c2) {
|
||||
auto result = QLinearGradient(rect.topRight(), rect.bottomLeft());
|
||||
result.setStops({
|
||||
{ 0., st::groupCallLive1->c },
|
||||
{ 1., st::groupCallMuted1->c },
|
||||
});
|
||||
result.setStops({ { 0., c1 }, { 1., c2 } });
|
||||
return result;
|
||||
}
|
||||
|
||||
QLinearGradient UnreadStoryOutlineGradient(QRectF rect) {
|
||||
return UnreadStoryOutlineGradient(
|
||||
std::move(rect),
|
||||
st::groupCallLive1->c,
|
||||
st::groupCallMuted1->c);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
||||
@@ -28,6 +28,10 @@ void PaintOutlineSegments(
|
||||
float64 radius,
|
||||
const std::vector<OutlineSegment> &segments);
|
||||
|
||||
[[nodiscard]] QLinearGradient UnreadStoryOutlineGradient(
|
||||
QRectF rect,
|
||||
const QColor &c1,
|
||||
const QColor &c2);
|
||||
[[nodiscard]] QLinearGradient UnreadStoryOutlineGradient(QRectF rect = {});
|
||||
|
||||
} // namespace Ui
|
||||
|
||||
Reference in New Issue
Block a user