Qt: Support setting custom preferences

This makes it possible to set the console.log.level from the Advanced
preferences window.

Change-Id: I5c5551f089a935eef77f54fdcad0ba060f14edfd
Reviewed-on: https://code.wireshark.org/review/32930
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Tomasz Moń 2019-04-21 19:40:19 +02:00 committed by Peter Wu
parent 6a3b24be29
commit c42433b6bb
5 changed files with 19 additions and 0 deletions

View File

@ -1060,6 +1060,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
prefs_remove_decode_as_value@Base 2.3.0
prefs_set_bool_value@Base 2.3.0
prefs_set_color_value@Base 2.3.0
prefs_set_custom_value@Base 3.1.0
prefs_set_effect_flags@Base 2.5.0
prefs_set_effect_flags_by_name@Base 2.5.0
prefs_set_enum_value@Base 2.3.0

View File

@ -237,6 +237,8 @@ WS_DLL_PUBLIC gboolean prefs_get_enum_radiobuttons(pref_t *pref);
WS_DLL_PUBLIC gboolean prefs_set_color_value(pref_t *pref, color_t value, pref_source_t source);
WS_DLL_PUBLIC color_t* prefs_get_color_value(pref_t *pref, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_custom_value(pref_t *pref, const char *value, pref_source_t source);
WS_DLL_PUBLIC unsigned int prefs_set_string_value(pref_t *pref, const char* value, pref_source_t source);
WS_DLL_PUBLIC char* prefs_get_string_value(pref_t *pref, pref_source_t source);

View File

@ -1379,6 +1379,18 @@ gboolean prefs_get_enum_radiobuttons(pref_t *pref)
return pref->info.enum_info.radio_buttons;
}
/*
* For use by UI code that sets preferences.
*/
unsigned int
prefs_set_custom_value(pref_t *pref, const char *value, pref_source_t source _U_)
{
/* XXX - support pref source for custom preferences */
unsigned int changed = 0;
pref->custom_cbs.set_cb(pref, value, &changed);
return changed;
}
static void
register_string_like_preference(module_t *module, const char *name,
const char *title, const char *description,

View File

@ -79,6 +79,7 @@ public:
}
};
REGISTER_PREFERENCE_TYPE(PREF_STRING, StringPreference)
REGISTER_PREFERENCE_TYPE(PREF_CUSTOM, StringPreference)
class UIntPreference : public StringPreference
{

View File

@ -513,6 +513,9 @@ bool AdvancedPrefsModel::setData(const QModelIndex &dataindex, const QVariant &v
prefs_set_color_value(item->getPref(), color, pref_stashed);
break;
}
case PREF_CUSTOM:
prefs_set_custom_value(item->getPref(), value.toString().toStdString().c_str(), pref_stashed);
break;
}
}