Show user as active when in call panel.

This commit is contained in:
John Preston 2020-12-08 21:06:56 +04:00
parent d6ab9347c1
commit 5fe8c0ed7e
7 changed files with 32 additions and 2 deletions

View file

@ -241,6 +241,12 @@ GroupPanel::GroupPanel(not_null<GroupCall*> call)
GroupPanel::~GroupPanel() = default;
bool GroupPanel::isActive() const {
return _window->isActiveWindow()
&& _window->isVisible()
&& !(_window->windowState() & Qt::WindowMinimized);
}
void GroupPanel::showAndActivate() {
if (_window->isHidden()) {
_window->show();

View file

@ -67,6 +67,7 @@ public:
GroupPanel(not_null<GroupCall*> call);
~GroupPanel();
[[nodiscard]] bool isActive() const;
void showAndActivate();
void closeBeforeDestroy();

View file

@ -455,6 +455,17 @@ void Instance::destroyCurrentCall() {
}
}
bool Instance::hasActivePanel(not_null<Main::Session*> session) const {
if (inCall()) {
return (&_currentCall->user()->session() == session)
&& _currentCallPanel->isActive();
} else if (inGroupCall()) {
return (&_currentGroupCall->channel()->session() == session)
&& _currentGroupCallPanel->isActive();
}
return false;
}
bool Instance::activateCurrentCall() {
if (inCall()) {
_currentCallPanel->showAndActivate();

View file

@ -52,6 +52,8 @@ public:
[[nodiscard]] rpl::producer<GroupCall*> currentGroupCallValue() const;
[[nodiscard]] bool inCall() const;
[[nodiscard]] bool inGroupCall() const;
[[nodiscard]] bool hasActivePanel(
not_null<Main::Session*> session) const;
bool activateCurrentCall();
std::shared_ptr<tgcalls::VideoCaptureInterface> getVideoCapture() override;

View file

@ -202,6 +202,12 @@ Panel::Panel(not_null<Call*> call)
Panel::~Panel() = default;
bool Panel::isActive() const {
return _window->isActiveWindow()
&& _window->isVisible()
&& !(_window->windowState() & Qt::WindowMinimized);
}
void Panel::showAndActivate() {
_window->raise();
_window->setWindowState(_window->windowState() | Qt::WindowActive);

View file

@ -51,6 +51,7 @@ public:
Panel(not_null<Call*> call);
~Panel();
[[nodiscard]] bool isActive() const;
void showAndActivate();
void replaceCall(not_null<Call*> call);
void closeBeforeDestroy();

View file

@ -880,9 +880,12 @@ void Application::localPasscodeChanged() {
bool Application::hasActiveWindow(not_null<Main::Session*> session) const {
if (App::quitting() || !_window) {
return false;
} else if (_calls->hasActivePanel(session)) {
return true;
} else if (const auto controller = _window->sessionController()) {
if (&controller->session() == session) {
return _window->widget()->isActive();
if (&controller->session() == session
&& _window->widget()->isActive()) {
return true;
}
}
return false;