Version 1.1: Show user name in call top bar.

This commit is contained in:
John Preston 2017-05-14 22:44:50 +03:00
parent 983a13f66b
commit 0b77c0bce8
10 changed files with 55 additions and 15 deletions

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "{user}'s app does not support calls. They need to update their app before you can call them.";
"lng_call_error_audio_io" = "There seems to be a problem with audio playback on your computer. Please make sure that your computer's speakers and microphone are working and try again.";
"lng_call_bar_info" = "Show call info";
"lng_call_bar_hangup" = "End call";
"lng_call_box_title" = "Calls";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "{user}s App unterstützt keine Anrufe. Dein Chatpartner muss seine App aktualisieren, bevor du anrufen kannst.";
"lng_call_error_audio_io" = "Leider gibt es ein Problem mit der Audiowiedergabe auf deinem Computer. Bitte stelle sicher, dass Lautsprecher und Mikrofon funktionieren und probiere es erneut.";
"lng_call_bar_info" = "Anrufinfo anzeigen";
"lng_call_bar_hangup" = "Anruf beenden";
"lng_call_box_title" = "Anrufe";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "La app de {user} no soporta llamadas. Debe actualizar su app para recibir tu llamada.";
"lng_call_error_audio_io" = "Parece existir un problema con la reproducción de audio en tu PC. Por favor, verifica que tu altavoz y micrófono están funcionando y reinténtalo.";
"lng_call_bar_info" = "Información";
"lng_call_bar_hangup" = "Terminar llamada";
"lng_call_box_title" = "Llamadas";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "L'app di {user} non supporta le chiamate. Deve aggiornare la sua app prima che tu possa chiamarlo.";
"lng_call_error_audio_io" = "Sembra esserci un problema con la riproduzione audio del tuo computer. Per favore assicurati che gli altoparlanti e il microfono del tuo computer stiano funzionando e riprova.";
"lng_call_bar_info" = "Info chiamata";
"lng_call_bar_hangup" = "Termina chiamata";
"lng_call_box_title" = "Chiamate";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "{user}님의 앱이 전화를 지원하고 있지 않습니다. 상대방 앱을 업데이트 해야합니다.";
"lng_call_error_audio_io" = "회원님 컴퓨터의 음성 재생에 문제가 있습니다. 스피커와 마이크가 작동을 하는지 확인 후 다시 시도해주세요.";
"lng_call_bar_info" = "전화 정보 보기";
"lng_call_bar_hangup" = "통화종료";
"lng_call_box_title" = "전화";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "{user}'s app heeft nog geen ondersteuning voor spraakoproepen en zal eerst een update moeten uitvoeren.";
"lng_call_error_audio_io" = "Er lijkt iets mis te gaan met het afspelen van audio op je computer. Zorg dat je microfoon en luidsprekers werken en probeer het opnieuw.";
"lng_call_bar_info" = "Oproepinformatie";
"lng_call_bar_hangup" = "Nu beëindigen";
"lng_call_box_title" = "Spraakoproepen";

View File

@ -1143,7 +1143,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_call_error_outdated" = "O aplicativo de {user} não suporta chamadas. O aplicativo desse usuário precisa ser atualizado para que você possa chamá-lo.";
"lng_call_error_audio_io" = "Parece haver um problema com a reprodução de áudio em seu computador. Verifique se os auto-falantes e microfone estão funcionando e tente novamente.";
"lng_call_bar_info" = "Informações da Chamada";
"lng_call_bar_hangup" = "Encerrar chamada";
"lng_call_box_title" = "Chamadas";

View File

@ -147,6 +147,14 @@ callBarLabel: LabelSimple(defaultLabelSimple) {
font: semiboldFont;
textFg: callBarFg;
}
callBarInfoLabel: FlatLabel(defaultFlatLabel) {
maxHeight: 28px;
align: align(top);
textFg: callBarFg;
style: TextStyle(defaultTextStyle) {
font: semiboldFont;
}
}
callBarLabelTop: 10px;
callArrowPosition: point(-2px, 1px);

View File

