mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Implement nice confcall bar text.
This commit is contained in:
parent
ae1711a685
commit
180e663a43
2 changed files with 90 additions and 25 deletions
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_group_call.h"
|
#include "data/data_group_call.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
@ -580,28 +581,33 @@ void TopBar::initBlobsUnder(
|
||||||
|
|
||||||
void TopBar::subscribeToMembersChanges(not_null<GroupCall*> call) {
|
void TopBar::subscribeToMembersChanges(not_null<GroupCall*> call) {
|
||||||
const auto peer = call->peer();
|
const auto peer = call->peer();
|
||||||
peer->session().changes().peerFlagsValue(
|
const auto group = _groupCall.get();
|
||||||
peer,
|
const auto conference = group && group->conference();
|
||||||
Data::PeerUpdate::Flag::GroupCall
|
auto realValue = conference
|
||||||
) | rpl::map([=] {
|
? (rpl::single(group->conferenceCall().get()) | rpl::type_erased())
|
||||||
return peer->groupCall();
|
: peer->session().changes().peerFlagsValue(
|
||||||
}) | rpl::filter([=](Data::GroupCall *real) {
|
peer,
|
||||||
const auto call = _groupCall.get();
|
Data::PeerUpdate::Flag::GroupCall
|
||||||
return call && real && (real->id() == call->id());
|
) | rpl::map([=] {
|
||||||
}) | rpl::take(
|
return peer->groupCall();
|
||||||
1
|
}) | rpl::filter([=](Data::GroupCall *real) {
|
||||||
|
const auto call = _groupCall.get();
|
||||||
|
return call && real && (real->id() == call->id());
|
||||||
|
}) | rpl::take(1);
|
||||||
|
std::move(
|
||||||
|
realValue
|
||||||
) | rpl::before_next([=](not_null<Data::GroupCall*> real) {
|
) | rpl::before_next([=](not_null<Data::GroupCall*> real) {
|
||||||
real->titleValue() | rpl::start_with_next([=] {
|
real->titleValue() | rpl::start_with_next([=] {
|
||||||
updateInfoLabels();
|
updateInfoLabels();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}) | rpl::map([=](not_null<Data::GroupCall*> real) {
|
}) | rpl::map([=](not_null<Data::GroupCall*> real) {
|
||||||
|
|
||||||
return HistoryView::GroupCallBarContentByCall(
|
return HistoryView::GroupCallBarContentByCall(
|
||||||
real,
|
real,
|
||||||
st::groupCallTopBarUserpics.size);
|
st::groupCallTopBarUserpics.size);
|
||||||
}) | rpl::flatten_latest(
|
}) | rpl::flatten_latest(
|
||||||
) | rpl::filter([=](const Ui::GroupCallBarContent &content) {
|
) | rpl::filter([=](const Ui::GroupCallBarContent &content) {
|
||||||
if (_users.size() != content.users.size()) {
|
if (_users.size() != content.users.size()
|
||||||
|
|| (conference && _usersCount != content.count)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (auto i = 0, count = int(_users.size()); i != count; ++i) {
|
for (auto i = 0, count = int(_users.size()); i != count; ++i) {
|
||||||
|
@ -613,10 +619,14 @@ void TopBar::subscribeToMembersChanges(not_null<GroupCall*> call) {
|
||||||
return false;
|
return false;
|
||||||
}) | rpl::start_with_next([=](const Ui::GroupCallBarContent &content) {
|
}) | rpl::start_with_next([=](const Ui::GroupCallBarContent &content) {
|
||||||
_users = content.users;
|
_users = content.users;
|
||||||
|
_usersCount = content.count;
|
||||||
for (auto &user : _users) {
|
for (auto &user : _users) {
|
||||||
user.speaking = false;
|
user.speaking = false;
|
||||||
}
|
}
|
||||||
_userpics->update(_users, !isHidden());
|
_userpics->update(_users, !isHidden());
|
||||||
|
if (conference) {
|
||||||
|
updateInfoLabels();
|
||||||
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_userpics->widthValue(
|
_userpics->widthValue(
|
||||||
|
@ -655,14 +665,62 @@ void TopBar::setInfoLabels() {
|
||||||
} else if (const auto group = _groupCall.get()) {
|
} else if (const auto group = _groupCall.get()) {
|
||||||
const auto peer = group->peer();
|
const auto peer = group->peer();
|
||||||
const auto real = peer->groupCall();
|
const auto real = peer->groupCall();
|
||||||
const auto name = peer->name();
|
const auto connecting = _isGroupConnecting.current();
|
||||||
const auto text = _isGroupConnecting.current()
|
if (!group->conference()) {
|
||||||
? tr::lng_group_call_connecting(tr::now)
|
_shortInfoLabel.destroy();
|
||||||
: (real && real->id() == group->id() && !real->title().isEmpty())
|
}
|
||||||
? real->title()
|
if (!group->conference() || connecting) {
|
||||||
: name;
|
const auto name = peer->name();
|
||||||
_fullInfoLabel->setText(text);
|
const auto title = (real && real->id() == group->id())
|
||||||
_shortInfoLabel->setText(text);
|
? real->title()
|
||||||
|
: QString();
|
||||||
|
const auto text = _isGroupConnecting.current()
|
||||||
|
? tr::lng_group_call_connecting(tr::now)
|
||||||
|
: !title.isEmpty()
|
||||||
|
? title
|
||||||
|
: name;
|
||||||
|
_fullInfoLabel->setText(text);
|
||||||
|
if (_shortInfoLabel) {
|
||||||
|
_shortInfoLabel->setText(text);
|
||||||
|
}
|
||||||
|
} else if (!_usersCount
|
||||||
|
|| _users.empty()
|
||||||
|
|| (_users.size() == 1
|
||||||
|
&& _users.front().id == peer->session().userPeerId().value
|
||||||
|
&& _usersCount == 1)) {
|
||||||
|
_fullInfoLabel->setText(tr::lng_confcall_join_title(tr::now));
|
||||||
|
_shortInfoLabel->setText(tr::lng_confcall_join_title(tr::now));
|
||||||
|
} else {
|
||||||
|
const auto textWithUserpics = [&](int userpics) {
|
||||||
|
const auto other = std::max(_usersCount - userpics, 0);
|
||||||
|
auto names = QStringList();
|
||||||
|
for (const auto &entry : _users) {
|
||||||
|
const auto user = peer->owner().peer(PeerId(entry.id));
|
||||||
|
names.push_back(user->shortName());
|
||||||
|
if (names.size() >= userpics) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (other > 0) {
|
||||||
|
return tr::lng_forwarding_from(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
other,
|
||||||
|
lt_user,
|
||||||
|
names.join(u", "_q));
|
||||||
|
} else if (userpics > 1) {
|
||||||
|
return tr::lng_forwarding_from_two(
|
||||||
|
tr::now,
|
||||||
|
lt_user,
|
||||||
|
names.mid(0, userpics - 1).join(u", "_q),
|
||||||
|
lt_second_user,
|
||||||
|
names.back());
|
||||||
|
}
|
||||||
|
return names.back();
|
||||||
|
};
|
||||||
|
_fullInfoLabel->setText(textWithUserpics(int(_users.size())));
|
||||||
|
_shortInfoLabel->setText(textWithUserpics(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,10 +790,8 @@ void TopBar::updateControlsGeometry() {
|
||||||
height());
|
height());
|
||||||
|
|
||||||
auto fullWidth = _fullInfoLabel->textMaxWidth();
|
auto fullWidth = _fullInfoLabel->textMaxWidth();
|
||||||
auto showFull = (left + fullWidth + right <= width());
|
auto showFull = !_shortInfoLabel
|
||||||
_fullInfoLabel->setVisible(showFull);
|
|| (left + fullWidth + right <= width());
|
||||||
_shortInfoLabel->setVisible(!showFull);
|
|
||||||
|
|
||||||
auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) {
|
auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) {
|
||||||
auto minPadding = qMax(left, right);
|
auto minPadding = qMax(left, right);
|
||||||
auto infoWidth = infoLabel->textMaxWidth();
|
auto infoWidth = infoLabel->textMaxWidth();
|
||||||
|
@ -746,8 +802,13 @@ void TopBar::updateControlsGeometry() {
|
||||||
}
|
}
|
||||||
infoLabel->setGeometryToLeft(infoLeft, st::callBarLabelTop, infoWidth, st::callBarInfoLabel.style.font->height);
|
infoLabel->setGeometryToLeft(infoLeft, st::callBarLabelTop, infoWidth, st::callBarInfoLabel.style.font->height);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_fullInfoLabel->setVisible(showFull);
|
||||||
setInfoLabelGeometry(_fullInfoLabel);
|
setInfoLabelGeometry(_fullInfoLabel);
|
||||||
setInfoLabelGeometry(_shortInfoLabel);
|
if (_shortInfoLabel) {
|
||||||
|
_shortInfoLabel->setVisible(!showFull);
|
||||||
|
setInfoLabelGeometry(_shortInfoLabel);
|
||||||
|
}
|
||||||
|
|
||||||
_gradients.set_points(
|
_gradients.set_points(
|
||||||
QPointF(0, st::callBarHeight / 2),
|
QPointF(0, st::callBarHeight / 2),
|
||||||
|
|
|
@ -85,6 +85,7 @@ private:
|
||||||
|
|
||||||
bool _muted = false;
|
bool _muted = false;
|
||||||
std::vector<Ui::GroupCallUser> _users;
|
std::vector<Ui::GroupCallUser> _users;
|
||||||
|
int _usersCount = 0;
|
||||||
std::unique_ptr<Ui::GroupCallUserpics> _userpics;
|
std::unique_ptr<Ui::GroupCallUserpics> _userpics;
|
||||||
int _userpicsWidth = 0;
|
int _userpicsWidth = 0;
|
||||||
object_ptr<Ui::LabelSimple> _durationLabel;
|
object_ptr<Ui::LabelSimple> _durationLabel;
|
||||||
|
@ -99,6 +100,9 @@ private:
|
||||||
|
|
||||||
rpl::variable<bool> _isGroupConnecting = false;
|
rpl::variable<bool> _isGroupConnecting = false;
|
||||||
|
|
||||||
|
std::vector<not_null<PeerData*>> _conferenceFirstUsers;
|
||||||
|
int _conferenceUsersCount = 0;
|
||||||
|
|
||||||
QBrush _groupBrush;
|
QBrush _groupBrush;
|
||||||
anim::linear_gradients<BarState> _gradients;
|
anim::linear_gradients<BarState> _gradients;
|
||||||
Ui::Animations::Simple _switchStateAnimation;
|
Ui::Animations::Simple _switchStateAnimation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue