tdesktop/Telegram/SourceFiles/calls/calls_panel.h

163 lines
4.0 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/weak_ptr.h"
#include "base/timer.h"
#include "base/object_ptr.h"
#include "calls/calls_call.h"
#include "calls/group/ui/desktop_capture_choose_source.h"
2019-04-02 09:13:30 +00:00
#include "ui/effects/animations.h"
#include "ui/gl/gl_window.h"
2017-11-21 13:23:56 +00:00
#include "ui/rp_widget.h"
2020-05-29 14:08:18 +00:00
class Image;
2020-05-25 14:16:04 +00:00
namespace Data {
class PhotoMedia;
2020-05-28 14:32:10 +00:00
class CloudImageView;
2020-05-25 14:16:04 +00:00
} // namespace Data
namespace Ui {
class IconButton;
2020-11-28 12:00:06 +00:00
class CallButton;
class LayerManager;
class FlatLabel;
template <typename Widget>
class FadeWrap;
2020-08-14 08:32:05 +00:00
template <typename Widget>
class PaddingWrap;
2021-07-28 13:24:11 +00:00
class RpWindow;
namespace GL {
enum class Backend;
} // namespace GL
namespace Platform {
class TitleControls;
} // namespace Platform
} // namespace Ui
2018-05-27 08:24:47 +00:00
namespace style {
struct CallSignalBars;
struct CallBodyLayout;
2018-05-27 08:24:47 +00:00
} // namespace style
namespace Calls {
class Userpic;
class SignalBars;
class VideoBubble;
2018-05-27 08:24:47 +00:00
class Panel final : private Group::Ui::DesktopCapture::ChooseSourceDelegate {
public:
Panel(not_null<Call*> call);
2020-05-25 14:16:04 +00:00
~Panel();
[[nodiscard]] bool isActive() const;
void showAndActivate();
void minimize();
void replaceCall(not_null<Call*> call);
2020-08-14 15:59:24 +00:00
void closeBeforeDestroy();
QWidget *chooseSourceParent() override;
QString chooseSourceActiveDeviceId() override;
bool chooseSourceActiveWithAudio() override;
bool chooseSourceWithAudioSupported() override;
rpl::lifetime &chooseSourceInstanceLifetime() override;
void chooseSourceAccepted(
const QString &deviceId,
bool withAudio) override;
void chooseSourceStop() override;
[[nodiscard]] rpl::lifetime &lifetime();
private:
class Incoming;
using State = Call::State;
using Type = Call::Type;
2020-08-14 10:54:15 +00:00
enum class AnswerHangupRedialState : uchar {
Answer,
Hangup,
Redial,
};
2021-07-28 13:24:11 +00:00
[[nodiscard]] not_null<Ui::RpWindow*> window() const;
2020-08-12 13:35:31 +00:00
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
void paint(QRect clip);
void initWindow();
void initWidget();
void initControls();
2020-08-04 09:06:48 +00:00
void reinitWithCall(Call *call);
void initLayout();
void initGeometry();
2020-08-12 13:35:31 +00:00
void handleClose();
void updateControlsGeometry();
void updateHangupGeometry();
void updateStatusGeometry();
void updateOutgoingVideoBubbleGeometry();
void stateChanged(State state);
void showControls();
void updateStatusText(State state);
void startDurationUpdateTimer(crl::time currentDuration);
void setIncomingSize(QSize size);
void refreshIncomingGeometry();
void refreshOutgoingPreviewInBody(State state);
void toggleFullScreen(bool fullscreen);
2020-08-14 08:32:05 +00:00
void createRemoteAudioMute();
2020-08-14 10:54:15 +00:00
void refreshAnswerHangupRedialLabel();
[[nodiscard]] QRect incomingFrameGeometry() const;
[[nodiscard]] QRect outgoingFrameGeometry() const;
2017-05-04 13:32:56 +00:00
Call *_call = nullptr;
not_null<UserData*> _user;
Ui::GL::Window _window;
const std::unique_ptr<Ui::LayerManager> _layerBg;
std::unique_ptr<Incoming> _incoming;
2021-02-03 10:43:31 +00:00
#ifndef Q_OS_MAC
std::unique_ptr<Ui::Platform::TitleControls> _controls;
2021-02-03 10:43:31 +00:00
#endif // !Q_OS_MAC
QSize _incomingFrameSize;
2020-08-04 09:06:48 +00:00
rpl::lifetime _callLifetime;
not_null<const style::CallBodyLayout*> _bodySt;
2020-11-28 12:00:06 +00:00
object_ptr<Ui::CallButton> _answerHangupRedial;
object_ptr<Ui::FadeWrap<Ui::CallButton>> _decline;
object_ptr<Ui::FadeWrap<Ui::CallButton>> _cancel;
bool _hangupShown = false;
bool _outgoingPreviewInBody = false;
2020-08-14 10:54:15 +00:00
std::optional<AnswerHangupRedialState> _answerHangupRedialState;
2019-04-02 09:13:30 +00:00
Ui::Animations::Simple _hangupShownProgress;
object_ptr<Ui::CallButton> _screencast;
2020-11-28 12:00:06 +00:00
object_ptr<Ui::CallButton> _camera;
object_ptr<Ui::CallButton> _mute;
object_ptr<Ui::FlatLabel> _name;
object_ptr<Ui::FlatLabel> _status;
object_ptr<Ui::RpWidget> _fingerprint = { nullptr };
2020-08-14 08:32:05 +00:00
object_ptr<Ui::PaddingWrap<Ui::FlatLabel>> _remoteAudioMute = { nullptr };
std::unique_ptr<Userpic> _userpic;
std::unique_ptr<VideoBubble> _outgoingVideoBubble;
2020-08-14 08:32:05 +00:00
QPixmap _bottomShadow;
int _bodyTop = 0;
int _buttonsTop = 0;
base::Timer _updateDurationTimer;
base::Timer _updateOuterRippleTimer;
};
} // namespace Calls