Add manage supergroup / channel box.

This commit is contained in:
John Preston 2017-11-08 20:45:30 +04:00
parent 7f8cdf85d5
commit 3998fad7ef
35 changed files with 438 additions and 44 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

View File

@ -649,6 +649,16 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_media_selected_link#one" = "{count} Shared link";
"lng_media_selected_link#other" = "{count} Shared links";
"lng_manage_group_title" = "Manage Group";
"lng_manage_channel_title" = "Manage Channel";
"lng_manage_group_info" = "Group Info";
"lng_manage_channel_info" = "Channel Info";
"lng_manage_peer_recent_actions" = "Recent Actions";
"lng_manage_peer_members" = "Members";
"lng_manage_peer_administrators" = "Administrators";
"lng_manage_peer_banned_users" = "Banned users";
"lng_manage_peer_restricted_users" = "Restricted users";
"lng_report_title" = "Report channel";
"lng_report_group_title" = "Report group";
"lng_report_bot_title" = "Report bot";

View File

@ -387,7 +387,8 @@ void PeerListRow::paintNameIcon(
Painter &p,
int x,
int y,
int outerWidth) {
int outerWidth,
bool selected) {
st::dialogsVerifiedIcon.paint(p, x, y, outerWidth);
}
@ -1060,7 +1061,8 @@ TimeMs PeerListContent::paintRow(Painter &p, TimeMs ms, RowIndex index) {
p,
namex + qMin(name.maxWidth(), namew),
_st.item.namePosition.y(),
width());
width(),
selected);
}
auto nameCheckedRatio = row->disabled() ? 0. : row->checkedRatio();
p.setPen(anim::pen(st::contactsNameFg, st::contactsNameCheckedFg, nameCheckedRatio));

View File

@ -91,7 +91,8 @@ public:
Painter &p,
int x,
int y,
int outerWidth);
int outerWidth,
bool selected);
virtual QSize actionSize() const {
return QSize();
}

View File

