From: Axel Lender Date: Thu, 10 Nov 2022 12:13:32 +0000 (+0100) Subject: Resize WebView widget once the loginpage rendered X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~10^2~158^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=664e0c18ec3273d6b4364c9c49f77d88211962e4;p=nextcloud-desktop.git Resize WebView widget once the loginpage rendered When the login dialogue displays the login page itself the WebView widget did not resize according to the dimensions of the login page. Signed-off-by: Axel Lender --- diff --git a/src/gui/wizard/webview.cpp b/src/gui/wizard/webview.cpp index 0ecaca08c..99fd18bb2 100644 --- a/src/gui/wizard/webview.cpp +++ b/src/gui/wizard/webview.cpp @@ -111,12 +111,30 @@ WebView::WebView(QWidget *parent) connect(_webview, &QWebEngineView::loadProgress, _ui.progressBar, &QProgressBar::setValue); connect(_schemeHandler, &WebViewPageUrlSchemeHandler::urlCatched, this, &WebView::urlCatched); + + connect(_page, &QWebEnginePage::contentsSizeChanged, this, &WebView::slotResizeToContents); } void WebView::setUrl(const QUrl &url) { _page->setUrl(url); } +QSize WebView::minimumSizeHint() const { + return _size; +} + +void WebView::slotResizeToContents(const QSizeF &size){ + //this widget also holds the progressbar + const int newHeight = size.toSize().height() + _ui.progressBar->height(); + const int newWidth = size.toSize().width(); + _size = QSize(newWidth, newHeight); + + this->updateGeometry(); + + //only resize once + disconnect(_page, &QWebEnginePage::contentsSizeChanged, this, &WebView::slotResizeToContents); +} + WebView::~WebView() { /* * The Qt implmentation deletes children in the order they are added to the diff --git a/src/gui/wizard/webview.h b/src/gui/wizard/webview.h index 6cfbcb8c0..999666687 100644 --- a/src/gui/wizard/webview.h +++ b/src/gui/wizard/webview.h @@ -23,13 +23,19 @@ public: WebView(QWidget *parent = nullptr); ~WebView() override; void setUrl(const QUrl &url); + virtual QSize minimumSizeHint() const override; signals: void urlCatched(const QString user, const QString pass, const QString host); +private slots: + void slotResizeToContents(const QSizeF &size); + private: Ui_WebView _ui; + QSize _size; + QWebEngineView *_webview; QWebEngineProfile *_profile; WebEnginePage *_page;