diff options
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/capture_file_dialog.cpp | 15 | ||||
-rw-r--r-- | ui/qt/capture_file_dialog.h | 5 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 8 | ||||
-rw-r--r-- | ui/qt/main_window.h | 2 |
4 files changed, 29 insertions, 1 deletions
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index 90719d6a3e..852b2150a7 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -217,6 +217,21 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget * } +#ifndef Q_OS_WIN +void CaptureFileDialog::accept() +{ + // XXX also useful for Windows, but that uses a different dialog... + // Ensure that the filename has a valid extension before performing file + // existence checks and before closing the dialog. + // HACK: ensure that the filename field does not have the focus, otherwise + // selectFile will not change the filename. + setFocus(); + fixFilenameExtension(); + QFileDialog::accept(); +} +#endif // ! Q_OS_WIN + + // You have to use open, merge, saveAs, or exportPackets. We should // probably just make each type a subclass. int CaptureFileDialog::exec() { diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h index 72c144de03..3ef4f02e51 100644 --- a/ui/qt/capture_file_dialog.h +++ b/ui/qt/capture_file_dialog.h @@ -126,7 +126,10 @@ signals: public slots: - int exec(); +#ifndef Q_OS_WIN + void accept() Q_DECL_OVERRIDE; +#endif + int exec() Q_DECL_OVERRIDE; int open(QString &file_name, unsigned int &type); check_savability_t saveAs(QString &file_name, bool must_support_comments); check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range); diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 93ba8ca6c4..a0d71150b0 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -1464,7 +1464,10 @@ bool MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments, file_type = save_as_dlg.selectedFileType(); compressed = save_as_dlg.isCompressed(); +#ifdef Q_OS_WIN + // the Windows dialog does not fixup extensions, do it manually here. fileAddExtension(file_name, file_type, compressed); +#endif // Q_OS_WIN //#ifndef _WIN32 // /* If the file exists and it's user-immutable or not writable, @@ -1587,7 +1590,10 @@ void MainWindow::exportSelectedPackets() { file_type = esp_dlg.selectedFileType(); compressed = esp_dlg.isCompressed(); +#ifdef Q_OS_WIN + // the Windows dialog does not fixup extensions, do it manually here. fileAddExtension(file_name, file_type, compressed); +#endif // Q_OS_WIN //#ifndef _WIN32 // /* If the file exists and it's user-immutable or not writable, @@ -1643,6 +1649,7 @@ void MainWindow::exportDissections(export_type_e export_type) { ed_dlg.exec(); } +#ifdef Q_OS_WIN void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compressed) { QString file_name_lower; GSList *extensions_list; @@ -1697,6 +1704,7 @@ void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compre } } } +#endif // Q_OS_WIN bool MainWindow::testCaptureFileClose(QString before_what, FileCloseContext context) { bool capture_in_progress = false; diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 427edcef00..163dcb8823 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -236,7 +236,9 @@ private: void exportSelectedPackets(); void exportDissections(export_type_e export_type); +#ifdef Q_OS_WIN void fileAddExtension(QString &file_name, int file_type, bool compressed); +#endif // Q_OS_WIN bool testCaptureFileClose(QString before_what, FileCloseContext context = Default); void captureStop(); |