Skip to content

Commit

Permalink
Widgets|libappfw: Directory picker dialog remembers latest selection
Browse files Browse the repository at this point in the history
The directory picker opens up in the directory that was previously
selected. This makes it easier to make repeated selections in the
dialog.
  • Loading branch information
skyjake committed Apr 2, 2017
1 parent 75d5ddc commit 293127e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions doomsday/sdk/libappfw/src/widgets/directoryarraywidget.cpp
Expand Up @@ -20,12 +20,15 @@
#include "de/BaseGuiApp"
#include "de/BaseWindow"

#include <de/Config>
#include <de/NativePath>
#include <de/TextValue>
#include <QFileDialog>

namespace de {

static String const CFG_LAST_FOLDER("resource.latestDirectory");

DENG2_PIMPL_NOREF(DirectoryArrayWidget)
{};

Expand All @@ -39,16 +42,17 @@ DirectoryArrayWidget::DirectoryArrayWidget(Variable &variable, String const &nam
// Use a native dialog to select the IWAD folder.
DENG2_BASE_GUI_APP->beginNativeUIMode();

QFileDialog dlg(nullptr,
tr("Select Folder"),
".", "");
QFileDialog dlg(nullptr, tr("Select Folder"),
Config::get().gets(CFG_LAST_FOLDER, "."), "");
dlg.setFileMode(QFileDialog::Directory);
dlg.setReadOnly(true);
//dlg.setNameFilter("*.wad");
dlg.setLabelText(QFileDialog::Accept, tr("Select"));
if (dlg.exec())
{
elementsMenu().items() << makeItem(TextValue(dlg.selectedFiles().at(0)));
String dir = dlg.selectedFiles().at(0);
Config::get().set(CFG_LAST_FOLDER, dir.fileNamePath());
elementsMenu().items() << makeItem(TextValue(dir));
setVariableFromWidget();
}

Expand Down

0 comments on commit 293127e

Please sign in to comment.