aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2015-12-29 14:57:53 +0100
committerAnders Broman <a.broman58@gmail.com>2015-12-30 08:11:57 +0000
commit0d47113ddc53714ecd6d3c1b58b694321649d89e (patch)
tree1fb4c3b5fe3092d6442aaf924b37b2e165c1c223 /ui/qt
parent0921c8214ef225fe2b84c5ace0113ea1e931c70c (diff)
extcap: Add file extension check
The file-open dialog can now be set with file extensions, allowing the exclusion of unwanted file types. The syntax is the same as for the Qt QFileDialog, e.g.: "Wireshark (*.pcap *.pcapng)" Also, the mustexist option is now considered correctly Change-Id: I9d4efbb5089ce1af640b2a894de07ed79520271e Reviewed-on: https://code.wireshark.org/review/12913 Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/extcap_argument.cpp8
-rw-r--r--ui/qt/extcap_argument.h2
-rw-r--r--ui/qt/extcap_argument_file.cpp16
3 files changed, 23 insertions, 3 deletions
diff --git a/ui/qt/extcap_argument.cpp b/ui/qt/extcap_argument.cpp
index b2ff0d04a7..0150446ae5 100644
--- a/ui/qt/extcap_argument.cpp
+++ b/ui/qt/extcap_argument.cpp
@@ -506,6 +506,14 @@ bool ExtcapArgument::isRequired()
return FALSE;
}
+bool ExtcapArgument::fileExists()
+{
+ if ( _argument != NULL )
+ return _argument->fileexists;
+
+ return FALSE;
+}
+
bool ExtcapArgument::isDefault()
{
if ( value().compare(defaultValue()) == 0 )
diff --git a/ui/qt/extcap_argument.h b/ui/qt/extcap_argument.h
index 0fdc59f31b..9287628a7c 100644
--- a/ui/qt/extcap_argument.h
+++ b/ui/qt/extcap_argument.h
@@ -98,6 +98,8 @@ Q_SIGNALS:
protected:
+ bool fileExists();
+
void setDefault(GHashTable * defaultsList);
ExtcapValueList loadValues(QString parent);
diff --git a/ui/qt/extcap_argument_file.cpp b/ui/qt/extcap_argument_file.cpp
index 557e3693b4..f0115ceda4 100644
--- a/ui/qt/extcap_argument_file.cpp
+++ b/ui/qt/extcap_argument_file.cpp
@@ -71,7 +71,6 @@ QWidget * ExtcapArgumentFileSelection::createEditor(QWidget * parent)
button->setToolTip(QString().fromUtf8(_argument->tooltip));
}
-
connect(button, SIGNAL(clicked()), (QObject *)this, SLOT(openFileDialog()));
editLayout->addWidget(textBox);
@@ -98,12 +97,23 @@ void ExtcapArgumentFileSelection::openFileDialog()
if (QFileInfo(filename).exists())
workingDir = QFileInfo(filename).dir();
+ QString fileExt(tr("Any File (*.*)"));
+ if ( _argument->fileextension != NULL )
+ {
+ QString givenExt = QString().fromUtf8(_argument->fileextension);
+ if ( givenExt.length() != 0 )
+ fileExt.prepend(";;").prepend(givenExt);
+ }
+
filename = QFileDialog::getOpenFileName((QWidget *)(textBox->parent()),
QString().fromUtf8(_argument->display) + " " + tr("Open File"),
- workingDir.absolutePath(), tr("All Files (*.*)"));
+ workingDir.absolutePath(), fileExt);
- if ( QFileInfo(filename).exists() )
+ if ( ! fileExists() || QFileInfo(filename).exists() )
+ {
textBox->setText(filename);
+ emit valueChanged();
+ }
}
bool ExtcapArgumentFileSelection::isValid()