diff options
author | Roland Knall <roland.knall@br-automation.com> | 2015-12-29 14:50:55 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-12-30 08:10:54 +0000 |
commit | 0921c8214ef225fe2b84c5ace0113ea1e931c70c (patch) | |
tree | 42c2c029f3eed5a1b21e017dbe10124dac80dab6 /ui/qt/extcap_options_dialog.cpp | |
parent | b1239859664fa2ffe71d1ddbd6416c5b7f87bd5d (diff) |
extcap: Add Required and cleanup
An option may now use the "required=true" argument (see sshdump.c)
which will ensure, that the capture can only be started via the
dialog, if the option has been provided. To ensure, that this is
working properly, multiselect has been moved to a separate source
file.
Renamed one method so it may not interfere with a future save
functionality, and cleaned up the interface to use only default
buttons and roles
ONLY the Qt interface is being supported.
Change-Id: Ie1c9a63c1bba2e557d55b1de6f4775d8b9fce515
Reviewed-on: https://code.wireshark.org/review/12912
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/extcap_options_dialog.cpp')
-rw-r--r-- | ui/qt/extcap_options_dialog.cpp | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp index 9f5f515ba2..229c5e5843 100644 --- a/ui/qt/extcap_options_dialog.cpp +++ b/ui/qt/extcap_options_dialog.cpp @@ -62,17 +62,14 @@ ExtcapOptionsDialog::ExtcapOptionsDialog(QWidget *parent) : ui(new Ui::ExtcapOptionsDialog), device_name(""), device_idx(0), - device_defaults(NULL), - start_bt_(NULL) + device_defaults(NULL) { ui->setupUi(this); setWindowTitle(wsApp->windowTitleString(tr("Extcap Interface Options"))); - start_bt_ = ui->buttonBox->addButton(tr("Start"), QDialogButtonBox::AcceptRole); + ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start")); - start_bt_->setEnabled((global_capture_opts.num_selected > 0)? true: false); - connect(start_bt_, SIGNAL(clicked(bool)), this, SLOT(start_button_clicked())); } ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, QWidget *parent) @@ -116,18 +113,38 @@ ExtcapOptionsDialog::~ExtcapOptionsDialog() delete ui; } -void ExtcapOptionsDialog::start_button_clicked() +void ExtcapOptionsDialog::on_buttonBox_accepted() { - if (saveOptionsToPreferences()) { + if (saveOptionToCaptureInfo()) { accept(); } } +void ExtcapOptionsDialog::anyValueChanged() +{ + /* Guard, that only extcap arguments are given, which should be the case anyway */ + if ( dynamic_cast<ExtcapArgument *>(QObject::sender()) == NULL ) + return; + + bool allowStart = true; + + ExtcapArgumentList::const_iterator iter; + + for(iter = extcapArguments.constBegin(); iter != extcapArguments.constEnd() && allowStart; ++iter) + { + if ( (*iter)->isRequired() && ! (*iter)->isValid() ) + allowStart = false; + } + + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowStart); +} + void ExtcapOptionsDialog::updateWidgets() { GList * arguments = NULL, * walker = NULL, * item = NULL; QWidget * lblWidget = NULL, *editWidget = NULL; ExtcapArgument * argument = NULL; + bool allowStart = true; unsigned int counter = 0; @@ -158,6 +175,12 @@ void ExtcapOptionsDialog::updateWidgets() { layout->addWidget(editWidget, counter, 1, Qt::AlignVCenter); } + + if ( argument->isRequired() && ! argument->isValid() ) + allowStart = false; + + connect(argument, SIGNAL(valueChanged()), this, SLOT(anyValueChanged())); + counter++; } } @@ -167,10 +190,15 @@ void ExtcapOptionsDialog::updateWidgets() walker = walker->next; } - if ( counter > 0 ) { + if ( counter > 0 ) + { + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowStart); + ui->verticalLayout->addLayout(layout); ui->verticalLayout->addSpacerItem(new QSpacerItem(20, 100, QSizePolicy::Minimum, QSizePolicy::Expanding)); - } else { + } + else + { delete layout; } } @@ -178,7 +206,7 @@ void ExtcapOptionsDialog::updateWidgets() // Not sure why we have to do this manually. void ExtcapOptionsDialog::on_buttonBox_rejected() { - if (saveOptionsToPreferences()) { + if (saveOptionToCaptureInfo()) { reject(); } } @@ -189,7 +217,7 @@ void ExtcapOptionsDialog::on_buttonBox_helpRequested() wsApp->helpTopicAction(HELP_EXTCAP_OPTIONS_DIALOG); } -bool ExtcapOptionsDialog::saveOptionsToPreferences() +bool ExtcapOptionsDialog::saveOptionToCaptureInfo() { GHashTable * ret_args; interface_t device; |