aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt')
-rw-r--r--ui/qt/main_window_preferences_frame.ui2
-rw-r--r--ui/qt/module_preferences_scroll_area.cpp98
-rw-r--r--ui/qt/module_preferences_scroll_area.h2
-rw-r--r--ui/qt/preferences_dialog.cpp17
4 files changed, 102 insertions, 17 deletions
diff --git a/ui/qt/main_window_preferences_frame.ui b/ui/qt/main_window_preferences_frame.ui
index 7a4e8af51c..42646127c3 100644
--- a/ui/qt/main_window_preferences_frame.ui
+++ b/ui/qt/main_window_preferences_frame.ui
@@ -70,7 +70,7 @@
<item row="1" column="2">
<widget class="QPushButton" name="foStyleSpecifiedPushButton">
<property name="text">
- <string>Choose...</string>
+ <string>Browse...</string>
</property>
</widget>
</item>
diff --git a/ui/qt/module_preferences_scroll_area.cpp b/ui/qt/module_preferences_scroll_area.cpp
index ada6e557d2..e30dbdbada 100644
--- a/ui/qt/module_preferences_scroll_area.cpp
+++ b/ui/qt/module_preferences_scroll_area.cpp
@@ -32,6 +32,7 @@
#include <QButtonGroup>
#include <QCheckBox>
#include <QComboBox>
+#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
@@ -152,6 +153,29 @@ pref_show(pref_t *pref, gpointer layout_ptr)
vb->addLayout(hb);
break;
}
+ case PREF_FILENAME:
+ case PREF_DIRNAME:
+ {
+ vb->addWidget(new QLabel(pref->title));
+ QHBoxLayout *hb = new QHBoxLayout();
+ QLineEdit *path_le = new QLineEdit();
+ QStyleOption style_opt;
+ path_le->setProperty(pref_prop_, qVariantFromValue(pref));
+ path_le->setMinimumWidth(path_le->fontMetrics().height() * 20);
+ path_le->setStyleSheet(QString(
+ "QLineEdit {"
+ " margin-left: %1px;"
+ "}"
+ )
+ .arg(path_le->style()->subElementRect(QStyle::SE_CheckBoxContents, &style_opt).left()));
+ hb->addWidget(path_le);
+ QPushButton *path_pb = new QPushButton("Browse...");
+ path_pb->setProperty(pref_prop_, qVariantFromValue(pref));
+ hb->addWidget(path_pb);
+ hb->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum));
+ vb->addLayout(hb);
+ break;
+ }
case PREF_COLOR:
{
// XXX - Not needed yet. When it is needed we can add a label + QFrame which pops up a
@@ -182,12 +206,20 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
pref_t *pref = le->property(pref_prop_).value<pref_t *>();
if (!pref) continue;
- if (pref->type == PREF_UINT) {
+ switch (pref->type) {
+ case PREF_UINT:
connect(le, SIGNAL(textEdited(QString)), this, SLOT(uintLineEditTextEdited(QString)));
- } else if (pref->type == PREF_STRING) {
+ break;
+ case PREF_STRING:
+ case PREF_FILENAME:
+ case PREF_DIRNAME:
connect(le, SIGNAL(textEdited(QString)), this, SLOT(stringLineEditTextEdited(QString)));
- } else if (pref->type == PREF_RANGE) {
+ break;
+ case PREF_RANGE:
connect(le, SIGNAL(textEdited(QString)), this, SLOT(rangeSyntaxLineEditTextEdited(QString)));
+ break;
+ default:
+ break;
}
}
@@ -200,30 +232,34 @@ ModulePreferencesScrollArea::ModulePreferencesScrollArea(module_t *module, QWidg
}
}
- foreach (QRadioButton *enum_rb, findChildren<QRadioButton *>()) {
- pref_t *pref = enum_rb->property(pref_prop_).value<pref_t *>();
+ foreach (QRadioButton *rb, findChildren<QRadioButton *>()) {
+ pref_t *pref = rb->property(pref_prop_).value<pref_t *>();
if (!pref) continue;
if (pref->type == PREF_ENUM && pref->info.enum_info.radio_buttons) {
- connect(enum_rb, SIGNAL(toggled(bool)), this, SLOT(enumRadioButtonToggled(bool)));
+ connect(rb, SIGNAL(toggled(bool)), this, SLOT(enumRadioButtonToggled(bool)));
}
}
- foreach (QComboBox *enum_cb, findChildren<QComboBox *>()) {
- pref_t *pref = enum_cb->property(pref_prop_).value<pref_t *>();
+ foreach (QComboBox *combo, findChildren<QComboBox *>()) {
+ pref_t *pref = combo->property(pref_prop_).value<pref_t *>();
if (!pref) continue;
if (pref->type == PREF_ENUM && !pref->info.enum_info.radio_buttons) {
- connect(enum_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(enumComboBoxCurrentIndexChanged(int)));
+ connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(enumComboBoxCurrentIndexChanged(int)));
}
}
- foreach (QPushButton *uat_pb, findChildren<QPushButton *>()) {
- pref_t *pref = uat_pb->property(pref_prop_).value<pref_t *>();
+ foreach (QPushButton *pb, findChildren<QPushButton *>()) {
+ pref_t *pref = pb->property(pref_prop_).value<pref_t *>();
if (!pref) continue;
if (pref->type == PREF_UAT) {
- connect(uat_pb, SIGNAL(pressed()), this, SLOT(uatPushButtonPressed()));
+ connect(pb, SIGNAL(pressed()), this, SLOT(uatPushButtonPressed()));
+ } else if (pref->type == PREF_FILENAME) {
+ connect(pb, SIGNAL(pressed()), this, SLOT(filenamePushButtonPressed()));
+ } else if (pref->type == PREF_DIRNAME) {
+ connect(pb, SIGNAL(pressed()), this, SLOT(dirnamePushButtonPressed()));
}
}
@@ -400,6 +436,44 @@ void ModulePreferencesScrollArea::uatPushButtonPressed()
qDebug() << "FIX Implement UATs:" << pref->title;
}
+void ModulePreferencesScrollArea::filenamePushButtonPressed()
+{
+ QPushButton *filename_pb = qobject_cast<QPushButton*>(sender());
+ if (!filename_pb) return;
+
+ pref_t *pref = filename_pb->property(pref_prop_).value<pref_t *>();
+ if (!pref) return;
+
+ QString filename = QFileDialog::getSaveFileName(this,
+ QString("Wireshark: ") + pref->description,
+ pref->stashed_val.string);
+
+ if (!filename.isEmpty()) {
+ g_free((void *)pref->stashed_val.string);
+ pref->stashed_val.string = qstring_strdup(filename);
+ updateWidgets();
+ }
+}
+
+void ModulePreferencesScrollArea::dirnamePushButtonPressed()
+{
+ QPushButton *dirname_pb = qobject_cast<QPushButton*>(sender());
+ if (!dirname_pb) return;
+
+ pref_t *pref = dirname_pb->property(pref_prop_).value<pref_t *>();
+ if (!pref) return;
+
+ QString dirname = QFileDialog::getExistingDirectory(this,
+ QString("Wireshark: ") + pref->description,
+ pref->stashed_val.string);
+
+ if (!dirname.isEmpty()) {
+ g_free((void *)pref->stashed_val.string);
+ pref->stashed_val.string = qstring_strdup(dirname);
+ updateWidgets();
+ }
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/module_preferences_scroll_area.h b/ui/qt/module_preferences_scroll_area.h
index 8a297ef86c..f5be4c7c1b 100644
--- a/ui/qt/module_preferences_scroll_area.h
+++ b/ui/qt/module_preferences_scroll_area.h
@@ -65,6 +65,8 @@ private slots:
void stringLineEditTextEdited(const QString &new_str);
void rangeSyntaxLineEditTextEdited(const QString &new_str);
void uatPushButtonPressed();
+ void filenamePushButtonPressed();
+ void dirnamePushButtonPressed();
};
#endif // MODULE_PREFERENCES_SCROLL_AREA_H
diff --git a/ui/qt/preferences_dialog.cpp b/ui/qt/preferences_dialog.cpp
index 4c2da2c703..8332b37025 100644
--- a/ui/qt/preferences_dialog.cpp
+++ b/ui/qt/preferences_dialog.cpp
@@ -48,7 +48,6 @@
#include <QKeyEvent>
#include <QLineEdit>
#include <QMessageBox>
-#include <QPushButton>
#include <QSpacerItem>
#include <QTreeWidgetItemIterator>
@@ -427,6 +426,7 @@ bool PreferencesDialog::stashedPrefIsDefault(pref_t *pref)
case PREF_STRING:
case PREF_FILENAME:
+ case PREF_DIRNAME:
if (!(g_strcmp0(pref->default_val.string, pref->stashed_val.string)))
return true;
break;
@@ -597,10 +597,19 @@ void PreferencesDialog::on_advancedTree_itemActivated(QTreeWidgetItem *item, int
break;
}
case PREF_FILENAME:
+ case PREF_DIRNAME:
{
- QString filename = QFileDialog::getSaveFileName(this,
- QString("Wireshark: ") + pref->description,
- pref->stashed_val.string);
+ QString filename;
+
+ if (pref->type == PREF_FILENAME) {
+ filename = QFileDialog::getSaveFileName(this,
+ QString("Wireshark: ") + pref->description,
+ pref->stashed_val.string);
+ } else {
+ filename = QFileDialog::getExistingDirectory(this,
+ QString("Wireshark: ") + pref->description,
+ pref->stashed_val.string);
+ }
if (!filename.isEmpty()) {
g_free((void *)pref->stashed_val.string);
pref->stashed_val.string = qstring_strdup(filename);