2020-11-24 15:54:20 +03:00
|
|
|
/*
|
|
|
|
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"
|
2021-09-07 21:31:35 +03:00
|
|
|
#include "base/flags.h"
|
2020-11-24 15:54:20 +03:00
|
|
|
#include "base/object_ptr.h"
|
2022-01-18 15:53:04 +03:00
|
|
|
#include "base/unique_qptr.h"
|
2021-04-22 13:13:13 +04:00
|
|
|
#include "calls/group/calls_group_call.h"
|
2021-06-18 17:45:22 +04:00
|
|
|
#include "calls/group/calls_group_common.h"
|
2021-04-22 13:13:13 +04:00
|
|
|
#include "calls/group/calls_choose_join_as.h"
|
2021-04-20 14:30:42 +04:00
|
|
|
#include "calls/group/ui/desktop_capture_choose_source.h"
|
2020-11-24 15:54:20 +03:00
|
|
|
#include "ui/effects/animations.h"
|
2021-06-21 11:29:29 +04:00
|
|
|
#include "ui/gl/gl_window.h"
|
2020-11-24 15:54:20 +03:00
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
|
|
|
|
class Image;
|
|
|
|
|
2022-02-04 09:43:56 +03:00
|
|
|
namespace base {
|
|
|
|
class PowerSaveBlocker;
|
|
|
|
} // namespace base
|
|
|
|
|
2020-11-24 15:54:20 +03:00
|
|
|
namespace Data {
|
|
|
|
class PhotoMedia;
|
|
|
|
class CloudImageView;
|
2021-03-05 20:59:35 +04:00
|
|
|
class GroupCall;
|
2020-11-24 15:54:20 +03:00
|
|
|
} // namespace Data
|
|
|
|
|
|
|
|
namespace Ui {
|
2021-09-07 21:31:35 +03:00
|
|
|
class BoxContent;
|
|
|
|
enum class LayerOption;
|
|
|
|
using LayerOptions = base::flags<LayerOption>;
|
2021-03-09 17:24:32 +04:00
|
|
|
class AbstractButton;
|
2021-05-28 19:08:11 +04:00
|
|
|
class ImportantTooltip;
|
2021-03-09 19:13:48 +04:00
|
|
|
class DropdownMenu;
|
2020-11-28 15:00:06 +03:00
|
|
|
class CallButton;
|
|
|
|
class CallMuteButton;
|
2020-11-24 15:54:20 +03:00
|
|
|
class IconButton;
|
|
|
|
class FlatLabel;
|
2021-04-23 19:05:52 +04:00
|
|
|
class RpWidget;
|
2020-11-24 15:54:20 +03:00
|
|
|
template <typename Widget>
|
|
|
|
class FadeWrap;
|
|
|
|
template <typename Widget>
|
|
|
|
class PaddingWrap;
|
2020-11-25 17:09:59 +03:00
|
|
|
class ScrollArea;
|
2020-11-28 17:07:36 +03:00
|
|
|
class GenericBox;
|
2020-11-27 17:50:41 +03:00
|
|
|
class LayerManager;
|
2021-04-06 18:02:43 +04:00
|
|
|
class GroupCallScheduledLeft;
|
2021-05-31 17:10:30 +04:00
|
|
|
namespace Toast {
|
|
|
|
class Instance;
|
|
|
|
} // namespace Toast
|
2020-11-24 15:54:20 +03:00
|
|
|
namespace Platform {
|
2022-01-18 15:53:04 +03:00
|
|
|
struct SeparateTitleControls;
|
2020-11-24 15:54:20 +03:00
|
|
|
} // namespace Platform
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace style {
|
|
|
|
struct CallSignalBars;
|
|
|
|
struct CallBodyLayout;
|
|
|
|
} // namespace style
|
|
|
|
|
2021-03-15 22:40:59 +04:00
|
|
|
namespace Calls::Group {
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-05-31 17:10:30 +04:00
|
|
|
class Toasts;
|
2021-03-15 22:40:59 +04:00
|
|
|
class Members;
|
2021-05-23 17:08:52 +04:00
|
|
|
class Viewport;
|
2021-04-22 20:05:17 +04:00
|
|
|
enum class PanelMode;
|
2021-06-18 17:45:22 +04:00
|
|
|
enum class StickedTooltip;
|
2021-07-27 21:09:13 +03:00
|
|
|
class MicLevelTester;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-04-20 14:30:42 +04:00
|
|
|
class Panel final : private Ui::DesktopCapture::ChooseSourceDelegate {
|
2020-11-24 15:54:20 +03:00
|
|
|
public:
|
2021-03-15 22:40:59 +04:00
|
|
|
Panel(not_null<GroupCall*> call);
|
|
|
|
~Panel();
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-05-31 17:10:30 +04:00
|
|
|
[[nodiscard]] not_null<GroupCall*> call() const;
|
2020-12-08 21:06:56 +04:00
|
|
|
[[nodiscard]] bool isActive() const;
|
2021-05-31 17:10:30 +04:00
|
|
|
|
|
|
|
void showToast(TextWithEntities &&text, crl::time duration = 0);
|
2021-09-07 21:31:35 +03:00
|
|
|
void showBox(object_ptr<Ui::BoxContent> box);
|
|
|
|
void showBox(
|
|
|
|
object_ptr<Ui::BoxContent> box,
|
|
|
|
Ui::LayerOptions options,
|
|
|
|
anim::type animated = anim::type::normal);
|
2021-05-31 17:10:30 +04:00
|
|
|
|
2020-12-22 20:09:32 +04:00
|
|
|
void minimize();
|
|
|
|
void close();
|
2020-11-24 15:54:20 +03:00
|
|
|
void showAndActivate();
|
|
|
|
void closeBeforeDestroy();
|
|
|
|
|
2021-06-21 11:29:29 +04:00
|
|
|
rpl::lifetime &lifetime();
|
|
|
|
|
2020-11-24 15:54:20 +03:00
|
|
|
private:
|
|
|
|
using State = GroupCall::State;
|
2021-05-21 17:15:45 +04:00
|
|
|
struct ControlsBackgroundNarrow;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-06-18 16:11:32 +04:00
|
|
|
enum class NiceTooltipType {
|
|
|
|
Normal,
|
|
|
|
Sticked,
|
|
|
|
};
|
|
|
|
enum class StickedTooltipHide {
|
|
|
|
Unavailable,
|
|
|
|
Activated,
|
|
|
|
Discarded,
|
|
|
|
};
|
|
|
|
|
2021-07-28 16:24:11 +03:00
|
|
|
[[nodiscard]] not_null<Ui::RpWindow*> window() const;
|
2020-11-24 15:54:20 +03:00
|
|
|
[[nodiscard]] not_null<Ui::RpWidget*> widget() const;
|
|
|
|
|
2021-05-21 17:15:45 +04:00
|
|
|
[[nodiscard]] PanelMode mode() const;
|
|
|
|
|
2020-11-24 15:54:20 +03:00
|
|
|
void paint(QRect clip);
|
|
|
|
|
|
|
|
void initWindow();
|
|
|
|
void initWidget();
|
|
|
|
void initControls();
|
2021-04-07 14:56:53 +04:00
|
|
|
void initShareAction();
|
2020-11-24 15:54:20 +03:00
|
|
|
void initLayout();
|
|
|
|
void initGeometry();
|
2021-04-06 18:02:43 +04:00
|
|
|
void setupScheduledLabels(rpl::producer<TimeId> date);
|
2021-04-05 14:29:03 +04:00
|
|
|
void setupMembers();
|
2021-05-29 23:57:21 +04:00
|
|
|
void setupVideo(not_null<Viewport*> viewport);
|
2021-04-05 16:28:25 +04:00
|
|
|
void setupRealMuteButtonState(not_null<Data::GroupCall*> real);
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2020-11-25 17:09:59 +03:00
|
|
|
bool handleClose();
|
2021-04-06 19:19:37 +04:00
|
|
|
void startScheduledNow();
|
2022-03-04 15:14:15 +04:00
|
|
|
void toggleFullScreen();
|
2022-02-28 16:14:28 +03:00
|
|
|
void trackControls(bool track, bool force = false);
|
2021-04-27 18:06:56 +04:00
|
|
|
void raiseControls();
|
2021-05-11 19:00:37 +04:00
|
|
|
void enlargeVideo();
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-05-28 19:08:11 +04:00
|
|
|
void trackControl(Ui::RpWidget *widget, rpl::lifetime &lifetime);
|
|
|
|
void trackControlOver(not_null<Ui::RpWidget*> control, bool over);
|
2021-06-18 16:11:32 +04:00
|
|
|
void showNiceTooltip(
|
|
|
|
not_null<Ui::RpWidget*> control,
|
|
|
|
NiceTooltipType type = NiceTooltipType::Normal);
|
|
|
|
void showStickedTooltip();
|
|
|
|
void hideStickedTooltip(StickedTooltipHide hide);
|
|
|
|
void hideStickedTooltip(StickedTooltip type, StickedTooltipHide hide);
|
|
|
|
void hideNiceTooltip();
|
2021-05-26 18:21:50 +04:00
|
|
|
|
2021-04-22 20:05:17 +04:00
|
|
|
bool updateMode();
|
2020-11-24 15:54:20 +03:00
|
|
|
void updateControlsGeometry();
|
2021-05-11 17:17:35 +04:00
|
|
|
void updateButtonsGeometry();
|
2021-06-18 16:11:32 +04:00
|
|
|
void updateTooltipGeometry();
|
2021-05-21 18:27:30 +04:00
|
|
|
void updateButtonsStyles();
|
2021-04-05 14:29:03 +04:00
|
|
|
void updateMembersGeometry();
|
2021-04-27 18:06:56 +04:00
|
|
|
void refreshControlsBackground();
|
2022-03-04 18:24:44 +04:00
|
|
|
void refreshTitleBackground();
|
2021-05-21 17:15:45 +04:00
|
|
|
void setupControlsBackgroundWide();
|
|
|
|
void setupControlsBackgroundNarrow();
|
2020-11-24 15:54:20 +03:00
|
|
|
void showControls();
|
2021-04-07 14:56:53 +04:00
|
|
|
void refreshLeftButton();
|
2021-05-26 14:27:48 +04:00
|
|
|
void refreshVideoButtons(
|
|
|
|
std::optional<bool> overrideWideMode = std::nullopt);
|
2021-05-26 18:21:50 +04:00
|
|
|
void refreshTopButton();
|
2022-02-28 20:06:54 +03:00
|
|
|
void createPinOnTop();
|
2022-02-28 20:26:37 +03:00
|
|
|
void setupEmptyRtmp();
|
2021-05-18 10:32:06 +04:00
|
|
|
void toggleWideControls(bool shown);
|
2021-06-18 16:11:32 +04:00
|
|
|
void updateWideControlsVisibility();
|
2021-05-26 15:12:00 +04:00
|
|
|
[[nodiscard]] bool videoButtonInNarrowMode() const;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2020-12-15 14:49:31 +04:00
|
|
|
void endCall();
|
2020-11-28 17:07:36 +03:00
|
|
|
|
2021-03-09 19:13:48 +04:00
|
|
|
void showMainMenu();
|
|
|
|
void chooseJoinAs();
|
2021-05-26 18:21:50 +04:00
|
|
|
void chooseShareScreenSource();
|
2021-06-08 17:11:18 +04:00
|
|
|
void screenSharingPrivacyRequest();
|
2020-11-28 21:17:13 +03:00
|
|
|
void addMembers();
|
2021-03-19 19:10:44 +04:00
|
|
|
void kickParticipant(not_null<PeerData*> participantPeer);
|
|
|
|
void kickParticipantSure(not_null<PeerData*> participantPeer);
|
2021-03-09 17:24:32 +04:00
|
|
|
[[nodiscard]] QRect computeTitleRect() const;
|
2020-11-26 16:04:11 +03:00
|
|
|
void refreshTitle();
|
2021-03-05 20:59:35 +04:00
|
|
|
void refreshTitleGeometry();
|
2022-03-08 18:16:59 +04:00
|
|
|
void refreshTitleColors();
|
2021-04-05 16:28:25 +04:00
|
|
|
void setupRealCallViewers();
|
2021-03-05 20:59:35 +04:00
|
|
|
void subscribeToChanges(not_null<Data::GroupCall*> real);
|
2020-11-26 16:04:11 +03:00
|
|
|
|
2020-12-14 16:52:18 +04:00
|
|
|
void migrate(not_null<ChannelData*> channel);
|
|
|
|
void subscribeToPeerChanges();
|
|
|
|
|
2021-04-20 14:30:42 +04:00
|
|
|
QWidget *chooseSourceParent() override;
|
2021-04-29 20:28:12 +04:00
|
|
|
QString chooseSourceActiveDeviceId() override;
|
2021-07-13 16:27:44 +03:00
|
|
|
bool chooseSourceActiveWithAudio() override;
|
|
|
|
bool chooseSourceWithAudioSupported() override;
|
2021-04-20 14:30:42 +04:00
|
|
|
rpl::lifetime &chooseSourceInstanceLifetime() override;
|
2021-07-13 16:27:44 +03:00
|
|
|
void chooseSourceAccepted(
|
|
|
|
const QString &deviceId,
|
|
|
|
bool withAudio) override;
|
2021-04-29 20:28:12 +04:00
|
|
|
void chooseSourceStop() override;
|
2021-04-20 14:30:42 +04:00
|
|
|
|
2021-04-05 14:29:03 +04:00
|
|
|
const not_null<GroupCall*> _call;
|
2020-12-14 16:52:18 +04:00
|
|
|
not_null<PeerData*> _peer;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-06-21 11:29:29 +04:00
|
|
|
Ui::GL::Window _window;
|
2020-11-27 17:50:41 +03:00
|
|
|
const std::unique_ptr<Ui::LayerManager> _layerBg;
|
2021-05-21 17:15:45 +04:00
|
|
|
rpl::variable<PanelMode> _mode;
|
2022-03-04 15:14:15 +04:00
|
|
|
rpl::variable<bool> _fullScreenOrMaximized = false;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-02-03 14:43:31 +04:00
|
|
|
#ifndef Q_OS_MAC
|
2022-03-15 19:41:16 +04:00
|
|
|
rpl::variable<int> _controlsTop = 0;
|
2022-02-28 20:06:54 +03:00
|
|
|
const std::unique_ptr<Ui::Platform::SeparateTitleControls> _controls;
|
2021-02-03 14:43:31 +04:00
|
|
|
#endif // !Q_OS_MAC
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2022-02-04 09:43:56 +03:00
|
|
|
const std::unique_ptr<base::PowerSaveBlocker> _powerSaveBlocker;
|
|
|
|
|
2020-11-24 15:54:20 +03:00
|
|
|
rpl::lifetime _callLifetime;
|
|
|
|
|
2022-03-04 18:24:44 +04:00
|
|
|
object_ptr<Ui::RpWidget> _titleBackground = { nullptr };
|
2020-11-26 16:04:11 +03:00
|
|
|
object_ptr<Ui::FlatLabel> _title = { nullptr };
|
2022-03-08 18:16:59 +04:00
|
|
|
object_ptr<Ui::FlatLabel> _titleSeparator = { nullptr };
|
|
|
|
object_ptr<Ui::FlatLabel> _viewers = { nullptr };
|
2020-12-16 19:31:16 +04:00
|
|
|
object_ptr<Ui::FlatLabel> _subtitle = { nullptr };
|
2021-03-09 17:24:32 +04:00
|
|
|
object_ptr<Ui::AbstractButton> _recordingMark = { nullptr };
|
2021-03-09 19:13:48 +04:00
|
|
|
object_ptr<Ui::IconButton> _menuToggle = { nullptr };
|
2022-02-28 20:06:54 +03:00
|
|
|
object_ptr<Ui::IconButton> _pinOnTop = { nullptr };
|
2021-03-09 19:13:48 +04:00
|
|
|
object_ptr<Ui::DropdownMenu> _menu = { nullptr };
|
2021-05-26 18:21:50 +04:00
|
|
|
rpl::variable<bool> _wideMenuShown = false;
|
2021-03-09 19:13:48 +04:00
|
|
|
object_ptr<Ui::AbstractButton> _joinAsToggle = { nullptr };
|
2021-04-05 14:29:03 +04:00
|
|
|
object_ptr<Members> _members = { nullptr };
|
2021-05-23 17:08:52 +04:00
|
|
|
std::unique_ptr<Viewport> _viewport;
|
2021-05-13 14:38:59 +04:00
|
|
|
rpl::lifetime _trackControlsOverStateLifetime;
|
2021-05-26 18:21:50 +04:00
|
|
|
rpl::lifetime _trackControlsMenuLifetime;
|
2021-04-06 13:59:14 +04:00
|
|
|
object_ptr<Ui::FlatLabel> _startsIn = { nullptr };
|
|
|
|
object_ptr<Ui::RpWidget> _countdown = { nullptr };
|
2021-04-06 18:02:43 +04:00
|
|
|
std::shared_ptr<Ui::GroupCallScheduledLeft> _countdownData;
|
2021-04-06 13:59:14 +04:00
|
|
|
object_ptr<Ui::FlatLabel> _startsWhen = { nullptr };
|
2022-03-01 13:58:45 +03:00
|
|
|
object_ptr<Ui::RpWidget> _emptyRtmp = { nullptr };
|
2021-03-15 22:40:59 +04:00
|
|
|
ChooseJoinAsProcess _joinAsProcess;
|
2021-05-11 19:00:37 +04:00
|
|
|
std::optional<QRect> _lastSmallGeometry;
|
|
|
|
std::optional<QRect> _lastLargeGeometry;
|
|
|
|
bool _lastLargeMaximized = false;
|
2021-05-18 17:07:19 +04:00
|
|
|
bool _showWideControls = false;
|
2021-05-18 10:32:06 +04:00
|
|
|
bool _trackControls = false;
|
2021-05-18 17:07:19 +04:00
|
|
|
bool _wideControlsShown = false;
|
2021-05-18 10:32:06 +04:00
|
|
|
Ui::Animations::Simple _wideControlsAnimation;
|
2020-11-25 17:09:59 +03:00
|
|
|
|
2021-05-21 17:15:45 +04:00
|
|
|
object_ptr<Ui::RpWidget> _controlsBackgroundWide = { nullptr };
|
|
|
|
std::unique_ptr<ControlsBackgroundNarrow> _controlsBackgroundNarrow;
|
2021-04-07 14:56:53 +04:00
|
|
|
object_ptr<Ui::CallButton> _settings = { nullptr };
|
2021-05-26 18:21:50 +04:00
|
|
|
object_ptr<Ui::CallButton> _wideMenu = { nullptr };
|
2021-04-27 16:03:36 +04:00
|
|
|
object_ptr<Ui::CallButton> _callShare = { nullptr };
|
2021-04-26 13:21:01 +04:00
|
|
|
object_ptr<Ui::CallButton> _video = { nullptr };
|
2021-04-27 16:03:36 +04:00
|
|
|
object_ptr<Ui::CallButton> _screenShare = { nullptr };
|
2020-11-28 15:00:06 +03:00
|
|
|
std::unique_ptr<Ui::CallMuteButton> _mute;
|
|
|
|
object_ptr<Ui::CallButton> _hangup;
|
2021-05-28 19:08:11 +04:00
|
|
|
object_ptr<Ui::ImportantTooltip> _niceTooltip = { nullptr };
|
2021-06-18 16:11:32 +04:00
|
|
|
QPointer<Ui::IconButton> _stickedTooltipClose;
|
|
|
|
QPointer<Ui::RpWidget> _niceTooltipControl;
|
|
|
|
StickedTooltips _stickedTooltipsShown;
|
2021-04-27 16:03:36 +04:00
|
|
|
Fn<void()> _callShareLinkCallback;
|
2020-11-24 15:54:20 +03:00
|
|
|
|
2021-05-31 17:10:30 +04:00
|
|
|
const std::unique_ptr<Toasts> _toasts;
|
|
|
|
base::weak_ptr<Ui::Toast::Instance> _lastToast;
|
|
|
|
|
2021-06-18 17:45:22 +04:00
|
|
|
std::unique_ptr<MicLevelTester> _micLevelTester;
|
|
|
|
|
2022-03-04 18:24:44 +04:00
|
|
|
style::complex_color _controlsBackgroundColor;
|
2022-03-01 19:12:51 +03:00
|
|
|
base::Timer _hideControlsTimer;
|
|
|
|
rpl::lifetime _hideControlsTimerLifetime;
|
|
|
|
|
2020-12-14 16:52:18 +04:00
|
|
|
rpl::lifetime _peerLifetime;
|
|
|
|
|
2020-11-24 15:54:20 +03:00
|
|
|
};
|
|
|
|
|
2021-03-15 22:40:59 +04:00
|
|
|
} // namespace Calls::Group
|