Middle-elide file/folder labels so the extension is always visible

Authored by ngraham on Mar 2 2019, 1:02 PM.



This ensures that the filename extension is always visible, and also is just a
nicer way to elide file and folder names in general.

BUG: 404955
FIXED-IN: 19.12.0

Test Plan

Details view:

Icons view with limited label height:

Diff Detail

R318 Dolphin
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Mar 2 2019, 1:02 PM
Restricted Application added a project: Dolphin. · View Herald TranscriptMar 2 2019, 1:02 PM
Restricted Application added a subscriber: kfm-devel. · View Herald Transcript
ngraham requested review of this revision.Mar 2 2019, 1:02 PM

Hmm, I don't know, I'm afraid this would make the filenames harder to recognize.
The file extension can always be guessed by looking at the file icon/preview. Advanced user could also add the Type column in detail view mode. And there is also the Information panel...

Also note that the file dialog uses right-elision as well, so that would need to be patched accordingly.

In my opinion, middle elision is actually more comprehensible for filenames than right-elision is. macOS Finder also uses middle elision here, for comparison.

I'll do the file dialogs as well for consistency.

rooty accepted this revision.EditedMar 11 2019, 7:39 PM
rooty added a subscriber: rooty.

Right-sided elision isn't all that useful considering the filename that's being elided is usually pretty long already. This patch, however, would enable the user to always see the extension (which is a huge deal, especially if we're dealing with something malicious).

So +1 from me (will you be doing file dialogs in a separate patch or as part of this one?)

This revision is now accepted and ready to land.Mar 11 2019, 7:39 PM
rooty resigned from this revision.Mar 28 2019, 11:22 PM
This revision now requires review to proceed.Mar 28 2019, 11:22 PM
ngraham edited reviewers, added: VDG; removed: rooty.May 3 2019, 3:23 PM

Any chance we can reach some consensus on this?

ndavis added a subscriber: ndavis.Jun 25 2019, 9:33 PM

It feels strange at first, but I think it's a good idea.

elvisangelaccio accepted this revision.Jun 30 2019, 8:29 PM

I guess go for it.

As long as the file picker gets the same patch ;)

This revision is now accepted and ready to land.Jun 30 2019, 8:29 PM
ngraham edited the summary of this revision. (Show Details)Jun 30 2019, 9:17 PM
GB_2 accepted this revision.Aug 16 2019, 8:14 AM
GB_2 edited the summary of this revision. (Show Details)
GB_2 added a subscriber: GB_2.

Now we need the file dialog patch.

meven added a subscriber: meven.Sat, May 16, 6:58 AM

We would need a custom elideText function to solve https://bugs.kde.org/show_bug.cgi?id=404955
Original Qt function :


Currently we end up with Qt::ElideMiddle:

What we want I guess is : Qt::ElideLeft, keeping file extension.

A function wrapping m_customizedFontMetrics.elidedText(text, Qt::ElideMiddle, availableTextWidth) while excluding file extension.