Skip to content

Commit 537d195

Browse files
committed
[welcome page] add a minmium width to the recent project list
1 parent 06a41ef commit 537d195

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/app/qgswelcomepageitemsmodel.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,23 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem & option,
9292
QTextDocument doc;
9393
QPixmap icon = qvariant_cast<QPixmap>( index.data( Qt::DecorationRole ) );
9494

95+
int width;
96+
if ( option.rect.width() < 450 )
97+
{
98+
width = 450;
99+
}
100+
else
101+
{
102+
width = option.rect.width();
103+
}
104+
95105
int titleSize = QApplication::fontMetrics().height() * 1.1;
96106
int textSize = titleSize * 0.85;
97107

98108
doc.setHtml( QString( "<div style='font-size:%1px;'><span style='font-size:%2px;font-weight:bold;'>%3</span><br>%4<br>%5</div>" ).arg( textSize ).arg( titleSize ).arg( index.data( QgsWelcomePageItemsModel::TitleRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::PathRole ).toString() ).arg( index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
99-
doc.setTextWidth( option.rect.width() - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
109+
doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) );
100110

101-
return QSize( option.rect.width(), qMax( doc.size().height() + 10, ( double )icon.height() ) + 20 );
111+
return QSize( width, qMax( doc.size().height() + 10, ( double )icon.height() ) + 20 );
102112
}
103113

104114
QgsWelcomePageItemsModel::QgsWelcomePageItemsModel( QObject* parent )

0 commit comments

Comments
 (0)