Commit b269980d authored by David Faure's avatar David Faure

Fix QFileDialog not remembering the last visited directory.

Summary:
This regression (compared to kdelibs4's direct KFileDialog usage) came
from the fact that QFileDialog's lastVisited() only gets updated if
the helper emits directoryEntered.

So QFileDialog was setting the current dir as startDir every single
time, overriding's KFileWidget's own logic for reusing the last dir
initially.

Test Plan:
QFileDialog::getOpenFileName(this, i18n("Select file"));
twice in a row, from the same process.

Reviewers: anthonyfieroni, elvisangelaccio, plasma-devel, broulik, arichardson, ngraham

Reviewed By: ngraham

Subscribers: ngraham, apol

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14437
parent 22da1e66
......@@ -347,6 +347,37 @@ private Q_SLOTS:
QTRY_VERIFY(timerRun);
}
void testRememberLastDirectory()
{
const QUrl dir = QUrl::fromLocalFile(QDir::tempPath()).adjusted(QUrl::StripTrailingSlash);
// Open and navigate
{
QFileDialog dialog;
dialog.open();
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
fw->setUrl(dir);
fw->slotCancel();
}
// Open another filedialog, check that the default directory is the one from above
{
QFileDialog dialog;
dialog.open();
KFileWidget *fw = findFileWidget();
QVERIFY(fw);
// real show() is delayed to next event.
QVERIFY(QTest::qWaitForWindowExposed(fw->window()));
QCOMPARE(fw->isVisible(), true);
QCOMPARE(dialog.directoryUrl().adjusted(QUrl::StripTrailingSlash), dir);
fw->slotCancel();
}
}
private:
QTemporaryDir m_tempDir;
......
......@@ -114,6 +114,7 @@ KDEPlatformFileDialog::KDEPlatformFileDialog()
connect(m_fileWidget, SIGNAL(accepted()), m_fileWidget, SLOT(accept()));
connect(m_fileWidget, SIGNAL(accepted()), SLOT(accept()));
connect(m_fileWidget->cancelButton(), SIGNAL(clicked(bool)), SLOT(reject()));
connect(m_fileWidget->dirOperator(), &KDirOperator::urlEntered, this, &KDEPlatformFileDialogBase::directoryEntered);
layout()->addWidget(m_buttons);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment