mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow mute for me even force-muted participants.
This commit is contained in:
parent
ce091b0b63
commit
4080fa9bdc
5 changed files with 62 additions and 42 deletions
|
@ -434,6 +434,7 @@ PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
||||||
PeerListRow::PeerListRow(not_null<PeerData*> peer, PeerListRowId id)
|
PeerListRow::PeerListRow(not_null<PeerData*> peer, PeerListRowId id)
|
||||||
: _id(id)
|
: _id(id)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
|
, _hidden(false)
|
||||||
, _initialized(false)
|
, _initialized(false)
|
||||||
, _isSearchResult(false)
|
, _isSearchResult(false)
|
||||||
, _isSavedMessagesChat(false)
|
, _isSavedMessagesChat(false)
|
||||||
|
@ -442,6 +443,7 @@ PeerListRow::PeerListRow(not_null<PeerData*> peer, PeerListRowId id)
|
||||||
|
|
||||||
PeerListRow::PeerListRow(PeerListRowId id)
|
PeerListRow::PeerListRow(PeerListRowId id)
|
||||||
: _id(id)
|
: _id(id)
|
||||||
|
, _hidden(false)
|
||||||
, _initialized(false)
|
, _initialized(false)
|
||||||
, _isSearchResult(false)
|
, _isSearchResult(false)
|
||||||
, _isSavedMessagesChat(false)
|
, _isSavedMessagesChat(false)
|
||||||
|
|
|
@ -243,7 +243,7 @@ private:
|
||||||
base::flat_set<QChar> _nameFirstLetters;
|
base::flat_set<QChar> _nameFirstLetters;
|
||||||
int _absoluteIndex = -1;
|
int _absoluteIndex = -1;
|
||||||
State _disabledState = State::Active;
|
State _disabledState = State::Active;
|
||||||
bool _hidden = false;
|
bool _hidden : 1;
|
||||||
bool _initialized : 1;
|
bool _initialized : 1;
|
||||||
bool _isSearchResult : 1;
|
bool _isSearchResult : 1;
|
||||||
bool _isSavedMessagesChat : 1;
|
bool _isSavedMessagesChat : 1;
|
||||||
|
|
|
@ -1299,16 +1299,14 @@ void Members::Controller::addMuteActionsToContextMenu(
|
||||||
not_null<PeerData*> participantPeer,
|
not_null<PeerData*> participantPeer,
|
||||||
bool participantIsCallAdmin,
|
bool participantIsCallAdmin,
|
||||||
not_null<Row*> row) {
|
not_null<Row*> row) {
|
||||||
const auto muteString = [=] {
|
const auto muteUnmuteString = [=](bool muted, bool mutedByMe) {
|
||||||
return (_peer->canManageGroupCall()
|
return (muted && _peer->canManageGroupCall())
|
||||||
? tr::lng_group_call_context_mute
|
? tr::lng_group_call_context_unmute(tr::now)
|
||||||
: tr::lng_group_call_context_mute_for_me)(tr::now);
|
: mutedByMe
|
||||||
};
|
? tr::lng_group_call_context_unmute_for_me(tr::now)
|
||||||
|
: _peer->canManageGroupCall()
|
||||||
const auto unmuteString = [=] {
|
? tr::lng_group_call_context_mute(tr::now)
|
||||||
return (_peer->canManageGroupCall()
|
: tr::lng_group_call_context_mute_for_me(tr::now);
|
||||||
? tr::lng_group_call_context_unmute
|
|
||||||
: tr::lng_group_call_context_unmute_for_me)(tr::now);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto toggleMute = crl::guard(this, [=](bool mute, bool local) {
|
const auto toggleMute = crl::guard(this, [=](bool mute, bool local) {
|
||||||
|
@ -1329,13 +1327,13 @@ void Members::Controller::addMuteActionsToContextMenu(
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto muteState = row->state();
|
const auto muteState = row->state();
|
||||||
const auto isMuted = (muteState == Row::State::Muted)
|
const auto muted = (muteState == Row::State::Muted)
|
||||||
|| (muteState == Row::State::RaisedHand)
|
|| (muteState == Row::State::RaisedHand);
|
||||||
|| (muteState == Row::State::MutedByMe);
|
const auto mutedByMe = row->mutedByMe();
|
||||||
|
|
||||||
auto mutesFromVolume = rpl::never<bool>() | rpl::type_erased();
|
auto mutesFromVolume = rpl::never<bool>() | rpl::type_erased();
|
||||||
|
|
||||||
if (!isMuted || _call->joinAs() == participantPeer) {
|
if (!muted || _call->joinAs() == participantPeer) {
|
||||||
auto otherParticipantStateValue
|
auto otherParticipantStateValue
|
||||||
= _call->otherParticipantStateValue(
|
= _call->otherParticipantStateValue(
|
||||||
) | rpl::filter([=](const Group::ParticipantState &data) {
|
) | rpl::filter([=](const Group::ParticipantState &data) {
|
||||||
|
@ -1348,7 +1346,7 @@ void Members::Controller::addMuteActionsToContextMenu(
|
||||||
otherParticipantStateValue,
|
otherParticipantStateValue,
|
||||||
row->volume(),
|
row->volume(),
|
||||||
Group::kMaxVolume,
|
Group::kMaxVolume,
|
||||||
isMuted);
|
muted);
|
||||||
|
|
||||||
mutesFromVolume = volumeItem->toggleMuteRequests();
|
mutesFromVolume = volumeItem->toggleMuteRequests();
|
||||||
|
|
||||||
|
@ -1397,20 +1395,32 @@ void Members::Controller::addMuteActionsToContextMenu(
|
||||||
auto callback = [=] {
|
auto callback = [=] {
|
||||||
const auto state = row->state();
|
const auto state = row->state();
|
||||||
const auto muted = (state == Row::State::Muted)
|
const auto muted = (state == Row::State::Muted)
|
||||||
|| (state == Row::State::RaisedHand)
|
|| (state == Row::State::RaisedHand);
|
||||||
|| (state == Row::State::MutedByMe);
|
const auto mutedByMe = row->mutedByMe();
|
||||||
toggleMute(!muted, false);
|
toggleMute(!mutedByMe && (!_call->canManage() || !muted), false);
|
||||||
};
|
};
|
||||||
return menu->addAction(
|
return menu->addAction(
|
||||||
isMuted ? unmuteString() : muteString(),
|
muteUnmuteString(muted, mutedByMe),
|
||||||
std::move(callback));
|
std::move(callback));
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (muteAction) {
|
if (muteAction) {
|
||||||
std::move(
|
std::move(
|
||||||
mutesFromVolume
|
mutesFromVolume
|
||||||
) | rpl::start_with_next([=](bool muted) {
|
) | rpl::start_with_next([=](bool mutedFromVolume) {
|
||||||
muteAction->setText(muted ? unmuteString() : muteString());
|
const auto state = _call->canManage()
|
||||||
|
? (mutedFromVolume
|
||||||
|
? (row->raisedHandRating()
|
||||||
|
? Row::State::RaisedHand
|
||||||
|
: Row::State::Muted)
|
||||||
|
: Row::State::Inactive)
|
||||||
|
: row->state();
|
||||||
|
const auto muted = (state == Row::State::Muted)
|
||||||
|
|| (state == Row::State::RaisedHand);
|
||||||
|
const auto mutedByMe = _call->canManage()
|
||||||
|
? false
|
||||||
|
: mutedFromVolume;
|
||||||
|
muteAction->setText(muteUnmuteString(muted, mutedByMe));
|
||||||
}, menu->lifetime());
|
}, menu->lifetime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,12 @@ MembersRow::MembersRow(
|
||||||
not_null<MembersRowDelegate*> delegate,
|
not_null<MembersRowDelegate*> delegate,
|
||||||
not_null<PeerData*> participantPeer)
|
not_null<PeerData*> participantPeer)
|
||||||
: PeerListRow(participantPeer)
|
: PeerListRow(participantPeer)
|
||||||
, _delegate(delegate) {
|
, _delegate(delegate)
|
||||||
|
, _sounding(false)
|
||||||
|
, _speaking(false)
|
||||||
|
, _raisedHandStatus(false)
|
||||||
|
, _skipLevelUpdate(false)
|
||||||
|
, _mutedByMe(false) {
|
||||||
refreshStatus();
|
refreshStatus();
|
||||||
_aboutText = participantPeer->about();
|
_aboutText = participantPeer->about();
|
||||||
}
|
}
|
||||||
|
@ -147,25 +152,27 @@ void MembersRow::updateState(
|
||||||
setState(State::Invited);
|
setState(State::Invited);
|
||||||
setSounding(false);
|
setSounding(false);
|
||||||
setSpeaking(false);
|
setSpeaking(false);
|
||||||
|
_mutedByMe = false;
|
||||||
_raisedHandRating = 0;
|
_raisedHandRating = 0;
|
||||||
} else if (!participant->muted
|
} else if (!participant->muted
|
||||||
|| (participant->sounding && participant->ssrc != 0)) {
|
|| (participant->sounding && participant->ssrc != 0)) {
|
||||||
setState(participant->mutedByMe ? State::MutedByMe : State::Active);
|
setState(State::Active);
|
||||||
setSounding(participant->sounding && participant->ssrc != 0);
|
setSounding(participant->sounding && participant->ssrc != 0);
|
||||||
setSpeaking(participant->speaking && participant->ssrc != 0);
|
setSpeaking(participant->speaking && participant->ssrc != 0);
|
||||||
|
_mutedByMe = participant->mutedByMe;
|
||||||
_raisedHandRating = 0;
|
_raisedHandRating = 0;
|
||||||
} else if (participant->canSelfUnmute) {
|
} else if (participant->canSelfUnmute) {
|
||||||
setState(participant->mutedByMe
|
setState(State::Inactive);
|
||||||
? State::MutedByMe
|
|
||||||
: State::Inactive);
|
|
||||||
setSounding(false);
|
setSounding(false);
|
||||||
setSpeaking(false);
|
setSpeaking(false);
|
||||||
|
_mutedByMe = participant->mutedByMe;
|
||||||
_raisedHandRating = 0;
|
_raisedHandRating = 0;
|
||||||
} else {
|
} else {
|
||||||
_raisedHandRating = participant->raisedHandRating;
|
|
||||||
setState(_raisedHandRating ? State::RaisedHand : State::Muted);
|
|
||||||
setSounding(false);
|
setSounding(false);
|
||||||
setSpeaking(false);
|
setSpeaking(false);
|
||||||
|
_mutedByMe = participant->mutedByMe;
|
||||||
|
_raisedHandRating = participant->raisedHandRating;
|
||||||
|
setState(_raisedHandRating ? State::RaisedHand : State::Muted);
|
||||||
}
|
}
|
||||||
refreshStatus();
|
refreshStatus();
|
||||||
}
|
}
|
||||||
|
@ -182,7 +189,7 @@ void MembersRow::setSpeaking(bool speaking) {
|
||||||
st::widgetFadeDuration);
|
st::widgetFadeDuration);
|
||||||
|
|
||||||
if (!_speaking
|
if (!_speaking
|
||||||
|| (_state == State::MutedByMe)
|
|| _mutedByMe
|
||||||
|| (_state == State::Muted)
|
|| (_state == State::Muted)
|
||||||
|| (_state == State::RaisedHand)) {
|
|| (_state == State::RaisedHand)) {
|
||||||
if (_statusIcon) {
|
if (_statusIcon) {
|
||||||
|
@ -381,11 +388,10 @@ void MembersRow::paintBlobs(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto size = sizew;
|
auto size = sizew;
|
||||||
const auto mutedByMe = (_state == State::MutedByMe);
|
|
||||||
const auto shift = QPointF(x + size / 2., y + size / 2.);
|
const auto shift = QPointF(x + size / 2., y + size / 2.);
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.translate(shift);
|
p.translate(shift);
|
||||||
const auto brush = mutedByMe
|
const auto brush = _mutedByMe
|
||||||
? st::groupCallMemberMutedIcon->b
|
? st::groupCallMemberMutedIcon->b
|
||||||
: anim::brush(
|
: anim::brush(
|
||||||
st::groupCallMemberInactiveStatus,
|
st::groupCallMemberInactiveStatus,
|
||||||
|
@ -614,7 +620,7 @@ void MembersRow::paintComplexStatusText(
|
||||||
: QString();
|
: QString();
|
||||||
if (about.isEmpty()
|
if (about.isEmpty()
|
||||||
&& _state != State::Invited
|
&& _state != State::Invited
|
||||||
&& _state != State::MutedByMe) {
|
&& !_mutedByMe) {
|
||||||
paintStatusIcon(p, x, y, st, font, selected, narrowMode);
|
paintStatusIcon(p, x, y, st, font, selected, narrowMode);
|
||||||
|
|
||||||
const auto translatedWidth = statusIconWidth(narrowMode);
|
const auto translatedWidth = statusIconWidth(narrowMode);
|
||||||
|
@ -640,7 +646,7 @@ void MembersRow::paintComplexStatusText(
|
||||||
p.setFont(font);
|
p.setFont(font);
|
||||||
if (style == MembersRowStyle::Video) {
|
if (style == MembersRowStyle::Video) {
|
||||||
p.setPen(st::groupCallVideoSubTextFg);
|
p.setPen(st::groupCallVideoSubTextFg);
|
||||||
} else if (_state == State::MutedByMe) {
|
} else if (_mutedByMe) {
|
||||||
p.setPen(st::groupCallMemberMutedIcon);
|
p.setPen(st::groupCallMemberMutedIcon);
|
||||||
} else {
|
} else {
|
||||||
p.setPen(st::groupCallMemberNotJoinedStatus);
|
p.setPen(st::groupCallMemberNotJoinedStatus);
|
||||||
|
@ -649,7 +655,7 @@ void MembersRow::paintComplexStatusText(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
outerWidth,
|
outerWidth,
|
||||||
(_state == State::MutedByMe
|
(_mutedByMe
|
||||||
? tr::lng_group_call_muted_by_me_status(tr::now)
|
? tr::lng_group_call_muted_by_me_status(tr::now)
|
||||||
: !about.isEmpty()
|
: !about.isEmpty()
|
||||||
? font->m.elidedText(about, Qt::ElideRight, availableWidth)
|
? font->m.elidedText(about, Qt::ElideRight, availableWidth)
|
||||||
|
@ -715,12 +721,11 @@ MembersRowDelegate::IconState MembersRow::computeIconState(
|
||||||
(_state == State::Active) ? 1. : 0.);
|
(_state == State::Active) ? 1. : 0.);
|
||||||
const auto muted = _mutedAnimation.value(
|
const auto muted = _mutedAnimation.value(
|
||||||
(_state == State::Muted || _state == State::RaisedHand) ? 1. : 0.);
|
(_state == State::Muted || _state == State::RaisedHand) ? 1. : 0.);
|
||||||
const auto mutedByMe = (_state == State::MutedByMe);
|
|
||||||
return {
|
return {
|
||||||
.speaking = speaking,
|
.speaking = speaking,
|
||||||
.active = active,
|
.active = active,
|
||||||
.muted = muted,
|
.muted = muted,
|
||||||
.mutedByMe = (_state == State::MutedByMe),
|
.mutedByMe = _mutedByMe,
|
||||||
.raisedHand = (_state == State::RaisedHand),
|
.raisedHand = (_state == State::RaisedHand),
|
||||||
.invited = (_state == State::Invited),
|
.invited = (_state == State::Invited),
|
||||||
.style = style,
|
.style = style,
|
||||||
|
|
|
@ -73,7 +73,6 @@ public:
|
||||||
Inactive,
|
Inactive,
|
||||||
Muted,
|
Muted,
|
||||||
RaisedHand,
|
RaisedHand,
|
||||||
MutedByMe,
|
|
||||||
Invited,
|
Invited,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,6 +94,9 @@ public:
|
||||||
[[nodiscard]] bool speaking() const {
|
[[nodiscard]] bool speaking() const {
|
||||||
return _speaking;
|
return _speaking;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] bool mutedByMe() const {
|
||||||
|
return _mutedByMe;
|
||||||
|
}
|
||||||
[[nodiscard]] crl::time speakingLastTime() const {
|
[[nodiscard]] crl::time speakingLastTime() const {
|
||||||
return _speakingLastTime;
|
return _speakingLastTime;
|
||||||
}
|
}
|
||||||
|
@ -212,10 +214,11 @@ private:
|
||||||
uint64 _raisedHandRating = 0;
|
uint64 _raisedHandRating = 0;
|
||||||
uint32 _ssrc = 0;
|
uint32 _ssrc = 0;
|
||||||
int _volume = Group::kDefaultVolume;
|
int _volume = Group::kDefaultVolume;
|
||||||
bool _sounding = false;
|
bool _sounding : 1;
|
||||||
bool _speaking = false;
|
bool _speaking : 1;
|
||||||
bool _raisedHandStatus = false;
|
bool _raisedHandStatus : 1;
|
||||||
bool _skipLevelUpdate = false;
|
bool _skipLevelUpdate : 1;
|
||||||
|
bool _mutedByMe : 1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue