mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix geometry applying in webview windows.
This commit is contained in:
parent
6734f99ba8
commit
2bdc204c47
4 changed files with 43 additions and 30 deletions
|
@ -534,12 +534,15 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||||
const auto bottom = _webviewBottom.get();
|
const auto bottom = _webviewBottom.get();
|
||||||
bottom->show();
|
bottom->show();
|
||||||
|
|
||||||
bottom->heightValue(
|
rpl::combine(
|
||||||
) | rpl::start_with_next([=](int height) {
|
container->geometryValue() | rpl::map([=] {
|
||||||
const auto inner = _widget->innerGeometry();
|
return _widget->innerGeometry();
|
||||||
|
}),
|
||||||
|
bottom->heightValue()
|
||||||
|
) | rpl::start_with_next([=](QRect inner, int height) {
|
||||||
bottom->move(inner.x(), inner.y() + inner.height() - height);
|
bottom->move(inner.x(), inner.y() + inner.height() - height);
|
||||||
container->resize(inner.width(), inner.height() - height);
|
|
||||||
bottom->resizeToWidth(inner.width());
|
bottom->resizeToWidth(inner.width());
|
||||||
|
_footerHeight = bottom->height();
|
||||||
}, bottom->lifetime());
|
}, bottom->lifetime());
|
||||||
container->show();
|
container->show();
|
||||||
|
|
||||||
|
@ -584,10 +587,12 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
container->geometryValue(
|
rpl::combine(
|
||||||
) | rpl::start_with_next([=](QRect geometry) {
|
container->geometryValue(),
|
||||||
if (raw->widget()) {
|
_footerHeight.value()
|
||||||
raw->widget()->setGeometry(geometry);
|
) | rpl::start_with_next([=](QRect geometry, int footer) {
|
||||||
|
if (const auto view = raw->widget()) {
|
||||||
|
view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer }));
|
||||||
}
|
}
|
||||||
}, _webview->lifetime);
|
}, _webview->lifetime);
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,13 @@ private:
|
||||||
[[nodiscard]] bool progressWithBackground() const;
|
[[nodiscard]] bool progressWithBackground() const;
|
||||||
[[nodiscard]] QRect progressRect() const;
|
[[nodiscard]] QRect progressRect() const;
|
||||||
void setupProgressGeometry();
|
void setupProgressGeometry();
|
||||||
|
void updateFooterHeight();
|
||||||
|
|
||||||
const not_null<PanelDelegate*> _delegate;
|
const not_null<PanelDelegate*> _delegate;
|
||||||
std::unique_ptr<SeparatePanel> _widget;
|
std::unique_ptr<SeparatePanel> _widget;
|
||||||
std::unique_ptr<WebviewWithLifetime> _webview;
|
std::unique_ptr<WebviewWithLifetime> _webview;
|
||||||
std::unique_ptr<RpWidget> _webviewBottom;
|
std::unique_ptr<RpWidget> _webviewBottom;
|
||||||
|
rpl::variable<int> _footerHeight;
|
||||||
std::unique_ptr<Progress> _progress;
|
std::unique_ptr<Progress> _progress;
|
||||||
QPointer<Checkbox> _saveWebviewInformation;
|
QPointer<Checkbox> _saveWebviewInformation;
|
||||||
QPointer<FormSummary> _weakFormSummary;
|
QPointer<FormSummary> _weakFormSummary;
|
||||||
|
|
|
@ -570,17 +570,15 @@ void Panel::createWebviewBottom() {
|
||||||
label->show();
|
label->show();
|
||||||
_webviewBottom->resize(_webviewBottom->width(), height);
|
_webviewBottom->resize(_webviewBottom->width(), height);
|
||||||
|
|
||||||
bottom->heightValue(
|
rpl::combine(
|
||||||
) | rpl::start_with_next([=](int height) {
|
_webviewParent->geometryValue() | rpl::map([=] {
|
||||||
const auto inner = _widget->innerGeometry();
|
return _widget->innerGeometry();
|
||||||
if (_mainButton && !_mainButton->isHidden()) {
|
}),
|
||||||
height = _mainButton->height();
|
bottom->heightValue()
|
||||||
}
|
) | rpl::start_with_next([=](QRect inner, int height) {
|
||||||
bottom->move(inner.x(), inner.y() + inner.height() - height);
|
bottom->move(inner.x(), inner.y() + inner.height() - height);
|
||||||
if (const auto container = _webviewParent.data()) {
|
|
||||||
container->setFixedSize(inner.width(), inner.height() - height);
|
|
||||||
}
|
|
||||||
bottom->resizeToWidth(inner.width());
|
bottom->resizeToWidth(inner.width());
|
||||||
|
updateFooterHeight();
|
||||||
}, bottom->lifetime());
|
}, bottom->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,10 +634,13 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
container->geometryValue(
|
updateFooterHeight();
|
||||||
) | rpl::start_with_next([=](QRect geometry) {
|
rpl::combine(
|
||||||
if (raw->widget()) {
|
container->geometryValue(),
|
||||||
raw->widget()->setGeometry(geometry);
|
_footerHeight.value()
|
||||||
|
) | rpl::start_with_next([=](QRect geometry, int footer) {
|
||||||
|
if (const auto view = raw->widget()) {
|
||||||
|
view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer }));
|
||||||
}
|
}
|
||||||
}, _webview->lifetime);
|
}, _webview->lifetime);
|
||||||
|
|
||||||
|
@ -1185,22 +1186,25 @@ void Panel::createMainButton() {
|
||||||
button->hide();
|
button->hide();
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
_webviewParent->geometryValue() | rpl::map([=] {
|
||||||
|
return _widget->innerGeometry();
|
||||||
|
}),
|
||||||
button->shownValue(),
|
button->shownValue(),
|
||||||
button->heightValue()
|
button->heightValue()
|
||||||
) | rpl::start_with_next([=](bool shown, int height) {
|
) | rpl::start_with_next([=](QRect inner, bool shown, int height) {
|
||||||
const auto inner = _widget->innerGeometry();
|
|
||||||
if (!shown) {
|
|
||||||
height = _webviewBottom->height();
|
|
||||||
}
|
|
||||||
button->move(inner.x(), inner.y() + inner.height() - height);
|
button->move(inner.x(), inner.y() + inner.height() - height);
|
||||||
if (const auto raw = _webviewParent.data()) {
|
|
||||||
raw->setFixedSize(inner.width(), inner.height() - height);
|
|
||||||
}
|
|
||||||
button->resizeToWidth(inner.width());
|
button->resizeToWidth(inner.width());
|
||||||
_webviewBottom->setVisible(!shown);
|
_webviewBottom->setVisible(!shown);
|
||||||
|
updateFooterHeight();
|
||||||
}, button->lifetime());
|
}, button->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel::updateFooterHeight() {
|
||||||
|
_footerHeight = (_mainButton && !_mainButton->isHidden())
|
||||||
|
? _mainButton->height()
|
||||||
|
: _webviewBottom->height();
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::showBox(object_ptr<BoxContent> box) {
|
void Panel::showBox(object_ptr<BoxContent> box) {
|
||||||
if (const auto widget = _webview ? _webview->window.widget() : nullptr) {
|
if (const auto widget = _webview ? _webview->window.widget() : nullptr) {
|
||||||
const auto hideNow = !widget->isHidden();
|
const auto hideNow = !widget->isHidden();
|
||||||
|
|
|
@ -143,6 +143,7 @@ private:
|
||||||
[[nodiscard]] bool progressWithBackground() const;
|
[[nodiscard]] bool progressWithBackground() const;
|
||||||
[[nodiscard]] QRect progressRect() const;
|
[[nodiscard]] QRect progressRect() const;
|
||||||
void setupProgressGeometry();
|
void setupProgressGeometry();
|
||||||
|
void updateFooterHeight();
|
||||||
|
|
||||||
Webview::StorageId _storageId;
|
Webview::StorageId _storageId;
|
||||||
const not_null<Delegate*> _delegate;
|
const not_null<Delegate*> _delegate;
|
||||||
|
@ -153,9 +154,10 @@ private:
|
||||||
std::unique_ptr<WebviewWithLifetime> _webview;
|
std::unique_ptr<WebviewWithLifetime> _webview;
|
||||||
std::unique_ptr<RpWidget> _webviewBottom;
|
std::unique_ptr<RpWidget> _webviewBottom;
|
||||||
rpl::variable<QString> _bottomText;
|
rpl::variable<QString> _bottomText;
|
||||||
QPointer<QWidget> _webviewParent;
|
QPointer<RpWidget> _webviewParent;
|
||||||
std::unique_ptr<Button> _mainButton;
|
std::unique_ptr<Button> _mainButton;
|
||||||
mutable crl::time _mainButtonLastClick = 0;
|
mutable crl::time _mainButtonLastClick = 0;
|
||||||
|
rpl::variable<int> _footerHeight = 0;
|
||||||
std::unique_ptr<Progress> _progress;
|
std::unique_ptr<Progress> _progress;
|
||||||
rpl::event_stream<> _themeUpdateForced;
|
rpl::event_stream<> _themeUpdateForced;
|
||||||
rpl::lifetime _headerColorLifetime;
|
rpl::lifetime _headerColorLifetime;
|
||||||
|
|
Loading…
Add table
Reference in a new issue