mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Don't show topic buttons in topic preview.
This commit is contained in:
parent
c585112e37
commit
cbcdeae200
18 changed files with 97 additions and 21 deletions
|
@ -683,6 +683,10 @@ QString InnerWidget::elementAuthorRank(not_null<const Element*> view) {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool InnerWidget::elementHideTopicButton(not_null<const Element*> view) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
||||
memento->setFilter(std::move(_filter));
|
||||
memento->setAdmins(std::move(_admins));
|
||||
|
|
|
@ -141,6 +141,8 @@ public:
|
|||
HistoryView::Element *replacing) override;
|
||||
QString elementAuthorRank(
|
||||
not_null<const HistoryView::Element*> view) override;
|
||||
bool elementHideTopicButton(
|
||||
not_null<const HistoryView::Element*> view) override;
|
||||
|
||||
~InnerWidget();
|
||||
|
||||
|
|
|
@ -324,6 +324,10 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
bool elementHideTopicButton(not_null<const Element*> view) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
not_null<HistoryView::ElementDelegate*> delegate() override {
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ private:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
@ -279,6 +280,8 @@ void Item::setupTop() {
|
|||
const auto topic = _thread->asTopic();
|
||||
auto nameValue = (topic
|
||||
? Info::Profile::TitleValue(topic)
|
||||
: _thread->peer()->isSelf()
|
||||
? tr::lng_saved_messages()
|
||||
: Info::Profile::NameValue(_thread->peer())
|
||||
) | rpl::start_spawning(_top->lifetime());
|
||||
const auto name = Ui::CreateChild<Ui::FlatLabel>(
|
||||
|
@ -294,18 +297,24 @@ void Item::setupTop() {
|
|||
) | rpl::map([](StatusFields &&fields) {
|
||||
return fields.text;
|
||||
});
|
||||
const auto status = Ui::CreateChild<Ui::FlatLabel>(
|
||||
_top.get(),
|
||||
(topic
|
||||
? Info::Profile::NameValue(topic->channel())
|
||||
: std::move(statusText)),
|
||||
st::previewStatus);
|
||||
std::move(statusFields) | rpl::start_with_next([=](const StatusFields &fields) {
|
||||
status->setTextColorOverride(fields.active
|
||||
? st::windowActiveTextFg->c
|
||||
: std::optional<QColor>());
|
||||
}, status->lifetime());
|
||||
status->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
const auto status = _thread->peer()->isSelf()
|
||||
? nullptr
|
||||
: Ui::CreateChild<Ui::FlatLabel>(
|
||||
_top.get(),
|
||||
(topic
|
||||
? Info::Profile::NameValue(topic->channel())
|
||||
: std::move(statusText)),
|
||||
st::previewStatus);
|
||||
if (status) {
|
||||
std::move(
|
||||
statusFields
|
||||
) | rpl::start_with_next([=](const StatusFields &fields) {
|
||||
status->setTextColorOverride(fields.active
|
||||
? st::windowActiveTextFg->c
|
||||
: std::optional<QColor>());
|
||||
}, status->lifetime());
|
||||
status->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
const auto userpic = topic
|
||||
? nullptr
|
||||
: Ui::CreateChild<Ui::UserpicButton>(
|
||||
|
@ -313,6 +322,7 @@ void Item::setupTop() {
|
|||
_thread->peer(),
|
||||
st::previewUserpic);
|
||||
if (userpic) {
|
||||
userpic->showSavedMessagesOnSelf(true);
|
||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
}
|
||||
const auto icon = topic
|
||||
|
@ -334,15 +344,23 @@ void Item::setupTop() {
|
|||
name->resizeToNaturalWidth(width
|
||||
- st.namePosition.x()
|
||||
- st.photoPosition.x());
|
||||
name->move(st::previewTop.namePosition);
|
||||
if (status) {
|
||||
name->move(st::previewTop.namePosition);
|
||||
} else {
|
||||
name->move(
|
||||
st::previewTop.namePosition.x(),
|
||||
(st::previewTop.height - name->height()) / 2);
|
||||
}
|
||||
}, name->lifetime());
|
||||
|
||||
_top->geometryValue() | rpl::start_with_next([=](QRect geometry) {
|
||||
const auto &st = st::previewTop;
|
||||
status->resizeToWidth(geometry.width()
|
||||
- st.statusPosition.x()
|
||||
- st.photoPosition.x());
|
||||
status->move(st.statusPosition);
|
||||
if (status) {
|
||||
status->resizeToWidth(geometry.width()
|
||||
- st.statusPosition.x()
|
||||
- st.photoPosition.x());
|
||||
status->move(st.statusPosition);
|
||||
}
|
||||
shadow->setGeometry(
|
||||
geometry.x(),
|
||||
geometry.y() + geometry.height(),
|
||||
|
@ -673,6 +691,10 @@ QString Item::listElementAuthorRank(not_null<const Element*> view) {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool Item::listElementHideTopicButton(not_null<const Element*> view) {
|
||||
return _thread->asTopic() != nullptr;
|
||||
}
|
||||
|
||||
History *Item::listTranslateHistory() {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -198,10 +198,16 @@ void DefaultElementDelegate::elementStartEffect(
|
|||
}
|
||||
|
||||
QString DefaultElementDelegate::elementAuthorRank(
|
||||
not_null<const Element*> view) {
|
||||
not_null<const Element*> view) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DefaultElementDelegate::elementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SimpleElementDelegate::SimpleElementDelegate(
|
||||
not_null<Window::SessionController*> controller,
|
||||
Fn<void()> update)
|
||||
|
|
|
@ -117,6 +117,7 @@ public:
|
|||
not_null<const Element*> view,
|
||||
Element *replacing) = 0;
|
||||
virtual QString elementAuthorRank(not_null<const Element*> view) = 0;
|
||||
virtual bool elementHideTopicButton(not_null<const Element*> view) = 0;
|
||||
|
||||
virtual ~ElementDelegate() {
|
||||
}
|
||||
|
@ -170,6 +171,7 @@ public:
|
|||
not_null<const Element*> view,
|
||||
Element *replacing) override;
|
||||
QString elementAuthorRank(not_null<const Element*> view) override;
|
||||
bool elementHideTopicButton(not_null<const Element*> view) override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1867,6 +1867,11 @@ QString ListWidget::elementAuthorRank(not_null<const Element*> view) {
|
|||
return _delegate->listElementAuthorRank(view);
|
||||
}
|
||||
|
||||
bool ListWidget::elementHideTopicButton(not_null<const Element*> view) {
|
||||
return _delegate->listElementHideTopicButton(view);
|
||||
}
|
||||
|
||||
|
||||
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
||||
memento->setAroundPosition(_aroundPosition);
|
||||
const auto state = countScrollState();
|
||||
|
|
|
@ -155,6 +155,7 @@ public:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) = 0;
|
||||
virtual QString listElementAuthorRank(not_null<const Element*> view) = 0;
|
||||
virtual bool listElementHideTopicButton(not_null<const Element*> view) = 0;
|
||||
virtual History *listTranslateHistory() = 0;
|
||||
virtual void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) = 0;
|
||||
|
@ -368,7 +369,7 @@ public:
|
|||
[[nodiscard]] auto replyToMessageRequested() const
|
||||
-> rpl::producer<ReplyToMessageRequest>;
|
||||
void replyToMessageRequestNotify(
|
||||
FullReplyTo to,
|
||||
FullReplyTo to,
|
||||
bool forceAnotherChat = false);
|
||||
[[nodiscard]] rpl::producer<FullMsgId> readMessageRequested() const;
|
||||
[[nodiscard]] rpl::producer<FullMsgId> showMessageRequested() const;
|
||||
|
@ -425,6 +426,7 @@ public:
|
|||
not_null<const Element*> view,
|
||||
Element *replacing) override;
|
||||
QString elementAuthorRank(not_null<const Element*> view) override;
|
||||
bool elementHideTopicButton(not_null<const Element*> view) override;
|
||||
|
||||
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
||||
void overrideIsChatWide(bool isWide);
|
||||
|
|
|
@ -1037,8 +1037,7 @@ QSize Message::performCountOptimalSize() {
|
|||
void Message::refreshTopicButton() {
|
||||
const auto item = data();
|
||||
if (isAttachedToPrevious()
|
||||
|| (context() != Context::History
|
||||
&& context() != Context::ChatPreview)) {
|
||||
|| delegate()->elementHideTopicButton(this)) {
|
||||
_topicButton = nullptr;
|
||||
} else if (const auto topic = item->topic()) {
|
||||
if (!_topicButton) {
|
||||
|
|
|
@ -679,6 +679,11 @@ QString PinnedWidget::listElementAuthorRank(not_null<const Element*> view) {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool PinnedWidget::listElementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
History *PinnedWidget::listTranslateHistory() {
|
||||
return _history;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,7 @@ public:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
|
|
@ -2614,6 +2614,11 @@ QString RepliesWidget::listElementAuthorRank(not_null<const Element*> view) {
|
|||
: QString();
|
||||
}
|
||||
|
||||
bool RepliesWidget::listElementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
History *RepliesWidget::listTranslateHistory() {
|
||||
return _history;
|
||||
}
|
||||
|
|
|
@ -175,6 +175,7 @@ public:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
|
|
@ -1450,6 +1450,11 @@ QString ScheduledWidget::listElementAuthorRank(
|
|||
return {};
|
||||
}
|
||||
|
||||
bool ScheduledWidget::listElementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
History *ScheduledWidget::listTranslateHistory() {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -159,6 +159,7 @@ public:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
|
|
@ -736,6 +736,11 @@ QString SublistWidget::listElementAuthorRank(not_null<const Element*> view) {
|
|||
return {};
|
||||
}
|
||||
|
||||
bool SublistWidget::listElementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
History *SublistWidget::listTranslateHistory() {
|
||||
return _history;
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ public:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
|
|
@ -161,6 +161,7 @@ private:
|
|||
Painter &p,
|
||||
const Ui::ChatPaintContext &context) override;
|
||||
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||
bool listElementHideTopicButton(not_null<const Element*> view) override;
|
||||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
|
@ -1046,6 +1047,11 @@ QString ShortcutMessages::listElementAuthorRank(
|
|||
return {};
|
||||
}
|
||||
|
||||
bool ShortcutMessages::listElementHideTopicButton(
|
||||
not_null<const Element*> view) {
|
||||
return true;
|
||||
}
|
||||
|
||||
History *ShortcutMessages::listTranslateHistory() {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue