mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
feat: quick admins & recent actions
Co-authored-by: c0re100 <corehusky@gmail.com>
This commit is contained in:
parent
a96f8d8ac3
commit
4e9443e200
9 changed files with 96 additions and 0 deletions
BIN
Telegram/Resources/icons/ayu/top_bar_admins.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_admins.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 648 B |
BIN
Telegram/Resources/icons/ayu/top_bar_admins@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_admins@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
Telegram/Resources/icons/ayu/top_bar_admins@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_admins@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 544 B |
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions@2x.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 901 B |
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions@3x.png
Normal file
BIN
Telegram/Resources/icons/ayu/top_bar_recent_actions@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -10,6 +10,7 @@
|
|||
using "ui/basic.style";
|
||||
using "ui/colors.palette";
|
||||
using "ui/widgets/widgets.style";
|
||||
using "info/info.style";
|
||||
|
||||
iconPreviewStroke: activeButtonBg;
|
||||
|
||||
|
@ -25,3 +26,33 @@ cpIconSize: 64px;
|
|||
recentStickersLimitPadding: margins(22px, 4px, 22px, 8px);
|
||||
imageViewPadding: margins(22px, 10px, 22px, 10px);
|
||||
imageViewInnerPadding: margins(16px, 16px, 16px, 16px);
|
||||
|
||||
topBarAdmins: IconButton {
|
||||
width: 40px;
|
||||
height: topBarHeight;
|
||||
|
||||
icon: icon {{ "ayu/top_bar_admins", menuIconFg }};
|
||||
iconOver: icon {{ "ayu/top_bar_admins", menuIconFgOver }};
|
||||
iconPosition: point(4px, 11px);
|
||||
|
||||
rippleAreaPosition: point(0px, 7px);
|
||||
rippleAreaSize: 40px;
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: windowBgOver;
|
||||
}
|
||||
}
|
||||
|
||||
topBarRecentActions: IconButton {
|
||||
width: 40px;
|
||||
height: topBarHeight;
|
||||
|
||||
icon: icon {{ "ayu/top_bar_recent_actions", menuIconFg }};
|
||||
iconOver: icon {{ "ayu/top_bar_recent_actions", menuIconFgOver }};
|
||||
iconPosition: point(4px, 11px);
|
||||
|
||||
rippleAreaPosition: point(0px, 7px);
|
||||
rippleAreaSize: 40px;
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: windowBgOver;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "history/admin_log/history_admin_log_section.h"
|
||||
#include "styles/style_ayu_styles.h"
|
||||
|
||||
|
||||
namespace HistoryView {
|
||||
|
@ -127,6 +130,8 @@ TopBarWidget::TopBarWidget(
|
|||
, _search(this, st::topBarSearch)
|
||||
, _infoToggle(this, st::topBarInfo)
|
||||
, _menuToggle(this, st::topBarMenuToggle)
|
||||
, _recentActions(this, st::topBarRecentActions)
|
||||
, _admins(this, st::topBarAdmins)
|
||||
, _titlePeerText(st::windowMinWidth / 3)
|
||||
, _onlineUpdater([=] { updateOnlineDisplay(); }) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
@ -149,6 +154,21 @@ TopBarWidget::TopBarWidget(
|
|||
_groupCall->setClickedCallback([=] { groupCall(); });
|
||||
_menuToggle->setClickedCallback([=] { showPeerMenu(); });
|
||||
_infoToggle->setClickedCallback([=] { toggleInfoSection(); });
|
||||
|
||||
_recentActions->setClickedCallback([=]
|
||||
{
|
||||
const auto channel = _activeChat.key.peer()->asChannel();
|
||||
_controller->showSection(std::make_shared<AdminLog::SectionMemento>(channel));
|
||||
});
|
||||
_admins->setClickedCallback([=]
|
||||
{
|
||||
ParticipantsBoxController::Start(
|
||||
controller,
|
||||
_activeChat.key.peer(),
|
||||
ParticipantsBoxController::Role::Admins
|
||||
);
|
||||
});
|
||||
|
||||
_back->setAcceptBoth();
|
||||
_back->addClickHandler([=](Qt::MouseButton) {
|
||||
InvokeQueued(_back.data(), [=] { backClicked(); });
|
||||
|
@ -1071,6 +1091,16 @@ void TopBarWidget::updateControlsGeometry() {
|
|||
_groupCall->moveToRight(_rightTaken, otherButtonsTop);
|
||||
_rightTaken += _call->width();
|
||||
}
|
||||
|
||||
_recentActions->moveToRight(_rightTaken, otherButtonsTop);
|
||||
if (!_recentActions->isHidden()) {
|
||||
_rightTaken += _recentActions->width();
|
||||
}
|
||||
_admins->moveToRight(_rightTaken, otherButtonsTop);
|
||||
if (!_admins->isHidden()) {
|
||||
_rightTaken += _admins->width();
|
||||
}
|
||||
|
||||
_search->moveToRight(_rightTaken, otherButtonsTop);
|
||||
if (!_search->isHidden()) {
|
||||
_rightTaken += _search->width() + st::topBarCallSkip;
|
||||
|
@ -1180,6 +1210,39 @@ void TopBarWidget::updateControlsVisibility() {
|
|||
&& !isOneColumn
|
||||
&& _controller->canShowThirdSection()
|
||||
&& !_chooseForReportReason);
|
||||
|
||||
const auto showRecentActions = [&]
|
||||
{
|
||||
if (_activeChat.section == Section::ChatsList) {
|
||||
return false;
|
||||
}
|
||||
if (const auto peer = _activeChat.key.peer()) {
|
||||
if (peer->isMegagroup() || peer->isChannel()) {
|
||||
const auto channel = peer->asChannel();
|
||||
return channel->hasAdminRights() || channel->amCreator();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
_recentActions->setVisible(showRecentActions);
|
||||
const auto showAdmins = [&]
|
||||
{
|
||||
if (_activeChat.section == Section::ChatsList) {
|
||||
return false;
|
||||
}
|
||||
if (const auto peer = _activeChat.key.peer()) {
|
||||
if (peer->isMegagroup()) {
|
||||
return true;
|
||||
}
|
||||
if (peer->isChannel()) {
|
||||
const auto channel = peer->asChannel();
|
||||
return channel->hasAdminRights() || channel->amCreator();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
_admins->setVisible(showAdmins);
|
||||
|
||||
const auto callsEnabled = [&] {
|
||||
if (const auto peer = _activeChat.key.peer()) {
|
||||
if (const auto user = peer->asUser()) {
|
||||
|
|
|
@ -232,6 +232,8 @@ private:
|
|||
object_ptr<Ui::IconButton> _search;
|
||||
object_ptr<Ui::IconButton> _infoToggle;
|
||||
object_ptr<Ui::IconButton> _menuToggle;
|
||||
object_ptr<Ui::IconButton> _recentActions;
|
||||
object_ptr<Ui::IconButton> _admins;
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
|
||||
object_ptr<TWidget> _membersShowArea = { nullptr };
|
||||
|
|
Loading…
Add table
Reference in a new issue