Qt: Support ampersand in funnel menu and button

An ampersand in the menu item or a button is used as shortcut, so
use "&&" to get a real ampersand.


(cherry picked from commit c84681aca2)
This commit is contained in:
Stig Bjørlykke 2020-10-30 13:52:54 +00:00 committed by Wireshark GitLab Utility
parent d5ea403f8d
commit b668d0a9d5
3 changed files with 9 additions and 3 deletions

View File

@ -58,13 +58,16 @@ static void progress_window_destroy(struct progdlg *progress_dialog);
class FunnelAction : public QAction
{
public:
FunnelAction(const QString title, funnel_menu_callback callback, gpointer callback_data, gboolean retap, QObject *parent = nullptr) :
FunnelAction(QString title, funnel_menu_callback callback, gpointer callback_data, gboolean retap, QObject *parent = nullptr) :
QAction(parent),
title_(title),
callback_(callback),
callback_data_(callback_data),
retap_(retap)
{
// Use "&&" to get a real ampersand in the menu item.
title.replace('&', "&&");
setText(title);
setObjectName(FunnelStatistics::actionName());
}

View File

@ -118,8 +118,11 @@ void FunnelTextDialog::setTextEditable(gboolean editable)
ui->textEdit->setReadOnly(!editable);
}
void FunnelTextDialog::addButton(funnel_bt_t *funnel_button, const QString label)
void FunnelTextDialog::addButton(funnel_bt_t *funnel_button, QString label)
{
// Use "&&" to get a real ampersand in the button.
label.replace('&', "&&");
QPushButton *button = new QPushButton(label);
ui->buttonBox->addButton(button, QDialogButtonBox::ActionRole);
text_button_to_funnel_button_[button] = funnel_button;

View File

@ -45,7 +45,7 @@ public:
const char *getText();
void setCloseCallback(text_win_close_cb_t close_cb, void* close_cb_data);
void setTextEditable(gboolean editable);
void addButton(funnel_bt_t *button_cb, const QString label);
void addButton(funnel_bt_t *button_cb, QString label);
private slots:
void buttonClicked();