Bug 498745

Summary: In file properties dialog, print start and end of hashsum instead of cutting it, if window is not wide enough
Product: [Frameworks and Libraries] frameworks-kio Reporter: Andrew Shark <ashark>
Component: Properties dialogAssignee: KIO Bugs <kio-bugs-null>
Status: CONFIRMED ---    
Severity: wishlist CC: kamkaz, kdelibs-bugs-null, nate
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Screenshot showing a problem
A drawing of how the solution could look

Description Andrew Shark 2025-01-16 14:16:14 UTC
In the file properties dialog in the Checksums tab, if the width of window is thinner than the length of
sha256sum digest length (64 symbols), then it is shown unintuitively. It just cuts the end of the line.

Let's say the sha256sum of some file is
  7a6a86097f479b6b8e4eaa163ecc2871264c9c9c4e78b458a0e1ee5c79a5e40c

In usual situation, when the window is wide enough, it is displayed as expected:

   ┌──────────────────────────────────────────────────────────────────────────────────┐
   │ md5                                                                              │
   │ sha1                                                                             │
   │ sha256    7a6a86097f479b6b8e4eaa163ecc2871264c9c9c4e78b458a0e1ee5c79a5e40c       │
   │ sha512                                                                           │
   │                                                                                  │
   └──────────────────────────────────────────────────────────────────────────────────┘

Now, if the window length is thinner, it may be displayed for example like this:

   ┌─────────────────────────────────────────────────────────┐
   │ md5                                                     │
   │ sha1                                                    │
   │ sha256    7a6a86097f479b6b8e4eaa163ecc2871264c9c9c4e78b4│
   │ sha512                                                  │
   │                                                         │
   └─────────────────────────────────────────────────────────┘

This confuses the user, because they want to compare the beginning and the end of line. I.e. the user knows what hashsum
is expected (from the file download page), and remembers the start (7a6a) and end (e40c). But when they do check, they
see "7a6a" at the beginning _but_ something unexpected from the middle "78b4" instead of end.

What I propose instead is that the line is squashed (with three dots) in the middle, and user could see the actual ending of
the hashsum. Like this:

   ┌─────────────────────────────────────────────────────────┐
   │ md5                                                     │
   │ sha1                                                    │
   │ sha256    7a6a86097f479b6b8e4e...e78b458a0e1ee5c79a5e40c|
   │ sha512                                                  │
   │                                                         │
   └─────────────────────────────────────────────────────────┘

SOFTWARE VERSIONS:
Operating System: ArcoLinux 
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Comment 1 Andrew Shark 2025-01-16 14:17:53 UTC
Created attachment 177413 [details]
Screenshot showing a problem
Comment 2 Andrew Shark 2025-01-16 14:18:40 UTC
Created attachment 177414 [details]
A drawing of how the solution could look
Comment 3 kamkaz 2025-02-20 01:19:45 UTC
It seems to be tricky to achieve.

One attempt could be using `QFontMetrics::elidedText()`. It has, however, some issues:
- Likely, we would have to paint the text ourselves instead of relying on the default QLineEdit painting. Does it mean, that there would be no way to select the text? It's at least a bit confusing. What should happen if the text is selected, does it snap to showing the entire hash?
- the formatting on the elided text would be pretty plain (as in, no formatting, just ellipsis (...) in the middle, same color, not even separating space)

Is there an easier / better way to do it? Do we already have some widget like that?