Add wordwrap in output window
Current output view widget in KDevelop outputs single lines only. And in case of very long lines outputted from application (like Vulkan debug messages) output view becomes unusable. You have to scroll a lot and read continuous line. Typical solution for such issue is usage of word wrapping when output text will fit output window. It greatly improves usability and simplify read process. In order to implement this functionality following changes was required:
- Enable WordWrap on
KDevelop::FocusedTreeView
inOutputWidget
- Disable uniform rows on
KDevelop::FocusedTreeView
inOutputWidget
- Add
sizeHint
toOutputDelegate
.
Unfortunately QFontMetrics::boundingRect
and QStyle::itemTextRect
provides incorrect data, so a bit of a hack was used here.
Result returned by QStyle::itemTextRect
is slightly smaller then required. I believe it's because this function ignores margins. So what I do - I calculated line count from text and add required amount of margins. For multi-string text it results in slightly bigger rectangle that actually required. I tried it on long Vulkan messages and it became much more usable.