2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-24 11:17:10 +00:00

222 lines
5.8 KiB
C
Raw Permalink 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 "calls/calls_call.h"
#include "calls/group/ui/desktop_capture_choose_source.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"
2020-05-29 18:08:18 +04:00
class Image;
2022-02-04 09:43:56 +03:00
namespace base {
class PowerSaveBlocker;
} // namespace base
2020-05-25 18:16:04 +04:00
namespace Data {
class PhotoMedia;
} // namespace Data
2025-03-30 00:53:11 +05:00
namespace Main {
class SessionShow;
} // namespace Main
namespace Ui {
class Show;
2025-03-30 00:53:11 +05:00
class BoxContent;
class LayerWidget;
enum class LayerOption;
using LayerOptions = base::flags<LayerOption>;
class IconButton;
2020-11-28 15:00:06 +03:00
class CallButton;
class LayerManager;
class FlatLabel;
template <typename Widget>
class FadeWrap;
2020-08-14 12:32:05 +04:00
template <typename Widget>
class PaddingWrap;
2021-07-28 16:24:11 +03:00
class RpWindow;
class PopupMenu;
} // namespace Ui
2025-03-30 00:53:11 +05:00
namespace Ui::Toast {
class Instance;
struct Config;
} // namespace Ui::Toast
namespace Ui::Platform {
struct SeparateTitleControls;
} // namespace Ui::Platform
2018-05-27 11:24:47 +03:00
namespace style {
struct CallSignalBars;
struct CallBodyLayout;
2018-05-27 11:24:47 +03:00
} // namespace style
namespace Calls {
class Window;
class Userpic;
class SignalBars;
class VideoBubble;
struct DeviceSelection;
struct ConferencePanelMigration;
2018-05-27 11:24:47 +03:00
2025-03-30 00:53:11 +05:00
class Panel final
: public base::has_weak_ptr
, private Group::Ui::DesktopCapture::ChooseSourceDelegate {
public:
Panel(not_null<Call*> call);
2020-05-25 18:16:04 +04:00
~Panel();
2025-03-30 00:53:11 +05:00
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
[[nodiscard]] not_null<UserData*> user() const;
[[nodiscard]] bool isVisible() const;
[[nodiscard]] bool isActive() const;
2025-03-30 00:53:11 +05:00
[[nodiscard]] ConferencePanelMigration migrationInfo() const;
void showAndActivate();
void minimize();
void toggleFullScreen();
void replaceCall(not_null<Call*> call);
void closeBeforeDestroy(bool windowIsReused = false);
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::producer<bool> startOutgoingRequests() const;
[[nodiscard]] std::shared_ptr<Main::SessionShow> sessionShow();
[[nodiscard]] std::shared_ptr<Ui::Show> uiShow();
[[nodiscard]] not_null<Ui::RpWindow*> window() const;
2025-03-30 00:53:11 +05:00
[[nodiscard]] rpl::lifetime &lifetime();
private:
class Incoming;
using State = Call::State;
using Type = Call::Type;
2020-08-14 14:54:15 +04:00
enum class AnswerHangupRedialState : uchar {
Answer,
Hangup,
Redial,
StartCall,
2020-08-14 14:54:15 +04:00
};
2020-08-12 17:35:31 +04:00
void paint(QRect clip);
void initWindow();
void initWidget();
void initControls();
2025-04-01 21:50:39 +05:00
void initConferenceInvite();
2020-08-04 13:06:48 +04:00
void reinitWithCall(Call *call);
void initLayout();
void initMediaDeviceToggles();
void initGeometry();
2020-08-12 17:35:31 +04:00
[[nodiscard]] bool handleClose() const;
void requestControlsHidden(bool hidden);
void controlsShownForce(bool shown);
void updateControlsShown();
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 12:32:05 +04:00
void createRemoteAudioMute();
void createRemoteLowBattery();
void showRemoteLowBattery();
2020-08-14 14:54:15 +04:00
void refreshAnswerHangupRedialLabel();
void showDevicesMenu(
not_null<QWidget*> button,
std::vector<DeviceSelection> types);
[[nodiscard]] QRect incomingFrameGeometry() const;
[[nodiscard]] QRect outgoingFrameGeometry() const;
2017-05-04 16:32:56 +03:00
Call *_call = nullptr;
not_null<UserData*> _user;
std::shared_ptr<Window> _window;
std::unique_ptr<Incoming> _incoming;
QSize _incomingFrameSize;
2020-08-04 13:06:48 +04:00
rpl::lifetime _callLifetime;
not_null<const style::CallBodyLayout*> _bodySt;
base::unique_qptr<Ui::CallButton> _answerHangupRedial;
base::unique_qptr<Ui::FadeWrap<Ui::CallButton>> _decline;
base::unique_qptr<Ui::FadeWrap<Ui::CallButton>> _cancel;
bool _hangupShown = false;
2025-04-04 16:15:33 +05:00
bool _conferenceSupported = false;
bool _outgoingPreviewInBody = false;
2020-08-14 14:54:15 +04:00
std::optional<AnswerHangupRedialState> _answerHangupRedialState;
2019-04-02 13:13:30 +04:00
Ui::Animations::Simple _hangupShownProgress;
base::unique_qptr<Ui::FadeWrap<Ui::CallButton>> _screencast;
base::unique_qptr<Ui::CallButton> _camera;
Ui::CallButton *_cameraDeviceToggle = nullptr;
2023-03-02 08:52:24 +03:00
base::unique_qptr<Ui::CallButton> _startVideo;
base::unique_qptr<Ui::FadeWrap<Ui::CallButton>> _mute;
Ui::CallButton *_audioDeviceToggle = nullptr;
base::unique_qptr<Ui::FadeWrap<Ui::CallButton>> _addPeople;
base::unique_qptr<Ui::FlatLabel> _name;
base::unique_qptr<Ui::FlatLabel> _status;
base::unique_qptr<Ui::RpWidget> _conferenceParticipants;
base::unique_qptr<Ui::RpWidget> _fingerprint;
base::unique_qptr<Ui::PaddingWrap<Ui::FlatLabel>> _remoteAudioMute;
base::unique_qptr<Ui::PaddingWrap<Ui::FlatLabel>> _remoteLowBattery;
std::unique_ptr<Userpic> _userpic;
std::unique_ptr<VideoBubble> _outgoingVideoBubble;
2020-08-14 12:32:05 +04:00
QPixmap _bottomShadow;
int _bodyTop = 0;
int _buttonsTopShown = 0;
int _buttonsTop = 0;
base::Timer _hideControlsTimer;
base::Timer _controlsShownForceTimer;
std::unique_ptr<QObject> _hideControlsFilter;
bool _hideControlsRequested = false;
rpl::variable<bool> _fullScreenOrMaximized;
Ui::Animations::Simple _controlsShownAnimation;
bool _controlsShownForce = false;
bool _controlsShown = true;
bool _mouseInside = false;
base::unique_qptr<Ui::PopupMenu> _devicesMenu;
base::Timer _updateDurationTimer;
base::Timer _updateOuterRippleTimer;
2023-03-02 08:52:24 +03:00
rpl::event_stream<bool> _startOutgoingRequests;
rpl::lifetime _lifetime;
};
} // namespace Calls