Added ability to close call panel without hanging up call.

This commit is contained in:
23rd 2024-03-01 07:24:22 +03:00 committed by John Preston
parent c0c330a150
commit b790847fde
2 changed files with 12 additions and 8 deletions

View File

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "apiwrap.h"
#include "platform/platform_specific.h"
#include "base/event_filter.h"
#include "base/platform/base_platform_info.h"
#include "base/power_save_blocker.h"
#include "media/streaming/media_streaming_utility.h"
@ -147,17 +148,18 @@ void Panel::initWindow() {
window()->setTitle(_user->name());
window()->setTitleStyle(st::callTitle);
window()->events(
) | rpl::start_with_next([=](not_null<QEvent*> e) {
if (e->type() == QEvent::Close) {
handleClose();
base::install_event_filter(window().get(), [=](not_null<QEvent*> e) {
if (e->type() == QEvent::Close && handleClose()) {
e->ignore();
return base::EventFilterResult::Cancel;
} else if (e->type() == QEvent::KeyPress) {
if ((static_cast<QKeyEvent*>(e.get())->key() == Qt::Key_Escape)
&& window()->isFullScreen()) {
window()->showNormal();
}
}
}, window()->lifetime());
return base::EventFilterResult::Continue;
});
window()->setBodyTitleArea([=](QPoint widgetPoint) {
using Flag = Ui::WindowTitleHitTestFlag;
@ -828,10 +830,12 @@ void Panel::paint(QRect clip) {
}
}
void Panel::handleClose() {
bool Panel::handleClose() const {
if (_call) {
_call->hangup();
window()->hide();
return true;
}
return false;
}
not_null<Ui::RpWindow*> Panel::window() const {

View File

@ -106,7 +106,7 @@ private:
void initLayout();
void initGeometry();
void handleClose();
[[nodiscard]] bool handleClose() const;
void updateControlsGeometry();
void updateHangupGeometry();