mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show requests / group call / report in forums.
This commit is contained in:
parent
b92b8e56cb
commit
5314833c82
5 changed files with 148 additions and 10 deletions
|
@ -13,10 +13,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_entry.h"
|
||||
#include "history/history.h"
|
||||
#include "history/view/history_view_top_bar_widget.h"
|
||||
#include "history/view/history_view_contact_status.h"
|
||||
#include "history/view/history_view_requests_bar.h"
|
||||
#include "history/view/history_view_group_call_bar.h"
|
||||
#include "boxes/peers/edit_peer_requests_box.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/input_fields.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "ui/chat/requests_bar.h"
|
||||
#include "ui/chat/group_call_bar.h"
|
||||
#include "ui/controls/download_bar.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/ui_utility.h"
|
||||
|
@ -644,6 +650,18 @@ void Widget::updateControlsVisibility(bool fast) {
|
|||
_searchControls->setVisible(!_openedFolder && !_openedForum);
|
||||
if (_openedFolder || _openedForum) {
|
||||
_folderTopBar->show();
|
||||
if (_forumTopShadow) {
|
||||
_forumTopShadow->show();
|
||||
}
|
||||
if (_forumGroupCallBar) {
|
||||
_forumGroupCallBar->show();
|
||||
}
|
||||
if (_forumRequestsBar) {
|
||||
_forumRequestsBar->show();
|
||||
}
|
||||
if (_forumReportBar) {
|
||||
_forumReportBar->show();
|
||||
}
|
||||
} else {
|
||||
if (hasFocus()) {
|
||||
_filter->setFocus();
|
||||
|
@ -674,7 +692,7 @@ void Widget::changeOpenedSubsection(
|
|||
_cacheUnder = grabForFolderSlideAnimation();
|
||||
}
|
||||
change();
|
||||
refreshFolderTopBar();
|
||||
refreshTopBars();
|
||||
updateControlsVisibility(true);
|
||||
if (animated == anim::type::normal) {
|
||||
_connecting->setForceHidden(true);
|
||||
|
@ -701,7 +719,7 @@ void Widget::changeOpenedForum(ChannelData *forum, anim::type animated) {
|
|||
}, (forum != nullptr), animated);
|
||||
}
|
||||
|
||||
void Widget::refreshFolderTopBar() {
|
||||
void Widget::refreshTopBars() {
|
||||
if (_openedFolder || _openedForum) {
|
||||
if (!_folderTopBar) {
|
||||
_folderTopBar.create(this, controller());
|
||||
|
@ -720,6 +738,68 @@ void Widget::refreshFolderTopBar() {
|
|||
} else {
|
||||
_folderTopBar.destroy();
|
||||
}
|
||||
if (_openedForum) {
|
||||
_openedForum->updateFull();
|
||||
|
||||
_forumReportBar = std::make_unique<HistoryView::ContactStatus>(
|
||||
controller(),
|
||||
this,
|
||||
_openedForum);
|
||||
_forumRequestsBar = std::make_unique<Ui::RequestsBar>(
|
||||
this,
|
||||
HistoryView::RequestsBarContentByPeer(
|
||||
_openedForum,
|
||||
st::historyRequestsUserpics.size));
|
||||
_forumGroupCallBar = std::make_unique<Ui::GroupCallBar>(
|
||||
this,
|
||||
HistoryView::GroupCallBarContentByPeer(
|
||||
_openedForum,
|
||||
st::historyGroupCallUserpics.size),
|
||||
Core::App().appDeactivatedValue());
|
||||
_forumTopShadow = std::make_unique<Ui::PlainShadow>(this);
|
||||
|
||||
_forumRequestsBar->barClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
RequestsBoxController::Start(controller(), _openedForum);
|
||||
}, _forumRequestsBar->lifetime());
|
||||
|
||||
rpl::merge(
|
||||
_forumGroupCallBar->barClicks(),
|
||||
_forumGroupCallBar->joinClicks()
|
||||
) | rpl::start_with_next([=] {
|
||||
if (_openedForum->groupCall()) {
|
||||
controller()->startOrJoinGroupCall(_openedForum);
|
||||
}
|
||||
}, _forumGroupCallBar->lifetime());
|
||||
|
||||
if (_a_show.animating()) {
|
||||
_forumTopShadow->hide();
|
||||
_forumGroupCallBar->hide();
|
||||
_forumRequestsBar->hide();
|
||||
_forumReportBar->bar().hide();
|
||||
} else {
|
||||
_forumTopShadow->show();
|
||||
_forumGroupCallBar->show();
|
||||
_forumRequestsBar->show();
|
||||
_forumReportBar->show();
|
||||
_forumGroupCallBar->finishAnimating();
|
||||
_forumRequestsBar->finishAnimating();
|
||||
}
|
||||
|
||||
rpl::combine(
|
||||
_forumGroupCallBar->heightValue(),
|
||||
_forumRequestsBar->heightValue(),
|
||||
_forumReportBar->bar().heightValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
updateControlsGeometry();
|
||||
}, _forumRequestsBar->lifetime());
|
||||
} else {
|
||||
_forumTopShadow = nullptr;
|
||||
_forumGroupCallBar = nullptr;
|
||||
_forumRequestsBar = nullptr;
|
||||
_forumReportBar = nullptr;
|
||||
updateControlsGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap Widget::grabForFolderSlideAnimation() {
|
||||
|
@ -901,6 +981,18 @@ void Widget::startSlideAnimation() {
|
|||
if (_folderTopBar) {
|
||||
_folderTopBar->hide();
|
||||
}
|
||||
if (_forumTopShadow) {
|
||||
_forumTopShadow->hide();
|
||||
}
|
||||
if (_forumGroupCallBar) {
|
||||
_forumGroupCallBar->hide();
|
||||
}
|
||||
if (_forumRequestsBar) {
|
||||
_forumRequestsBar->hide();
|
||||
}
|
||||
if (_forumReportBar) {
|
||||
_forumReportBar->bar().hide();
|
||||
}
|
||||
|
||||
if (_showDirection == Window::SlideDirection::FromLeft) {
|
||||
std::swap(_cacheUnder, _cacheOver);
|
||||
|
@ -1792,7 +1884,31 @@ void Widget::updateControlsGeometry() {
|
|||
right -= _jumpToDate->width(); _jumpToDate->moveToLeft(right, _filter->y());
|
||||
right -= _chooseFromUser->width(); _chooseFromUser->moveToLeft(right, _filter->y());
|
||||
|
||||
auto scrollTop = filterAreaTop + filterAreaHeight;
|
||||
if (_forumTopShadow) {
|
||||
_forumTopShadow->setGeometry(
|
||||
0,
|
||||
filterAreaTop + filterAreaHeight,
|
||||
width(),
|
||||
st::lineWidth);
|
||||
}
|
||||
const auto forumGroupCallTop = filterAreaTop + filterAreaHeight;
|
||||
if (_forumGroupCallBar) {
|
||||
_forumGroupCallBar->move(0, forumGroupCallTop);
|
||||
_forumGroupCallBar->resizeToWidth(width());
|
||||
}
|
||||
const auto forumRequestsTop = forumGroupCallTop
|
||||
+ (_forumGroupCallBar ? _forumGroupCallBar->height() : 0);
|
||||
if (_forumRequestsBar) {
|
||||
_forumRequestsBar->move(0, forumRequestsTop);
|
||||
_forumRequestsBar->resizeToWidth(width());
|
||||
}
|
||||
const auto forumReportTop = forumRequestsTop
|
||||
+ (_forumRequestsBar ? _forumRequestsBar->height() : 0);
|
||||
if (_forumReportBar) {
|
||||
_forumReportBar->bar().move(0, forumReportTop);
|
||||
}
|
||||
auto scrollTop = forumReportTop
|
||||
+ (_forumReportBar ? _forumReportBar->bar().height() : 0);
|
||||
auto newScrollTop = _scroll->scrollTop() + _topDelta;
|
||||
auto scrollHeight = height() - scrollTop;
|
||||
const auto putBottomButton = [&](auto &button) {
|
||||
|
|
|
@ -26,6 +26,7 @@ class Session;
|
|||
|
||||
namespace HistoryView {
|
||||
class TopBarWidget;
|
||||
class ContactStatus;
|
||||
} // namespace HistoryView
|
||||
|
||||
namespace Ui {
|
||||
|
@ -35,7 +36,10 @@ class DropdownMenu;
|
|||
class FlatButton;
|
||||
class InputField;
|
||||
class CrossButton;
|
||||
class PlainShadow;
|
||||
class DownloadBar;
|
||||
class GroupCallBar;
|
||||
class RequestsBar;
|
||||
template <typename Widget>
|
||||
class FadeWrapScaled;
|
||||
} // namespace Ui
|
||||
|
@ -152,7 +156,7 @@ private:
|
|||
void updateJumpToDateVisibility(bool fast = false);
|
||||
void updateSearchFromVisibility(bool fast = false);
|
||||
void updateControlsGeometry();
|
||||
void refreshFolderTopBar();
|
||||
void refreshTopBars();
|
||||
void checkUpdateStatus();
|
||||
void changeOpenedSubsection(
|
||||
FnMut<void()> change,
|
||||
|
@ -196,6 +200,12 @@ private:
|
|||
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _jumpToDate;
|
||||
object_ptr<Ui::CrossButton> _cancelSearch;
|
||||
object_ptr<Ui::IconButton> _lockUnlock;
|
||||
|
||||
std::unique_ptr<Ui::PlainShadow> _forumTopShadow;
|
||||
std::unique_ptr<Ui::GroupCallBar> _forumGroupCallBar;
|
||||
std::unique_ptr<Ui::RequestsBar> _forumRequestsBar;
|
||||
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
||||
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
QPointer<InnerWidget> _inner;
|
||||
class BottomButton;
|
||||
|
|
|
@ -105,16 +105,22 @@ rpl::producer<Ui::RequestsBarContent> RequestsBarContentByPeer(
|
|||
auto lifetime = rpl::lifetime();
|
||||
auto state = lifetime.make_state<State>(peer);
|
||||
|
||||
const auto pushNext = [=] {
|
||||
if (state->pushScheduled
|
||||
|| (std::min(state->current.count, kRecentRequestsLimit)
|
||||
!= state->users.size())) {
|
||||
const auto pushNext = [=](bool now = false) {
|
||||
if (std::min(state->current.count, kRecentRequestsLimit)
|
||||
!= state->users.size()) {
|
||||
return;
|
||||
} else if (now) {
|
||||
state->pushScheduled = false;
|
||||
consumer.put_next_copy(state->current);
|
||||
} else if (state->pushScheduled) {
|
||||
return;
|
||||
}
|
||||
state->pushScheduled = true;
|
||||
crl::on_main(&state->guard, [=] {
|
||||
state->pushScheduled = false;
|
||||
consumer.put_next_copy(state->current);
|
||||
if (state->pushScheduled) {
|
||||
state->pushScheduled = false;
|
||||
consumer.put_next_copy(state->current);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -172,6 +178,7 @@ rpl::producer<Ui::RequestsBarContent> RequestsBarContentByPeer(
|
|||
}
|
||||
}, lifetime);
|
||||
|
||||
pushNext(true);
|
||||
return lifetime;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1382,6 +1382,10 @@ void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
|
|||
}
|
||||
}
|
||||
|
||||
void SessionController::startOrJoinGroupCall(not_null<PeerData*> peer) {
|
||||
startOrJoinGroupCall(peer, {});
|
||||
}
|
||||
|
||||
void SessionController::startOrJoinGroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
Calls::StartGroupCallArgs args) {
|
||||
|
|
|
@ -401,6 +401,7 @@ public:
|
|||
[[nodiscard]] bool canShowSeparateWindow(not_null<PeerData*> peer) const;
|
||||
void showPeer(not_null<PeerData*> peer, MsgId msgId = ShowAtUnreadMsgId);
|
||||
|
||||
void startOrJoinGroupCall(not_null<PeerData*> peer);
|
||||
void startOrJoinGroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
Calls::StartGroupCallArgs args);
|
||||
|
|
Loading…
Add table
Reference in a new issue