Skip to content

Commit

Permalink
Limit the maximum width of legend embedded widgets
Browse files Browse the repository at this point in the history
Since column is resized to contents, limit the expanded width of
embedded widgets, if they are not already limited.

Else, embedded widget may grow very wide due to large legend graphics.
  • Loading branch information
dakcarto committed Jun 14, 2019
1 parent a79f2ba commit 26b86ba
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gui/layertree/qgslayertreeview.cpp
Expand Up @@ -159,7 +159,16 @@ void QgsLayerTreeView::modelRowsInserted( const QModelIndex &index, int start, i
if ( QgsLayerTreeEmbeddedWidgetProvider *provider = QgsGui::layerTreeEmbeddedWidgetRegistry()->provider( providerId ) )
{
QModelIndex index = layerTreeModel()->legendNode2index( legendNodes[i] );
setIndexWidget( index, provider->createWidget( layer, i ) );
QWidget *wdgt = provider->createWidget( layer, i );
// Since column is resized to contents, limit the expanded width of embedded widgets,
// if they are not already limited, e.g. have the defaut MAX value.
// Else, embedded widget may grow very wide due to large legend graphics.
// TODO: Max width could be a configured setting.
if ( wdgt->maximumWidth() == QWIDGETSIZE_MAX )
{
wdgt->setMaximumWidth( 250 );
}
setIndexWidget( index, wdgt );
}
}
}
Expand Down

0 comments on commit 26b86ba

Please sign in to comment.