aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2015-12-29 14:50:55 +0100
committerAnders Broman <a.broman58@gmail.com>2015-12-30 08:10:54 +0000
commit0921c8214ef225fe2b84c5ace0113ea1e931c70c (patch)
tree42c2c029f3eed5a1b21e017dbe10124dac80dab6 /ui/qt
parentb1239859664fa2ffe71d1ddbd6416c5b7f87bd5d (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')
-rw-r--r--ui/qt/CMakeLists.txt2
-rw-r--r--ui/qt/Makefile.common2
-rw-r--r--ui/qt/extcap_argument.cpp208
-rw-r--r--ui/qt/extcap_argument.h14
-rw-r--r--ui/qt/extcap_argument_file.cpp13
-rw-r--r--ui/qt/extcap_argument_file.h5
-rw-r--r--ui/qt/extcap_argument_multiselect.cpp202
-rw-r--r--ui/qt/extcap_argument_multiselect.h74
-rw-r--r--ui/qt/extcap_options_dialog.cpp50
-rw-r--r--ui/qt/extcap_options_dialog.h8
-rw-r--r--ui/qt/extcap_options_dialog.ui8
11 files changed, 423 insertions, 163 deletions
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 9e4fb99532..2c03bc1f0b 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -161,6 +161,7 @@ if(ENABLE_EXTCAP)
${WIRESHARK_QT_HEADERS}
extcap_argument.h
extcap_argument_file.h
+ extcap_argument_multiselect.h
extcap_options_dialog.h
)
endif()
@@ -307,6 +308,7 @@ if(ENABLE_EXTCAP)
${WIRESHARK_QT_SRC}
extcap_argument.cpp
extcap_argument_file.cpp
+ extcap_argument_multiselect.cpp
extcap_options_dialog.cpp
)
endif()
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index 0c1d09cde1..c84ff3e534 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -181,6 +181,7 @@ MOC_HDRS = \
export_pdu_dialog.h \
extcap_argument.h \
extcap_argument_file.h \
+ extcap_argument_multiselect.h \
extcap_options_dialog.h \
file_set_dialog.h \
filter_action.h \
@@ -441,6 +442,7 @@ WIRESHARK_QT_SRC = \
export_pdu_dialog.cpp \
extcap_argument.cpp \
extcap_argument_file.cpp \
+ extcap_argument_multiselect.cpp \
extcap_options_dialog.cpp \
file_set_dialog.cpp \
filter_action.cpp \
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index ab1916db8d..b2ff0d04a7 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -44,149 +44,7 @@
#include <extcap_parser.h>
#include <extcap_argument_file.h>
-
-class ExtArgMultiSelect : public ExtcapArgument
-{
-public:
- ExtArgMultiSelect(extcap_arg * argument) :
- ExtcapArgument(argument), treeView(0), viewModel(0) {};
-
- virtual QList<QStandardItem *> valueWalker(ExtcapValueList list, QStringList &defaults)
- {
- ExtcapValueList::iterator iter = list.begin();
- QList<QStandardItem *> items;
-
- while ( iter != list.end() )
- {
- QStandardItem * item = new QStandardItem((*iter).value());
- if ( (*iter).enabled() == false )
- {
- item->setSelectable(false);
- }
- else
- item->setSelectable(true);
-
- item->setData((*iter).call(), Qt::UserRole);
- if ((*iter).isDefault())
- defaults << (*iter).call();
-
- item->setEditable(false);
- QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults);
- if ( childs.length() > 0 )
- item->appendRows(childs);
-
- items << item;
- ++iter;
- }
-
- return items;
- }
-
- void selectItemsWalker(QStandardItem * item, QStringList defaults)
- {
- QModelIndexList results;
- QModelIndex index;
-
- if ( item->hasChildren() )
- {
- for (int row = 0; row < item->rowCount(); row++)
- {
- QStandardItem * child = item->child(row);
- if ( child != 0 )
- {
- selectItemsWalker(child, defaults);
- }
- }
- }
-
- QString data = item->data(Qt::UserRole).toString();
-
- if ( defaults.contains(data) )
- {
- treeView->selectionModel()->select(item->index(), QItemSelectionModel::Select);
- index = item->index();
- while ( index.isValid() )
- {
- treeView->setExpanded(index, true);
- index = index.parent();
- }
- }
- }
-
- virtual QWidget * createEditor(QWidget * parent)
- {
- QStringList defaults;
-
- QList<QStandardItem *> items = valueWalker(values, defaults);
- if (items.length() == 0)
- return new QWidget();
-
- if ( _default != 0 )
- defaults = _default->toString().split(",", QString::SkipEmptyParts);
-
- viewModel = new QStandardItemModel();
- QList<QStandardItem *>::const_iterator iter = items.constBegin();
- while ( iter != items.constEnd() )
- {
- ((QStandardItemModel *)viewModel)->appendRow((*iter));
- ++iter;
- }
-
- treeView = new QTreeView(parent);
- treeView->setModel(viewModel);
-
- /* Shows at minimum 6 entries at most desktops */
- treeView->setMinimumHeight(100);
- treeView->setHeaderHidden(true);
- treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
-
- for (int row = 0; row < viewModel->rowCount(); row++ )
- selectItemsWalker(((QStandardItemModel*)viewModel)->item(row), defaults);
-
- return treeView;
- }
-
- virtual QString value()
- {
- if ( viewModel == 0 )
- return QString();
-
- QStringList result;
- QModelIndexList selected = treeView->selectionModel()->selectedIndexes();
-
- if ( selected.size() <= 0 )
- return QString();
-
- QModelIndexList::const_iterator iter = selected.constBegin();
- while ( iter != selected.constEnd() )
- {
- QModelIndex index = (QModelIndex)(*iter);
-
- result << viewModel->data(index, Qt::UserRole).toString();
-
- ++iter;
- }
-
- return result.join(QString(","));
- }
-
- virtual QString defaultValue()
- {
- if ( _argument != 0 && _argument->default_complex != 0)
- {
- gchar * str = extcap_get_complex_as_string(_argument->default_complex);
- if ( str != 0 )
- return QString(str);
- }
-
- return QString();
- }
-
-private:
- QTreeView * treeView;
- QAbstractItemModel * viewModel;
-};
+#include <extcap_argument_multiselect.h>
class ExtArgSelector : public ExtcapArgument
{
@@ -219,6 +77,8 @@ public:
boxSelection->setCurrentIndex(selected);
}
+ connect ( boxSelection, SIGNAL(currentIndexChanged(int)), SLOT(onIntChanged(int)) );
+
return boxSelection;
}
@@ -237,6 +97,7 @@ public:
}
private:
+
QComboBox * boxSelection;
};
@@ -287,6 +148,8 @@ public:
anyChecked = true;
}
}
+
+ connect(radio, SIGNAL(clicked(bool)), SLOT(onBoolChanged(bool)));
selectorGroup->addButton(radio, count);
vrLayout->addWidget(radio);
@@ -319,6 +182,7 @@ public:
}
private:
+
QButtonGroup * selectorGroup;
QList<QString> * callStrings;
};
@@ -350,6 +214,8 @@ public:
boolBox->setCheckState(Qt::Checked);
}
+ connect (boolBox, SIGNAL(stateChanged(int)), SLOT(onIntChanged(int)));
+
return boolBox;
}
@@ -381,11 +247,13 @@ public:
}
private:
+
QCheckBox * boolBox;
};
class ExtArgText : public ExtcapArgument
{
+
public:
ExtArgText(extcap_arg * argument) :
ExtcapArgument(argument), textBox(0)
@@ -402,6 +270,8 @@ public:
if ( _argument->tooltip != NULL )
textBox->setToolTip(QString().fromUtf8(_argument->tooltip));
+ connect(textBox , SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));
+
return textBox;
}
@@ -413,6 +283,14 @@ public:
return textBox->text();
}
+ virtual bool isValid()
+ {
+ if ( isRequired() && value().length() == 0 )
+ return false;
+
+ return true;
+ }
+
virtual QString defaultValue()
{
if ( _argument != 0 && _argument->default_complex != 0)
@@ -426,6 +304,7 @@ public:
}
protected:
+
QLineEdit * textBox;
};
@@ -438,6 +317,7 @@ public:
virtual QWidget * createEditor(QWidget * parent)
{
textBox = (QLineEdit *)ExtArgText::createEditor(parent);
+ textBox->disconnect(SIGNAL(textChanged(QString)));
if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
{
@@ -465,6 +345,8 @@ public:
textBox->setText(defaultValue());
+ connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));
+
return textBox;
};
@@ -488,6 +370,7 @@ public:
return result;
}
+
};
ExtcapValue::~ExtcapValue() {}
@@ -582,6 +465,12 @@ QString ExtcapArgument::value()
return QString();
}
+
+bool ExtcapArgument::isValid()
+{
+ return value().length() > 0;
+}
+
QString ExtcapArgument::defaultValue()
{
return QString();
@@ -609,6 +498,22 @@ void ExtcapArgument::setDefault(GHashTable * defaultsList)
}
}
+bool ExtcapArgument::isRequired()
+{
+ if ( _argument != NULL )
+ return _argument->is_required;
+
+ return FALSE;
+}
+
+bool ExtcapArgument::isDefault()
+{
+ if ( value().compare(defaultValue()) == 0 )
+ return true;
+
+ return false;
+}
+
ExtcapArgument * ExtcapArgument::create(extcap_arg * argument, GHashTable * device_defaults)
{
if ( argument == 0 || argument->display == 0 )
@@ -642,6 +547,23 @@ ExtcapArgument * ExtcapArgument::create(extcap_arg * argument, GHashTable * devi
return result;
}
+/* The following is a necessity, because Q_Object does not do well with multiple inheritances */
+void ExtcapArgument::onStringChanged(QString)
+{
+ emit valueChanged();
+}
+
+void ExtcapArgument::onIntChanged(int)
+{
+ if ( isValid() )
+ emit valueChanged();
+}
+
+void ExtcapArgument::onBoolChanged(bool)
+{
+ emit valueChanged();
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/extcap_argument.h b/ui/qt/extcap_argument.h
index 185f2bc607..0fdc59f31b 100644
--- a/ui/qt/extcap_argument.h
+++ b/ui/qt/extcap_argument.h
@@ -87,8 +87,15 @@ public:
virtual QString value();
virtual QString defaultValue();
+ bool isDefault();
+ bool isValid();
+ bool isRequired();
+
static ExtcapArgument * create(extcap_arg * argument = 0, GHashTable * device_defaults = 0);
+Q_SIGNALS:
+ void valueChanged();
+
protected:
void setDefault(GHashTable * defaultsList);
@@ -99,6 +106,13 @@ protected:
extcap_arg * _argument;
QVariant * _default;
+
+private Q_SLOTS:
+
+ void onStringChanged(QString);
+ void onIntChanged(int);
+ void onBoolChanged(bool);
+
};
#endif /* UI_QT_EXTCAP_ARGUMENT_H_ */
diff --git a/ui/qt/extcap_argument_file.cpp b/ui/qt/extcap_argument_file.cpp
index 7fec0a5fbc..557e3693b4 100644
--- a/ui/qt/extcap_argument_file.cpp
+++ b/ui/qt/extcap_argument_file.cpp
@@ -44,6 +44,12 @@ ExtcapArgumentFileSelection::ExtcapArgumentFileSelection (extcap_arg * argument)
_default = new QVariant(QString(""));
}
+ExtcapArgumentFileSelection::~ExtcapArgumentFileSelection()
+{
+ if ( textBox != NULL )
+ delete textBox;
+}
+
QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
{
QWidget * fileWidget = new QWidget(parent);
@@ -100,6 +106,13 @@ void ExtcapArgumentFileSelection::openFileDialog()
textBox->setText(filename);
}
+bool ExtcapArgumentFileSelection::isValid()
+{
+ if ( textBox->text().length() > 0 )
+ return true;
+ return false;
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/extcap_argument_file.h b/ui/qt/extcap_argument_file.h
index 14f715cb45..bc0ad5f725 100644
--- a/ui/qt/extcap_argument_file.h
+++ b/ui/qt/extcap_argument_file.h
@@ -34,12 +34,15 @@ class ExtcapArgumentFileSelection : public ExtcapArgument
Q_OBJECT
public:
- ExtcapArgumentFileSelection (extcap_arg * argument);
+ ExtcapArgumentFileSelection(extcap_arg * argument);
+ virtual ~ExtcapArgumentFileSelection();
virtual QWidget * createEditor(QWidget * parent);
virtual QString value();
+ virtual bool isValid();
+
protected:
QLineEdit * textBox;
diff --git a/ui/qt/extcap_argument_multiselect.cpp b/ui/qt/extcap_argument_multiselect.cpp
new file mode 100644
index 0000000000..b99a75379d
--- /dev/null
+++ b/ui/qt/extcap_argument_multiselect.cpp
@@ -0,0 +1,202 @@
+/* extcap_argument_multiselect.cpp
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <extcap_argument.h>
+#include <extcap_argument_file.h>
+
+#include <wsutil/utf8_entities.h>
+
+#include <QObject>
+#include <QWidget>
+#include <QLabel>
+#include <QLineEdit>
+#include <QBoxLayout>
+#include <QPushButton>
+#include <QVariant>
+
+#include <extcap_parser.h>
+#include <extcap_argument_multiselect.h>
+
+ExtArgMultiSelect::ExtArgMultiSelect(extcap_arg * argument) :
+ ExtcapArgument(argument), treeView(0), viewModel(0) {};
+
+ExtArgMultiSelect::~ExtArgMultiSelect()
+{
+ if ( treeView != 0 )
+ delete treeView;
+ if ( viewModel != 0 )
+ delete viewModel;
+}
+
+QList<QStandardItem *> ExtArgMultiSelect::valueWalker(ExtcapValueList list, QStringList &defaults)
+{
+ ExtcapValueList::iterator iter = list.begin();
+ QList<QStandardItem *> items;
+
+ while ( iter != list.end() )
+ {
+ QStandardItem * item = new QStandardItem((*iter).value());
+ if ( (*iter).enabled() == false )
+ {
+ item->setSelectable(false);
+ }
+ else
+ item->setSelectable(true);
+
+ item->setData((*iter).call(), Qt::UserRole);
+ if ((*iter).isDefault())
+ defaults << (*iter).call();
+
+ item->setEditable(false);
+ QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults);
+ if ( childs.length() > 0 )
+ item->appendRows(childs);
+
+ items << item;
+ ++iter;
+ }
+
+ return items;
+}
+
+void ExtArgMultiSelect::selectItemsWalker(QStandardItem * item, QStringList defaults)
+{
+ QModelIndexList results;
+ QModelIndex index;
+
+ if ( item->hasChildren() )
+ {
+ for (int row = 0; row < item->rowCount(); row++)
+ {
+ QStandardItem * child = item->child(row);
+ if ( child != 0 )
+ {
+ selectItemsWalker(child, defaults);
+ }
+ }
+ }
+
+ QString data = item->data(Qt::UserRole).toString();
+
+ if ( defaults.contains(data) )
+ {
+ treeView->selectionModel()->select(item->index(), QItemSelectionModel::Select);
+ index = item->index();
+ while ( index.isValid() )
+ {
+ treeView->setExpanded(index, true);
+ index = index.parent();
+ }
+ }
+}
+
+QWidget * ExtArgMultiSelect::createEditor(QWidget * parent)
+{
+ QStringList defaults;
+
+ QList<QStandardItem *> items = valueWalker(values, defaults);
+ if (items.length() == 0)
+ return new QWidget();
+
+ if ( _default != 0 )
+ defaults = _default->toString().split(",", QString::SkipEmptyParts);
+
+ viewModel = new QStandardItemModel();
+ QList<QStandardItem *>::const_iterator iter = items.constBegin();
+ while ( iter != items.constEnd() )
+ {
+ ((QStandardItemModel *)viewModel)->appendRow((*iter));
+ ++iter;
+ }
+
+ treeView = new QTreeView(parent);
+ treeView->setModel(viewModel);
+
+ /* Shows at minimum 6 entries at most desktops */
+ treeView->setMinimumHeight(100);
+ treeView->setHeaderHidden(true);
+ treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+ for (int row = 0; row < viewModel->rowCount(); row++ )
+ selectItemsWalker(((QStandardItemModel*)viewModel)->item(row), defaults);
+
+ connect ( treeView->selectionModel(),
+ SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ SLOT(selectionChanged(const QItemSelection &, const QItemSelection &)) );
+
+ return treeView;
+}
+
+QString ExtArgMultiSelect::value()
+{
+ if ( viewModel == 0 )
+ return QString();
+
+ QStringList result;
+ QModelIndexList selected = treeView->selectionModel()->selectedIndexes();
+
+ if ( selected.size() <= 0 )
+ return QString();
+
+ QModelIndexList::const_iterator iter = selected.constBegin();
+ while ( iter != selected.constEnd() )
+ {
+ QModelIndex index = (QModelIndex)(*iter);
+
+ result << viewModel->data(index, Qt::UserRole).toString();
+
+ ++iter;
+ }
+
+ return result.join(QString(","));
+}
+
+QString ExtArgMultiSelect::defaultValue()
+{
+ if ( _argument != 0 && _argument->default_complex != 0)
+ {
+ gchar * str = extcap_get_complex_as_string(_argument->default_complex);
+ if ( str != 0 )
+ return QString(str);
+ }
+
+ return QString();
+}
+
+void ExtArgMultiSelect::selectionChanged(const QItemSelection &, const QItemSelection &)
+{
+ emit valueChanged();
+}
+
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/extcap_argument_multiselect.h b/ui/qt/extcap_argument_multiselect.h
new file mode 100644
index 0000000000..9b9dcd6480
--- /dev/null
+++ b/ui/qt/extcap_argument_multiselect.h
@@ -0,0 +1,74 @@
+/* extcap_argument_multiselect.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_
+#define UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_
+
+#include <QObject>
+#include <QWidget>
+#include <QStandardItem>
+#include <QTreeView>
+#include <QAbstractItemModel>
+#include <QItemSelection>
+
+#include <extcap_parser.h>
+#include <extcap_argument.h>
+
+class ExtArgMultiSelect : public ExtcapArgument
+{
+ Q_OBJECT
+public:
+ ExtArgMultiSelect(extcap_arg * argument);
+ virtual ~ExtArgMultiSelect();
+
+ virtual QString value();
+ virtual QString defaultValue();
+
+protected:
+ virtual QList<QStandardItem *> valueWalker(ExtcapValueList list, QStringList &defaults);
+ void selectItemsWalker(QStandardItem * item, QStringList defaults);
+ virtual QWidget * createEditor(QWidget * parent);
+
+private Q_SLOTS:
+
+ void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
+
+private:
+
+ QTreeView * treeView;
+ QAbstractItemModel * viewModel;
+
+};
+
+#endif /* UI_QT_EXTCAP_ARGUMENT_MULTISELECT_H_ */
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
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;
diff --git a/ui/qt/extcap_options_dialog.h b/ui/qt/extcap_options_dialog.h
index 9cd57fe9cb..c508d62701 100644
--- a/ui/qt/extcap_options_dialog.h
+++ b/ui/qt/extcap_options_dialog.h
@@ -53,11 +53,12 @@ public:
~ExtcapOptionsDialog();
static ExtcapOptionsDialog * createForDevice(QString &device_name, QWidget *parent = 0);
-private slots:
- void start_button_clicked();
+private Q_SLOTS:
+ void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void updateWidgets();
+ void anyValueChanged();
private:
explicit ExtcapOptionsDialog(QWidget *parent = 0);
@@ -66,11 +67,10 @@ private:
QString device_name;
guint device_idx;
GHashTable * device_defaults;
- QPushButton *start_bt_;
ExtcapArgumentList extcapArguments;
- bool saveOptionsToPreferences();
+ bool saveOptionToCaptureInfo();
};
#endif /* HAVE_EXTCAP */
diff --git a/ui/qt/extcap_options_dialog.ui b/ui/qt/extcap_options_dialog.ui
index 1600df9b7b..d22380aee3 100644
--- a/ui/qt/extcap_options_dialog.ui
+++ b/ui/qt/extcap_options_dialog.ui
@@ -6,13 +6,13 @@
<rect>
<x>0</x>
<y>0</y>
- <width>450</width>
- <height>49</height>
+ <width>600</width>
+ <height>55</height>
</rect>
</property>
<property name="minimumSize">
<size>
- <width>450</width>
+ <width>600</width>
<height>0</height>
</size>
</property>
@@ -23,7 +23,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
- <set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
+ <set>QDialogButtonBox::Close|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>