Created attachment 174620 [details] Smartphone and PC connected SUMMARY Desktop Settings window title displays my phone name (when it's connected through KDE Connect with PC) in the title STEPS TO REPRODUCE 1. Connect your phone to PC through KDE Connect 2. Right click on desktop and open Desktop and Wallpaper 3. Look at the title OBSERVED RESULT Phone name > user_home_directory/Desktop Settings in the title EXPECTED RESULT Title says only Desktop Settings SOFTWARE/OS VERSIONS Operating System: Arch Linux KDE Plasma Version: 6.2.0 KDE Frameworks Version: 6.6.0 Qt Version: 6.7.3 Kernel Version: 6.11.2-arch1-1 (64-bit) Graphics Platform: Wayland
Created attachment 174621 [details] Smartphone and PC not connected
Can reproduce. How strange!
It's caused by this line in plasma-desktop:labelgenerator.cpp: > const QModelIndex index = s_placesModel->closestItem(url); At this point `url` points to the actual location to be shown. Then PlacesModel::closestItem() apparently thinks the entry that's closest to it is the KDE Connect one.
This is a bug in KFilePlacesModel::closestItem(). It does something super weird. Here's a debug log of it going through my places model to try to find the best match: Looking at QUrl("file:///home/nate") I think it matches QUrl("/home/nate/Desktop/") It's the new best match Looking at QUrl("file:///home/nate/Desktop") I think it matches QUrl("/home/nate/Desktop/") It's the new best match Looking at QUrl("file:///home/nate/Documents") Looking at QUrl("file:///home/nate/Documents/Tabletop games") Looking at QUrl("file:///home/nate/Downloads") Looking at QUrl("file:///home/nate/Music") Looking at QUrl("file:///home/nate/Pictures") Looking at QUrl("file:///home/nate/Videos") Looking at QUrl("file:///home/nate/Documents/KDE") Looking at QUrl("file:///home/nate/Documents/Work & Money/Blue Systems") Looking at QUrl("trash:/") I think it matches QUrl("/home/nate/Desktop/") Looking at QUrl("remote:/") I think it matches QUrl("/home/nate/Desktop/") Looking at QUrl("smb://gaston@192.168.1.140/Users/gaston") Looking at QUrl("recentlyused:/files") Looking at QUrl("recentlyused:/locations") Looking at QUrl("file:///home") I think it matches QUrl("/home/nate/Desktop/") Looking at QUrl("file:///") I think it matches QUrl("/home/nate/Desktop/") Looking at QUrl("kdeconnect://2af2212406d8fc90/") I think it matches QUrl("/home/nate/Desktop/") It's the new best match Looks like every IOWorker that's not file:/ is being considered a match, so it thinks they're all great matches and returns the last one, which is typically KDE Connect.
It looks like QUrl::isParentOf changed behavior here. Now this line of code returns true: > QUrl("kdeconnect://foobar).isParentOf(QUrl("file://my/favorite/place)) That doesn't seem to have been the case in the past. This is what's tripping it up.
> QUrl("kdeconnect://foobar).isParentOf(QUrl("file://my/favorite/place)) Cannot reproduce with Qt 6.8.0 or Qt dev. There have been numerous changes to QUrl normalization and what not recently, though. Maybe it’s a Qt 6.7(.3) issue that’s since been fixed? Either way, this would be a Qt bg, QUrl::isParentOf clearly states that the schemes of the two URLs must match for them to ever be considered related. The only change I can see to this particular function is from Sep 2022 when it was ported from count/length to size, so the issue must be elsewhere(?)
Kai looked into this and found that the QUrl behavior did not change, but what did change is that desktop:/ got changed into /home/$USER/Desktop by https://invent.kde.org/plasma/plasma-desktop/-/commit/6ba1f9197348db4aa2d6c465cba34699c48e19ba, which triggered this issue. Alexander, could you look into that?
I can reproduce this as well. So the bug needs to be fixed in KFilePlacesModel::closestItem(), not the code that was changed in https://invent.kde.org/plasma/plasma-desktop/-/commit/6ba1f9197348db4aa2d6c465cba34699c48e19ba, correct?
There may be multiple ways to fix it. KFilePlacesModel::closestItem() does not seem to be doing the right thing in my estimation, due to the way QUrl::isParentOf() works), but it also wasn't a problem with the old code that passed it desktop:/. The issue only appears when it gets /home/$USER/Desktop instead.
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/2729
Git commit 9a6336387a42af3639d85a26b65b3337dda3e360 by Nate Graham. Committed on 23/01/2025 at 20:31. Pushed by ngraham into branch 'master'. applets/folder: Don't use DesktopSchemeHelper::getFileUrl to get title It isn't needed since we don't directly display it to the user; instead we poke and prod it in various ways and then return the processed string. This means we need the original URL, not a modified version of it, which makes KFilePlacesModel::closestItem() return the wrong thing. KFilePlacesModel::closestItem() isn't doing anything technically incorrect here; it's our problem for giving it malformed data. This fixes the Folder View widget having the wrong title when showing the contents of desktop:/, as it does by default. FIXED-IN: 6.3.0 M +1 -1 containments/desktop/plugins/folder/labelgenerator.cpp https://invent.kde.org/plasma/plasma-desktop/-/commit/9a6336387a42af3639d85a26b65b3337dda3e360
Git commit 985180895292b612c2e96d8c17e7fcf54b698a84 by Nate Graham. Committed on 23/01/2025 at 22:18. Pushed by ngraham into branch 'Plasma/6.3'. applets/folder: Don't use DesktopSchemeHelper::getFileUrl to get title It isn't needed since we don't directly display it to the user; instead we poke and prod it in various ways and then return the processed string. This means we need the original URL, not a modified version of it, which makes KFilePlacesModel::closestItem() return the wrong thing. KFilePlacesModel::closestItem() isn't doing anything technically incorrect here; it's our problem for giving it malformed data. This fixes the Folder View widget having the wrong title when showing the contents of desktop:/, as it does by default. FIXED-IN: 6.3.0 (cherry picked from commit 9a6336387a42af3639d85a26b65b3337dda3e360) Co-authored-by: Nate Graham <nate@kde.org> M +1 -1 containments/desktop/plugins/folder/labelgenerator.cpp https://invent.kde.org/plasma/plasma-desktop/-/commit/985180895292b612c2e96d8c17e7fcf54b698a84