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; GroupPanel::~GroupPanel() = default;
bool GroupPanel::isActive() const {
return _window->isActiveWindow()
&& _window->isVisible()
&& !(_window->windowState() & Qt::WindowMinimized);
}
void GroupPanel::showAndActivate() { void GroupPanel::showAndActivate() {
if (_window->isHidden()) { if (_window->isHidden()) {
_window->show(); _window->show();

View file

@ -67,6 +67,7 @@ public:
GroupPanel(not_null<GroupCall*> call); GroupPanel(not_null<GroupCall*> call);
~GroupPanel(); ~GroupPanel();
[[nodiscard]] bool isActive() const;
void showAndActivate(); void showAndActivate();
void closeBeforeDestroy(); 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() { bool Instance::activateCurrentCall() {
if (inCall()) { if (inCall()) {
_currentCallPanel->showAndActivate(); _currentCallPanel->showAndActivate();

View file

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

View file

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

View file

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

View file

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