summaryrefslogtreecommitdiff
path: root/ui/qt/module_preferences_scroll_area.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-02-24 10:31:29 -0800
committerGerald Combs <gerald@wireshark.org>2015-02-24 18:35:16 +0000
commitc280a40443100293585f3ee5656fc620e2ce8483 (patch)
tree7e7bd786f7be6a0d9aa9fb00b039e5e5a467882d /ui/qt/module_preferences_scroll_area.cpp
parentc0c62783860965f44f19cca5c5b43459042018f9 (diff)
downloadwireshark-c280a40443100293585f3ee5656fc620e2ce8483.tar.gz
Qt: Escape ampersands in checkboxes and radio buttons.
Convert "&" to "&&" in checkbox and radio button preference labels so that they aren't interpreted as shortucts. Fixes QKeySequence::mnemonic: "Attempt to dissect LCID 1&2 as srb1&2" contains multiple occurrences of '&' Change-Id: Iacab6f81db01e6eca2cfdbaeda666f2e9c1016ed Reviewed-on: https://code.wireshark.org/review/7346 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/module_preferences_scroll_area.cpp')
-rw-r--r--ui/qt/module_preferences_scroll_area.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/qt/module_preferences_scroll_area.cpp b/ui/qt/module_preferences_scroll_area.cpp
index f1290e2fe9..016700f291 100644
--- a/ui/qt/module_preferences_scroll_area.cpp
+++ b/ui/qt/module_preferences_scroll_area.cpp
@@ -47,6 +47,15 @@ Q_DECLARE_METATYPE(pref_t *)
const char *pref_prop_ = "pref_ptr";
+// Escape our ampersands so that Qt won't try to interpret them as
+// mnemonics.
+static const QString title_to_shortcut(const char *title) {
+ QString shortcut_str(title);
+ shortcut_str.replace('&', "&&");
+ return shortcut_str;
+}
+
+
extern "C" {
// Callbacks prefs routines
@@ -77,7 +86,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
}
case PREF_BOOL:
{
- QCheckBox *bool_cb = new QCheckBox(pref->title);
+ QCheckBox *bool_cb = new QCheckBox(title_to_shortcut(pref->title));
bool_cb->setToolTip(tooltip);
bool_cb->setProperty(pref_prop_, qVariantFromValue(pref));
vb->addWidget(bool_cb);
@@ -94,7 +103,7 @@ pref_show(pref_t *pref, gpointer layout_ptr)
vb->addWidget(label);
QButtonGroup *enum_bg = new QButtonGroup();
for (ev = pref->info.enum_info.enumvals; ev && ev->description; ev++) {
- QRadioButton *enum_rb = new QRadioButton(ev->description);
+ QRadioButton *enum_rb = new QRadioButton(title_to_shortcut(ev->description));
enum_rb->setToolTip(tooltip);
QStyleOption style_opt;
enum_rb->setProperty(pref_prop_, qVariantFromValue(pref));
@@ -301,9 +310,8 @@ ModulePreferencesScrollArea::~ModulePreferencesScrollArea()
delete ui;
}
-void ModulePreferencesScrollArea::showEvent(QShowEvent *evt)
+void ModulePreferencesScrollArea::showEvent(QShowEvent *)
{
- Q_UNUSED(evt)
updateWidgets();
}