mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 23:15:59 +00:00
Start fullscreen support in SeparatePanel.
This commit is contained in:
@@ -378,6 +378,13 @@ Panel::Panel(
|
|||||||
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
|
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
|
||||||
_widget->setInnerSize(st::botWebViewPanelSize, true);
|
_widget->setInnerSize(st::botWebViewPanelSize, true);
|
||||||
|
|
||||||
|
_fullscreen.value(
|
||||||
|
) | rpl::start_with_next([=](bool fullscreen) {
|
||||||
|
_widget->toggleFullScreen(fullscreen);
|
||||||
|
layoutButtons();
|
||||||
|
sendSafeArea();
|
||||||
|
}, _widget->lifetime());
|
||||||
|
|
||||||
_widget->closeRequests(
|
_widget->closeRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (_closeNeedConfirmation) {
|
if (_closeNeedConfirmation) {
|
||||||
@@ -612,6 +619,15 @@ bool Panel::showWebview(
|
|||||||
.isAttention = true,
|
.isAttention = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (_widget->isFullScreen()) {
|
||||||
|
callback(u"Close Full Screen"_q, [=] {
|
||||||
|
_fullscreen = false;
|
||||||
|
}, &st::menuIconPlayerWindowed);
|
||||||
|
} else {
|
||||||
|
callback(u"Show Full Screen"_q, [=] {
|
||||||
|
_fullscreen = true;
|
||||||
|
}, &st::menuIconPlayerFullScreen);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -619,7 +635,7 @@ bool Panel::showWebview(
|
|||||||
void Panel::createWebviewBottom() {
|
void Panel::createWebviewBottom() {
|
||||||
_webviewBottom = std::make_unique<RpWidget>(_widget.get());
|
_webviewBottom = std::make_unique<RpWidget>(_widget.get());
|
||||||
const auto bottom = _webviewBottom.get();
|
const auto bottom = _webviewBottom.get();
|
||||||
bottom->show();
|
bottom->setVisible(!_fullscreen.current());
|
||||||
|
|
||||||
const auto &padding = st::paymentsPanelPadding;
|
const auto &padding = st::paymentsPanelPadding;
|
||||||
const auto label = CreateChild<FlatLabel>(
|
const auto label = CreateChild<FlatLabel>(
|
||||||
@@ -744,6 +760,8 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
|||||||
_themeUpdateForced.fire({});
|
_themeUpdateForced.fire({});
|
||||||
} else if (command == "web_app_request_viewport") {
|
} else if (command == "web_app_request_viewport") {
|
||||||
sendViewport();
|
sendViewport();
|
||||||
|
} else if (command == "web_app_request_safe_area") {
|
||||||
|
sendSafeArea();
|
||||||
} else if (command == "web_app_open_tg_link") {
|
} else if (command == "web_app_open_tg_link") {
|
||||||
openTgLink(arguments);
|
openTgLink(arguments);
|
||||||
} else if (command == "web_app_open_link") {
|
} else if (command == "web_app_open_link") {
|
||||||
@@ -828,6 +846,11 @@ void Panel::sendViewport() {
|
|||||||
"is_expanded: true }");
|
"is_expanded: true }");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel::sendSafeArea() {
|
||||||
|
postEvent("safe_area_changed",
|
||||||
|
"{ top: 0, right: 0, bottom: 0, left: 0 }");
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::setTitle(rpl::producer<QString> title) {
|
void Panel::setTitle(rpl::producer<QString> title) {
|
||||||
_widget->setTitle(std::move(title));
|
_widget->setTitle(std::move(title));
|
||||||
}
|
}
|
||||||
@@ -1362,12 +1385,15 @@ void Panel::createButton(std::unique_ptr<Button> &button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Panel::layoutButtons() {
|
void Panel::layoutButtons() {
|
||||||
|
if (!_webviewBottom) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto inner = _widget->innerGeometry();
|
const auto inner = _widget->innerGeometry();
|
||||||
const auto shown = [](std::unique_ptr<Button> &button) {
|
const auto shown = [](std::unique_ptr<Button> &button) {
|
||||||
return button && !button->isHidden();
|
return button && !button->isHidden();
|
||||||
};
|
};
|
||||||
const auto any = shown(_mainButton) || shown(_secondaryButton);
|
const auto any = shown(_mainButton) || shown(_secondaryButton);
|
||||||
_webviewBottom->setVisible(!any);
|
_webviewBottom->setVisible(!any && !_fullscreen.current());
|
||||||
if (any) {
|
if (any) {
|
||||||
_bottomButtonsBg->show();
|
_bottomButtonsBg->show();
|
||||||
|
|
||||||
@@ -1437,6 +1463,8 @@ void Panel::layoutButtons() {
|
|||||||
}
|
}
|
||||||
_footerHeight = any
|
_footerHeight = any
|
||||||
? _bottomButtonsBg->height()
|
? _bottomButtonsBg->height()
|
||||||
|
: _fullscreen.current()
|
||||||
|
? 0
|
||||||
: _webviewBottom->height();
|
: _webviewBottom->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1461,7 +1489,7 @@ void Panel::showBox(
|
|||||||
&& widget->isHidden()
|
&& widget->isHidden()
|
||||||
&& _webview->lastHidingBox == raw) {
|
&& _webview->lastHidingBox == raw) {
|
||||||
widget->show();
|
widget->show();
|
||||||
_webviewBottom->show();
|
_webviewBottom->setVisible(!_fullscreen.current());
|
||||||
}
|
}
|
||||||
}, _webview->lifetime);
|
}, _webview->lifetime);
|
||||||
if (hideNow) {
|
if (hideNow) {
|
||||||
|
@@ -147,6 +147,7 @@ private:
|
|||||||
void scheduleCloseWithConfirmation();
|
void scheduleCloseWithConfirmation();
|
||||||
void closeWithConfirmation();
|
void closeWithConfirmation();
|
||||||
void sendViewport();
|
void sendViewport();
|
||||||
|
void sendSafeArea();
|
||||||
|
|
||||||
using EventData = std::variant<QString, QJsonObject>;
|
using EventData = std::variant<QString, QJsonObject>;
|
||||||
void postEvent(const QString &event);
|
void postEvent(const QString &event);
|
||||||
@@ -179,6 +180,7 @@ private:
|
|||||||
std::optional<QColor> _bottomBarColor;
|
std::optional<QColor> _bottomBarColor;
|
||||||
rpl::lifetime _headerColorLifetime;
|
rpl::lifetime _headerColorLifetime;
|
||||||
rpl::lifetime _bottomBarColorLifetime;
|
rpl::lifetime _bottomBarColorLifetime;
|
||||||
|
rpl::variable<bool> _fullscreen = false;
|
||||||
bool _webviewProgress = false;
|
bool _webviewProgress = false;
|
||||||
bool _themeUpdateScheduled = false;
|
bool _themeUpdateScheduled = false;
|
||||||
bool _hiddenForPayment = false;
|
bool _hiddenForPayment = false;
|
||||||
|
@@ -159,6 +159,8 @@ menuIconWinHello: icon {{ "menu/passcode_winhello", menuIconColor }};
|
|||||||
menuIconTouchID: icon {{ "menu/passcode_finger", menuIconColor }};
|
menuIconTouchID: icon {{ "menu/passcode_finger", menuIconColor }};
|
||||||
menuIconAppleWatch: icon {{ "menu/passcode_watch", menuIconColor }};
|
menuIconAppleWatch: icon {{ "menu/passcode_watch", menuIconColor }};
|
||||||
menuIconSystemPwd: menuIconPermissions;
|
menuIconSystemPwd: menuIconPermissions;
|
||||||
|
menuIconPlayerFullScreen: icon {{ "player/player_fullscreen", menuIconColor }};
|
||||||
|
menuIconPlayerWindowed: icon {{ "player/player_minimize", menuIconColor }};
|
||||||
|
|
||||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||||
|
Submodule Telegram/lib_ui updated: b969b5bd32...967ae393e8
Reference in New Issue
Block a user