mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved inaccessible groups in box for user's own groups to sub-list.
Fixed #27729.
This commit is contained in:
parent
d1be7c1ff7
commit
abe83ccb8f
2 changed files with 43 additions and 9 deletions
|
@ -151,6 +151,7 @@ menuIconAsTopics: icon {{ "menu/mode_topics", menuIconColor }};
|
||||||
menuIconAsMessages: icon {{ "menu/mode_messages", menuIconColor }};
|
menuIconAsMessages: icon {{ "menu/mode_messages", menuIconColor }};
|
||||||
menuIconTagFilter: icon{{ "menu/tag_filter", menuIconColor }};
|
menuIconTagFilter: icon{{ "menu/tag_filter", menuIconColor }};
|
||||||
menuIconTagRename: icon{{ "menu/tag_rename", menuIconColor }};
|
menuIconTagRename: icon{{ "menu/tag_rename", menuIconColor }};
|
||||||
|
menuIconGroupsHide: icon {{ "menu/hide_members", menuIconColor }};
|
||||||
|
|
||||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||||
|
|
|
@ -27,10 +27,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/rect.h"
|
#include "ui/rect.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/tooltip.h"
|
#include "ui/widgets/tooltip.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_chat.h" // popupMenuExpandedSeparator
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_info.h" // infoTopBarMenu
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
|
@ -177,7 +178,9 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
||||||
const auto count = c ? c->membersCount() : g->count;
|
const auto count = c ? c->membersCount() : g->count;
|
||||||
_status.setText(
|
_status.setText(
|
||||||
st::defaultTextStyle,
|
st::defaultTextStyle,
|
||||||
!p->username().isEmpty()
|
(g && !g->amIn())
|
||||||
|
? tr::lng_chat_status_unaccessible(tr::now)
|
||||||
|
: !p->username().isEmpty()
|
||||||
? ('@' + p->username())
|
? ('@' + p->username())
|
||||||
: (count > 0)
|
: (count > 0)
|
||||||
? ((c && !c->isMegagroup())
|
? ((c && !c->isMegagroup())
|
||||||
|
@ -219,10 +222,11 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto add = [&](not_null<PeerData*> peer) {
|
const auto add = [&](
|
||||||
const auto row = box->addRow(
|
not_null<PeerData*> peer,
|
||||||
object_ptr<Button>(box, rpl::single(QString())),
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
{});
|
const auto row = container->add(
|
||||||
|
object_ptr<Button>(container, rpl::single(QString())));
|
||||||
row->setPeer(peer);
|
row->setPeer(peer);
|
||||||
row->setClickedCallback([=] {
|
row->setClickedCallback([=] {
|
||||||
controller->showPeerHistory(peer);
|
controller->showPeerHistory(peer);
|
||||||
|
@ -233,8 +237,16 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
||||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto inaccessibleWrap = box->verticalLayout()->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
box->verticalLayout(),
|
||||||
|
object_ptr<Ui::VerticalLayout>(box->verticalLayout())));
|
||||||
|
inaccessibleWrap->toggle(false, anim::type::instant);
|
||||||
|
|
||||||
const auto &data = controller->session().data();
|
const auto &data = controller->session().data();
|
||||||
auto ids = std::vector<PeerId>();
|
auto ids = std::vector<PeerId>();
|
||||||
|
auto inaccessibleIds = std::vector<PeerId>();
|
||||||
|
|
||||||
if (chats) {
|
if (chats) {
|
||||||
data.enumerateGroups([&](not_null<PeerData*> peer) {
|
data.enumerateGroups([&](not_null<PeerData*> peer) {
|
||||||
peer = peer->migrateToOrMe();
|
peer = peer->migrateToOrMe();
|
||||||
|
@ -244,8 +256,13 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
||||||
const auto c = peer->asChannel();
|
const auto c = peer->asChannel();
|
||||||
const auto g = peer->asChat();
|
const auto g = peer->asChat();
|
||||||
if ((c && c->amCreator()) || (g && g->amCreator())) {
|
if ((c && c->amCreator()) || (g && g->amCreator())) {
|
||||||
|
if (g && !g->amIn()) {
|
||||||
|
inaccessibleIds.push_back(peer->id);
|
||||||
|
add(peer, inaccessibleWrap->entity());
|
||||||
|
} else {
|
||||||
|
add(peer, box->verticalLayout());
|
||||||
|
}
|
||||||
ids.push_back(peer->id);
|
ids.push_back(peer->id);
|
||||||
add(peer);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,13 +270,29 @@ not_null<Ui::SettingsButton*> AddMyChannelsBox(
|
||||||
if (channel->amCreator()
|
if (channel->amCreator()
|
||||||
&& !ranges::contains(ids, channel->id)) {
|
&& !ranges::contains(ids, channel->id)) {
|
||||||
ids.push_back(channel->id);
|
ids.push_back(channel->id);
|
||||||
add(channel);
|
add(channel, box->verticalLayout());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (ids.empty()) {
|
if (ids.empty()) {
|
||||||
addIcon(box);
|
addIcon(box);
|
||||||
}
|
}
|
||||||
|
if (!inaccessibleIds.empty()) {
|
||||||
|
const auto icon = [=] {
|
||||||
|
return !inaccessibleWrap->toggled()
|
||||||
|
? &st::menuIconGroups
|
||||||
|
: &st::menuIconGroupsHide;
|
||||||
|
};
|
||||||
|
auto button = object_ptr<Ui::IconButton>(box, st::backgroundSwitchToDark);
|
||||||
|
button->setClickedCallback([=, raw = button.data()] {
|
||||||
|
inaccessibleWrap->toggle(
|
||||||
|
!inaccessibleWrap->toggled(),
|
||||||
|
anim::type::normal);
|
||||||
|
raw->setIconOverride(icon(), icon());
|
||||||
|
});
|
||||||
|
button->setIconOverride(icon(), icon());
|
||||||
|
box->addTopButton(std::move(button));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using Menu = base::unique_qptr<Ui::PopupMenu>;
|
using Menu = base::unique_qptr<Ui::PopupMenu>;
|
||||||
|
|
Loading…
Add table
Reference in a new issue