mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve top bar design for forum / topic.
This commit is contained in:
parent
3a967bbbfe
commit
f9173ea849
5 changed files with 62 additions and 16 deletions
|
@ -707,14 +707,16 @@ void Widget::refreshFolderTopBar() {
|
||||||
_folderTopBar.create(this, controller());
|
_folderTopBar.create(this, controller());
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
const auto history = _openedForum
|
||||||
|
? session().data().history(_openedForum).get()
|
||||||
|
: nullptr;
|
||||||
_folderTopBar->setActiveChat(
|
_folderTopBar->setActiveChat(
|
||||||
HistoryView::TopBarWidget::ActiveChat{
|
HistoryView::TopBarWidget::ActiveChat{
|
||||||
.key = (_openedForum
|
.key = (_openedForum
|
||||||
? Dialogs::Key(session().data().history(_openedForum))
|
? Dialogs::Key(history)
|
||||||
: Dialogs::Key(_openedFolder)),
|
: Dialogs::Key(_openedFolder)),
|
||||||
.section = Dialogs::EntryState::Section::ChatsList,
|
.section = Dialogs::EntryState::Section::ChatsList,
|
||||||
},
|
}, history ? history->sendActionPainter().get() : nullptr);
|
||||||
nullptr);
|
|
||||||
} else {
|
} else {
|
||||||
_folderTopBar.destroy();
|
_folderTopBar.destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,7 +822,10 @@ void RowPainter::Paint(
|
||||||
const auto badgesState = entry->chatListBadgesState();
|
const auto badgesState = entry->chatListBadgesState();
|
||||||
const auto item = entry->chatListMessage();
|
const auto item = entry->chatListMessage();
|
||||||
const auto cloudDraft = [&]() -> const Data::Draft*{
|
const auto cloudDraft = [&]() -> const Data::Draft*{
|
||||||
if (thread && (!item || !badgesState.unread)) {
|
if (!thread) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
if ((!peer || !peer->isForum()) && (!item || !badgesState.unread)) {
|
||||||
// Draw item, if there are unread messages.
|
// Draw item, if there are unread messages.
|
||||||
const auto draft = thread->owningHistory()->cloudDraft(
|
const auto draft = thread->owningHistory()->cloudDraft(
|
||||||
thread->topicRootId());
|
thread->topicRootId());
|
||||||
|
|
|
@ -1924,7 +1924,9 @@ void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
|
||||||
TimeId History::adjustedChatListTimeId() const {
|
TimeId History::adjustedChatListTimeId() const {
|
||||||
const auto result = chatListTimeId();
|
const auto result = chatListTimeId();
|
||||||
if (const auto draft = cloudDraft(MsgId(0))) {
|
if (const auto draft = cloudDraft(MsgId(0))) {
|
||||||
if (!Data::DraftIsNull(draft) && !session().supportMode()) {
|
if (!peer->forum()
|
||||||
|
&& !Data::DraftIsNull(draft)
|
||||||
|
&& !session().supportMode()) {
|
||||||
return std::max(result, draft->date);
|
return std::max(result, draft->date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2914,6 +2916,9 @@ void History::forumChanged(Data::Forum *old) {
|
||||||
} else {
|
} else {
|
||||||
_flags &= ~Flag::IsForum;
|
_flags &= ~Flag::IsForum;
|
||||||
}
|
}
|
||||||
|
if (cloudDraft(MsgId(0))) {
|
||||||
|
updateChatListSortPosition();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<History*> History::migrateToOrMe() const {
|
not_null<History*> History::migrateToOrMe() const {
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "info/info_memento.h"
|
#include "info/info_memento.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -177,11 +178,15 @@ TopBarWidget::TopBarWidget(
|
||||||
&& (_activeChat.key.peer() == update.peer)) {
|
&& (_activeChat.key.peer() == update.peer)) {
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
}
|
}
|
||||||
if (update.flags
|
if ((update.flags & UpdateFlag::OnlineStatus)
|
||||||
& (UpdateFlag::OnlineStatus
|
&& trackOnlineOf(update.peer)) {
|
||||||
| UpdateFlag::Members
|
|
||||||
| UpdateFlag::SupportInfo)) {
|
|
||||||
updateOnlineDisplay();
|
updateOnlineDisplay();
|
||||||
|
} else if (update.flags
|
||||||
|
& (UpdateFlag::Members | UpdateFlag::SupportInfo)) {
|
||||||
|
if (update.peer == _activeChat.key.peer()
|
||||||
|
&& !_activeChat.key.topic()) {
|
||||||
|
updateOnlineDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((update.flags & UpdateFlag::EmojiStatus)
|
if ((update.flags & UpdateFlag::EmojiStatus)
|
||||||
&& (_activeChat.key.peer() == update.peer)) {
|
&& (_activeChat.key.peer() == update.peer)) {
|
||||||
|
@ -496,8 +501,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
||||||
} else if (folder
|
} else if (folder
|
||||||
|| history->peer->sharedMediaInfo()
|
|| history->peer->sharedMediaInfo()
|
||||||
|| (_activeChat.section == Section::Scheduled)
|
|| (_activeChat.section == Section::Scheduled)
|
||||||
|| (_activeChat.section == Section::Pinned)
|
|| (_activeChat.section == Section::Pinned)) {
|
||||||
|| (_activeChat.section == Section::ChatsList)) {
|
|
||||||
// #TODO forum name emoji.
|
// #TODO forum name emoji.
|
||||||
auto text = (_activeChat.section == Section::Scheduled)
|
auto text = (_activeChat.section == Section::Scheduled)
|
||||||
? ((history && history->peer->isSelf())
|
? ((history && history->peer->isSelf())
|
||||||
|
@ -768,7 +772,17 @@ void TopBarWidget::setActiveChat(
|
||||||
return (seen.peer == history->peer);
|
return (seen.peer == history->peer);
|
||||||
}) | rpl::start_with_next([=](const InteractionSeen &seen) {
|
}) | rpl::start_with_next([=](const InteractionSeen &seen) {
|
||||||
handleEmojiInteractionSeen(seen.emoticon);
|
handleEmojiInteractionSeen(seen.emoticon);
|
||||||
}, lifetime());
|
}, _activeChatLifetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const auto topic = _activeChat.key.topic()) {
|
||||||
|
Info::Profile::NameValue(
|
||||||
|
topic->channel()
|
||||||
|
) | rpl::start_with_next([=](const QString &name) {
|
||||||
|
_titlePeerText.setText(st::dialogsTextStyle, name);
|
||||||
|
_titlePeerTextOnline = false;
|
||||||
|
update();
|
||||||
|
}, _activeChatLifetime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateUnreadBadge();
|
updateUnreadBadge();
|
||||||
|
@ -930,7 +944,9 @@ void TopBarWidget::updateControlsGeometry() {
|
||||||
_rightTaken += _call->width();
|
_rightTaken += _call->width();
|
||||||
}
|
}
|
||||||
_search->moveToRight(_rightTaken, otherButtonsTop);
|
_search->moveToRight(_rightTaken, otherButtonsTop);
|
||||||
_rightTaken += _search->width() + st::topBarCallSkip;
|
if (!_search->isHidden()) {
|
||||||
|
_rightTaken += _search->width() + st::topBarCallSkip;
|
||||||
|
}
|
||||||
|
|
||||||
updateMembersShowArea();
|
updateMembersShowArea();
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1046,10 @@ void TopBarWidget::updateControlsVisibility() {
|
||||||
void TopBarWidget::updateMembersShowArea() {
|
void TopBarWidget::updateMembersShowArea() {
|
||||||
const auto membersShowAreaNeeded = [&] {
|
const auto membersShowAreaNeeded = [&] {
|
||||||
const auto peer = _activeChat.key.peer();
|
const auto peer = _activeChat.key.peer();
|
||||||
if (showSelectedState() || !peer) {
|
if (showSelectedState()
|
||||||
|
|| !peer
|
||||||
|
|| _activeChat.section == Section::ChatsList
|
||||||
|
|| _activeChat.key.topic()) {
|
||||||
return false;
|
return false;
|
||||||
} else if (const auto chat = peer->asChat()) {
|
} else if (const auto chat = peer->asChat()) {
|
||||||
return chat->amIn();
|
return chat->amIn();
|
||||||
|
@ -1194,9 +1213,25 @@ void TopBarWidget::updateInfoToggleActive() {
|
||||||
_infoToggle->setRippleColorOverride(rippleOverride);
|
_infoToggle->setRippleColorOverride(rippleOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TopBarWidget::trackOnlineOf(not_null<PeerData*> user) const {
|
||||||
|
const auto peer = _activeChat.key.peer();
|
||||||
|
if (!peer || _activeChat.key.topic() || !user->isUser()) {
|
||||||
|
return false;
|
||||||
|
} else if (peer->isUser()) {
|
||||||
|
return (peer == user);
|
||||||
|
} else if (const auto chat = peer->asChat()) {
|
||||||
|
return chat->participants.contains(user->asUser());
|
||||||
|
} else if (const auto channel = peer->asMegagroup()) {
|
||||||
|
return ranges::contains(
|
||||||
|
channel->mgInfo->lastParticipants,
|
||||||
|
not_null{ user->asUser() });
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void TopBarWidget::updateOnlineDisplay() {
|
void TopBarWidget::updateOnlineDisplay() {
|
||||||
const auto peer = _activeChat.key.peer();
|
const auto peer = _activeChat.key.peer();
|
||||||
if (!peer) {
|
if (!peer || _activeChat.key.topic()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,8 @@ private:
|
||||||
int availableWidth,
|
int availableWidth,
|
||||||
int outerWidth);
|
int outerWidth);
|
||||||
bool paintConnectingState(Painter &p, int left, int top, int outerWidth);
|
bool paintConnectingState(Painter &p, int left, int top, int outerWidth);
|
||||||
QRect getMembersShowAreaGeometry() const;
|
[[nodiscard]] QRect getMembersShowAreaGeometry() const;
|
||||||
|
[[nodiscard]] bool trackOnlineOf(not_null<PeerData*> user) const;
|
||||||
void updateMembersShowArea();
|
void updateMembersShowArea();
|
||||||
void updateOnlineDisplay();
|
void updateOnlineDisplay();
|
||||||
void updateOnlineDisplayTimer();
|
void updateOnlineDisplayTimer();
|
||||||
|
|
Loading…
Add table
Reference in a new issue