mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Improve single column layout forum / topic top bar.
This commit is contained in:
parent
b497e5ea21
commit
b92b8e56cb
4 changed files with 136 additions and 105 deletions
|
@ -838,7 +838,10 @@ void TopBarWidget::setCustomTitle(const QString &title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopBarWidget::refreshInfoButton() {
|
void TopBarWidget::refreshInfoButton() {
|
||||||
if (const auto peer = _activeChat.key.peer()) {
|
if (_activeChat.key.topic()
|
||||||
|
|| _activeChat.section == Section::ChatsList) {
|
||||||
|
_info.destroy();
|
||||||
|
} else if (const auto peer = _activeChat.key.peer()) {
|
||||||
auto info = object_ptr<Ui::UserpicButton>(
|
auto info = object_ptr<Ui::UserpicButton>(
|
||||||
this,
|
this,
|
||||||
_controller,
|
_controller,
|
||||||
|
@ -924,6 +927,9 @@ void TopBarWidget::updateControlsGeometry() {
|
||||||
if (_info && !_info->isHidden()) {
|
if (_info && !_info->isHidden()) {
|
||||||
_info->moveToLeft(_leftTaken, otherButtonsTop);
|
_info->moveToLeft(_leftTaken, otherButtonsTop);
|
||||||
_leftTaken += _info->width();
|
_leftTaken += _info->width();
|
||||||
|
} else if (_activeChat.key.topic()
|
||||||
|
|| _activeChat.section == Section::ChatsList) {
|
||||||
|
_leftTaken += st::topBarArrowPadding.right();
|
||||||
}
|
}
|
||||||
|
|
||||||
_rightTaken = 0;
|
_rightTaken = 0;
|
||||||
|
@ -984,8 +990,8 @@ void TopBarWidget::updateControlsVisibility() {
|
||||||
_back->setVisible(backVisible && !_chooseForReportReason);
|
_back->setVisible(backVisible && !_chooseForReportReason);
|
||||||
_cancelChoose->setVisible(_chooseForReportReason.has_value());
|
_cancelChoose->setVisible(_chooseForReportReason.has_value());
|
||||||
if (_info) {
|
if (_info) {
|
||||||
_info->setVisible((isOneColumn || !_primaryWindow)
|
_info->setVisible(!_chooseForReportReason
|
||||||
&& !_chooseForReportReason);
|
&& (isOneColumn || !_primaryWindow));
|
||||||
}
|
}
|
||||||
if (_unreadBadge) {
|
if (_unreadBadge) {
|
||||||
_unreadBadge->setVisible(!_chooseForReportReason);
|
_unreadBadge->setVisible(!_chooseForReportReason);
|
||||||
|
|
|
@ -116,6 +116,106 @@ Cover::Cover(
|
||||||
: st::infoProfileCover;
|
: st::infoProfileCover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TopicIconView::TopicIconView(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Data::ForumTopic*> topic)
|
||||||
|
: AbstractButton(parent) {
|
||||||
|
setup(topic, [=] {
|
||||||
|
return controller->isGifPausedAtLeastFor(
|
||||||
|
Window::GifPauseReason::Layer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void TopicIconView::setup(
|
||||||
|
not_null<Data::ForumTopic*> topic,
|
||||||
|
Fn<bool()> paused) {
|
||||||
|
setupPlayer(topic);
|
||||||
|
setupImage(topic);
|
||||||
|
|
||||||
|
resize(st::infoTopicCover.photo.size);
|
||||||
|
paintRequest(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
auto p = QPainter(this);
|
||||||
|
const auto paint = [&](const QImage &image) {
|
||||||
|
const auto size = image.size() / image.devicePixelRatio();
|
||||||
|
p.drawImage(
|
||||||
|
(st::infoTopicCover.photo.size.width() - size.width()) / 2,
|
||||||
|
(st::infoTopicCover.photo.size.height() - size.height()) / 2,
|
||||||
|
image);
|
||||||
|
};
|
||||||
|
if (_player && _player->ready()) {
|
||||||
|
paint(_player->frame(
|
||||||
|
st::infoTopicCover.photo.size,
|
||||||
|
QColor(0, 0, 0, 0),
|
||||||
|
false,
|
||||||
|
crl::now(),
|
||||||
|
paused()).image);
|
||||||
|
_player->markFrameShown();
|
||||||
|
} else if (!topic->iconId() && !_image.isNull()) {
|
||||||
|
paint(_image);
|
||||||
|
}
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TopicIconView::setupPlayer(not_null<Data::ForumTopic*> topic) {
|
||||||
|
IconIdValue(
|
||||||
|
topic
|
||||||
|
) | rpl::map([=](DocumentId id) {
|
||||||
|
return topic->owner().customEmojiManager().resolve(id);
|
||||||
|
}) | rpl::flatten_latest(
|
||||||
|
) | rpl::map([=](not_null<DocumentData*> document) {
|
||||||
|
const auto media = document->createMediaView();
|
||||||
|
media->checkStickerLarge();
|
||||||
|
media->goodThumbnailWanted();
|
||||||
|
|
||||||
|
return rpl::single() | rpl::then(
|
||||||
|
document->owner().session().downloaderTaskFinished()
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return media->loaded();
|
||||||
|
}) | rpl::take(1) | rpl::map([=] {
|
||||||
|
auto result = std::shared_ptr<StickerPlayer>();
|
||||||
|
const auto sticker = document->sticker();
|
||||||
|
if (sticker->isLottie()) {
|
||||||
|
result = std::make_shared<HistoryView::LottiePlayer>(
|
||||||
|
ChatHelpers::LottiePlayerFromDocument(
|
||||||
|
media.get(),
|
||||||
|
ChatHelpers::StickerLottieSize::StickerSet,
|
||||||
|
st::infoTopicCover.photo.size,
|
||||||
|
Lottie::Quality::High));
|
||||||
|
} else if (sticker->isWebm()) {
|
||||||
|
result = std::make_shared<HistoryView::WebmPlayer>(
|
||||||
|
media->owner()->location(),
|
||||||
|
media->bytes(),
|
||||||
|
st::infoTopicCover.photo.size);
|
||||||
|
} else {
|
||||||
|
result = std::make_shared<HistoryView::StaticStickerPlayer>(
|
||||||
|
media->owner()->location(),
|
||||||
|
media->bytes(),
|
||||||
|
st::infoTopicCover.photo.size);
|
||||||
|
}
|
||||||
|
result->setRepaintCallback([=] { update(); });
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}) | rpl::flatten_latest(
|
||||||
|
) | rpl::start_with_next([=](std::shared_ptr<StickerPlayer> player) {
|
||||||
|
_player = std::move(player);
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TopicIconView::setupImage(not_null<Data::ForumTopic*> topic) {
|
||||||
|
rpl::combine(
|
||||||
|
TitleValue(topic),
|
||||||
|
ColorIdValue(topic)
|
||||||
|
) | rpl::map([=](const QString &title, int32 colorId) {
|
||||||
|
using namespace Data;
|
||||||
|
return ForumTopicIconFrame(colorId, title, st::infoForumTopicIcon);
|
||||||
|
}) | rpl::start_with_next([=](QImage &&image) {
|
||||||
|
_image = std::move(image);
|
||||||
|
update();
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
Cover::Cover(
|
Cover::Cover(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
@ -147,14 +247,12 @@ Cover::Cover(
|
||||||
_peer,
|
_peer,
|
||||||
Ui::UserpicButton::Role::OpenPhoto,
|
Ui::UserpicButton::Role::OpenPhoto,
|
||||||
_st.photo))
|
_st.photo))
|
||||||
, _iconView(topic ? object_ptr<Ui::RpWidget>(this) : nullptr)
|
, _iconView(topic
|
||||||
|
? object_ptr<TopicIconView>(this, controller, topic)
|
||||||
|
: nullptr)
|
||||||
, _name(this, _st.name)
|
, _name(this, _st.name)
|
||||||
, _status(this, _st.status)
|
, _status(this, _st.status)
|
||||||
, _refreshStatusTimer([this] { refreshStatusText(); }) {
|
, _refreshStatusTimer([this] { refreshStatusText(); }) {
|
||||||
if (topic) {
|
|
||||||
setupIcon(topic);
|
|
||||||
}
|
|
||||||
|
|
||||||
_peer->updateFull();
|
_peer->updateFull();
|
||||||
|
|
||||||
_name->setSelectable(true);
|
_name->setSelectable(true);
|
||||||
|
@ -190,94 +288,6 @@ Cover::Cover(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::setupIconPlayer(not_null<Data::ForumTopic*> topic) {
|
|
||||||
IconIdValue(
|
|
||||||
topic
|
|
||||||
) | rpl::map([=](DocumentId id) {
|
|
||||||
return topic->owner().customEmojiManager().resolve(id);
|
|
||||||
}) | rpl::flatten_latest(
|
|
||||||
) | rpl::map([=](not_null<DocumentData*> document) {
|
|
||||||
const auto media = document->createMediaView();
|
|
||||||
media->checkStickerLarge();
|
|
||||||
media->goodThumbnailWanted();
|
|
||||||
|
|
||||||
return rpl::single() | rpl::then(
|
|
||||||
document->owner().session().downloaderTaskFinished()
|
|
||||||
) | rpl::filter([=] {
|
|
||||||
return media->loaded();
|
|
||||||
}) | rpl::take(1) | rpl::map([=] {
|
|
||||||
auto result = std::shared_ptr<StickerPlayer>();
|
|
||||||
const auto sticker = document->sticker();
|
|
||||||
if (sticker->isLottie()) {
|
|
||||||
result = std::make_shared<HistoryView::LottiePlayer>(
|
|
||||||
ChatHelpers::LottiePlayerFromDocument(
|
|
||||||
media.get(),
|
|
||||||
ChatHelpers::StickerLottieSize::StickerSet,
|
|
||||||
_st.photo.size,
|
|
||||||
Lottie::Quality::High));
|
|
||||||
} else if (sticker->isWebm()) {
|
|
||||||
result = std::make_shared<HistoryView::WebmPlayer>(
|
|
||||||
media->owner()->location(),
|
|
||||||
media->bytes(),
|
|
||||||
_st.photo.size);
|
|
||||||
} else {
|
|
||||||
result = std::make_shared<HistoryView::StaticStickerPlayer>(
|
|
||||||
media->owner()->location(),
|
|
||||||
media->bytes(),
|
|
||||||
_st.photo.size);
|
|
||||||
}
|
|
||||||
result->setRepaintCallback([=] { _iconView->update(); });
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}) | rpl::flatten_latest(
|
|
||||||
) | rpl::start_with_next([=](std::shared_ptr<StickerPlayer> player) {
|
|
||||||
_iconPlayer = std::move(player);
|
|
||||||
}, lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cover::setupIconImage(not_null<Data::ForumTopic*> topic) {
|
|
||||||
rpl::combine(
|
|
||||||
TitleValue(topic),
|
|
||||||
ColorIdValue(topic)
|
|
||||||
) | rpl::map([=](const QString &title, int32 colorId) {
|
|
||||||
using namespace Data;
|
|
||||||
return ForumTopicIconFrame(colorId, title, st::infoForumTopicIcon);
|
|
||||||
}) | rpl::start_with_next([=](QImage &&image) {
|
|
||||||
_iconImage = std::move(image);
|
|
||||||
_iconView->update();
|
|
||||||
}, lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cover::setupIcon(not_null<Data::ForumTopic*> topic) {
|
|
||||||
setupIconPlayer(topic);
|
|
||||||
setupIconImage(topic);
|
|
||||||
|
|
||||||
_iconView->resize(_st.photo.size);
|
|
||||||
_iconView->paintRequest(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
auto p = QPainter(_iconView.data());
|
|
||||||
const auto paint = [&](const QImage &image) {
|
|
||||||
const auto size = image.size() / image.devicePixelRatio();
|
|
||||||
p.drawImage(
|
|
||||||
(_st.photo.size.width() - size.width()) / 2,
|
|
||||||
(_st.photo.size.height() - size.height()) / 2,
|
|
||||||
image);
|
|
||||||
};
|
|
||||||
if (_iconPlayer && _iconPlayer->ready()) {
|
|
||||||
paint(_iconPlayer->frame(
|
|
||||||
_st.photo.size,
|
|
||||||
QColor(0, 0, 0, 0),
|
|
||||||
false,
|
|
||||||
crl::now(),
|
|
||||||
_controller->isGifPausedAtLeastFor(
|
|
||||||
Window::GifPauseReason::Layer)).image);
|
|
||||||
_iconPlayer->markFrameShown();
|
|
||||||
} else if (!topic->iconId() && !_iconImage.isNull()) {
|
|
||||||
paint(_iconImage);
|
|
||||||
}
|
|
||||||
}, _iconView->lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cover::setupChildGeometry() {
|
void Cover::setupChildGeometry() {
|
||||||
widthValue(
|
widthValue(
|
||||||
) | rpl::start_with_next([this](int newWidth) {
|
) | rpl::start_with_next([this](int newWidth) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
|
#include "ui/abstract_button.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -43,6 +44,27 @@ namespace Info::Profile {
|
||||||
class EmojiStatusPanel;
|
class EmojiStatusPanel;
|
||||||
class Badge;
|
class Badge;
|
||||||
|
|
||||||
|
class TopicIconView final : public Ui::AbstractButton {
|
||||||
|
public:
|
||||||
|
TopicIconView(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Data::ForumTopic*> topic);
|
||||||
|
|
||||||
|
private:
|
||||||
|
using StickerPlayer = HistoryView::StickerPlayer;
|
||||||
|
|
||||||
|
void setup(
|
||||||
|
not_null<Data::ForumTopic*> topic,
|
||||||
|
Fn<bool()> paused);
|
||||||
|
void setupPlayer(not_null<Data::ForumTopic*> topic);
|
||||||
|
void setupImage(not_null<Data::ForumTopic*> topic);
|
||||||
|
|
||||||
|
std::shared_ptr<StickerPlayer> _player;
|
||||||
|
QImage _image;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class Cover final : public Ui::FixedHeightWidget {
|
class Cover final : public Ui::FixedHeightWidget {
|
||||||
public:
|
public:
|
||||||
Cover(
|
Cover(
|
||||||
|
@ -67,8 +89,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using StickerPlayer = HistoryView::StickerPlayer;
|
|
||||||
|
|
||||||
Cover(
|
Cover(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
@ -76,9 +96,6 @@ private:
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
rpl::producer<QString> title);
|
rpl::producer<QString> title);
|
||||||
|
|
||||||
void setupIcon(not_null<Data::ForumTopic*> topic);
|
|
||||||
void setupIconPlayer(not_null<Data::ForumTopic*> topic);
|
|
||||||
void setupIconImage(not_null<Data::ForumTopic*> topic);
|
|
||||||
void setupChildGeometry();
|
void setupChildGeometry();
|
||||||
void initViewers(rpl::producer<QString> title);
|
void initViewers(rpl::producer<QString> title);
|
||||||
void refreshStatusText();
|
void refreshStatusText();
|
||||||
|
@ -95,9 +112,7 @@ private:
|
||||||
int _onlineCount = 0;
|
int _onlineCount = 0;
|
||||||
|
|
||||||
object_ptr<Ui::UserpicButton> _userpic;
|
object_ptr<Ui::UserpicButton> _userpic;
|
||||||
object_ptr<Ui::RpWidget> _iconView;
|
object_ptr<TopicIconView> _iconView;
|
||||||
std::shared_ptr<StickerPlayer> _iconPlayer;
|
|
||||||
QImage _iconImage;
|
|
||||||
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
object_ptr<Ui::FlatLabel> _name = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _status = { nullptr };
|
object_ptr<Ui::FlatLabel> _status = { nullptr };
|
||||||
//object_ptr<CoverDropArea> _dropArea = { nullptr };
|
//object_ptr<CoverDropArea> _dropArea = { nullptr };
|
||||||
|
|
|
@ -523,7 +523,7 @@ void Filler::addToggleUnreadMark() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto unread = IsUnreadThread(_thread);
|
const auto unread = IsUnreadThread(_thread);
|
||||||
if (_thread->asTopic() && !unread) {
|
if ((_thread->asTopic() || peer->isForum()) && !unread) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto weak = base::make_weak(_thread);
|
const auto weak = base::make_weak(_thread);
|
||||||
|
|
Loading…
Add table
Reference in a new issue