summaryrefslogtreecommitdiffstats
path: root/ui/qt/preferences_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/preferences_dialog.cpp')
-rw-r--r--ui/qt/preferences_dialog.cpp77
1 files changed, 61 insertions, 16 deletions
diff --git a/ui/qt/preferences_dialog.cpp b/ui/qt/preferences_dialog.cpp
index 7f78350c..76a880e2 100644
--- a/ui/qt/preferences_dialog.cpp
+++ b/ui/qt/preferences_dialog.cpp
@@ -22,21 +22,25 @@
#include <ui/simple_dialog.h>
#include <ui/recent.h>
#include <main_window.h>
+#include <extcap.h>
#include <ui/qt/utils/qt_ui_utils.h>
#include "main_application.h"
+#include <QDesktopServices>
+#include <QUrl>
+
extern "C" {
// Callbacks prefs routines
-static guint
-module_prefs_unstash(module_t *module, gpointer data)
+static unsigned
+module_prefs_unstash(module_t *module, void *data)
{
- gboolean *must_redissect_p = static_cast<gboolean *>(data);
+ unsigned int *must_redissect_p = static_cast<unsigned int *>(data);
pref_unstash_data_t unstashed_data;
- unstashed_data.handle_decode_as = TRUE;
+ unstashed_data.handle_decode_as = true;
module->prefs_changed_flags = 0; /* assume none of them changed */
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = gxx_list_next(pref_l)) {
@@ -60,8 +64,8 @@ module_prefs_unstash(module_t *module, gpointer data)
return 0; /* Keep unstashing. */
}
-static guint
-module_prefs_clean_stash(module_t *module, gpointer)
+static unsigned
+module_prefs_clean_stash(module_t *module, void *)
{
for (GList *pref_l = module->prefs; pref_l && pref_l->data; pref_l = gxx_list_next(pref_l)) {
pref_t *pref = gxx_list_data(pref_t *, pref_l);
@@ -112,6 +116,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :
pd_ui_->splitter->setStretchFactor(0, 1);
pd_ui_->splitter->setStretchFactor(1, 5);
+
+ // The calculations done in showEvent to set the minimum size of the
+ // protocol column mean that if we load the splitter state it will become
+ // impossible to shrink the splitter below the width of the widest protocol
+ // that initially fits, so don't do this unless we change showEvent.
+ //loadSplitterState(pd_ui_->splitter);
+
pd_ui_->prefsView->sortByColumn(ModulePrefsModel::colName, Qt::AscendingOrder);
//Set the Appearance leaf to expanded
@@ -225,7 +236,7 @@ void PreferencesDialog::on_advancedSearchLineEdit_textEdited(const QString &text
* the countdown.
*/
searchLineEditText = text;
- guint gui_debounce_timer = prefs_get_uint_value("gui", "debounce.timer");
+ unsigned gui_debounce_timer = prefs_get_uint_value("gui", "debounce.timer");
searchLineEditTimer->start(gui_debounce_timer);
}
@@ -237,19 +248,25 @@ void PreferencesDialog::on_showChangedValuesCheckBox_toggled(bool checked)
pd_ui_->advancedView->expandAll();
}
-void PreferencesDialog::on_buttonBox_accepted()
+void PreferencesDialog::apply()
{
- gchar* err = NULL;
+ char* err = NULL;
unsigned int redissect_flags = 0;
// XXX - We should validate preferences as the user changes them, not here.
// XXX - We're also too enthusiastic about setting must_redissect.
- prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (gpointer)&redissect_flags);
+ prefs_modules_foreach_submodules(NULL, module_prefs_unstash, (void *)&redissect_flags);
+
+ extcap_register_preferences();
if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) {
// Layout type changed, reset sizes
recent.gui_geometry_main_upper_pane = 0;
recent.gui_geometry_main_lower_pane = 0;
+ g_free(recent.gui_geometry_main_master_split);
+ g_free(recent.gui_geometry_main_extra_split);
+ recent.gui_geometry_main_master_split = NULL;
+ recent.gui_geometry_main_extra_split = NULL;
}
pd_ui_->columnFrame->unstash();
@@ -299,28 +316,41 @@ void PreferencesDialog::on_buttonBox_accepted()
mainApp->setMonospaceFont(prefs.gui_font_name);
+ if (redissect_flags & (PREF_EFFECT_GUI_COLOR)) {
+ mainApp->emitAppSignal(MainApplication::ColorsChanged);
+ }
+
if (redissect_flags & PREF_EFFECT_FIELDS) {
- mainApp->queueAppSignal(MainApplication::FieldsChanged);
+ mainApp->emitAppSignal(MainApplication::FieldsChanged);
}
if (redissect_flags & PREF_EFFECT_DISSECTION) {
// Freeze the packet list early to avoid updating column data before doing a
// full redissection. The packet list will be thawed when redissection is done.
- mainApp->queueAppSignal(MainApplication::FreezePacketList);
+ mainApp->emitAppSignal(MainApplication::FreezePacketList);
/* Redissect all the packets, and re-evaluate the display filter. */
- mainApp->queueAppSignal(MainApplication::PacketDissectionChanged);
+ mainApp->emitAppSignal(MainApplication::PacketDissectionChanged);
+ }
+
+ if (redissect_flags) {
+ mainApp->emitAppSignal(MainApplication::PreferencesChanged);
}
- mainApp->queueAppSignal(MainApplication::PreferencesChanged);
if (redissect_flags & PREF_EFFECT_GUI_LAYOUT) {
- mainApp->queueAppSignal(MainApplication::RecentPreferencesRead);
+ mainApp->emitAppSignal(MainApplication::RecentPreferencesRead);
}
if (prefs.capture_no_extcap != saved_capture_no_extcap_)
mainApp->refreshLocalInterfaces();
}
+void PreferencesDialog::on_buttonBox_accepted()
+{
+ apply();
+ accept();
+}
+
void PreferencesDialog::on_buttonBox_rejected()
{
//handle frames that don't have their own OK/Cancel "buttons"
@@ -329,9 +359,24 @@ void PreferencesDialog::on_buttonBox_rejected()
#ifdef HAVE_LIBGNUTLS
pd_ui_->rsaKeysFrame->rejectChanges();
#endif
+ reject();
+}
+
+void PreferencesDialog::on_buttonBox_clicked(QAbstractButton *button)
+{
+ if (pd_ui_->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
+ apply();
+ }
}
void PreferencesDialog::on_buttonBox_helpRequested()
{
- mainApp->helpTopicAction(HELP_PREFERENCES_DIALOG);
+ QString help_page = modulePrefsModel_.data(pd_ui_->prefsView->currentIndex(), ModulePrefsModel::ModuleHelp).toString();
+ if (!help_page.isEmpty()) {
+ QString url = gchar_free_to_qstring(user_guide_url(help_page.toUtf8().constData()));
+ QDesktopServices::openUrl(QUrl(url));
+ } else {
+ // Generic help
+ mainApp->helpTopicAction(HELP_PREFERENCES_DIALOG);
+ }
}