diff options
author | Gerald Combs <gerald@zing.org> | 2017-01-22 12:14:33 -0800 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-01-23 01:26:41 +0000 |
commit | 82b61bb40486ba851aee082e6b59155dd38e724d (patch) | |
tree | 98601b1b2e22e6a98d6f64d628266ac31369763f | |
parent | 936ebfe2ed549f59027905520412d31d5cdde1f7 (diff) | |
download | wireshark-82b61bb40486ba851aee082e6b59155dd38e724d.tar.gz wireshark-82b61bb40486ba851aee082e6b59155dd38e724d.tar.bz2 wireshark-82b61bb40486ba851aee082e6b59155dd38e724d.zip |
Qt: Reject drag and drop if we're capturing.
Ignore drag enter events in the main window and warn the user if we
can't open files (which presumably means we're in the middle of a
capture).
Don't yell at the user in the corresponding GTK+ code.
Change-Id: Iffb5df5969c7ff76a854247b4b8d10d0e4b02e70
Reviewed-on: https://code.wireshark.org/review/19734
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r-- | ui/gtk/drag_and_drop.c | 4 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 19 |
2 files changed, 18 insertions, 5 deletions
diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c index 84479d0908..dcd5306b0a 100644 --- a/ui/gtk/drag_and_drop.c +++ b/ui/gtk/drag_and_drop.c @@ -251,7 +251,7 @@ dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gin if((global_capture_session.state != CAPTURE_STOPPED)) { simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTN_OK, - "%sDrag and Drop currently not possible!%s\n\n" + "%sDrag and Drop currently not possible.%s\n\n" "Dropping a file isn't possible while a capture is in progress.", simple_dialog_primary_start(), simple_dialog_primary_end()); return; @@ -262,7 +262,7 @@ dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gin if(cfile.state == FILE_READ_IN_PROGRESS) { simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTN_OK, - "%sDrag and Drop currently not possible!%s\n\n" + "%sDrag and Drop currently not possible.%s\n\n" "Dropping a file isn't possible while loading another capture file.", simple_dialog_primary_start(), simple_dialog_primary_end()); return; diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index ab1dbf4bc6..b13e89480d 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -873,14 +873,27 @@ void MainWindow::closeEvent(QCloseEvent *event) { // order to set DROPDESCRIPTION. void MainWindow::dragEnterEvent(QDragEnterEvent *event) { - bool accept = false; + if (!main_ui_->actionFileOpen->isEnabled()) { + // We could alternatively call setAcceptDrops(!capture_in_progress) + // in setMenusForCaptureInProgress but that wouldn't provide feedback. + + main_ui_->statusBar->pushTemporaryStatus(tr("Unable to drop files during capture.")); + event->setDropAction(Qt::IgnoreAction); + event->ignore(); + return; + } + + bool have_files = false; foreach (QUrl drag_url, event->mimeData()->urls()) { if (!drag_url.toLocalFile().isEmpty()) { - accept = true; + have_files = true; break; } } - if (accept) event->acceptProposedAction(); + + if (have_files) { + event->acceptProposedAction(); + } } void MainWindow::dropEvent(QDropEvent *event) |