Tweak column widths in tree view of file open/save dialogs
ClosedPublic

Authored by sharvey on Apr 6 2018, 7:53 PM.

Details

Summary

Adjust column sizing options so that "last" column is no longer the largest.
First column (folder/file name & icon) will now occupy the majority of the space but does not compress other columns.

BUG: 354388
BUG: 338502
BUG: 196508
BUG: 177743
BUG: 96638
FIXED-IN: 5.46

Test Plan
  • Compile KIO with patch
  • Recompile an application (i.e. Kate), ensuring it will include the patched version of KIO
  • File -> Open (and/or File -> Save); select Detailed Tree View option
  • Check that Name column is the widest and occupies most of the space

Diff Detail

Repository
R241 KIO
Branch
arcpatch-D11993
Lint
No Linters Available
Unit
No Unit Test Coverage
sharvey created this revision.Apr 6 2018, 7:53 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptApr 6 2018, 7:53 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
sharvey requested review of this revision.Apr 6 2018, 7:53 PM
sharvey edited the summary of this revision. (Show Details)Apr 6 2018, 7:55 PM
sharvey added reviewers: ngraham, dfaure.
sharvey edited the summary of this revision. (Show Details)Apr 6 2018, 7:58 PM


Before (from user bug report)


After (mine)

broulik added a subscriber: broulik.Apr 6 2018, 8:03 PM
broulik added inline comments.
src/filewidgets/kdiroperatordetailview.cpp
87–89

For first colum you want to set it to 0, here it blew up the "Size" column to full width

sharvey updated this revision to Diff 31517.Apr 6 2018, 8:06 PM
  • Fix incorrect column index
sharvey marked an inline comment as done.Apr 6 2018, 8:08 PM
sharvey added inline comments.
src/filewidgets/kdiroperatordetailview.cpp
87–89

I got misled by my manual adjustment of the columns from previous tests. Thanks for catching.

Thanks for updating! I think this patch makes sense (and seems to work well) but I'm not too familiar with QTreeView, let's wait a bit for further feedback and merge it once Frameworks 5.45 has been tagged.

ngraham accepted this revision.Apr 6 2018, 8:37 PM

So. Much. Better. Now.

This patch is a breath of fresh air when using Detailed View or Detailed Tree View. You can resize the window and open and close the preview without wanting to kill something!

This revision is now accepted and ready to land.Apr 6 2018, 8:37 PM
sharvey marked an inline comment as done.Apr 6 2018, 8:39 PM

This patch is a breath of fresh air when using Detailed View or Detailed Tree View. You can resize the window and open and close the preview without wanting to kill something!

Such passion over a file dialog :)

Question: is expandNameColumn() even needed anymore with this change?

Give me a moment to comment it out again and re-check. I thought it was, but let me run another test.

I wasn't able to find any regressions stemming from removing that code, and once gone, I was able to hack out even more code that seemed to exist purely in support of it. Here's a diff that applies on top of this patch: https://paste.kde.org/p9z7riqdo

And while we're digging into this code, it would be quite nice to set QHeaderView::ResizeToContents for the other two columns so they always display the correct width and never have to be resized. That even fits under the umbrella of the patch's title "tweak column widths..."

In the works...

I'm to tired to test this myself, but could you please test this with the edge case where some file names are so long that they don't fit in the view? Also, Stretch disables manual resizing, right?' If that is also deemed useful, we could adapt the solution from https://centaurialpha.github.io/resize-qheaderview-to-contents-and-interactive. That's pyqt, but the same idea applies to C++. The resize event handling code is even already there, just needs to be adjusted.

I'll give that a test. I'm sure I can find a file (or make one up) with an absurdly long filename.

Once I figure out why @ngraham's uploaded diff won't apply... grr.

sharvey updated this revision to Diff 31540.Apr 7 2018, 12:54 AM
  • Remove unneeded resize code; ensure other columns fill to contents

All seems to be well with the removal of the extraneous resizing code.

Here's the result of a test with a ridiculously long filename:

I think that looks perfectly reasonable.

Also, yes - Stretch has disabled the ability to manually resize the columns. Columns 1 & 2 are set to fit the size of their contents, while column 0 fills all the remaining space. Resizing the dialog results in only the Name column (column 0) to change size; the others stay fixed to the size of their contents.

Got a few code niggles, detailed below.

