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 /ui/qt/main_window.cpp | |
parent | 936ebfe2ed549f59027905520412d31d5cdde1f7 (diff) | |
download | wireshark-82b61bb40486ba851aee082e6b59155dd38e724d.tar.gz |
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>
Diffstat (limited to 'ui/qt/main_window.cpp')
-rw-r--r-- | ui/qt/main_window.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
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) |