@ -0,0 +1,228 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#include "boxes/peers/manage_peer_box.h"
#include <rpl/combine.h>
#include "lang/lang_keys.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/labels.h"
#include "history/history_admin_log_section.h"
#include "window/window_controller.h"
#include "profile/profile_channel_controllers.h"
#include "info/profile/info_profile_button.h"
#include "info/profile/info_profile_icon.h"
#include "info/profile/info_profile_values.h"
#include "styles/style_boxes.h"
#include "styles/style_info.h"
namespace {
base::lambda<QString()> ManageBoxTitle(
not_null<ChannelData*> channel) {
return langFactory(channel->isMegagroup()
? lng_manage_group_title
: lng_manage_channel_title);
}
auto ToPositiveNumberString() {
return rpl::map([](int count) {
return count ? QString::number(count) : QString();
});
}
template <typename Callback>
Info::Profile::Button *AddButton(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> &&text,
Callback callback,
const style::icon &icon) {
auto button = parent->add(
object_ptr<Info::Profile::Button>(
parent,
std::move(text),
st::managePeerButton));
button->addClickHandler(std::forward<Callback>(callback));
Ui::CreateChild<Info::Profile::FloatingIcon>(
button,
icon,
st::managePeerButtonIconPosition);
return button;
}
template <typename Callback>
void AddButtonWithCount(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> &&text,
rpl::producer<QString> &&count,
Callback callback,
const style::icon &icon) {
auto button = AddButton(
parent,
std::move(text),
std::forward<Callback>(callback),
icon);
auto label = Ui::CreateChild<Ui::FlatLabel>(
button,
std::move(count),
st::managePeerButtonLabel);
rpl::combine(button->widthValue(), label->widthValue())
| rpl::start_with_next([label](int outerWidth, int width) {
label->moveToRight(
st::managePeerButtonLabelPosition.x(),
st::managePeerButtonLabelPosition.y(),
outerWidth);
}, label->lifetime());
}
bool HasRecentActions(not_null<ChannelData*> channel) {
return channel->hasAdminRights() || channel->amCreator();
}
void ShowRecentActions(
not_null<Window::Controller*> controller,
not_null<ChannelData*> channel) {
controller->showSection(
AdminLog::SectionMemento(channel),
Window::SectionShow());
}
void FillManageBox(
not_null<Window::Controller*> controller,
not_null<ChannelData*> channel,
not_null<Ui::VerticalLayout*> content) {
using Profile::ParticipantsBoxController;
auto isGroup = channel->isMegagroup();
if (channel->canEditInformation()) {
AddButton(
content,
Lang::Viewer(isGroup
? lng_manage_group_info
: lng_manage_channel_info),
[=] {
},
st::infoIconInformation);
}
if (HasRecentActions(channel)) {
AddButton(
content,
Lang::Viewer(lng_manage_peer_recent_actions),
[=] { ShowRecentActions(controller, channel); },
st::infoIconRecentActions);
}
if (channel->canViewMembers()) {
AddButtonWithCount(
content,
Lang::Viewer(lng_manage_peer_members),
Info::Profile::MembersCountValue(channel)
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
controller,
channel,
ParticipantsBoxController::Role::Members);
},
st::infoIconMembers);
}
if (channel->canViewAdmins()) {
AddButtonWithCount(
content,
Lang::Viewer(lng_manage_peer_administrators),
Info::Profile::AdminsCountValue(channel)
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
controller,
channel,
ParticipantsBoxController::Role::Admins);
},
st::infoIconAdministrators);
}
if (channel->canViewBanned()) {
AddButtonWithCount(
content,
Lang::Viewer(lng_manage_peer_restricted_users),
Info::Profile::RestrictedCountValue(channel)
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
controller,
channel,
ParticipantsBoxController::Role::Restricted);
},
st::infoIconRestrictedUsers);
AddButtonWithCount(
content,
Lang::Viewer(lng_manage_peer_banned_users),
Info::Profile::KickedCountValue(channel)
| ToPositiveNumberString(),
[=] {
ParticipantsBoxController::Start(
controller,
channel,
ParticipantsBoxController::Role::Kicked);
},
st::infoIconBlacklist);
}
}
} // namespace
ManagePeerBox::ManagePeerBox(
QWidget*,
not_null<ChannelData*> channel)
: _channel(channel) {
}
bool ManagePeerBox::Available(not_null<ChannelData*> channel) {
// canViewAdmins() is removed, because in supergroups it is
// always true and in channels it is equal to canViewBanned().
return channel->canViewMembers()
// || channel->canViewAdmins()
|| channel->canViewBanned()
|| channel->canEditInformation()
|| HasRecentActions(channel);
}
void ManagePeerBox::prepare() {
_channel->updateFull();
setTitle(ManageBoxTitle(_channel));
addButton(langFactory(lng_cancel), [this] { closeBox(); });
setupContent();
}
void ManagePeerBox::setupContent() {
auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
FillManageBox(controller(), _channel, content);
widthValue()
| rpl::start_with_next([=](int width) {
content->resizeToWidth(width);
}, content->lifetime());
content->heightValue()
| rpl::start_with_next([=](int height) {
setDimensions(st::boxWidth, height);
}, content->lifetime());
}

View File

@ -0,0 +1,39 @@
/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
Telegram Desktop is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
It is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "boxes/abstract_box.h"
class ManagePeerBox : public BoxContent {
public:
ManagePeerBox(QWidget*, not_null<ChannelData*> channel);
static bool Available(not_null<ChannelData*> channel);
protected:
void prepare() override;
private:
void setupContent();
not_null<ChannelData*> _channel;
};

View File

