Skip to content

Commit

Permalink
Merge pull request #5161 from xllndr/master
Browse files Browse the repository at this point in the history
Resize WebView widget once the loginpage rendered
  • Loading branch information
claucambra authored Mar 7, 2023
2 parents 22d9a74 + 664e0c1 commit f0ddc54
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 f0ddc54

Please sign in to comment.