Skip to content

Commit

Permalink
[welcome page] increase text width to avoid reflow on hidpi screens
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Oct 2, 2015
1 parent 89518f4 commit 1fdfe30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/qgswelcomepageitemsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void QgsWelcomePageItemDelegate::paint( QPainter* painter, const QStyleOptionVie
int textSize = titleSize * 0.85;

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() ) );
doc.setTextWidth( 800 );
doc.setTextWidth( 2800 );

QPixmap icon = qvariant_cast<QPixmap>( index.data( Qt::DecorationRole ) );
if ( !icon.isNull() )
Expand All @@ -94,7 +94,7 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem & option,
int textSize = titleSize * 0.85;

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() ) );
doc.setTextWidth( 800 );
doc.setTextWidth( 2800 );

QPixmap icon = qvariant_cast<QPixmap>( index.data( Qt::DecorationRole ) );

Expand Down

4 comments on commit 1fdfe30

@slarosa
Copy link
Member

@slarosa slarosa commented on 1fdfe30 Oct 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn with the increasing of text width in recent projects widget it always shows the horizontal scroll bar, Any chance to display it as needed?

@nirvn
Copy link
Contributor Author

@nirvn nirvn commented on 1fdfe30 Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slarosa I did notice the horizontal scroll bar after the PR was committed. It's a bit odd on my computer, whereas the scroll bar will only appear if I resize the QGIS window to be smaller than its original size on launch. Can you confirm it's the case for you too?

That said, I've tried to look into it and I'm at lost as to what's happening here. If you look at the sizeHint function (which begins at line 89), you'll see the code does not use the QTextDocument width to set the item's width. Some dark Qt voodoo at play here.

@slarosa
Copy link
Member

@slarosa slarosa commented on 1fdfe30 Oct 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirvn I see anyway the scrollbar not need to resize the window (15'' screen).

you'll see the code does not use the QTextDocument width to set the item's width. Some dark Qt voodoo at play here.

hmm, I guess option.rect.width() is related to doc.setTextWidth( 2800 ), but I am not sure.

Anyway, I expect the horizontal scrollbar must be shown as needed and if I resize the window I also would expect the text must be wrapped and not cut.

@nirvn
Copy link
Contributor Author

@nirvn nirvn commented on 1fdfe30 Oct 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slarosa PR #2368 fixes the issue.

Please sign in to comment.