Show remote audio muted tooltip.

This commit is contained in:
John Preston 2020-08-14 12:32:05 +04:00
parent a106d80a41
commit cb18c9a9b3
7 changed files with 86 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1751,6 +1751,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_call_rate_label" = "Please rate the quality of your call";
"lng_call_rate_comment" = "Comment (optional)";
"lng_call_start_video" = "Start Video";
"lng_call_stop_video" = "Stop Video";
"lng_call_end_call" = "End Call";
"lng_call_mute_audio" = "Mute";
"lng_call_unmute_audio" = "Unmute";
"lng_call_accept" = "Accept";
"lng_call_decline" = "Decline";
"lng_call_redial" = "Redial";
"lng_call_cancel" = "Cancel";
"lng_call_microphone_off" = "{user}'s microphone is off";
"lng_no_mic_permission" = "Telegram needs access to your microphone so that you can make calls and record voice messages.";
"lng_player_message_today" = "Today at {time}";

View file

@ -37,7 +37,7 @@ callHeightMin: 440px;
callWidth: 720px;
callHeight: 540px;
callBottomControlsHeight: 85px;
callBottomControlsHeight: 87px;
CallBodyLayout {
height: pixels;
@ -84,6 +84,10 @@ callFingerprintTop: 11px;
callFingerprintSkip: 3px;
callFingerprintBottom: -16px;
callTooltipMutedIcon: icon{{ "calls_mute_tooltip", toastFg }};
callTooltipMutedIconPosition: point(8px, 4px);
callTooltipPadding: margins(41px, 6px, 15px, 7px);
callButton: IconButton {
width: 68px;
height: 68px;
@ -169,6 +173,7 @@ callCameraUnmute: CallButton(callMicrophoneUnmute) {
}
}
}
callBottomShadowSize: 124px;
callName: FlatLabel(defaultFlatLabel) {
minWidth: 260px;
@ -192,6 +197,11 @@ callStatus: FlatLabel(defaultFlatLabel) {
linkFontOver: font(14px underline);
}
}
callRemoteAudioMute: FlatLabel(callStatus) {
minWidth: 0px;
textFg: toastFg;
}
callRemoteAudioMuteSkip: 12px;
callBarHeight: 38px;
callBarMuteToggle: IconButton {

View file

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/ripple_animation.h"
#include "ui/image/image.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/platform/ui_platform_utility.h"
#include "ui/empty_userpic.h"
#include "ui/emoji_config.h"
@ -287,6 +288,7 @@ Panel::Panel(not_null<Call*> call)
initWidget();
initControls();
initLayout();
initBottomShadow();
showAndActivate();
}
@ -475,6 +477,15 @@ void Panel::reinitWithCall(Call *call) {
) | rpl::map([=](Call::RemoteAudioState state) {
return (state == Call::RemoteAudioState::Muted);
});
rpl::duplicate(
remoteMuted
) | rpl::start_with_next([=](bool muted) {
if (muted) {
createRemoteAudioMute();
} else {
_remoteAudioMute.destroy();
}
}, _callLifetime);
_userpic = std::make_unique<Userpic>(
widget(),
_user,
@ -541,6 +552,37 @@ void Panel::reinitWithCall(Call *call) {
updateStatusText(_call->state());
}
void Panel::createRemoteAudioMute() {
_remoteAudioMute.create(
widget(),
object_ptr<Ui::FlatLabel>(
widget(),
tr::lng_call_microphone_off(
lt_user,
rpl::single(_user->shortName())),
st::callRemoteAudioMute),
st::callTooltipPadding);
_remoteAudioMute->paintRequest(
) | rpl::start_with_next([=] {
auto p = QPainter(_remoteAudioMute);
const auto height = _remoteAudioMute->height();
auto hq = PainterHighQualityEnabler(p);
p.setBrush(st::toastBg);
p.setPen(Qt::NoPen);
p.drawRoundedRect(_remoteAudioMute->rect(), height / 2, height / 2);
st::callTooltipMutedIcon.paint(
p,
st::callTooltipMutedIconPosition,
_remoteAudioMute->width());
}, _remoteAudioMute->lifetime());
showControls();
updateControlsGeometry();
}
void Panel::initLayout() {
initGeometry();
@ -563,6 +605,9 @@ void Panel::initLayout() {
#endif // Q_OS_WIN
}
void Panel::initBottomShadow() {
}
void Panel::showControls() {
Expects(_call != nullptr);
@ -574,6 +619,9 @@ void Panel::showControls() {
_name->setVisible(!shown);
_status->setVisible(!shown);
_userpic->setVisible(!shown);
if (_remoteAudioMute) {
_remoteAudioMute->setVisible(shown);
}
}
void Panel::hideBeforeDestroy() {
@ -698,6 +746,14 @@ void Panel::updateControlsGeometry() {
_bodyTop + _bodySt->nameTop);
updateStatusGeometry();
if (_remoteAudioMute) {
_remoteAudioMute->moveToLeft(
(widget()->width() - _remoteAudioMute->width()) / 2,
(_buttonsTop
- st::callRemoteAudioMuteSkip
- _remoteAudioMute->height()));
}
if (_outgoingPreviewInBody) {
_outgoingVideoBubble->updateGeometry(
VideoBubble::DragMode::None,

View file

@ -26,6 +26,8 @@ class IconButton;
class FlatLabel;
template <typename Widget>
class FadeWrap;
template <typename Widget>
class PaddingWrap;
class Window;
namespace Platform {
class TitleControls;
@ -39,6 +41,7 @@ struct CallBodyLayout;
namespace Calls {
class Tooltip;
class Userpic;
class SignalBars;
class VideoBubble;
@ -73,6 +76,7 @@ private:
void reinitWithCall(Call *call);
void initLayout();
void initGeometry();
void initBottomShadow();
void handleClose();
void handleMouseMove(not_null<QMouseEvent*> e);
@ -94,6 +98,7 @@ private:
void refreshOutgoingPreviewInBody(State state);
void toggleFullScreen(bool fullscreen);
void createRemoteAudioMute();
[[nodiscard]] QRect incomingFrameGeometry() const;
[[nodiscard]] QRect outgoingFrameGeometry() const;
@ -123,10 +128,12 @@ private:
object_ptr<Ui::FlatLabel> _name;
object_ptr<Ui::FlatLabel> _status;
object_ptr<SignalBars> _signalBars = { nullptr };
object_ptr<Ui::PaddingWrap<Ui::FlatLabel>> _remoteAudioMute = { nullptr };
std::unique_ptr<Userpic> _userpic;
std::unique_ptr<VideoBubble> _outgoingVideoBubble;
std::vector<EmojiPtr> _fingerprint;
QRect _fingerprintArea;
QPixmap _bottomShadow;
int _bodyTop = 0;
int _buttonsTop = 0;
int _fingerprintHeight = 0;