tdesktop/Telegram/SourceFiles/calls/group/calls_group_panel.h

273 lines
7.8 KiB
C
Raw Normal View History

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