diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:14:53 +0000 |
commit | a86c5f7cae7ec9a3398300555a0b644689d946a1 (patch) | |
tree | 39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /ui/qt/extcap_options_dialog.cpp | |
parent | Releasing progress-linux version 4.2.6-1~progress7.99u1. (diff) | |
download | wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip |
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ui/qt/extcap_options_dialog.cpp')
-rw-r--r-- | ui/qt/extcap_options_dialog.cpp | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp index 52c360c0..014a949a 100644 --- a/ui/qt/extcap_options_dialog.cpp +++ b/ui/qt/extcap_options_dialog.cpp @@ -9,8 +9,6 @@ #include <config.h> -#include <glib.h> - #include <extcap_options_dialog.h> #include <ui_extcap_options_dialog.h> @@ -59,8 +57,7 @@ ExtcapOptionsDialog::ExtcapOptionsDialog(bool startCaptureOnClose, QWidget *pare ui(new Ui::ExtcapOptionsDialog), device_name(""), device_idx(0), - defaultValueIcon_(StockIcon("x-reset")), - start_capture_on_close_(startCaptureOnClose) + defaultValueIcon_(StockIcon("x-reset")) { ui->setupUi(this); @@ -68,10 +65,11 @@ ExtcapOptionsDialog::ExtcapOptionsDialog(bool startCaptureOnClose, QWidget *pare ui->checkSaveOnStart->setCheckState(prefs.extcap_save_on_start ? Qt::Checked : Qt::Unchecked); + ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start")); if (startCaptureOnClose) { - ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start")); - } else { - ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Save")); + // This dialog was spawned because the user wanted to start a capture + // immediately but a mandatory parameter was not configured. + ui->buttonBox->button(QDialogButtonBox::Save)->hide(); } } @@ -80,7 +78,7 @@ ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, bo interface_t *device; ExtcapOptionsDialog * resultDialog = NULL; bool dev_found = false; - guint if_idx; + unsigned if_idx; if (dev_name.length() == 0) return NULL; @@ -118,26 +116,6 @@ ExtcapOptionsDialog::~ExtcapOptionsDialog() delete ui; } -void ExtcapOptionsDialog::on_buttonBox_accepted() -{ - if (saveOptionToCaptureInfo()) { - /* Starting a new capture with those values */ - prefs.extcap_save_on_start = ui->checkSaveOnStart->checkState() == Qt::Checked; - - /* If the button says "Save" instead of "Start", unconditionally - * save. XXX - Why not have both buttons? (#19199) - * - * XXX - If extcap_save_on_start is the only preference that has - * changed, or if it changed from true to false, we should write - * out a new preference file with its new value, but don't. - */ - if (prefs.extcap_save_on_start || !start_capture_on_close_) - storeValues(); - - accept(); - } -} - void ExtcapOptionsDialog::anyValueChanged() { bool allowStart = true; @@ -241,7 +219,7 @@ void ExtcapOptionsDialog::loadArguments() extcapArguments << optional; /* argument items are now owned by ExtcapArgument. Only free the lists */ - extcap_free_if_configuration(arguments, FALSE); + extcap_free_if_configuration(arguments, false); } void ExtcapOptionsDialog::updateWidgets() @@ -403,12 +381,6 @@ void ExtcapOptionsDialog::updateWidgets() } } -// Not sure why we have to do this manually. -void ExtcapOptionsDialog::on_buttonBox_rejected() -{ - reject(); -} - void ExtcapOptionsDialog::on_buttonBox_helpRequested() { interface_t *device; @@ -474,8 +446,8 @@ bool ExtcapOptionsDialog::saveOptionToCaptureInfo() continue; } - gchar * call_string = qstring_strdup(call); - gchar * value_string = NULL; + char * call_string = qstring_strdup(call); + char * value_string = NULL; if (value.length() > 0) value_string = qstring_strdup(value); @@ -491,8 +463,41 @@ bool ExtcapOptionsDialog::saveOptionToCaptureInfo() void ExtcapOptionsDialog::on_buttonBox_clicked(QAbstractButton *button) { /* Only the save button has the ActionRole */ - if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) + switch (ui->buttonBox->buttonRole(button)) { + case QDialogButtonBox::ResetRole: resetValues(); + break; + case QDialogButtonBox::RejectRole: + case QDialogButtonBox::DestructiveRole: + /* entries are only saved if saveOptionToCaptureInfo() is called, + * so do nothing. */ + reject(); + break; + case QDialogButtonBox::AcceptRole: + if (saveOptionToCaptureInfo()) { + /* Starting a new capture with those values */ + prefs.extcap_save_on_start = ui->checkSaveOnStart->checkState() == Qt::Checked; + + /* XXX - If extcap_save_on_start is the only preference that has + * changed, or if it changed from true to false, we should write + * out a new preference file with its new value, but don't. + */ + if (ui->buttonBox->standardButton(button) == QDialogButtonBox::Save) { + storeValues(); + /* Reject the dialog, because we don't want to start a capture. */ + reject(); + } else { + /* Start */ + if (prefs.extcap_save_on_start) { + storeValues(); + } + accept(); + } + } + break; + default: + break; + } } void ExtcapOptionsDialog::resetValues() @@ -549,14 +554,14 @@ void ExtcapOptionsDialog::resetValues() } - /* Values are stored when dialog is commited, just check validity*/ + /* Values are stored when dialog is committed, just check validity */ anyValueChanged(); } } GHashTable *ExtcapOptionsDialog::getArgumentSettings(bool useCallsAsKey, bool includeEmptyValues) { - GHashTable * entries = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable * entries = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ExtcapArgumentList::const_iterator iter; QString value; @@ -615,7 +620,7 @@ GHashTable *ExtcapOptionsDialog::getArgumentSettings(bool useCallsAsKey, bool in if ((key.length() > 0) && (includeEmptyValues || isBoolflag || value.length() > 0) ) { - gchar * val = qstring_strdup(value); + char * val = qstring_strdup(value); g_hash_table_insert(entries, qstring_strdup(key), val); } @@ -634,6 +639,8 @@ void ExtcapOptionsDialog::storeValues() mainApp->emitAppSignal(MainApplication::PreferencesChanged); } + + g_hash_table_unref(entries); } ExtcapValueList ExtcapOptionsDialog::loadValuesFor(int argNum, QString argumentName, QString parent) @@ -673,7 +680,7 @@ ExtcapValueList ExtcapOptionsDialog::loadValuesFor(int argNum, QString argumentN QString call = QString().fromUtf8(v->call); ExtcapValue element = ExtcapValue(display, call, - v->enabled == (gboolean)TRUE, v->is_default == (gboolean)TRUE); + v->enabled == true, v->is_default == true); #if 0 /* TODO: Disabled due to wrong parent handling. It leads to an infinite loop for now. To implement this properly, other things |