From 97849250dae00c975f9de344ccf73fe2a9423846 Mon Sep 17 00:00:00 2001 From: Radim Blazek Date: Wed, 12 Feb 2014 17:12:25 +0100 Subject: [PATCH] identify resutlts dialog: always keep minimum QgsIdentifyResultsWebView height --- src/app/qgsidentifyresultsdialog.cpp | 31 +++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/app/qgsidentifyresultsdialog.cpp b/src/app/qgsidentifyresultsdialog.cpp index 9efe600ed8b8..e5eaab243c31 100644 --- a/src/app/qgsidentifyresultsdialog.cpp +++ b/src/app/qgsidentifyresultsdialog.cpp @@ -151,29 +151,26 @@ QSize QgsIdentifyResultsWebView::sizeHint() const QgsDebugMsg( QString( "content size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); int height = s.height(); - // if page is not yet loaded set some minimum height - if ( height == 0 ) + // parent is qt_scrollarea_viewport + // parent is not available the first time - before results dialog was shown + QWidget *widget = qobject_cast( parent() ); + if ( widget ) { - height = 100; + // It can probably happen that parent is available but it does not have yet + // correct size, see #9377. + int max = widget->size().height() * 0.9; + QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) ); + height = qMin( height, max ); } else { - // parent is qt_scrollarea_viewport - // parent is not available the first time - before results dialog was shown - QWidget *widget = qobject_cast( parent() ); - if ( widget ) - { - int max = widget->size().height() * 0.9; - QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) ); - if ( height > max ) - height = max; - } - else - { - QgsDebugMsg( "parent not available" ) ; - } + QgsDebugMsg( "parent not available" ) ; } + // Always keep some minimum size, e.g. if page is not yet loaded + // or parent has wrong size + height = qMax( height, 100 ); + s = QSize( size().width(), height ); QgsDebugMsg( QString( "size: %1 x %2" ).arg( s.width() ).arg( s.height() ) ); return s;