Skip to content

Commit

Permalink
Resize WebView widget once the loginpage rendered
Browse files Browse the repository at this point in the history
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 <lender@b1-systems.de>
  • Loading branch information
b1-lender committed Jan 23, 2023
1 parent 593377a commit d1c6907
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/gui/wizard/webview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/gui/wizard/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ class WebView : public QWidget
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;
Expand Down

0 comments on commit d1c6907

Please sign in to comment.