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