QFileDialog does not set the initialDirectory option in codepaths from
QFileDialog::selectUrl or QFileDialog::selectFile when passing the task
on to the native widget. So KDEPlatformFileDialogHelper has to make sure
itself that info is kept.
Because KDEPlatformFileDialogHelper::initializeDialog() calls
setDirectory(options()->initialDirectory()); as intended, usually during
the show event (and thus resets any otherwise wanted state of the filewidget
it has from previous setup calls via QFileDialog), to whatever value the
initialDirectory option had before, usually the working directory as set
during initialization.
Details
- Reviewers
dfaure graesslin - Group Reviewers
Frameworks Plasma - Commits
- R135:7bbbd93cd3fc: Fix Plasma-QPA filedialog to show wrong directory with QFileDialog::selectUrl()
New unit test kfiledialog_unittest testSelectUrl no longer fails with added
code, also behaves now as expected with code e.g. from KUrlRequester.
Diff Detail
- Repository
- R135 Integration for Qt applications in Plasma
- Branch
- fixFileDialogDirectoryWithSelectUrl
- Lint
No Linters Available - Unit
No Unit Test Coverage
src/platformtheme/kdeplatformfiledialoghelper.cpp | ||
---|---|---|
365 | Should say 5.8.0, the autotest fails for me (without the fix) with current Qt 5.8 git. |
src/platformtheme/kdeplatformfiledialoghelper.cpp | ||
---|---|---|
368 | This does NOT build for me. qplatformdialoghelper.h:295:5: error: ‘QFileDialogOptions::QFileDialogOptions(const QFileDialogOptions&)’ is private Qt 5.8 git, gcc 4.8. I am not sure why Q_DISABLE_COPY(QFileDialogOptions) is used, sounds like the right fix is to add support for copying and moving to these classes in Qt; but short term this might mean doing the copy by hand (calling 20 setters, sucks). It is curious however that it built for you? |
src/platformtheme/kdeplatformfiledialoghelper.cpp | ||
---|---|---|
368 | Seems the code needs to be adapted to have a variant for the changes introduced by this commit: QSharedPointer<QFileDialogOptions> opt = options()->clone(); Could you give that a try? I only have Qt from my distro packages, which is Qt 5.7.0 I am not used to browsing of Qt branches and sadly cannot spot from http://code.qt.io/cgit/qt/qtbase.git/log/src/gui/kernel/qplatformdialoghelper.h at which version this is added. |
git log says this is qtbase commit 1a42124, from before v5.8.0-alpha1.
So I'll check for 5.8 and use clone, thanks for the information.
Okay, thanks for fixing for Qt 5.8. Cherry-picked your commit also for the Plasma/5.8 branch now for upcoming Plasma 5.8.4 release, given Plasma 5.9.0 will only appear after Qt 5.8.0 (by schedules at least), so chances are people will want to run 5.8 with 5.8 :)