Function-wise, this is a vast usability improvement. And in case you have a really excessively long file name, you can just use Tree view (the non-details version), which only has one column.

src/filewidgets/kdiroperatordetailview.cpp
35 ↗(On Diff #31540)

Oops, we shouldn't get rid of the initialization for both of these variables, just the one for m_resizeColumns. Remember to remove its definition in the header file, too.

src/filewidgets/kdiroperatordetailview_p.h
56 ↗(On Diff #31540)

Don't leave code commented out like this; if it's not used anymore, delete it!

58 ↗(On Diff #31540)

We don't need this anymore.

sharvey updated this revision to Diff 31545.Apr 7 2018, 2:18 AM
  • Remove leftover commented-out code; restore variable declaration
sharvey marked 3 inline comments as done.Apr 7 2018, 2:21 AM
sharvey added inline comments.
src/filewidgets/kdiroperatordetailview_p.h
56 ↗(On Diff #31540)

Remnants of testing. Won't do that again.

ngraham accepted this revision.Apr 7 2018, 2:24 AM
cfeck added a subscriber: cfeck.Apr 7 2018, 2:40 AM

I vaguely remember there was some code to delay resizing of the columns until all items were loaded for performance reasons. Please check the commit history before deleting code.

I vaguely remember there was some code to delay resizing of the columns until all items were loaded for performance reasons. Please check the commit history before deleting code.

File history during the frameworks era: https://cgit.kde.org/kio.git/log/src/filewidgets/kdiroperatordetailview.cpp

File history during the kdelibs era: https://cgit.kde.org/kdelibs.git/log/kfile/kdiroperatordetailview.cpp?h=Active/Two

Here's the commit from 2007 that added most of the code we're proposing to remove: https://cgit.kde.org/kdelibs.git/commit/kfile/kdiroperatordetailview.cpp?h=Active/Two&id=32af0ab2db10e64933b10c2434727b883441c0cf

Apparently the goal was to allow the columns to remain resizable before all the items had loaded. A bit of an odd goal, and I'm not able to reproduce the issue in my slow VM. Apparently hardware has become a bit faster in the past 11 years. :)

Of note: while digging, I found multiple commits that were attempting, unsuccessfully, to fix the problem that this patch fixes. It'll be nice to finally have it done. Overall, the spelunking expedition has made me more confident that this patch is sane.

ngraham edited the summary of this revision. (Show Details)Apr 9 2018, 9:08 PM
ngraham edited the summary of this revision. (Show Details)Apr 9 2018, 9:43 PM
ngraham edited the summary of this revision. (Show Details)Apr 10 2018, 5:32 PM
ngraham edited subscribers, added: Dolphin; removed: Frameworks.
ngraham edited the summary of this revision. (Show Details)Apr 10 2018, 6:47 PM

Any more opinions on this? As you can see from the Summary section, it fixes (or obviates) a ton of bugs, many of them very old.

broulik accepted this revision.Apr 11 2018, 6:08 AM

The only downside this has is that you can longer resize the column wider manually but then you might as well resize the window and actually see more :)

The only downside this has is that you can no longer resize the column wider manually but then you might as well resize the window and actually see more :)

Precisely! :)

ngraham added a comment.EditedApr 11 2018, 2:07 PM

@sharvey, can you re-base this onto current master (git pull --rebase origin master)? It doesn't want to land.

sharvey updated this revision to Diff 31992.Apr 12 2018, 6:37 PM
sharvey marked an inline comment as done.
  • Remove unneeded resize code; ensure other columns fill to contents
  • Remove leftover commented-out code; restore variable declaration

Rebased (I think). Had to manually resolve a conflict. Hopefully it'll land now.

ngraham added inline comments.Apr 12 2018, 6:42 PM
src/filewidgets/kdiroperatordetailview.cpp
52 ↗(On Diff #31540)

Uh-oh :)

53 ↗(On Diff #31540)

Uh-oh part II :)

sharvey updated this revision to Diff 32002.Apr 12 2018, 7:35 PM
  • Repairing merge error
sharvey marked 2 inline comments as done.Apr 12 2018, 7:36 PM

Merge errors tracked down and eradicated.

src/filewidgets/kdiroperatordetailview.cpp
52 ↗(On Diff #31540)

What is that? (finding it and killing it)

ngraham accepted this revision.Apr 12 2018, 7:42 PM

Works, thanks!

ngraham closed this revision.Apr 12 2018, 7:43 PM