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