Summary: | SaveFile does not set the current_name | ||
---|---|---|---|
Product: | [Plasma] xdg-desktop-portal-kde | Reporter: | Chris Holland <zrenfire> |
Component: | general | Assignee: | Jan Grulich <jgrulich> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | andysem, angrypenguinpoland, bero, chimak111, jgrulich, ken20001, MurzNN, nate, russianneuromancer, toivo |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Ubuntu | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/xdg-desktop-portal-kde/ccea985840cf5b05b0359067854abc3da080e737 | Version Fixed In: | 5.14.5 |
Sentry Crash Report: | |||
Attachments: |
Debug output requested by Jan Grulich in comment #7
dbus-monitor log xdg-desktop-portal-kde log |
Description
Chris Holland
2018-12-12 22:39:36 UTC
I was wrong, setLabelText is *suppose* to set the label next to the filename TextField but it seems the the KDE KDialog ignores it. https://github.com/qt/qtbase/blob/5.11/src/widgets/dialogs/qfiledialog.cpp#L605 Looking at the selectFile logic... https://github.com/qt/qtbase/blob/5.11/src/widgets/dialogs/qfiledialog.cpp#L1047 It seems that it will set the lineEdit text even if the filename does not exist, and even if it's a relative path. So I suggest we move the selectFile(currentName) after we navigate to the correct directory. if (!currentFolder.isEmpty()) { fileDialog->setDirectoryUrl(QUrl(currentFolder)); } if (!currentFile.isEmpty()) { fileDialog->selectFile(currentFile); } if (!currentName.isEmpty()) { fileDialog->selectFile(currentName); } Git commit fa5161c17e6acbe72efe833eb314a5c15183317b by Jan Grulich. Committed on 13/12/2018 at 06:47. Pushed by grulich into branch 'Plasma/5.14'. FileChooser: make use of current_name property in Save dialog It's not used in Qt portal implementation, but gtk has API for that and sets it in Save dialog and we should try to call selectFile() with it to get pre-selected file for the dialog M +4 -5 src/filechooser.cpp https://commits.kde.org/xdg-desktop-portal-kde/fa5161c17e6acbe72efe833eb314a5c15183317b Git commit ccea985840cf5b05b0359067854abc3da080e737 by Jan Grulich. Committed on 13/12/2018 at 10:05. Pushed by grulich into branch 'master'. FileChooser: make use of current_name property in Save dialog It's not used in Qt portal implementation, but gtk has API for that and sets it in Save dialog and we should try to call selectFile() with it to get pre-selected file for the dialog M +4 -5 src/filechooser.cpp https://commits.kde.org/xdg-desktop-portal-kde/ccea985840cf5b05b0359067854abc3da080e737 It does not work for me - after recompiling xdg-desktop-portal-kde from the latest git (commit 23b11bf) and restarting my computer, when I try to save the page (CTRL-S), the file name field is still blank. If I unset GTK_USE_PORTAL=1 (i.e. use GTK file selection dialog), the file name field will be filled in automatically, e.g. `402077 – SaveFile does not set the current_name.html`. It does work for me. Are you sure you installed xdg-desktop-portal-kde to correct location? (In reply to Jan Grulich from comment #5) > It does work for me. Are you sure you installed xdg-desktop-portal-kde to > correct location? I am very sure that xdg-desktop-portal-kde is installed to the correct location. I used the PKGBUILD from https://www.archlinux.org/packages/extra/x86_64/xdg-desktop-portal-kde/ , and made necessary changes to the PKGBUILD to include your patch. Unfortunately the file name field bug is still present. I am using Firefox 64.0 and xdg-desktop-portal 1.0.3. Can you run "dbus-monitor --session" in a terminal while opening the dialog and attach the output here? Also start xdg-desktop-portal-kde in terminal to see the output, using "QT_LOGGING_RULES='xdp*.debug=true' /usr/libexec/xdg-desktop-portal-kde" and attach the output here as well. You will need to kill it first before you can start it again manually, otherwise you just get an error that it failed to register. Created attachment 116963 [details] Debug output requested by Jan Grulich in comment #7 Text files containing debug output can be found in the archive file. From the logs it looks everything is correct and I can't think of any reason why it doesn't work for you. Maybe try to put some debug there to see if selectFile() is really called in SaveFile() method. Hey, the same issue in Kubuntu 18.10 xdg-desktop-portal: 1.0.3-1 xdg-desktop-portal-kde: 5.14.4-0 Created attachment 116976 [details]
dbus-monitor log
Created attachment 116977 [details]
xdg-desktop-portal-kde log
(In reply to Eugene from comment #10) > xdg-desktop-portal-kde: 5.14.4-0 The fix is in 5.14.5, which hasn't been released yet. See the "Version Fixed In" field up towards the top of the page. *** Bug 402305 has been marked as a duplicate of this bug. *** (In reply to Jan Grulich from comment #9) > From the logs it looks everything is correct and I can't think of any reason > why it doesn't work for you. Maybe try to put some debug there to see if > selectFile() is really called in SaveFile() method. I recompiled xdg-desktop-portal-kde from the latest git (commit 57b2179) and it now works. Hi. I tried xdg-desktop-portal-kde 5.14.5 and even the last released 5.14.90 in OpenMandriva Cooker and it does not fix the problem. The file name field is still blank ... BTW. if needed this is our spec https://github.com/OpenMandrivaAssociation/xdg-desktop-portal-kde Any idea? Not yet working here (xdg-desktop-portal 1.1.1, xdg-desktop-portal-kde 5.14.5, qt 5.12)... dbus monitor output looks good, relevant part being: method call time=1547863266.166011 sender=:1.327 -> destination=:1.321 serial=88 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.impl.portal.FileChooser; member=SaveFile object path "/org/freedesktop/portal/desktop/request/1_324/gtk582257145" string "" string "x11:4a00011" string "Save As" array [ dict entry( string "modal" variant boolean true ) dict entry( string "filters" variant array [ struct { string "Web Page, complete" array [ struct { uint32 0 string "*.[hH][tT][mM]" } struct { uint32 0 string "*.[hH][tT][mM][lL]" } ] } struct { string "Web Page, HTML only" array [ struct { uint32 0 string "*.[hH][tT][mM]" } struct { uint32 0 string "*.[hH][tT][mM][lL]" } ] } struct { string "Text Files" array [ struct { uint32 0 string "*.[tT][xX][tT]" } struct { uint32 0 string "*.[tT][eE][xX][tT]" } ] } struct { string "All Files" array [ struct { uint32 0 string "*" } ] } ] ) dict entry( string "current_name" variant string "OpenMandriva.html" ) dict entry( string "current_folder" variant array of bytes "/home/bero/Downloads" + \0 ) ] xdg-desktop-portal-kde log looks good too: xdp-kde-file-chooser: SaveFile called with parameters: xdp-kde-file-chooser: handle: "/org/freedesktop/portal/desktop/request/1_324/gtk582257145" xdp-kde-file-chooser: parent_window: "x11:4a00011" xdp-kde-file-chooser: title: "Save As" xdp-kde-file-chooser: options: QMap(("current_folder", QVariant(QByteArray, "/home/bero/Downloads\x00"))("current_name", QVariant(QString, "OpenMandriva.html"))("filters", QVariant(QDBusArgument, ))("modal", QVariant(bool, true))) filters etc. are all set correctly, but current_name is empty in the dialog. Code looks correct though... Will debug a bit more. The dialog also doesn't respect current_folder even though the fileDialog->setDirectoryUrl code path is hit... Starting to suspect a QFileDialog bug here, but haven't looked too closely yet The problem is that, at least here, with Qt 5.12.0, QFileDialog::setDirectoryUrl() expects a "real" URL and doesn't work if it's passed a QUrl with an empty scheme (such as QUrl(currentName) if currentName is a local file name). Everything starts working correctly if I change the code to use QFileDialog::setDirectory() instead of QFileDialog::setDirectoryUrl(), or if I use QUrl("file:" + currentFolder) in place of QUrl(currentFolder). Of course that will break things if currentFolder is remote, or is already a file: URL -- not sure if this can happen. Will attach a patch with some safety checks, but if you know it's always a local directory name, one of the workarounds I've already mentioned is sufficient. Looks like this is fixed on git master by the switch from QFileDialog to KFileWidget; I've submitted a less intrusive patch to phabricator https://phabricator.kde.org/D18378 in case anyone wants to put it on the 5.14 branch. Thanks for the investigation, Bernhard. If it's already fixed in master, this bug should be closed, and I'm afraid there aren't any more 5.14.x releases scheduled. Each non-LTS plasma version gets 5, and 5.14.5 was already released. But you could target your patch for the 5.12 LTS branch maybe? |