@ -245,16 +245,20 @@ using UpdateFlag = Notify::PeerUpdate::Flag;
NotifySettings globalNotifyAll, globalNotifyUsers, globalNotifyChats;
NotifySettingsPtr globalNotifyAllPtr = UnknownNotifySettings, globalNotifyUsersPtr = UnknownNotifySettings, globalNotifyChatsPtr = UnknownNotifySettings;
PeerClickHandler::PeerClickHandler(not_null<PeerData*> peer) : _peer(peer) {
PeerClickHandler::PeerClickHandler(not_null<PeerData*> peer)
: _peer(peer) {
}
void PeerClickHandler::onClick(Qt::MouseButton button) const {
if (button == Qt::LeftButton && App::main()) {
if (_peer && _peer->isChannel() && App::main()->historyPeer() != _peer) {
if (button == Qt::LeftButton && App::wnd()) {
auto controller = App::wnd()->controller();
if (_peer && _peer->isChannel() && controller->historyPeer.current() != _peer) {
if (!_peer->asChannel()->isPublic() && !_peer->asChannel()->amIn()) {
Ui::show(Box<InformBox>(lang((_peer->isMegagroup()) ? lng_group_not_accessible : lng_channel_not_accessible)));
Ui::show(Box<InformBox>(lang(_peer->isMegagroup()
? lng_group_not_accessible
: lng_channel_not_accessible)));
} else {
App::wnd()->controller()->showPeerHistory(
controller->showPeerHistory(
_peer,
Window::SectionShow::Way::Forward);
}
@ -264,15 +268,21 @@ void PeerClickHandler::onClick(Qt::MouseButton button) const {
}
}
PeerData::PeerData(const PeerId &id) : id(id), _colorIndex(peerColorIndex(id)) {
PeerData::PeerData(const PeerId &id)
: id(id)
, _colorIndex(peerColorIndex(id)) {
nameText.setText(st::msgNameStyle, QString(), _textNameOptions);
_userpicEmpty.set(_colorIndex, QString());
}
void PeerData::updateNameDelayed(const QString &newName, const QString &newNameOrPhone, const QString &newUsername) {
void PeerData::updateNameDelayed(
const QString &newName,
const QString &newNameOrPhone,
const QString &newUsername) {
if (name == newName) {
if (isUser()) {
if (asUser()->nameOrPhone == newNameOrPhone && asUser()->username == newUsername) {
if (asUser()->nameOrPhone == newNameOrPhone
&& asUser()->username == newUsername) {
return;
}
} else if (isChannel()) {

View File

@ -85,7 +85,7 @@ public:
Widget(QWidget *parent, not_null<Window::Controller*> controller, not_null<ChannelData*> channel);
not_null<ChannelData*> channel() const;
PeerData *peerForDialogs() const override {
PeerData *activePeer() const override {
return channel();
}

View File

@ -1731,6 +1731,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
if (peerId) {
_peer = App::peer(peerId);
_topBar->setHistoryPeer(_peer);
_channel = peerToChannel(_peer->id);
_canSendMessages = canSendMessages(_peer);
_tabbedSelector->setCurrentPeer(_peer);
@ -1843,6 +1844,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
emit historyShown(_history, _showAtMsgId);
controller()->historyPeer = _peer;
if (_peer) {
controller()->activePeer = _peer;
}
update();
}

View File

@ -313,6 +313,10 @@ infoIconMediaLink: icon {{ "info_media_link", infoIconFg }};
infoIconMediaGroup: icon {{ "info_common_groups", infoIconFg }};
infoIconMediaVoice: icon {{ "info_media_voice", infoIconFg }};
infoIconMediaRound: icon {{ "info_media_round", infoIconFg }};
infoIconRecentActions: icon {{ "info_recent_actions", infoIconFg }};
infoIconAdministrators: icon {{ "info_administrators", infoIconFg }};
infoIconBlacklist: icon {{ "info_blacklist", infoIconFg }};
infoIconRestrictedUsers: icon {{ "info_restricted_users", infoIconFg }};
infoInformationIconPosition: point(25px, 12px);
infoNotificationsIconPosition: point(20px, 5px);
infoSharedMediaIconPosition: point(20px, 24px);
@ -483,11 +487,21 @@ infoMembersCreatorIcon: icon {{
profileAdminStartFg,
point(4px, 3px)
}};
infoMembersCreatorIconOver: icon {{
"profile_admin_star",
profileAdminStarFgOver,
point(4px, 3px)
}};
infoMembersAdminIcon: icon {{
"profile_admin_star",
profileOtherAdminStarFg,
point(4px, 3px)
}};
infoMembersAdminIconOver: icon {{
"profile_admin_star",
profileOtherAdminStarFgOver,
point(4px, 3px)
}};
infoMembersRemoveIcon: icon {{
"simple_close",
menuIconFg
@ -522,3 +536,13 @@ infoCommonGroupsList: PeerList(infoMembersList) {
statusPosition: point(79px, 31px);
}
}
managePeerButton: InfoProfileButton(infoProfileButton) {
padding: margins(76px, 10px, 76px, 8px);
}
managePeerButtonIconPosition: infoSharedMediaButtonIconPosition;
managePeerButtonLabel: FlatLabel(defaultFlatLabel) {
textFg: windowActiveTextFg;
style: semiboldTextStyle;
}
managePeerButtonLabelPosition: point(25px, 10px);

View File

@ -56,8 +56,8 @@ void SectionWidget::init() {
}, _content->lifetime());
}
PeerData *SectionWidget::peerForDialogs() const {
return _content->peerForDialogs();
PeerData *SectionWidget::activePeer() const {
return _content->activePeer();
}
bool SectionWidget::hasTopBarShadow() const {

View File

@ -48,7 +48,7 @@ public:
Wrap wrap,
not_null<MoveMemento*> memento);
PeerData *peerForDialogs() const override;
PeerData *activePeer() const override;
bool hasTopBarShadow() const override;
QPixmap grabForShowAnimation(

View File

@ -88,7 +88,7 @@ public:
not_null<Memento*> memento);
not_null<PeerData*> peer() const;
PeerData *peerForDialogs() const override {
PeerData *activePeer() const override {
return peer();
}
Wrap wrap() const {

View File

@ -363,11 +363,16 @@ void MemberListRow::paintNameIcon(
Painter &p,
int x,
int y,
int outerWidth) {
int outerWidth,
bool selected) {
auto icon = [&] {
return (_type.rights == Rights::Admin)
? &st::infoMembersAdminIcon
: &st::infoMembersCreatorIcon;
? (selected
? &st::infoMembersAdminIconOver
: &st::infoMembersAdminIcon)
: (selected
? &st::infoMembersCreatorIconOver
: &st::infoMembersCreatorIcon);
}();
icon->paint(p, x, y, outerWidth);
}

View File

@ -58,7 +58,8 @@ public:
Painter &p,
int x,
int y,
int outerWidth) override;
int outerWidth,
bool selected) override;
not_null<UserData*> user() const {
return peer()->asUser();

View File

@ -202,6 +202,45 @@ rpl::producer<int> MembersCountValue(
Unexpected("User in MembersCountViewer().");
}
rpl::producer<int> AdminsCountValue(
not_null<ChannelData*> channel) {
using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue(
channel,
Flag::AdminsChanged | Flag::ChannelRightsChanged)
| rpl::map([channel] {
return channel->canViewAdmins()
? channel->adminsCount()
: 0;
});
}
rpl::producer<int> RestrictedCountValue(
not_null<ChannelData*> channel) {
using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue(
channel,
Flag::BannedUsersChanged | Flag::ChannelRightsChanged)
| rpl::map([channel] {
return channel->canViewBanned()
? channel->restrictedCount()
: 0;
});
}
rpl::producer<int> KickedCountValue(
not_null<ChannelData*> channel) {
using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue(
channel,
Flag::BannedUsersChanged | Flag::ChannelRightsChanged)
| rpl::map([channel] {
return channel->canViewBanned()
? channel->kickedCount()
: 0;
});
}
rpl::producer<int> SharedMediaCountValue(
not_null<PeerData*> peer,
PeerData *migrated,

View File

@ -75,6 +75,12 @@ rpl::producer<bool> AmInChannelValue(
not_null<ChannelData*> channel);
rpl::producer<int> MembersCountValue(
not_null<PeerData*> peer);
rpl::producer<int> AdminsCountValue(
not_null<ChannelData*> channel);
rpl::producer<int> RestrictedCountValue(
not_null<ChannelData*> channel);
rpl::producer<int> KickedCountValue(
not_null<ChannelData*> channel);
rpl::producer<int> SharedMediaCountValue(
not_null<PeerData*> peer,
PeerData *migrated,

View File

@ -271,7 +271,7 @@ MainWidget::MainWidget(
});
using namespace rpl::mappers;
_controller->historyPeer.value()
_controller->activePeer.value()
| rpl::map([](PeerData *peer) {
auto canWrite = peer
? Data::CanWriteValue(peer)
@ -2432,7 +2432,7 @@ void MainWidget::ui_showPeerHistory(
break;
}
}
if (auto historyPeer = _history->peer()) {
if (auto historyPeer = _controller->historyPeer.current()) {
if (way == Way::Forward && historyPeer->id == peerId) {
way = Way::ClearStack;
}
@ -2552,6 +2552,10 @@ void MainWidget::ui_showPeerHistory(
_dialogs->update();
}
if (!peerId) {
_controller->activePeer = nullptr;
}
checkFloatPlayerVisibility();
}
@ -2577,10 +2581,6 @@ void MainWidget::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPe
_dialogs->peerAfter(inPeer, inMsg, outPeer, outMsg);
}
PeerData *MainWidget::historyPeer() {
return _history->peer();
}
PeerData *MainWidget::peer() {
return _overview ? _overview->peer() : _history->peer();
}
@ -2962,6 +2962,10 @@ void MainWidget::showNewSection(
settingSection->showFast();
}
if (settingSection.data() == _mainSection.data()) {
_controller->activePeer = _mainSection->activePeer();
}
checkFloatPlayerVisibility();
orderWidgets();
}
@ -3530,8 +3534,11 @@ void MainWidget::updateThirdColumnToCurrentPeer(
} else {
Auth().data().setTabbedReplacedWithInfo(false);
if (!peer) {
_thirdSection.destroy();
_thirdShadow.destroy();
if (_thirdSection) {
_thirdSection.destroy();
_thirdShadow.destroy();
updateControlsGeometry();
}
} else if (Adaptive::ThreeColumn()
&& Auth().data().thirdSectionInfoEnabled()) {
switchInfoFast();

View File

@ -149,7 +149,6 @@ public:
void peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg);
void peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&outPeer, MsgId &outMsg);
PeerData *historyPeer();
PeerData *peer();
PeerData *activePeer();

View File

@ -177,7 +177,7 @@ public:
Widget(QWidget *parent, not_null<Window::Controller*> controller, not_null<UserData*> user);
not_null<UserData*> user() const;
PeerData *peerForDialogs() const override {
PeerData *activePeer() const override {
return user();
}

View File

@ -39,7 +39,7 @@ public:
Widget(QWidget *parent, not_null<Window::Controller*> controller, PeerData *peer);
PeerData *peer() const;
PeerData *peerForDialogs() const override {
PeerData *activePeer() const override {
return peer();
}

View File

@ -20,6 +20,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#pragma once
// rpl - reactive programming library
#include <rpl/lifetime.h>
#include <rpl/consumer.h>
#include <rpl/producer.h>

View File

@ -82,7 +82,7 @@ class SectionWidget : public AbstractSectionWidget {
public:
SectionWidget(QWidget *parent, not_null<Window::Controller*> controller);
virtual PeerData *peerForDialogs() const {
virtual PeerData *activePeer() const {
return nullptr;
}

View File

@ -99,7 +99,7 @@ TopBarWidget::TopBarWidget(
});
}
subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) {
if (App::main() && update.history->peer == App::main()->historyPeer()) {
if (update.history->peer == _controller->historyPeer.current()) {
rtlupdate(0, 0, width(), height());
}
});
@ -139,9 +139,8 @@ void TopBarWidget::onClearSelection() {
}
void TopBarWidget::onInfoClicked() {
auto p = App::main() ? App::main()->historyPeer() : nullptr;
if (p) {
_controller->showPeerInfo(p);
if (auto peer = _controller->historyPeer.current()) {
_controller->showPeerInfo(peer);
}
}
@ -205,7 +204,7 @@ void TopBarWidget::toggleInfoSection() {
&& (Auth().data().thirdSectionInfoEnabled()
|| Auth().data().tabbedReplacedWithInfo())) {
_controller->closeThirdSection();
} else if (auto peer = App::main()->historyPeer()) {
} else if (auto peer = _controller->historyPeer.current()) {
if (_controller->canShowThirdSection()) {
Auth().data().setThirdSectionInfoEnabled(true);
Auth().saveDataDelayed();
@ -289,7 +288,7 @@ void TopBarWidget::paintUnreadCounter(Painter &p, int outerWidth) {
auto fullCounter = App::histories().unreadBadge() + (Global::IncludeMuted() ? 0 : mutedCount);
// Do not include currently shown chat in the top bar unread counter.
if (auto historyShown = App::historyLoaded(App::main()->historyPeer())) {
if (auto historyShown = App::historyLoaded(App::wnd()->controller()->historyPeer.current())) {
auto shownUnreadCount = historyShown->unreadCount();
if (!historyShown->mute() || Global::IncludeMuted()) {
fullCounter -= shownUnreadCount;
@ -370,7 +369,6 @@ void TopBarWidget::animationFinished() {
}
void TopBarWidget::updateControlsVisibility() {
auto historyPeer = App::main() ? App::main()->historyPeer() : nullptr;
auto overviewPeer = App::main() ? App::main()->overviewPeer() : nullptr;
_clearSelection->show();
@ -378,9 +376,9 @@ void TopBarWidget::updateControlsVisibility() {
_forward->setVisible(_canForward);
_mediaType->setVisible(App::main() ? App::main()->showMediaTypeSwitch() : false);
if (historyPeer && !overviewPeer) {
if (_historyPeer && !overviewPeer) {
if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) {
_info->setPeer(historyPeer);
_info->setPeer(_historyPeer);
_info->show();
_menuToggle->hide();
_menu.destroy();
@ -392,7 +390,7 @@ void TopBarWidget::updateControlsVisibility() {
_infoToggle->setVisible(!Adaptive::OneColumn()
&& _controller->canShowThirdSection());
auto callsEnabled = false;
if (auto user = historyPeer->asUser()) {
if (auto user = _historyPeer->asUser()) {
callsEnabled = Global::PhoneCallsEnabled() && user->hasCalls();
}
_call->setVisible(callsEnabled);

View File

@ -52,6 +52,9 @@ public:
void updateMembersShowArea();
Ui::RoundButton *mediaTypeButton();
void setHistoryPeer(not_null<PeerData*> historyPeer) {
_historyPeer = historyPeer;
}
static void paintUnreadCounter(Painter &p, int outerWidth);
@ -83,6 +86,7 @@ private:
int countSelectedButtonsTop(float64 selectedShown);
not_null<Window::Controller*> _controller;
PeerData *_historyPeer = nullptr;
int _selectedCount = 0;
bool _canDelete = false;

View File

@ -90,8 +90,13 @@ public:
// This is needed while we have one HistoryWidget and one TopBarWidget
// for all histories we show in a window. Once each history is shown
// in its own HistoryWidget with its own TopBarWidget this can be removed.
//
// Also used in the Info::Profile to toggle Send Message button.
rpl::variable<PeerData*> historyPeer;
// This is used for auto-switch in third column Info::Profile.
rpl::variable<PeerData*> activePeer;
void enableGifPauseReason(GifPauseReason reason);
void disableGifPauseReason(GifPauseReason reason);
base::Observable<void> &gifPauseLevelChanged() {

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "boxes/add_contact_box.h"
#include "boxes/report_box.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/peers/manage_peer_box.h"
#include "auth_session.h"
#include "apiwrap.h"
#include "mainwidget.h"
@ -153,7 +154,7 @@ Filler::Filler(
bool Filler::showInfo() {
if (_source == PeerMenuSource::Profile) {
return false;
} else if (_controller->historyPeer.current() != _peer) {
} else if (_controller->activePeer.current() != _peer) {
return true;
} else if (!Adaptive::ThreeColumn()) {
return true;
@ -377,7 +378,14 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
void Filler::addChannelActions(not_null<ChannelData*> channel) {
if (_source != PeerMenuSource::ChatsList) {
//_addAction(manage);
if (ManagePeerBox::Available(channel)) {
auto text = lang(channel->isMegagroup()
? lng_manage_group_title
: lng_manage_channel_title);
_addAction(text, [channel] {
Ui::show(Box<ManagePeerBox>(channel));
});
}
if (channel->canAddMembers()) {
_addAction(
lang(lng_channel_add_members),

View File

@ -34,6 +34,8 @@
<(src_loc)/base/virtual_method.h
<(src_loc)/base/weak_unique_ptr.h
<(src_loc)/base/zlib_help.h
<(src_loc)/boxes/peers/manage_peer_box.cpp
<(src_loc)/boxes/peers/manage_peer_box.h
<(src_loc)/boxes/about_box.cpp
<(src_loc)/boxes/about_box.h
<(src_loc)/boxes/abstract_box.cpp