diff options
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 38 | ||||
-rw-r--r-- | ui/qt/capture_interfaces_dialog.h | 1 | ||||
-rw-r--r-- | ui/qt/interface_frame.cpp | 2 | ||||
-rw-r--r-- | ui/qt/main_welcome.cpp | 3 | ||||
-rw-r--r-- | ui/qt/main_welcome.h | 1 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 3 |
6 files changed, 45 insertions, 3 deletions
diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 771dd40498..9a51919d2a 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -272,11 +272,43 @@ void CaptureInterfacesDialog::updateGlobalDeviceSelections() #endif } -void CaptureInterfacesDialog::interfaceSelected() +/* Update TreeWidget selection based on global device selections. */ +void CaptureInterfacesDialog::updateFromGlobalDeviceSelections() { - updateGlobalDeviceSelections(); +#ifdef HAVE_LIBPCAP + QTreeWidgetItemIterator iter(ui->interfaceTree); - emit interfacesChanged(); + // Prevent recursive interface interfaceSelected signals + ui->interfaceTree->blockSignals(true); + + while (*iter) { + QString device_name = (*iter)->data(col_interface_, Qt::UserRole).value<QString>(); + for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { + interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (device_name.compare(QString().fromUtf8(device.name)) == 0) { + if (device.selected != (*iter)->isSelected()) { + (*iter)->setSelected(device.selected); + } + break; + } + } + ++iter; + } + + ui->interfaceTree->blockSignals(false); +#endif +} + +void CaptureInterfacesDialog::interfaceSelected() +{ + if (sender() == ui->interfaceTree) { + // Local changes, propagate our changes + updateGlobalDeviceSelections(); + emit interfacesChanged(); + } else { + // Changes from the welcome screen, adjust to its state. + updateFromGlobalDeviceSelections(); + } updateSelectedFilter(); diff --git a/ui/qt/capture_interfaces_dialog.h b/ui/qt/capture_interfaces_dialog.h index 8967c6b058..c679724e76 100644 --- a/ui/qt/capture_interfaces_dialog.h +++ b/ui/qt/capture_interfaces_dialog.h @@ -128,6 +128,7 @@ private: void updateSelectedFilter(); void updateGlobalDeviceSelections(); + void updateFromGlobalDeviceSelections(); }; #endif /* HAVE_LIBPCAP */ diff --git a/ui/qt/interface_frame.cpp b/ui/qt/interface_frame.cpp index 8d7d188236..f382f19f99 100644 --- a/ui/qt/interface_frame.cpp +++ b/ui/qt/interface_frame.cpp @@ -210,6 +210,8 @@ void InterfaceFrame::triggeredIfTypeButton() void InterfaceFrame::interfaceListChanged() { resetInterfaceTreeDisplay(); + // Ensure that device selection is consistent with the displayed selection. + updateSelectedInterfaces(); #ifdef HAVE_LIBPCAP if (!stat_timer_) { diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp index 3cf1b8a52d..8832b519dc 100644 --- a/ui/qt/main_welcome.cpp +++ b/ui/qt/main_welcome.cpp @@ -327,6 +327,9 @@ void MainWelcome::interfaceSelected() } else { welcome_ui_->captureFilterComboBox->lineEdit()->setText(user_filter); } + + // Notify others (capture interfaces dialog) that the selection has changed. + emit interfacesChanged(); } #ifdef HAVE_EXTCAP diff --git a/ui/qt/main_welcome.h b/ui/qt/main_welcome.h index 085983901e..f862154ba6 100644 --- a/ui/qt/main_welcome.h +++ b/ui/qt/main_welcome.h @@ -80,6 +80,7 @@ signals: #ifdef HAVE_EXTCAP void showExtcapOptions(QString &device_name); #endif + void interfacesChanged(); public slots: void setCaptureFilterText(const QString capture_filter); diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 2b7935dfef..555394eb16 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -3758,6 +3758,9 @@ void MainWindow::on_actionCaptureOptions_triggered() this->main_welcome_->getInterfaceFrame(), SLOT(interfaceListChanged())); connect(capture_interfaces_dialog_, SIGNAL(captureFilterTextEdited(QString)), this->main_welcome_, SLOT(setCaptureFilterText(QString))); + // Propagate selection changes from main UI to dialog. + connect(this->main_welcome_, SIGNAL(interfacesChanged()), + capture_interfaces_dialog_, SLOT(interfaceSelected())); connect(capture_interfaces_dialog_, SIGNAL(setFilterValid(bool, const QString)), this, SLOT(startInterfaceCapture(bool, const QString))); |