mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve topic three-dot menu.
This commit is contained in:
parent
03c08ad95f
commit
fba0f0c49b
4 changed files with 33 additions and 12 deletions
|
@ -223,6 +223,11 @@ bool ForumTopic::canWrite() const {
|
||||||
&& (!closed() || canToggleClosed());
|
&& (!closed() || canToggleClosed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ForumTopic::canSendPolls() const {
|
||||||
|
return canWrite()
|
||||||
|
&& !channel()->amRestricted(ChatRestriction::SendPolls);
|
||||||
|
}
|
||||||
|
|
||||||
bool ForumTopic::canEdit() const {
|
bool ForumTopic::canEdit() const {
|
||||||
return my() || channel()->canManageTopics();
|
return my() || channel()->canManageTopics();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool my() const;
|
[[nodiscard]] bool my() const;
|
||||||
[[nodiscard]] bool canWrite() const;
|
[[nodiscard]] bool canWrite() const;
|
||||||
|
[[nodiscard]] bool canSendPolls() const;
|
||||||
[[nodiscard]] bool canEdit() const;
|
[[nodiscard]] bool canEdit() const;
|
||||||
[[nodiscard]] bool canToggleClosed() const;
|
[[nodiscard]] bool canToggleClosed() const;
|
||||||
[[nodiscard]] bool canTogglePinned() const;
|
[[nodiscard]] bool canTogglePinned() const;
|
||||||
|
|
|
@ -1024,17 +1024,34 @@ void TopBarWidget::updateControlsVisibility() {
|
||||||
if (_unreadBadge) {
|
if (_unreadBadge) {
|
||||||
_unreadBadge->setVisible(!_chooseForReportReason);
|
_unreadBadge->setVisible(!_chooseForReportReason);
|
||||||
}
|
}
|
||||||
|
const auto topic = _activeChat.key.topic();
|
||||||
const auto section = _activeChat.section;
|
const auto section = _activeChat.section;
|
||||||
const auto historyMode = (section == Section::History);
|
const auto historyMode = (section == Section::History);
|
||||||
const auto hasPollsMenu = _activeChat.key.peer()
|
const auto hasPollsMenu = (_activeChat.key.peer()
|
||||||
&& _activeChat.key.peer()->canSendPolls();
|
&& _activeChat.key.peer()->canSendPolls())
|
||||||
|
|| (topic && topic->canSendPolls());
|
||||||
|
const auto hasTopicMenu = [&] {
|
||||||
|
if (!topic) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto empty = true;
|
||||||
|
const auto callback = [&](const Ui::Menu::MenuCallback::Args&) {
|
||||||
|
empty = false;
|
||||||
|
return (QAction*)nullptr;
|
||||||
|
};
|
||||||
|
Window::FillDialogsEntryMenu(
|
||||||
|
_controller,
|
||||||
|
_activeChat,
|
||||||
|
Ui::Menu::MenuCallback(callback));
|
||||||
|
return !empty;
|
||||||
|
}();
|
||||||
const auto hasMenu = !_activeChat.key.folder()
|
const auto hasMenu = !_activeChat.key.folder()
|
||||||
&& (section == Section::History
|
&& (section == Section::History
|
||||||
? true
|
? true
|
||||||
: (section == Section::Scheduled)
|
: (section == Section::Scheduled)
|
||||||
? hasPollsMenu
|
? hasPollsMenu
|
||||||
: (section == Section::Replies)
|
: (section == Section::Replies)
|
||||||
? (hasPollsMenu || _activeChat.key.topic())
|
? (hasPollsMenu || hasTopicMenu)
|
||||||
: (section == Section::ChatsList)
|
: (section == Section::ChatsList)
|
||||||
? (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
|
? (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
|
||||||
: false);
|
: false);
|
||||||
|
|
|
@ -937,7 +937,7 @@ void Filler::addManageChat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addCreatePoll() {
|
void Filler::addCreatePoll() {
|
||||||
if (!_peer->canSendPolls()) {
|
if (!(_topic ? _topic->canSendPolls() : _peer->canSendPolls())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
|
@ -1044,7 +1044,6 @@ void Filler::addCreateTopic() {
|
||||||
}
|
}
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto controller = _controller;
|
const auto controller = _controller;
|
||||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
|
||||||
_addAction(tr::lng_forum_create_topic(tr::now), [=] {
|
_addAction(tr::lng_forum_create_topic(tr::now), [=] {
|
||||||
if (const auto forum = peer->forum()) {
|
if (const auto forum = peer->forum()) {
|
||||||
controller->show(Box(
|
controller->show(Box(
|
||||||
|
@ -1053,6 +1052,7 @@ void Filler::addCreateTopic() {
|
||||||
forum->history()));
|
forum->history()));
|
||||||
}
|
}
|
||||||
}, &st::menuIconDiscussion);
|
}, &st::menuIconDiscussion);
|
||||||
|
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addViewAsMessages() {
|
void Filler::addViewAsMessages() {
|
||||||
|
@ -1064,7 +1064,6 @@ void Filler::addViewAsMessages() {
|
||||||
_addAction(tr::lng_forum_view_as_messages(tr::now), [=] {
|
_addAction(tr::lng_forum_view_as_messages(tr::now), [=] {
|
||||||
controller->showPeerHistory(peer->id);
|
controller->showPeerHistory(peer->id);
|
||||||
}, &st::menuIconViewReplies);
|
}, &st::menuIconViewReplies);
|
||||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addSearchTopics() {
|
void Filler::addSearchTopics() {
|
||||||
|
@ -1083,22 +1082,22 @@ void Filler::fillChatsListActions() {
|
||||||
if (!_peer || !_peer->isForum()) {
|
if (!_peer || !_peer->isForum()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addViewAsMessages();
|
addCreateTopic();
|
||||||
if (FillVideoChatMenu(_controller, _request, _addAction)) {
|
|
||||||
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
|
||||||
}
|
|
||||||
addInfo();
|
addInfo();
|
||||||
|
addViewAsMessages();
|
||||||
|
addManageChat();
|
||||||
|
FillVideoChatMenu(_controller, _request, _addAction);
|
||||||
addNewMembers();
|
addNewMembers();
|
||||||
const auto &all = _peer->forum()->topicsList()->indexed()->all();
|
const auto &all = _peer->forum()->topicsList()->indexed()->all();
|
||||||
if (all.size() > kTopicsSearchMinCount) {
|
if (all.size() > kTopicsSearchMinCount) {
|
||||||
addSearchTopics();
|
addSearchTopics();
|
||||||
}
|
}
|
||||||
|
_addAction(PeerMenuCallback::Args{ .isSeparator = true });
|
||||||
if (_peer->asChannel()->amIn()) {
|
if (_peer->asChannel()->amIn()) {
|
||||||
addLeaveChat();
|
addLeaveChat();
|
||||||
} else {
|
} else {
|
||||||
addJoinChat();
|
addJoinChat();
|
||||||
}
|
}
|
||||||
addCreateTopic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::fillContextMenuActions() {
|
void Filler::fillContextMenuActions() {
|
||||||
|
@ -1163,7 +1162,6 @@ void Filler::fillRepliesActions() {
|
||||||
if (_topic) {
|
if (_topic) {
|
||||||
addInfo();
|
addInfo();
|
||||||
addManageTopic();
|
addManageTopic();
|
||||||
addManageChat();
|
|
||||||
}
|
}
|
||||||
addCreatePoll();
|
addCreatePoll();
|
||||||
addToggleTopicClosed();
|
addToggleTopicClosed();
|
||||||
|
|
Loading…
Add table
Reference in a new issue