summaryrefslogtreecommitdiff
path: root/ui/qt
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-04-01 23:44:29 +0000
committerGuy Harris <guy@alum.mit.edu>2013-04-01 23:44:29 +0000
commitd94275940164f0b40d12d1caa709b113360491c2 (patch)
treec2db98b41c1d80160f286af62b5d94f6959359c7 /ui/qt
parentf8965b7b2cddad13ca785b283dc05d59c3af2438 (diff)
downloadwireshark-d94275940164f0b40d12d1caa709b113360491c2.tar.gz
Add routines to file.c to indicate whether:
a save can be done ("can" in the sense of "there's something to save" and in the sense of "we can write that something out"); a "save as" can be done (in the sense of "we can write what we have out"); there's unsaved data to save (which might be unsaved changes or might be a temporary file full of packets); and use them as appropriate. This means that the "unsaved data" indicator in the UI will be turned on for temporary files full of packets as well as for files with unsaved changes; that's what we want. svn path=/trunk/; revision=48693
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/main_window.cpp44
1 files changed, 9 insertions, 35 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 96eb9ea01b..47b4cf556d 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -372,14 +372,14 @@ void MainWindow::mergeCaptureFile()
return;
if (prefs.gui_ask_unsaved) {
- if (cap_file_->is_tempfile || cap_file_->unsaved_changes) {
+ if (cf_not_saved(cap_file_)) {
QMessageBox msg_dialog;
gchar *display_basename;
int response;
msg_dialog.setIcon(QMessageBox::Question);
- /* This is a temporary capture file or has unsaved changes; ask the
- user whether to save the capture. */
+ /* This file has unsaved data; ask the user whether to save
+ the capture. */
if (cap_file_->is_tempfile) {
msg_dialog.setText(tr("Save packets before merging?"));
msg_dialog.setInformativeText(tr("A temporary capture file can't be merged."));
@@ -980,7 +980,7 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString &before_what) {
#endif
if (prefs.gui_ask_unsaved) {
- if (cap_file_->is_tempfile || capture_in_progress || cap_file_->unsaved_changes) {
+ if (cf_not_saved(cap_file_) || capture_in_progress) {
QMessageBox msg_dialog;
QString question;
QPushButton *default_button;
@@ -988,9 +988,8 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString &before_what) {
msg_dialog.setIcon(QMessageBox::Question);
- /* This is a temporary capture file, or there's a capture in
- progress, or the file has unsaved changes; ask the user whether
- to save the data. */
+ /* This file has unsaved data or there's a capture in
+ progress; ask the user whether to save the data. */
if (cap_file_->is_tempfile) {
msg_dialog.setText(tr("You have unsaved packets"));
@@ -1121,7 +1120,7 @@ void MainWindow::setTitlebarForCaptureFile()
if (cap_file_ && cap_file_->filename) {
display_name = cf_get_display_name(cap_file_);
- setWindowModified(cap_file_->unsaved_changes);
+ setWindowModified(cf_not_saved(cap_file_));
// Clear the window title so that setWindowFilePath does something
setWindowTitle(NULL);
setWindowFilePath(display_name);
@@ -1169,33 +1168,8 @@ void MainWindow::setMenusForCaptureFile(bool force_disable)
main_ui_->actionFileMerge->setEnabled(cf_can_write_with_wiretap(cap_file_));
main_ui_->actionFileClose->setEnabled(true);
- /*
- * "Save" should be available only if:
- *
- * the file has unsaved changes, and we can save it in some
- * format through Wiretap
- *
- * or
- *
- * the file is a temporary file and has no unsaved changes (so
- * that "saving" it just means copying it).
- */
- main_ui_->actionFileSave->setEnabled(
- (cap_file_->unsaved_changes && cf_can_write_with_wiretap(cap_file_)) ||
- (cap_file_->is_tempfile && !cap_file_->unsaved_changes));
- /*
- * "Save As..." should be available only if:
- *
- * we can save it in some format through Wiretap
- *
- * or
- *
- * the file is a temporary file and has no unsaved changes (so
- * that "saving" it just means copying it).
- */
- main_ui_->actionFileSaveAs->setEnabled(
- cf_can_write_with_wiretap(cap_file_) ||
- (cap_file_->is_tempfile && !cap_file_->unsaved_changes));
+ main_ui_->actionFileSave->setEnabled(cf_can_save(cap_file_));
+ main_ui_->actionFileSaveAs->setEnabled(cf_can_save_as(cap_file_));
/*
* "Export Specified Packets..." should be available only if
* we can write the file out in at least one format.