Improve webview progress style.

This commit is contained in:
John Preston 2021-04-13 16:38:38 +04:00
parent 40e46e8480
commit e52f947f98
2 changed files with 14 additions and 13 deletions

View File

@ -125,3 +125,9 @@ paymentsCriticalError: FlatLabel(boxLabel) {
textFg: windowSubTextFg; textFg: windowSubTextFg;
} }
paymentsCriticalErrorPadding: margins(10px, 40px, 10px, 0px); paymentsCriticalErrorPadding: margins(10px, 40px, 10px, 0px);
paymentsLoading: InfiniteRadialAnimation(defaultInfiniteRadialAnimation) {
size: size(24px, 24px);
color: windowSubTextFg;
thickness: 4px;
}

View File

@ -47,7 +47,7 @@ Panel::Progress::Progress(QWidget *parent, Fn<QRect()> rect)
: widget(parent) : widget(parent)
, animation( , animation(
[=] { if (!anim::Disabled()) widget.update(rect()); }, [=] { if (!anim::Disabled()) widget.update(rect()); },
st::boxLoadingAnimation) { st::paymentsLoading) {
} }
Panel::Panel(not_null<PanelDelegate*> delegate) Panel::Panel(not_null<PanelDelegate*> delegate)
@ -90,9 +90,7 @@ void Panel::toggleProgress(bool shown) {
auto p = QPainter(&_progress->widget); auto p = QPainter(&_progress->widget);
p.setOpacity( p.setOpacity(
_progress->shownAnimation.value(_progress->shown ? 1. : 0.)); _progress->shownAnimation.value(_progress->shown ? 1. : 0.));
auto thickness = _webviewBottom auto thickness = st::paymentsLoading.thickness;
? st::boxLoadingAnimation.thickness
: (st::boxLoadingAnimation.thickness * 2);
if (progressWithBackground()) { if (progressWithBackground()) {
auto color = st::windowBg->c; auto color = st::windowBg->c;
color.setAlphaF(kProgressOpacity); color.setAlphaF(kProgressOpacity);
@ -106,7 +104,7 @@ void Panel::toggleProgress(bool shown) {
rect.topLeft(), rect.topLeft(),
rect.size() - QSize(), rect.size() - QSize(),
_progress->widget.width(), _progress->widget.width(),
st::boxLoadingAnimation.color, st::paymentsLoading.color,
thickness); thickness);
}, _progress->widget.lifetime()); }, _progress->widget.lifetime());
_progress->widget.show(); _progress->widget.show();
@ -158,9 +156,8 @@ void Panel::setupProgressGeometry() {
_webviewBottom->geometryValue( _webviewBottom->geometryValue(
) | rpl::start_with_next([=](QRect bottom) { ) | rpl::start_with_next([=](QRect bottom) {
const auto height = bottom.height(); const auto height = bottom.height();
const auto size = height const auto size = st::paymentsLoading.size;
- st::layerBox.buttonPadding.top() const auto skip = (height - size.height()) / 2;
- st::layerBox.buttonPadding.bottom();
const auto inner = _widget->innerGeometry(); const auto inner = _widget->innerGeometry();
const auto right = inner.x() + inner.width(); const auto right = inner.x() + inner.width();
const auto top = inner.y() + inner.height() - height; const auto top = inner.y() + inner.height() - height;
@ -169,11 +166,9 @@ void Panel::setupProgressGeometry() {
// triggered the 'fire' of correct geometry before getting here). // triggered the 'fire' of correct geometry before getting here).
//const auto right = bottom.x() + bottom.width(); //const auto right = bottom.x() + bottom.width();
//const auto top = bottom.y(); //const auto top = bottom.y();
_progress->widget.setGeometry( _progress->widget.setGeometry(QRect{
right - size - st::layerBox.buttonPadding.right(), QPoint(right - skip - size.width(), top + skip),
top + st::layerBox.buttonPadding.top(), size });
size,
size);
}, _progress->geometryLifetime); }, _progress->geometryLifetime);
} else if (_weakFormSummary) { } else if (_weakFormSummary) {
_weakFormSummary->sizeValue( _weakFormSummary->sizeValue(