From 4f557ea164906c56c4e18246a12fb4908fb5e2ea Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 21 Dec 2018 11:03:34 -0800 Subject: [PATCH] Qt: Switch line edits to new-style signals and slots. Switch SyntaxLineEdit, CaptureFilterEdit, DisplayFilterEdit, FieldFilterEdit, and RangeSyntaxLineEdit to compile time signals and slots. Change-Id: I2fb26c04324997929436c3d920baa1bdc6056e44 Reviewed-on: https://code.wireshark.org/review/31162 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/widgets/capture_filter_edit.cpp | 37 +++++++++++++------------ ui/qt/widgets/display_filter_edit.cpp | 23 +++++++-------- ui/qt/widgets/field_filter_edit.cpp | 5 ++-- ui/qt/widgets/range_syntax_lineedit.cpp | 2 +- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/ui/qt/widgets/capture_filter_edit.cpp b/ui/qt/widgets/capture_filter_edit.cpp index 2d1bb6f613..351587f1b2 100644 --- a/ui/qt/widgets/capture_filter_edit.cpp +++ b/ui/qt/widgets/capture_filter_edit.cpp @@ -146,7 +146,7 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) : "}" "QToolButton::menu-indicator { image: none; }" ); - connect(bookmark_button_, SIGNAL(clicked()), this, SLOT(bookmarkClicked())); + connect(bookmark_button_, &StockIconToolButton::clicked, this, &CaptureFilterEdit::bookmarkClicked); } if (!plain_) { @@ -162,10 +162,11 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) : " margin-left: 1px;" "}" ); - connect(clear_button_, SIGNAL(clicked()), this, SLOT(clearFilter())); + connect(clear_button_, &StockIconToolButton::clicked, this, &CaptureFilterEdit::clearFilter); } - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&))); + connect(this, &CaptureFilterEdit::textChanged, this, + static_cast(&CaptureFilterEdit::checkFilter)); #if 0 // Disable the apply button for now @@ -182,10 +183,10 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) : " padding: 0 0 0 0;" "}" ); - connect(apply_button_, SIGNAL(clicked()), this, SLOT(applyCaptureFilter())); + connect(apply_button_, &StockIconToolButton::clicked, this, &CaptureFilterEdit::applyCaptureFilter); } #endif - connect(this, SIGNAL(returnPressed()), this, SLOT(applyCaptureFilter())); + connect(this, &CaptureFilterEdit::returnPressed, this, &CaptureFilterEdit::applyCaptureFilter); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); QSize bksz; @@ -209,19 +210,21 @@ CaptureFilterEdit::CaptureFilterEdit(QWidget *parent, bool plain) : QComboBox *cf_combo = qobject_cast(parent); if (cf_combo) { - connect(cf_combo, SIGNAL(activated(QString)), this, SIGNAL(textEdited(QString))); + connect(cf_combo, static_cast(&QComboBox::activated), + this, &CaptureFilterEdit::textEdited); } QThread *syntax_thread = new QThread; syntax_worker_ = new CaptureFilterSyntaxWorker; syntax_worker_->moveToThread(syntax_thread); - connect(wsApp, SIGNAL(appInitialized()), this, SLOT(updateBookmarkMenu())); - connect(wsApp, SIGNAL(captureFilterListChanged()), this, SLOT(updateBookmarkMenu())); - connect(syntax_thread, SIGNAL(started()), syntax_worker_, SLOT(start())); - connect(syntax_thread, SIGNAL(started()), this, SLOT(checkFilter())); - connect(syntax_worker_, SIGNAL(syntaxResult(QString,int,QString)), - this, SLOT(setFilterSyntaxState(QString,int,QString))); - connect(syntax_thread, SIGNAL(finished()), syntax_worker_, SLOT(deleteLater())); + connect(wsApp, &WiresharkApplication::appInitialized, this, &CaptureFilterEdit::updateBookmarkMenu); + connect(wsApp, &WiresharkApplication::captureFilterListChanged, this, &CaptureFilterEdit::updateBookmarkMenu); + connect(syntax_thread, &QThread::started, syntax_worker_, &CaptureFilterSyntaxWorker::start); + connect(syntax_thread, &QThread::started, this, + static_cast(&CaptureFilterEdit::checkFilter)); + connect(syntax_worker_, &CaptureFilterSyntaxWorker::syntaxResult, + this, &CaptureFilterEdit::setFilterSyntaxState); + connect(syntax_thread, &QThread::finished, syntax_worker_, &CaptureFilterSyntaxWorker::deleteLater); syntax_thread->start(); updateBookmarkMenu(); } @@ -379,11 +382,11 @@ void CaptureFilterEdit::updateBookmarkMenu() bb_menu->clear(); save_action_ = bb_menu->addAction(tr("Save this filter")); - connect(save_action_, SIGNAL(triggered(bool)), this, SLOT(saveFilter())); + connect(save_action_, &QAction::triggered, this, &CaptureFilterEdit::saveFilter); remove_action_ = bb_menu->addAction(tr("Remove this filter")); - connect(remove_action_, SIGNAL(triggered(bool)), this, SLOT(removeFilter())); + connect(remove_action_, &QAction::triggered, this, &CaptureFilterEdit::removeFilter); QAction *manage_action = bb_menu->addAction(tr("Manage Capture Filters")); - connect(manage_action, SIGNAL(triggered(bool)), this, SLOT(showFilters())); + connect(manage_action, &QAction::triggered, this, &CaptureFilterEdit::showFilters); bb_menu->addSeparator(); for (GList *cf_item = get_filter_list_first(CFILTER_LIST); cf_item; cf_item = g_list_next(cf_item)) { @@ -397,7 +400,7 @@ void CaptureFilterEdit::updateBookmarkMenu() QAction *prep_action = bb_menu->addAction(prep_text); prep_action->setData(cf_def->strval); - connect(prep_action, SIGNAL(triggered(bool)), this, SLOT(prepareFilter())); + connect(prep_action, &QAction::triggered, this, &CaptureFilterEdit::prepareFilter); } checkFilter(); diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp index e1cd6237f3..e3e9599f16 100644 --- a/ui/qt/widgets/display_filter_edit.cpp +++ b/ui/qt/widgets/display_filter_edit.cpp @@ -108,10 +108,11 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type " margin-left: 1px;" "}" ); - connect(clear_button_, SIGNAL(clicked()), this, SLOT(clearFilter())); + connect(clear_button_, &StockIconToolButton::clicked, this, &DisplayFilterEdit::clearFilter); } - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&))); + connect(this, &DisplayFilterEdit::textChanged, this, + static_cast(&DisplayFilterEdit::checkFilter)); if (type_ == DisplayFilterToApply) { apply_button_ = new StockIconToolButton(this, "x-filter-apply"); @@ -126,8 +127,8 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type " padding: 0 0 0 0;" "}" ); - connect(apply_button_, SIGNAL(clicked()), this, SLOT(applyDisplayFilter())); - connect(this, SIGNAL(returnPressed()), this, SLOT(applyDisplayFilter())); + connect(apply_button_, &StockIconToolButton::clicked, this, &DisplayFilterEdit::applyDisplayFilter); + connect(this, &DisplayFilterEdit::returnPressed, this, &DisplayFilterEdit::applyDisplayFilter); } int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); @@ -155,8 +156,8 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type .arg(cbsz.width() + apsz.width() + frameWidth + 1) ); - connect(wsApp, SIGNAL(appInitialized()), this, SLOT(updateBookmarkMenu())); - connect(wsApp, SIGNAL(displayFilterListChanged()), this, SLOT(updateBookmarkMenu())); + connect(wsApp, &WiresharkApplication::appInitialized, this, &DisplayFilterEdit::updateBookmarkMenu); + connect(wsApp, &WiresharkApplication::displayFilterListChanged, this, &DisplayFilterEdit::updateBookmarkMenu); } @@ -318,13 +319,13 @@ void DisplayFilterEdit::updateBookmarkMenu() bb_menu->clear(); save_action_ = bb_menu->addAction(tr("Save this filter")); - connect(save_action_, SIGNAL(triggered(bool)), this, SLOT(saveFilter())); + connect(save_action_, &QAction::triggered, this, &DisplayFilterEdit::saveFilter); remove_action_ = bb_menu->addAction(tr("Remove this filter")); - connect(remove_action_, SIGNAL(triggered(bool)), this, SLOT(removeFilter())); + connect(remove_action_, &QAction::triggered, this, &DisplayFilterEdit::removeFilter); QAction *manage_action = bb_menu->addAction(tr("Manage Display Filters")); - connect(manage_action, SIGNAL(triggered(bool)), this, SLOT(showFilters())); + connect(manage_action, &QAction::triggered, this, &DisplayFilterEdit::showFilters); QAction *expr_action = bb_menu->addAction(tr("Manage Filter Expressions")); - connect(expr_action, SIGNAL(triggered(bool)), this, SLOT(showExpressionPrefs())); + connect(expr_action, &QAction::triggered, this, &DisplayFilterEdit::showExpressionPrefs); bb_menu->addSeparator(); for (GList *df_item = get_filter_list_first(DFILTER_LIST); df_item; df_item = g_list_next(df_item)) { @@ -338,7 +339,7 @@ void DisplayFilterEdit::updateBookmarkMenu() QAction *prep_action = bb_menu->addAction(prep_text); prep_action->setData(df_def->strval); - connect(prep_action, SIGNAL(triggered(bool)), this, SLOT(applyOrPrepareFilter())); + connect(prep_action, &QAction::triggered, this, &DisplayFilterEdit::applyOrPrepareFilter); } checkFilter(); diff --git a/ui/qt/widgets/field_filter_edit.cpp b/ui/qt/widgets/field_filter_edit.cpp index debc9b0a21..1b66fc6404 100644 --- a/ui/qt/widgets/field_filter_edit.cpp +++ b/ui/qt/widgets/field_filter_edit.cpp @@ -65,8 +65,9 @@ FieldFilterEdit::FieldFilterEdit(QWidget *parent) : // Apply (right arrow) // Combo drop-down - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&))); -// connect(this, SIGNAL(returnPressed()), this, SLOT(applyDisplayFilter())); + connect(this, &FieldFilterEdit::textChanged, this, + static_cast(&FieldFilterEdit::checkFilter)); +// connect(this, &FieldFilterEdit::returnPressed, this, &FieldFilterEdit::applyDisplayFilter); } void FieldFilterEdit::setDefaultPlaceholderText() diff --git a/ui/qt/widgets/range_syntax_lineedit.cpp b/ui/qt/widgets/range_syntax_lineedit.cpp index 22f5106239..d6d6adcb00 100644 --- a/ui/qt/widgets/range_syntax_lineedit.cpp +++ b/ui/qt/widgets/range_syntax_lineedit.cpp @@ -16,7 +16,7 @@ RangeSyntaxLineEdit::RangeSyntaxLineEdit(QWidget *parent) : SyntaxLineEdit(parent), maxRange_(0xFFFFFFFF) { - connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkRange(QString))); + connect(this, &RangeSyntaxLineEdit::textChanged, this, &RangeSyntaxLineEdit::checkRange); } void RangeSyntaxLineEdit::setMaxRange(unsigned int max)