diff --git a/ui/qt/profile_dialog.cpp b/ui/qt/profile_dialog.cpp index 76f6b3c779..c9aa55bcd7 100644 --- a/ui/qt/profile_dialog.cpp +++ b/ui/qt/profile_dialog.cpp @@ -682,6 +682,8 @@ void ProfileDialog::finishImport(QFileInfo fi, int count, int skipped, QStringLi if (skipped > 0) msg.append(tr(", %Ln profile(s) skipped", "", skipped)); } + QMessageBox msgBox(icon, tr("Importing profiles"), msg, QMessageBox::Ok, this); + msgBox.exec(); storeLastDir(fi.absolutePath()); @@ -695,50 +697,9 @@ void ProfileDialog::finishImport(QFileInfo fi, int count, int skipped, QStringLi pd_ui_->profileTreeView->selectRow(idx.isValid() ? idx.row() : 0); } - QMessageBox msgBox(icon, tr("Importing profiles"), msg, QMessageBox::Ok, this); - msgBox.exec(); - updateWidgets(); } -QString ProfileDialog::lastOpenDir() -{ - QString result; - - switch (prefs.gui_fileopen_style) { - - case FO_STYLE_LAST_OPENED: - /* The user has specified that we should start out in the last directory - we looked in. If we've already opened a file, use its containing - directory, if we could determine it, as the directory, otherwise - use the "last opened" directory saved in the preferences file if - there was one. */ - /* This is now the default behaviour in file_selection_new() */ - result = QString(get_last_open_dir()); - break; - - case FO_STYLE_SPECIFIED: - /* The user has specified that we should always start out in a - specified directory; if they've specified that directory, - start out by showing the files in that dir. */ - if (prefs.gui_fileopen_dir[0] != '\0') - result = QString(prefs.gui_fileopen_dir); - break; - } - - QDir ld(result); - if (ld.exists()) - return result; - - return QString(); -} - -void ProfileDialog::storeLastDir(QString dir) -{ - if (mainApp && dir.length() > 0) - mainApp->setLastOpenDir(qUtf8Printable(dir)); -} - void ProfileDialog::resetTreeView() { if (model_) diff --git a/ui/qt/profile_dialog.h b/ui/qt/profile_dialog.h index 9030ec1bcc..d42594f0ff 100644 --- a/ui/qt/profile_dialog.h +++ b/ui/qt/profile_dialog.h @@ -64,8 +64,6 @@ private: void updateWidgets(); void resetTreeView(); - QString lastOpenDir(); - void storeLastDir(QString dir); void finishImport(QFileInfo fi, int count, int skipped, QStringList import); private slots: diff --git a/ui/qt/utils/qt_ui_utils.cpp b/ui/qt/utils/qt_ui_utils.cpp index 1d211c2c7a..9879fcbca5 100644 --- a/ui/qt/utils/qt_ui_utils.cpp +++ b/ui/qt/utils/qt_ui_utils.cpp @@ -17,12 +17,16 @@ #include #include #include +#include #include +#include #include "ui/ws_ui_util.h" #include +#include + #include #include #include @@ -295,3 +299,41 @@ QString make_filter_based_on_rtpstream_id(QVector stream_ids) return filter; } +QString lastOpenDir() +{ + QString result; + + switch (prefs.gui_fileopen_style) { + + case FO_STYLE_LAST_OPENED: + /* The user has specified that we should start out in the last directory + we looked in. If we've already opened a file, use its containing + directory, if we could determine it, as the directory, otherwise + use the "last opened" directory saved in the preferences file if + there was one. */ + /* This is now the default behaviour in file_selection_new() */ + result = QString(get_last_open_dir()); + break; + + case FO_STYLE_SPECIFIED: + /* The user has specified that we should always start out in a + specified directory; if they've specified that directory, + start out by showing the files in that dir. */ + if (prefs.gui_fileopen_dir[0] != '\0') + result = QString(prefs.gui_fileopen_dir); + break; + } + + QDir ld(result); + if (ld.exists()) + return result; + + return QString(); +} + +void storeLastDir(QString dir) +{ + if (mainApp && dir.length() > 0) + mainApp->setLastOpenDir(qUtf8Printable(dir)); +} + diff --git a/ui/qt/utils/qt_ui_utils.h b/ui/qt/utils/qt_ui_utils.h index 3e98fcac0e..2fd66a8c62 100644 --- a/ui/qt/utils/qt_ui_utils.h +++ b/ui/qt/utils/qt_ui_utils.h @@ -253,6 +253,21 @@ void qvector_rtpstream_ids_free(QVector stream_ids); */ QString make_filter_based_on_rtpstream_id(QVector stream_ids); +/** + * @brief Return the last directory that had been opened. + * + * This can be influenced by prefs.gui_fileopen_style which will allow to either + * open the real last dir or have the user set one specifically. + * + * @return a reference to that directory. + */ +QString lastOpenDir(); + +/** + * @brief Store the directory as last directory being used + */ +void storeLastDir(QString dir); + #endif /* __QT_UI_UTILS__H__ */ // XXX Add a routine to fetch the HWND corresponding to a widget using QPlatformIntegration