Skip to content

Commit 9784925

Browse files
committed
identify resutlts dialog: always keep minimum QgsIdentifyResultsWebView height
1 parent c64a051 commit 9784925

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/app/qgsidentifyresultsdialog.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,26 @@ QSize QgsIdentifyResultsWebView::sizeHint() const
151151
QgsDebugMsg( QString( "content size: %1 x %2" ).arg( s.width() ).arg( s.height() ) );
152152
int height = s.height();
153153

154-
// if page is not yet loaded set some minimum height
155-
if ( height == 0 )
154+
// parent is qt_scrollarea_viewport
155+
// parent is not available the first time - before results dialog was shown
156+
QWidget *widget = qobject_cast<QWidget *>( parent() );
157+
if ( widget )
156158
{
157-
height = 100;
159+
// It can probably happen that parent is available but it does not have yet
160+
// correct size, see #9377.
161+
int max = widget->size().height() * 0.9;
162+
QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) );
163+
height = qMin( height, max );
158164
}
159165
else
160166
{
161-
// parent is qt_scrollarea_viewport
162-
// parent is not available the first time - before results dialog was shown
163-
QWidget *widget = qobject_cast<QWidget *>( parent() );
164-
if ( widget )
165-
{
166-
int max = widget->size().height() * 0.9;
167-
QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) );
168-
if ( height > max )
169-
height = max;
170-
}
171-
else
172-
{
173-
QgsDebugMsg( "parent not available" ) ;
174-
}
167+
QgsDebugMsg( "parent not available" ) ;
175168
}
176169

170+
// Always keep some minimum size, e.g. if page is not yet loaded
171+
// or parent has wrong size
172+
height = qMax( height, 100 );
173+
177174
s = QSize( size().width(), height );
178175
QgsDebugMsg( QString( "size: %1 x %2" ).arg( s.width() ).arg( s.height() ) );
179176
return s;

0 commit comments

Comments
 (0)