aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2016-03-21 21:39:17 -0400
committerMichael Mann <mmann78@netscape.net>2016-03-26 01:44:07 +0000
commit11324a72578a748582196f3c0431e3a56894f5f5 (patch)
tree5ca2caf16f8adbdf5baca5ca5a61b40257ea3c74 /ui
parent928b570a34738e5c28adf86488bd4fda377791ac (diff)
Push initial directory code up into CaptureFileDialog.
That way each (CaptureFileDialog) user doesn't have to (remember to) check the preference, etc., to figure out what directory to start in. Change-Id: Ifa60e1ef9dbd11689a3f72906997cf3ed8ce259c Reviewed-on: https://code.wireshark.org/review/14550 Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/capture_file_dialog.cpp33
-rw-r--r--ui/qt/main_window.cpp60
-rw-r--r--ui/qt/main_window_slots.cpp20
3 files changed, 26 insertions, 87 deletions
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 3b659557f8..55cf12648c 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -32,14 +32,11 @@
#include <errno.h>
#include "file.h"
-#include "../../epan/addr_resolv.h"
-#include "../../epan/prefs.h"
-#include "../../wsutil/filesystem.h"
-#include "../../wsutil/nstime.h"
+#include "epan/addr_resolv.h"
+#include "wsutil/filesystem.h"
+#include "wsutil/nstime.h"
#include "ui/all_files_wildcard.h"
-#include <wireshark_application.h>
-
#include <QGridLayout>
#include <QHBoxLayout>
#include <QVBoxLayout>
@@ -52,6 +49,8 @@
#endif // Q_OS_WIN
#include <QPushButton>
+#include "epan/prefs.h"
+#include <wireshark_application.h>
#ifdef Q_OS_WIN
// All of these routines are required by file_dlg_win32.c.
@@ -100,8 +99,28 @@ CaptureFileDialog::CaptureFileDialog(QWidget *parent, capture_file *cf, QString
file_type_(-1)
#endif
{
+ 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.
+ */
+ setDirectory(wsApp->lastOpenDir());
+ 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')
+ setDirectory(prefs.gui_fileopen_dir);
+ break;
+ }
+
#if !defined(Q_OS_WIN)
- setDirectory(wsApp->lastOpenDir());
// Add extra widgets
// https://wiki.qt.io/Qt_project_org_faq#How_can_I_add_widgets_to_my_QFileDialog_instance.3F
setOption(QFileDialog::DontUseNativeDialog, true);
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 8789776c2c..3019748093 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -1013,26 +1013,6 @@ void MainWindow::mergeCaptureFile()
char *in_filenames[2];
char *tmpname;
- 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() */
- 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')
- merge_dlg.setDirectory(prefs.gui_fileopen_dir);
- break;
- }
-
if (merge_dlg.merge(file_name)) {
gchar *err_msg;
@@ -1257,26 +1237,6 @@ void MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments,
for (;;) {
CaptureFileDialog save_as_dlg(this, cf);
- 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() */
- 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')
- save_as_dlg.setDirectory(prefs.gui_fileopen_dir);
- break;
- }
-
/* If the file has comments, does the format the user selected
support them? If not, ask the user whether they want to
discard the comments or choose a different format. */
@@ -1377,26 +1337,6 @@ void MainWindow::exportSelectedPackets() {
for (;;) {
CaptureFileDialog esp_dlg(this, capture_file_.capFile());
- 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() */
- 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')
- esp_dlg.setDirectory(prefs.gui_fileopen_dir);
- break;
- }
-
/* If the file has comments, does the format the user selected
support them? If not, ask the user whether they want to
discard the comments or choose a different format. */
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 7bed427c2b..f535e70634 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -176,26 +176,6 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned
if (cf_path.isEmpty()) {
CaptureFileDialog open_dlg(this, capture_file_.capFile(), read_filter);
- 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() */
- 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')
- open_dlg.setDirectory(prefs.gui_fileopen_dir);
- break;
- }
-
if (open_dlg.open(file_name, type)) {
cf_path = file_name;
} else {