@ -27,6 +27,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "calls/calls_call.h"
#include "calls/calls_instance.h"
#include "styles/style_boxes.h"
#include "observer_peer.h"
#include "boxes/abstract_box.h"
#include "base/timer.h"
@ -76,7 +77,8 @@ void DebugInfoBox::updateText() {
TopBar::TopBar(QWidget *parent, const base::weak_unique_ptr<Call> &call) : TWidget(parent)
, _call(call)
, _durationLabel(this, st::callBarLabel)
, _infoLabel(this, st::callBarLabel, lang(lng_call_bar_info).toUpper())
, _fullInfoLabel(this, st::callBarInfoLabel)
, _shortInfoLabel(this, st::callBarInfoLabel)
, _hangupLabel(this, st::callBarLabel, lang(lng_call_bar_hangup).toUpper())
, _mute(this, st::callBarMuteToggle)
, _info(this)
@ -96,6 +98,14 @@ void TopBar::initControls() {
setMuted(mute);
update();
});
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::NameChanged, [this](const Notify::PeerUpdate &update) {
if (auto call = _call.get()) {
if (update.peer == call->user()) {
updateInfoLabels();
}
}
}));
setInfoLabels();
_info->setClickedCallback([this] {
if (auto call = _call.get()) {
if (cDebug() && (_info->clickModifiers() & Qt::ControlModifier)) {
@ -114,6 +124,21 @@ void TopBar::initControls() {
updateDurationText();
}
void TopBar::updateInfoLabels() {
setInfoLabels();
updateControlsGeometry();
}
void TopBar::setInfoLabels() {
if (auto call = _call.get()) {
auto user = call->user();
auto fullName = App::peerName(user);
auto shortName = user->firstName;
_fullInfoLabel->setText(fullName.toUpper());
_shortInfoLabel->setText(shortName.toUpper());
}
}
void TopBar::setMuted(bool mute) {
_mute->setIconOverride(mute ? &st::callBarUnmuteIcon : nullptr);
_mute->setRippleColorOverride(mute ? &st::callBarUnmuteRipple : nullptr);
@ -155,13 +180,23 @@ void TopBar::updateControlsGeometry() {
_hangup->setGeometryToRight(0, 0, right, height());
_info->setGeometryToLeft(_mute->width(), 0, width() - _mute->width() - _hangup->width(), height());
auto minPadding = qMax(left, right);
auto fullWidth = _fullInfoLabel->naturalWidth();
auto showFull = (left + fullWidth + right <= width());
_fullInfoLabel->setVisible(showFull);
_shortInfoLabel->setVisible(!showFull);
auto infoLeft = (width() - _infoLabel->width()) / 2;
if (infoLeft < minPadding) {
infoLeft = left + (width() - left - right - _infoLabel->width()) / 2;
}
_infoLabel->moveToLeft(infoLeft, st::callBarLabelTop);
auto setInfoLabelGeometry = [this, left, right](auto &&infoLabel) {
auto minPadding = qMax(left, right);
auto infoWidth = infoLabel->naturalWidth();
auto infoLeft = (width() - infoWidth) / 2;
if (infoLeft < minPadding) {
infoLeft = left;
infoWidth = width() - left - right;
}
infoLabel->setGeometryToLeft(infoLeft, st::callBarLabelTop, infoWidth, st::callBarInfoLabel.style.font->height);
};
setInfoLabelGeometry(_fullInfoLabel);
setInfoLabelGeometry(_shortInfoLabel);
}
void TopBar::paintEvent(QPaintEvent *e) {

View File

@ -27,6 +27,7 @@ namespace Ui {
class IconButton;
class AbstractButton;
class LabelSimple;
class FlatLabel;
} // namespace Ui
namespace Calls {
@ -45,6 +46,8 @@ protected:
private:
void initControls();
void updateInfoLabels();
void setInfoLabels();
void updateDurationText();
void updateControlsGeometry();
void startDurationUpdateTimer(TimeMs currentDuration);
@ -54,7 +57,8 @@ private:
bool _muted = false;
object_ptr<Ui::LabelSimple> _durationLabel;
object_ptr<Ui::LabelSimple> _infoLabel;
object_ptr<Ui::FlatLabel> _fullInfoLabel;
object_ptr<Ui::FlatLabel> _shortInfoLabel;
object_ptr<Ui::LabelSimple> _hangupLabel;
object_ptr<Ui::IconButton> _mute;
object_ptr<Ui::AbstractButton> _info;