Change group call icon in top bar.

This commit is contained in:
John Preston 2020-12-07 17:15:45 +04:00
parent 8b0430a255
commit ba185d1f6f
6 changed files with 33 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -64,6 +64,7 @@ TopBarWidget::TopBarWidget(
, _delete(this, tr::lng_selected_delete(), st::defaultActiveButton)
, _back(this, st::historyTopBarBack)
, _call(this, st::topBarCall)
, _groupCall(this, st::topBarGroupCall)
, _search(this, st::topBarSearch)
, _infoToggle(this, st::topBarInfo)
, _menuToggle(this, st::topBarMenuToggle)
@ -83,8 +84,9 @@ TopBarWidget::TopBarWidget(
_delete->setClickedCallback([=] { _deleteSelection.fire({}); });
_delete->setWidthChangedCallback([=] { updateControlsGeometry(); });
_clear->setClickedCallback([=] { _clearSelection.fire({}); });
_call->setClickedCallback([=] { onCall(); });
_search->setClickedCallback([=] { onSearch(); });
_call->setClickedCallback([=] { call(); });
_groupCall->setClickedCallback([=] { groupCall(); });
_search->setClickedCallback([=] { search(); });
_menuToggle->setClickedCallback([=] { showMenu(); });
_infoToggle->setClickedCallback([=] { toggleInfoSection(); });
_back->addClickHandler([=] { backClicked(); });
@ -202,21 +204,27 @@ void TopBarWidget::refreshLang() {
InvokeQueued(this, [this] { updateControlsGeometry(); });
}
void TopBarWidget::onSearch() {
void TopBarWidget::search() {
if (_activeChat.key) {
_controller->content()->searchInChat(_activeChat.key);
}
}
void TopBarWidget::onCall() {
void TopBarWidget::call() {
if (const auto peer = _activeChat.key.peer()) {
if (const auto user = peer->asUser()) {
Core::App().calls().startOutgoingCall(user, false);
} else if (const auto megagroup = peer->asMegagroup()) {
}
}
}
void TopBarWidget::groupCall() {
if (const auto peer = _activeChat.key.peer()) {
if (const auto megagroup = peer->asMegagroup()) {
if (megagroup->amAnonymous()) {
Ui::ShowMultilineToast({
.text = tr::lng_group_call_no_anonymous(tr::now),
});
});
} else if (const auto call = megagroup->call()) {
Core::App().calls().joinGroupCall(megagroup, call->input());
} else {
@ -653,6 +661,7 @@ void TopBarWidget::updateControlsGeometry() {
_search->moveToRight(_rightTaken, otherButtonsTop);
_rightTaken += _search->width() + st::topBarCallSkip;
_call->moveToRight(_rightTaken, otherButtonsTop);
_groupCall->moveToRight(_rightTaken, otherButtonsTop);
_rightTaken += _call->width();
updateMembersShowArea();
@ -713,13 +722,20 @@ void TopBarWidget::updateControlsVisibility() {
if (const auto user = peer->asUser()) {
return session().serverConfig().phoneCallsEnabled.current()
&& user->hasCalls();
} else if (const auto megagroup = peer->asMegagroup()) {
return megagroup->canManageCall();
}
}
return false;
}();
_call->setVisible(historyMode && callsEnabled);
const auto groupCallsEnabled = [&] {
if (const auto peer = _activeChat.key.peer()) {
if (const auto megagroup = peer->asMegagroup()) {
return megagroup->canManageCall();
}
}
return false;
}();
_groupCall->setVisible(historyMode && groupCallsEnabled);
if (_membersShowArea) {
_membersShowArea->show();

View File

@ -95,8 +95,9 @@ private:
void selectedShowCallback();
void updateInfoToggleActive();
void onCall();
void onSearch();
void call();
void groupCall();
void search();
void showMenu();
void toggleInfoSection();
@ -144,6 +145,7 @@ private:
object_ptr<Ui::AbstractButton> _info = { nullptr };
object_ptr<Ui::IconButton> _call;
object_ptr<Ui::IconButton> _groupCall;
object_ptr<Ui::IconButton> _search;
object_ptr<Ui::IconButton> _infoToggle;
object_ptr<Ui::IconButton> _menuToggle;

View File

@ -763,6 +763,11 @@ topBarCall: IconButton(topBarSearch) {
icon: icon {{ "top_bar_call", menuIconFg }};
iconOver: icon {{ "top_bar_call", menuIconFgOver }};
}
topBarGroupCall: IconButton(topBarSearch) {
icon: icon {{ "top_bar_group_call", menuIconFg }};
iconOver: icon {{ "top_bar_group_call", menuIconFgOver }};
iconPosition: point(8px, 15px);
}
topBarInfo: IconButton(topBarSearch) {
icon: icon {{ "top_bar_profile", menuIconFg }};
iconOver: icon {{ "top_bar_profile", menuIconFgOver }};