2017-04-19 20:25:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-04-19 20:25:48 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-11-30 17:33:27 +00:00
|
|
|
#include "base/weak_ptr.h"
|
2017-04-25 16:45:41 +00:00
|
|
|
#include "base/timer.h"
|
2017-04-29 18:41:41 +00:00
|
|
|
#include "calls/calls_call.h"
|
|
|
|
#include "ui/widgets/tooltip.h"
|
2017-11-21 13:23:56 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2017-04-19 20:25:48 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
|
|
|
class FlatLabel;
|
2017-05-05 10:14:40 +00:00
|
|
|
template <typename Widget>
|
2017-09-30 18:26:45 +00:00
|
|
|
class FadeWrap;
|
2017-04-19 20:25:48 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-05-27 08:24:47 +00:00
|
|
|
namespace style {
|
|
|
|
struct CallSignalBars;
|
|
|
|
} // namespace style
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
namespace Calls {
|
|
|
|
|
2018-05-27 08:24:47 +00:00
|
|
|
class SignalBars : public Ui::RpWidget, private base::Subscriber {
|
|
|
|
public:
|
|
|
|
SignalBars(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Call*> call,
|
|
|
|
const style::CallSignalBars &st,
|
|
|
|
base::lambda<void()> displayedChangedCallback = nullptr);
|
|
|
|
|
|
|
|
bool isDisplayed() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void changed(int count);
|
|
|
|
|
|
|
|
const style::CallSignalBars &_st;
|
|
|
|
int _count = Call::kSignalBarStarting;
|
|
|
|
base::lambda<void()> _displayedChangedCallback;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-11-21 13:23:56 +00:00
|
|
|
class Panel
|
|
|
|
: public Ui::RpWidget
|
|
|
|
, private base::Subscriber
|
|
|
|
, private Ui::AbstractTooltipShower {
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
Panel(not_null<Call*> call);
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-04-25 20:36:04 +00:00
|
|
|
void showAndActivate();
|
2017-08-17 08:31:24 +00:00
|
|
|
void replaceCall(not_null<Call*> call);
|
2017-05-04 13:32:56 +00:00
|
|
|
void hideAndDestroy();
|
2017-05-04 12:29:32 +00:00
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2017-05-12 15:27:19 +00:00
|
|
|
void closeEvent(QCloseEvent *e) override;
|
2017-04-19 20:25:48 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
2017-04-29 18:41:41 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
|
|
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
2017-11-21 13:23:56 +00:00
|
|
|
bool eventHook(QEvent *e) override;
|
2017-04-19 20:25:48 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-25 16:45:41 +00:00
|
|
|
using State = Call::State;
|
|
|
|
using Type = Call::Type;
|
|
|
|
|
2017-04-29 18:41:41 +00:00
|
|
|
// AbstractTooltipShower interface
|
|
|
|
QString tooltipText() const override;
|
|
|
|
QPoint tooltipPos() const override;
|
|
|
|
bool tooltipWindowActive() const override;
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
void initControls();
|
2017-05-04 12:29:32 +00:00
|
|
|
void reinitControls();
|
2017-04-19 20:25:48 +00:00
|
|
|
void initLayout();
|
|
|
|
void initGeometry();
|
2017-04-25 20:36:04 +00:00
|
|
|
void hideDeactivated();
|
2017-04-19 20:25:48 +00:00
|
|
|
void createBottomImage();
|
|
|
|
void createDefaultCacheImage();
|
|
|
|
void refreshCacheImageUserPhoto();
|
|
|
|
|
|
|
|
void processUserPhoto();
|
|
|
|
void refreshUserPhoto();
|
|
|
|
bool isGoodUserPhoto(PhotoData *photo);
|
|
|
|
void createUserpicCache(ImagePtr image);
|
2018-05-27 08:24:47 +00:00
|
|
|
QRect signalBarsRect() const;
|
|
|
|
void paintSignalBarsBg(Painter &p);
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateControlsGeometry();
|
2017-05-05 10:14:40 +00:00
|
|
|
void updateHangupGeometry();
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateStatusGeometry();
|
|
|
|
void stateChanged(State state);
|
2017-05-05 10:14:40 +00:00
|
|
|
void showControls();
|
2017-04-25 16:45:41 +00:00
|
|
|
void updateStatusText(State state);
|
|
|
|
void startDurationUpdateTimer(TimeMs currentDuration);
|
2017-04-29 18:41:41 +00:00
|
|
|
void fillFingerprint();
|
2017-05-04 13:32:56 +00:00
|
|
|
void toggleOpacityAnimation(bool visible);
|
2017-09-30 19:20:40 +00:00
|
|
|
void finishAnimating();
|
2017-05-04 13:32:56 +00:00
|
|
|
void destroyDelayed();
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-05-04 13:32:56 +00:00
|
|
|
Call *_call = nullptr;
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<UserData*> _user;
|
2017-04-19 20:25:48 +00:00
|
|
|
|
|
|
|
bool _useTransparency = true;
|
|
|
|
style::margins _padding;
|
|
|
|
int _contentTop = 0;
|
|
|
|
|
|
|
|
bool _dragging = false;
|
|
|
|
QPoint _dragStartMousePosition;
|
|
|
|
QPoint _dragStartMyPosition;
|
|
|
|
|
2017-05-04 12:29:32 +00:00
|
|
|
int _stateChangedSubscription = 0;
|
|
|
|
|
2017-04-19 20:25:48 +00:00
|
|
|
class Button;
|
2017-05-05 10:14:40 +00:00
|
|
|
object_ptr<Button> _answerHangupRedial;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::FadeWrap<Button>> _decline;
|
|
|
|
object_ptr<Ui::FadeWrap<Button>> _cancel;
|
2017-05-05 10:14:40 +00:00
|
|
|
bool _hangupShown = false;
|
|
|
|
Animation _hangupShownProgress;
|
2017-04-19 20:25:48 +00:00
|
|
|
object_ptr<Ui::IconButton> _mute;
|
|
|
|
object_ptr<Ui::FlatLabel> _name;
|
|
|
|
object_ptr<Ui::FlatLabel> _status;
|
2018-05-27 08:24:47 +00:00
|
|
|
object_ptr<SignalBars> _signalBars;
|
2017-04-19 20:25:48 +00:00
|
|
|
std::vector<EmojiPtr> _fingerprint;
|
2017-04-29 18:41:41 +00:00
|
|
|
QRect _fingerprintArea;
|
2017-04-19 20:25:48 +00:00
|
|
|
|
2017-04-25 16:45:41 +00:00
|
|
|
base::Timer _updateDurationTimer;
|
2017-05-07 19:09:20 +00:00
|
|
|
base::Timer _updateOuterRippleTimer;
|
2017-04-25 16:45:41 +00:00
|
|
|
|
2017-05-05 10:14:40 +00:00
|
|
|
bool _visible = false;
|
2017-04-19 20:25:48 +00:00
|
|
|
QPixmap _userPhoto;
|
|
|
|
PhotoId _userPhotoId = 0;
|
|
|
|
bool _userPhotoFull = false;
|
|
|
|
|
2017-05-04 13:32:56 +00:00
|
|
|
Animation _opacityAnimation;
|
|
|
|
QPixmap _animationCache;
|
2017-04-19 20:25:48 +00:00
|
|
|
QPixmap _bottomCache;
|
|
|
|
QPixmap _cache;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Calls
|