mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Improved style of recent posts in statistical info.
This commit is contained in:
parent
d1ba270a8c
commit
594b2bc8f2
3 changed files with 30 additions and 21 deletions
|
@ -42,7 +42,7 @@ namespace {
|
||||||
return QImage();
|
return QImage();
|
||||||
}
|
}
|
||||||
const auto factor = style::DevicePixelRatio();
|
const auto factor = style::DevicePixelRatio();
|
||||||
const auto size = st::statisticsRecentPostRowHeight * factor;
|
const auto size = st::peerListBoxItem.photoSize * factor;
|
||||||
const auto scaled = original.scaled(
|
const auto scaled = original.scaled(
|
||||||
QSize(size, size),
|
QSize(size, size),
|
||||||
Qt::KeepAspectRatioByExpanding,
|
Qt::KeepAspectRatioByExpanding,
|
||||||
|
@ -73,16 +73,16 @@ MessagePreview::MessagePreview(
|
||||||
: Ui::RpWidget(parent)
|
: Ui::RpWidget(parent)
|
||||||
, _item(item)
|
, _item(item)
|
||||||
, _date(
|
, _date(
|
||||||
st::statisticsHeaderDatesTextStyle,
|
st::statisticsHeaderTitleTextStyle,
|
||||||
Ui::FormatDateTime(ItemDateTime(item)))
|
Ui::FormatDateTime(ItemDateTime(item)))
|
||||||
, _views(
|
, _views(
|
||||||
st::statisticsDetailsPopupHeaderStyle,
|
st::defaultPeerListItem.nameStyle,
|
||||||
tr::lng_stats_recent_messages_views(
|
tr::lng_stats_recent_messages_views(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count_decimal,
|
lt_count_decimal,
|
||||||
views))
|
views))
|
||||||
, _shares(
|
, _shares(
|
||||||
st::statisticsHeaderDatesTextStyle,
|
st::statisticsHeaderTitleTextStyle,
|
||||||
tr::lng_stats_recent_messages_shares(
|
tr::lng_stats_recent_messages_shares(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count_decimal,
|
lt_count_decimal,
|
||||||
|
@ -90,7 +90,7 @@ MessagePreview::MessagePreview(
|
||||||
, _viewsWidth(_views.maxWidth())
|
, _viewsWidth(_views.maxWidth())
|
||||||
, _sharesWidth(_shares.maxWidth()) {
|
, _sharesWidth(_shares.maxWidth()) {
|
||||||
_text.setMarkedText(
|
_text.setMarkedText(
|
||||||
st::statisticsDetailsPopupHeaderStyle,
|
st::defaultPeerListItem.nameStyle,
|
||||||
_item->toPreview({ .generateImages = false }).text,
|
_item->toPreview({ .generateImages = false }).text,
|
||||||
Ui::DialogTextOptions(),
|
Ui::DialogTextOptions(),
|
||||||
Core::MarkedTextContext{
|
Core::MarkedTextContext{
|
||||||
|
@ -166,7 +166,7 @@ void MessagePreview::processPreview(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessagePreview::resizeGetHeight(int newWidth) {
|
int MessagePreview::resizeGetHeight(int newWidth) {
|
||||||
return st::statisticsRecentPostRowHeight;
|
return st::peerListBoxItem.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagePreview::paintEvent(QPaintEvent *e) {
|
void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
|
@ -175,13 +175,14 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
const auto padding = st::boxRowPadding.left() / 2;
|
const auto padding = st::boxRowPadding.left() / 2;
|
||||||
const auto rightWidth = std::max(_viewsWidth, _sharesWidth) + padding;
|
const auto rightWidth = std::max(_viewsWidth, _sharesWidth) + padding;
|
||||||
const auto left = _preview.isNull()
|
const auto left = _preview.isNull()
|
||||||
? 0
|
? st::peerListBoxItem.photoPosition.x()
|
||||||
: (_preview.width() / style::DevicePixelRatio()) + padding;
|
: st::peerListBoxItem.namePosition.x();
|
||||||
if (left) {
|
if (left) {
|
||||||
p.drawImage(0, 0, _preview);
|
p.drawImage(st::peerListBoxItem.photoPosition, _preview);
|
||||||
if (_spoiler) {
|
if (_spoiler) {
|
||||||
const auto rect = Rect(
|
const auto rect = QRect(
|
||||||
_preview.size() / _preview.devicePixelRatio());
|
st::peerListBoxItem.photoPosition,
|
||||||
|
Size(st::peerListBoxItem.photoSize));
|
||||||
const auto paused = On(PowerSaving::kChatSpoiler);
|
const auto paused = On(PowerSaving::kChatSpoiler);
|
||||||
FillSpoilerRect(
|
FillSpoilerRect(
|
||||||
p,
|
p,
|
||||||
|
@ -193,11 +194,13 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
_cornerCache);
|
_cornerCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto topTextTop = st::peerListBoxItem.namePosition.y();
|
||||||
|
const auto bottomTextTop = st::peerListBoxItem.statusPosition.y();
|
||||||
|
|
||||||
p.setBrush(Qt::NoBrush);
|
p.setBrush(Qt::NoBrush);
|
||||||
p.setPen(st::boxTextFg);
|
p.setPen(st::boxTextFg);
|
||||||
_text.draw(p, {
|
_text.draw(p, {
|
||||||
.position = { left, 0 },
|
.position = { left, topTextTop },
|
||||||
.outerWidth = width() - left,
|
.outerWidth = width() - left,
|
||||||
.availableWidth = width() - rightWidth - left,
|
.availableWidth = width() - rightWidth - left,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
|
@ -205,19 +208,19 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
.elisionHeight = st::statisticsDetailsPopupHeaderStyle.font->height,
|
.elisionHeight = st::statisticsDetailsPopupHeaderStyle.font->height,
|
||||||
});
|
});
|
||||||
_views.draw(p, {
|
_views.draw(p, {
|
||||||
.position = { width() - _viewsWidth, 0 },
|
.position = { width() - _viewsWidth, topTextTop },
|
||||||
.outerWidth = _viewsWidth,
|
.outerWidth = _viewsWidth,
|
||||||
.availableWidth = _viewsWidth,
|
.availableWidth = _viewsWidth,
|
||||||
});
|
});
|
||||||
|
|
||||||
p.setPen(st::windowSubTextFg);
|
p.setPen(st::windowSubTextFg);
|
||||||
_date.draw(p, {
|
_date.draw(p, {
|
||||||
.position = { left, height() / 2 },
|
.position = { left, bottomTextTop },
|
||||||
.outerWidth = width() - left,
|
.outerWidth = width() - left,
|
||||||
.availableWidth = width() - rightWidth - left,
|
.availableWidth = width() - rightWidth - left,
|
||||||
});
|
});
|
||||||
_shares.draw(p, {
|
_shares.draw(p, {
|
||||||
.position = { width() - _sharesWidth, height() / 2 },
|
.position = { width() - _sharesWidth, bottomTextTop },
|
||||||
.outerWidth = _sharesWidth,
|
.outerWidth = _sharesWidth,
|
||||||
.availableWidth = _sharesWidth,
|
.availableWidth = _sharesWidth,
|
||||||
});
|
});
|
||||||
|
|
|
@ -495,12 +495,13 @@ void FillRecentPosts(
|
||||||
not_null<Ui::VerticalLayout*> messageWrap,
|
not_null<Ui::VerticalLayout*> messageWrap,
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
const Data::StatisticsMessageInteractionInfo &info) {
|
const Data::StatisticsMessageInteractionInfo &info) {
|
||||||
const auto button = ::Settings::AddButton(
|
const auto button = messageWrap->add(
|
||||||
|
object_ptr<Ui::SettingsButton>(
|
||||||
messageWrap,
|
messageWrap,
|
||||||
nullptr,
|
rpl::never<QString>(),
|
||||||
st::settingsButton);
|
st::statisticsRecentPostButton));
|
||||||
const auto raw = Ui::CreateChild<MessagePreview>(
|
const auto raw = Ui::CreateChild<MessagePreview>(
|
||||||
button.get(),
|
button,
|
||||||
item,
|
item,
|
||||||
info.viewsCount,
|
info.viewsCount,
|
||||||
info.forwardsCount);
|
info.forwardsCount);
|
||||||
|
@ -508,7 +509,8 @@ void FillRecentPosts(
|
||||||
button->sizeValue(
|
button->sizeValue(
|
||||||
) | rpl::start_with_next([=](const QSize &s) {
|
) | rpl::start_with_next([=](const QSize &s) {
|
||||||
if (!s.isNull()) {
|
if (!s.isNull()) {
|
||||||
raw->setGeometry(Rect(s) - st::boxRowPadding);
|
raw->setGeometry(Rect(s)
|
||||||
|
- st::statisticsRecentPostButton.padding);
|
||||||
}
|
}
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
button->setClickedCallback([=, fullId = item->fullId()] {
|
button->setClickedCallback([=, fullId = item->fullId()] {
|
||||||
|
|
|
@ -100,3 +100,7 @@ statisticsOverviewMidSkip: 50px;
|
||||||
statisticsOverviewRightSkip: 14px;
|
statisticsOverviewRightSkip: 14px;
|
||||||
|
|
||||||
statisticsRecentPostRowHeight: 40px;
|
statisticsRecentPostRowHeight: 40px;
|
||||||
|
statisticsRecentPostButton: SettingsButton(defaultSettingsButton) {
|
||||||
|
height: 56px;
|
||||||
|
padding: margins(7px, 0px, 24px, 0px);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue