Word-wrap KMessageWidget text
ClosedPublic

Authored by ngraham on Feb 12 2019, 7:44 PM.

Details

Summary

Word-wrap KMessageWidget text to prevent the window from being widened
when the text is very long.

CCBUG: 404232

Only CCBUG: because word wrap only works where QLabel detects a word boundary;
it will not wrap a string with no spaces or other word boundaries (e.g.
"aaaaaaaaaaaaaaaaaaaa...")

Test Plan
  • Create a new text file with a 300-character name that has spaces in it
  • In the KMessageWidget's error message, the file name is wrapped at the word

boundaries

Diff Detail

Repository
R318 Dolphin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Feb 12 2019, 7:44 PM
Restricted Application added a project: Dolphin. · View Herald TranscriptFeb 12 2019, 7:44 PM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
ngraham requested review of this revision.Feb 12 2019, 7:44 PM
ngraham updated this revision to Diff 51538.Feb 12 2019, 7:46 PM

Add a TODO: to the comment

cfeck accepted this revision.Feb 12 2019, 8:52 PM
cfeck added a subscriber: cfeck.

I would just remove the comment. The commit references the bug anyway, and a bug reference in the code is only helpful if the code is wrong, and someone wants to understand why.

This revision is now accepted and ready to land.Feb 12 2019, 8:52 PM

Well, the code is not wrong but rather incomplete. :) Do you want me to remove the TODO: too?

cfeck added a comment.EditedFeb 12 2019, 9:08 PM

Well, fix the TODO, and you can remove the comment ;)

I guess QLabel needs new API to set https://doc.qt.io/qt-5/qtextoption.html#WrapMode-enum

But those plans should be tracked elsewhere, not in source. IMHO. You or maintainer decides, not me.

ngraham retitled this revision from Word-drap KMessageWidget text to Word-wrap KMessageWidget text.Feb 12 2019, 9:12 PM
ngraham updated this revision to Diff 51551.Feb 12 2019, 9:14 PM

Remove bug number in comment

ngraham updated this revision to Diff 51554.Feb 12 2019, 9:23 PM

Reference the appropriate Qt bug report

@cfeck What if we use a KSqueezedTextLabel in KMessageWidget instead? That would mostly fix also the 'aaaaaaaaaaaa' case without requiring new API in QLabel.

cfeck added a comment.Feb 16 2019, 5:47 PM

Dolphin could simply call KStringHandler::*squeeze(), maybe only on the actual filepath, if squeezing is preferred to wrapping.

That could also work, yes. @ngraham wanna give it a try?

Yep, that works great. Did it in D19103: Middle-elide very long filenames in error strings.

We'll still need this because word-wrapping the message is also an improvement.

elvisangelaccio accepted this revision.Feb 17 2019, 8:27 PM
This revision was automatically updated to reflect the committed changes.