Bug 494679 - Dolphin populates "Create new" menu with the content of home dir
Summary: Dolphin populates "Create new" menu with the content of home dir
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 24.08.2
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 494489 495166 495220 495280 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-10-13 16:24 UTC by Eugene Shalygin
Modified: 2024-10-26 00:57 UTC (History)
16 users (show)

See Also:
Latest Commit:
Version Fixed In: Frameworks 6.8
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Shalygin 2024-10-13 16:24:04 UTC
SUMMARY

"Create new" context menu contains the full list of files and dirs in $HOME, placed between "Folder" and file items.

SOFTWARE/OS VERSIONS
Operating System: Gentoo 2.15
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.3
Kernel Version: 6.11.3-gentoo (64-bit)
Graphics Platform: Wayland
Comment 1 Christian (Fuchs) 2024-10-14 14:58:07 UTC
Confirmed here with fedora packages on X11 as well.

Operating System: Fedora Linux 40
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2
Kernel Version: 6.10.12-200.fc40.x86_64 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i5-8265U CPU @ 1.60GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Manufacturer: LENOVO
Comment 2 Eugene Shalygin 2024-10-14 15:04:01 UTC
In another, very similar Gentoo installation, the menu is OK.
Comment 3 Christian (Fuchs) 2024-10-14 15:05:46 UTC
(In reply to Eugene Shalygin from comment #2)
> In another, very similar Gentoo installation, the menu is OK.

My first two guesses would be different locale or different xdg dirs, since there is technically a directory for templates.
Could you check for differences there? Unfortunately all boxes with 24.08.2 I have do show it as reproducable.
(Also double-check that you have the same frameworks- and Qt versions on both boxes)
Comment 4 Eugene Shalygin 2024-10-14 15:13:43 UTC
Qt, Frameworks, and Gear versions are identical. Locales might differ, the system without the bug is configured to:
$ locale
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY=en_IE.UTF-8
LC_MESSAGES="C.UTF-8"
LC_PAPER=de_DE.UTF-8
LC_NAME="C.UTF-8"
LC_ADDRESS=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

What do I need to look for with respect to XDG config?
Comment 5 Christian (Fuchs) 2024-10-14 15:48:44 UTC
(In reply to Eugene Shalygin from comment #4)

> What do I need to look for with respect to XDG config?

Found the bug, in my 

.config/user-dirs.dirs

I had the line
XDG_TEMPLATES_DIR="$HOME/"

Which I assume some old versions or distributions have set as the default.
Setting that to something else will fix the bug.
I wonder if there should be a check for that, since technically dolphin is behaving correctly, I just wonder why it only started doing that very recently, and why some systems have that value set and some do not.
Comment 6 Eugene Shalygin 2024-10-14 16:35:50 UTC
Thanks a lot! This must be it, because for me the bug is indeed observed in an older system. Actually, I don't think now that this is a but. Maybe it would be a bit more convenient, and certainly I'd have a hint that the long list of items is not a bug, if they were placed in a sub-menu (Create New -> From Template, for instance)?
Comment 7 Christian (Fuchs) 2024-10-14 17:33:34 UTC
(In reply to Eugene Shalygin from comment #6)
> Thanks a lot! This must be it, because for me the bug is indeed observed in
> an older system. Actually, I don't think now that this is a but. Maybe it
> would be a bit more convenient, and certainly I'd have a hint that the long
> list of items is not a bug, if they were placed in a sub-menu (Create New ->
> From Template, for instance)?

While that might make sense, it's imo still not great Usability, since users have no idea where to change these templates / where they come from. There is a kcm for that in systemsettings -> session -> places, but it's not obvious from the context menu. Maybe adding a link at the bottom to there and adding an explanation text to the kcm would help. I'll throw the bug report into the VDG group, maybe people in there have some ideas :)
Comment 8 Massimiliano L 2024-10-15 08:12:11 UTC
(In reply to Christian (Fuchs) from comment #5)
> (In reply to Eugene Shalygin from comment #4)
> 
> > What do I need to look for with respect to XDG config?
> 
> Found the bug, in my 
> 
> .config/user-dirs.dirs
> 
> I had the line
> XDG_TEMPLATES_DIR="$HOME/"
> 
> Which I assume some old versions or distributions have set as the default.
> Setting that to something else will fix the bug.
> I wonder if there should be a check for that, since technically dolphin is
> behaving correctly, I just wonder why it only started doing that very
> recently, and why some systems have that value set and some do not.

I have two Fedora installations with more or less the same age and the problem affected only one of the two. I believe this could have been a consequence of the user deleting the ~/Templates directory and whatever created/updated .config/user-dirs.dirs afterwards defaulted to $HOME/.
Comment 9 Felix Ernst 2024-10-15 09:05:55 UTC
This was brought up in the KDE file management chat room. There Jin Liu suggested the following:

>Maybe it should have some fool-proof check, as it's quite common to set these places to $HOME.

I would agree and say, if such an error is identified, it should not show the contents of $HOME and instead guide users towards resolving the situation.

But how would the user interface look to guide users there? I don't have a set opinion on that. Christian has pointed out that even the non-error case has a bad user experience currently, because it is not clear from the "Create New" menu how one would go about changing the entries of that menu. For this, Christian has opened a separate feature request in https://bugs.kde.org/show_bug.cgi?id=494774.

Here is an attempt at coming up with a possible solution:
- We should have an action in the "Create New" menu called "Add Custom Entry…". At the minimum, and if XDG_TEMPLATES_DIR is set to a sensible value, this action could simply open that Templates folder. Of course it would be even better if there was some explanation that users need to move template files into that folder.
- If XDG_TEMPLATES_DIR is set to $HOME or some other nonsense location, we should not show the contents of that directory in the "Create New" menu. So "Add Custom Entry…" would be one of the few entries in that menu. Clicking it, however, should not open the badly configured XDG_TEMPLATES_DIR but instead show an error message saying something like: "The folder for templates on this system is misconfigured and points to $HOME. Do you want to set it to a Templates folder in your home directory?" and then a button "Confirm" to trigger this.

The above is just the first idea I had. Other solutions might be better.
Comment 10 Felix Ernst 2024-10-15 09:10:26 UTC
The "Create New" menu used in Dolphin is implemented in the KIO framework (https://api.kde.org/frameworks/kio/html/classKNewFileMenu.html). So most of these changes would need to be implemented there.
Comment 11 Christian (Fuchs) 2024-10-15 09:20:55 UTC
(In reply to Felix Ernst from comment #9)
> [snip]
> The above is just the first idea I had. Other solutions might be better.

Hello Felix, thanks a lot for chiming in, I think your solution sounds good, I assume it will need work in multiple places though, since I think that the explanation and nonsense-location-fixing part should probably be in the KCM where you can set that dir, not dolphin / kio specific.

With regards to KIO, sorry if I placed the feature request on the wrong product, obviously feel free to move it :)

Also I think I have seen you in the VDG room in the past, so if you want to discuss details, of course always feel free to poke me there. I am currently bed-bound with flu/corona and not around a lot though. Very glad to hear that this will be worked on / improved.

Thanks for you work, kind regards,

Christian
Comment 12 Felix Ernst 2024-10-16 09:41:44 UTC
(In reply to Christian (Fuchs) from comment #11)
> With regards to KIO, sorry if I placed the feature request on the wrong
> product, obviously feel free to move it :)

It is not a bad location. People might be able to find it there more easily even.

> Also I think I have seen you in the VDG room in the past, so if you want to
> discuss details, of course always feel free to poke me there. I am currently
> bed-bound with flu/corona and not around a lot though. Very glad to hear
> that this will be worked on / improved.

Sorry to say, but I don't have plans to work on this currently. I hope someone else will. Thanks for the offer. Discussing details in the VDG is definitely the right approach.

> Thanks for you work, kind regards,

Thanks for your work, too. Get well soon!
Comment 13 Bug Janitor Service 2024-10-16 20:59:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1742
Comment 14 Antonio Rojas 2024-10-22 06:43:02 UTC
*** Bug 494489 has been marked as a duplicate of this bug. ***
Comment 15 Antonio Rojas 2024-10-22 06:43:33 UTC
*** Bug 495166 has been marked as a duplicate of this bug. ***
Comment 16 Antonio Rojas 2024-10-24 06:15:36 UTC
*** Bug 495280 has been marked as a duplicate of this bug. ***
Comment 17 David Edmundson 2024-10-24 08:09:47 UTC
*** Bug 495220 has been marked as a duplicate of this bug. ***
Comment 18 Méven 2024-10-25 07:16:46 UTC
Git commit c48a170cf87034ebf5aa3afce5982ce8b8de7a85 by Méven Car, on behalf of Benjamin Gonzalez.
Committed on 25/10/2024 at 07:16.
Pushed by meven into branch 'master'.

KNewFileMenu: Prevent using home directory as template directory

Fix unintentionally using home directory as template directory when configured incorrectly

M  +13   -2    src/filewidgets/knewfilemenu.cpp

https://invent.kde.org/frameworks/kio/-/commit/c48a170cf87034ebf5aa3afce5982ce8b8de7a85
Comment 19 David Tonhofer 2024-10-25 13:54:32 UTC
Observed in an up-to-date Fedora 40 KDE (which has always been a Fedora 40 KDE, no old data lying around) since .. very recently.

My latest dolphin update was 2024-10-11.

dolphin                   : Changed: '24.08.1 / 1.fc40'       ---> '24.08.2 / 1.fc40'           ('Fedora Project', 'x86_64')
dolphin-libs              : Changed: '24.08.1 / 1.fc40'       ---> '24.08.2 / 1.fc40'           ('Fedora Project', 'x86_64')
dolphin-plugins           : Changed: '24.08.1 / 1.fc40'       ---> '24.08.2 / 1.fc40'           ('Fedora Project', 'x86_64')

As described, set

XDG_TEMPLATES_DIR="$HOME/"
to
XDG_TEMPLATES_DIR="$HOME/Templates"

in 

$HOME/.config/user-dirs.dirs

Keep up the good work!