From 926337616567c4d5525773a9cb31a5afbbf08e15 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 21 Feb 2018 12:26:41 +0300 Subject: [PATCH] Issue #2436: Remember last visited directory as default path for saving files --- src/ModuleBase/ModuleBase_WidgetFileSelector.cpp | 10 +++++++++- src/ModuleBase/ModuleBase_WidgetFileSelector.h | 3 --- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp index ca7ee5de1..85b1772b0 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.cpp @@ -42,13 +42,19 @@ #include #include + +/// Default path +static QString myDefaultPath; + + ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent, const Config_WidgetAPI* theData) : ModuleBase_ModelWidget(theParent, theData), myFileDialog(0) { myTitle = translate(theData->getProperty("title")); myType = (theData->getProperty("type") == "save") ? WFS_SAVE : WFS_OPEN; - myDefaultPath = QString::fromStdString(theData->getProperty("path")); + if (myDefaultPath.isNull() || myDefaultPath.isEmpty()) + myDefaultPath = QString::fromStdString(theData->getProperty("path")); if (myDefaultPath.isEmpty()) myDefaultPath = Config_PropManager::string("Plugins", "import_initial_path").c_str(); @@ -139,6 +145,7 @@ void ModuleBase_WidgetFileSelector::onPathSelectionBtn() ? myDefaultPath : QFileInfo(myPathField->text()).absolutePath(); QString aFilter = filterString(); + // use Option prohibited native dialog using to have both lower/upper extensions of files // satisfied to dialog filter on Linux(Calibre) Issue #2055 myFileDialog = new QFileDialog(this, myTitle, aDefaultPath, aFilter); @@ -156,6 +163,7 @@ void ModuleBase_WidgetFileSelector::onPathSelectionBtn() if (myType == WFS_SAVE) aFileName = applyExtension(aFileName, mySelectedFilter); myPathField->setText(aFileName); + myDefaultPath = QFileInfo(aFileName).absolutePath(); emit focusOutWidget(this); } } diff --git a/src/ModuleBase/ModuleBase_WidgetFileSelector.h b/src/ModuleBase/ModuleBase_WidgetFileSelector.h index e337845e9..28e31619a 100644 --- a/src/ModuleBase/ModuleBase_WidgetFileSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetFileSelector.h @@ -121,9 +121,6 @@ protected: WFS_OPEN, ///< open file WFS_SAVE ///< save file } myType; ///< type of dialog - - /// Default path - QString myDefaultPath; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ -- 2.39.2