https://bugs.kde.org/show_bug.cgi?id=507825

            Bug ID: 507825
           Summary: The File dialog of KUrlRequester opens an incorrect
                    location
    Classification: Frameworks and Libraries
           Product: frameworks-kio
      Version First 6.16.0
       Reported In:
          Platform: Microsoft Windows
                OS: Microsoft Windows
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

This is a Windows specific issue, probably related to the fact that it uses
native file dialogs

STEPS TO REPRODUCE
1. Open an App with a KUrlRequester widget, like Kdenlive on Windows
2. Click on the button of the KUrlRequester widget to open the file dialog (in
Kdenlive Settings > environement)

OBSERVED RESULT
The file dialog always opens in C:\Windows\System32, whatever url is entered in
the KUrlRequester lineedit.

EXPECTED RESULT
The file dialog should open the directory and file that appears in the
KUrlRequester lineedit.

SOFTWARE/OS VERSIONS
Windows: Windows 11
KDE Frameworks Version: git master (6.18)
Qt Version: 6.8.3

ADDITIONAL INFORMATION
Patching kurlrequester like this fixes the issue ( I can create an MR if that
helps):

diff --git a/src/widgets/kurlrequester.cpp b/src/widgets/kurlrequester.cpp
index 4d054cdc9..7c4833cd5 100644
--- a/src/widgets/kurlrequester.cpp
+++ b/src/widgets/kurlrequester.cpp
@@ -230,7 +230,14 @@ public:
             QUrl u(url());
             // If we won't be able to list it (e.g. http), then don't try :)
             if (KProtocolManager::supportsListing(u)) {
-                dlg->selectUrl(u);
+                // selectUrl does not work properly on Native Dialogs
+                if (u.isLocalFile()) {
+                    QFileInfo info(u.toLocalFile());
+                    dlg->setDirectory(info.absolutePath());
+                    dlg->selectFile(info.fileName());
+                } else {
+                    dlg->selectUrl(u);
+                }
             }
         } else {
             dlg->setDirectoryUrl(m_startDir);

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to