From d6d2e9002895a686841dc8b85b83a5281002d10b Mon Sep 17 00:00:00 2001 From: karliss Date: Fri, 7 Aug 2020 17:18:42 +0300 Subject: [PATCH] Clazy warnings (#2371) * Refactor some of the connect calls. * Refactor more old style signal connect calls. --- src/common/UpdateWorker.cpp | 6 +++--- src/core/MainWindow.cpp | 10 ++++------ src/dialogs/EditVariablesDialog.cpp | 3 ++- src/dialogs/InitialOptionsDialog.cpp | 2 +- src/dialogs/preferences/AsmOptionsWidget.cpp | 2 +- src/dialogs/preferences/DebugOptionsWidget.cpp | 13 ++++++++----- src/dialogs/preferences/DebugOptionsWidget.h | 2 +- src/widgets/ClassesWidget.cpp | 3 ++- src/widgets/FlagsWidget.cpp | 2 +- src/widgets/Omnibar.cpp | 2 +- src/widgets/RegisterRefsWidget.cpp | 8 +++++--- src/widgets/SdbWidget.cpp | 2 +- src/widgets/VTablesWidget.cpp | 2 +- 13 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/common/UpdateWorker.cpp b/src/common/UpdateWorker.cpp index df568654..d768bf7d 100644 --- a/src/common/UpdateWorker.cpp +++ b/src/common/UpdateWorker.cpp @@ -24,7 +24,7 @@ UpdateWorker::UpdateWorker(QObject *parent) : QObject(parent), pending(false) { - connect(&t, &QTimer::timeout, [this]() { + connect(&t, &QTimer::timeout, this, [this]() { if (pending) { disconnect(checkReply, nullptr, this, nullptr); checkReply->close(); @@ -102,7 +102,7 @@ void UpdateWorker::showUpdateDialog(bool showDontCheckForUpdatesButton) QProgressDialog progressDial(tr("Downloading update..."), tr("Cancel"), 0, 100); - connect(this, &UpdateWorker::downloadProcess, + connect(this, &UpdateWorker::downloadProcess, &progressDial, [&progressDial](size_t curr, size_t total) { progressDial.setValue(100.0f * curr / total); }); @@ -110,7 +110,7 @@ void UpdateWorker::showUpdateDialog(bool showDontCheckForUpdatesButton) this, &UpdateWorker::abortDownload); connect(this, &UpdateWorker::downloadFinished, &progressDial, &QProgressDialog::cancel); - connect(this, &UpdateWorker::downloadFinished, + connect(this, &UpdateWorker::downloadFinished, this, [](QString filePath){ QMessageBox info(QMessageBox::Information, tr("Download finished!"), diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 6d332c07..4c77a12b 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -169,9 +169,9 @@ void MainWindow::initUI() // G and S goes to goto entry QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this); - connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus())); + connect(goto_shortcut, &QShortcut::activated, this->omnibar, [this](){ this->omnibar->setFocus(); }); QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this); - connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus())); + connect(seek_shortcut, &QShortcut::activated, this->omnibar, [this](){ this->omnibar->setFocus(); }); QShortcut *seek_to_func_end_shortcut = new QShortcut(QKeySequence(Qt::Key_Dollar), this); connect(seek_to_func_end_shortcut, &QShortcut::activated, this, &MainWindow::seekToFunctionLastInstruction); QShortcut *seek_to_func_start_shortcut = new QShortcut(QKeySequence(Qt::Key_AsciiCircum), this); @@ -184,8 +184,7 @@ void MainWindow::initUI() connect(ui->actionZoomOut, &QAction::triggered, this, &MainWindow::onZoomOut); connect(ui->actionZoomReset, &QAction::triggered, this, &MainWindow::onZoomReset); - connect(core, SIGNAL(projectSaved(bool, const QString &)), this, SLOT(projectSaved(bool, - const QString &))); + connect(core, &CutterCore::projectSaved, this, &MainWindow::projectSaved); connect(core, &CutterCore::toggleDebugView, this, &MainWindow::toggleDebugView); @@ -319,7 +318,7 @@ void MainWindow::initToolBar() this->visualNavbar->setMovable(false); addToolBarBreak(Qt::TopToolBarArea); addToolBar(visualNavbar); - QObject::connect(configuration, &Configuration::colorsUpdated, [this]() { + QObject::connect(configuration, &Configuration::colorsUpdated, this, [this]() { this->visualNavbar->updateGraphicsScene(); }); QObject::connect(configuration, &Configuration::interfaceThemeChanged, this, &MainWindow::chooseThemeIcons); @@ -619,7 +618,6 @@ void MainWindow::finalizeOpen() setFocus(); bool graphContainsFunc = false; for (auto dockWidget : dockWidgets) { - const QString className = dockWidget->metaObject()->className(); auto graphWidget = qobject_cast(dockWidget); if (graphWidget && dockWidget->isVisibleToUser()) { graphContainsFunc = !graphWidget->getGraphView()->getBlocks().empty(); diff --git a/src/dialogs/EditVariablesDialog.cpp b/src/dialogs/EditVariablesDialog.cpp index 02052959..1f31eb0b 100644 --- a/src/dialogs/EditVariablesDialog.cpp +++ b/src/dialogs/EditVariablesDialog.cpp @@ -13,7 +13,8 @@ EditVariablesDialog::EditVariablesDialog(RVA offset, QString initialVar, QWidget { ui->setupUi(this); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &EditVariablesDialog::applyFields); - connect(ui->dropdownLocalVars, SIGNAL(currentIndexChanged(int)), SLOT(updateFields())); + connect(ui->dropdownLocalVars, &QComboBox::currentIndexChanged, + this, &EditVariablesDialog::updateFields); QString fcnName = Core()->cmdRawAt("afn.", offset).trimmed(); setWindowTitle(tr("Set Variable Types for Function: %1").arg(fcnName)); diff --git a/src/dialogs/InitialOptionsDialog.cpp b/src/dialogs/InitialOptionsDialog.cpp index ee42b7da..d377a444 100644 --- a/src/dialogs/InitialOptionsDialog.cpp +++ b/src/dialogs/InitialOptionsDialog.cpp @@ -91,7 +91,7 @@ InitialOptionsDialog::InitialOptionsDialog(MainWindow *main): connect(ui->scriptCheckBox, &QCheckBox::stateChanged, this, &InitialOptionsDialog::updateScriptLayout); - connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject())); + connect(ui->cancelButton, &QPushButton::clicked, this, &InitialOptionsDialog::reject); ui->programLineEdit->setText(main->getFilename()); } diff --git a/src/dialogs/preferences/AsmOptionsWidget.cpp b/src/dialogs/preferences/AsmOptionsWidget.cpp index 32a6c39f..94a7ddc6 100644 --- a/src/dialogs/preferences/AsmOptionsWidget.cpp +++ b/src/dialogs/preferences/AsmOptionsWidget.cpp @@ -64,7 +64,7 @@ AsmOptionsWidget::AsmOptionsWidget(PreferencesDialog *dialog) &AsmOptionsWidget::asmComboBoxChanged); connect(ui->offsetCheckBox, &QCheckBox::toggled, this, &AsmOptionsWidget::offsetCheckBoxToggled); connect(ui->relOffsetCheckBox, &QCheckBox::toggled, this, &AsmOptionsWidget::relOffCheckBoxToggled); - connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(updateAsmOptionsFromVars())); + connect(Core(), &CutterCore::asmOptionsChanged, this, &AsmOptionsWidget::updateAsmOptionsFromVars); updateAsmOptionsFromVars(); } diff --git a/src/dialogs/preferences/DebugOptionsWidget.cpp b/src/dialogs/preferences/DebugOptionsWidget.cpp index 2cf04e10..e40d2876 100644 --- a/src/dialogs/preferences/DebugOptionsWidget.cpp +++ b/src/dialogs/preferences/DebugOptionsWidget.cpp @@ -17,6 +17,9 @@ DebugOptionsWidget::DebugOptionsWidget(PreferencesDialog *dialog) ui->setupUi(this); updateDebugPlugin(); + + connect(ui->pluginComboBox, &QComboBox::currentTextChanged, + this, &DebugOptionsWidget::onDebugPluginChanged); } DebugOptionsWidget::~DebugOptionsWidget() {} @@ -24,8 +27,8 @@ DebugOptionsWidget::~DebugOptionsWidget() {} void DebugOptionsWidget::updateDebugPlugin() { ui->esilBreakOnInvalid->setChecked(Config()->getConfigBool("esil.breakoninvalid")); - disconnect(ui->pluginComboBox, SIGNAL(currentIndexChanged(const QString &)), this, - SLOT(on_pluginComboBox_currentIndexChanged(const QString &))); + disconnect(ui->pluginComboBox, &QComboBox::currentTextChanged, + this, &DebugOptionsWidget::onDebugPluginChanged); QStringList plugins = Core()->getDebugPlugins(); for (const QString &str : plugins) @@ -34,8 +37,8 @@ void DebugOptionsWidget::updateDebugPlugin() QString plugin = Core()->getActiveDebugPlugin(); ui->pluginComboBox->setCurrentText(plugin); - connect(ui->pluginComboBox, SIGNAL(currentIndexChanged(const QString &)), this, - SLOT(on_pluginComboBox_currentIndexChanged(const QString &))); + connect(ui->pluginComboBox, &QComboBox::currentTextChanged, + this, &DebugOptionsWidget::onDebugPluginChanged); QString stackSize = Core()->getConfig("esil.stack.size"); ui->stackSize->setText(stackSize); @@ -47,7 +50,7 @@ void DebugOptionsWidget::updateDebugPlugin() connect(ui->stackSize, &QLineEdit::editingFinished, this, &DebugOptionsWidget::updateStackSize); } -void DebugOptionsWidget::on_pluginComboBox_currentIndexChanged(const QString &plugin) +void DebugOptionsWidget::onDebugPluginChanged(const QString &plugin) { Core()->setDebugPlugin(plugin); } diff --git a/src/dialogs/preferences/DebugOptionsWidget.h b/src/dialogs/preferences/DebugOptionsWidget.h index 367c4e9b..9d7050ea 100644 --- a/src/dialogs/preferences/DebugOptionsWidget.h +++ b/src/dialogs/preferences/DebugOptionsWidget.h @@ -26,6 +26,6 @@ private slots: void updateDebugPlugin(); void updateStackAddr(); void updateStackSize(); - void on_pluginComboBox_currentIndexChanged(const QString &index); + void onDebugPluginChanged(const QString &index); void on_esilBreakOnInvalid_toggled(bool checked); }; diff --git a/src/widgets/ClassesWidget.cpp b/src/widgets/ClassesWidget.cpp index 50f72ac9..334095ae 100644 --- a/src/widgets/ClassesWidget.cpp +++ b/src/widgets/ClassesWidget.cpp @@ -590,7 +590,8 @@ ClassesWidget::ClassesWidget(MainWindow *main) : ui->classSourceCombo->setCurrentIndex(1); - connect(ui->classSourceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshClasses())); + connect(ui->classSourceCombo, &QComboBox::currentIndexChanged, + this, &ClassesWidget::refreshClasses); connect(ui->classesTreeView, &QTreeView::customContextMenuRequested, this, &ClassesWidget::showContextMenu); refreshClasses(); diff --git a/src/widgets/FlagsWidget.cpp b/src/widgets/FlagsWidget.cpp index 05360458..3cae7585 100644 --- a/src/widgets/FlagsWidget.cpp +++ b/src/widgets/FlagsWidget.cpp @@ -158,7 +158,7 @@ FlagsWidget::FlagsWidget(MainWindow *main) : // Ctrl-F to move the focus to the Filter search box QShortcut *searchShortcut = new QShortcut(QKeySequence::Find, this); - connect(searchShortcut, SIGNAL(activated()), ui->filterLineEdit, SLOT(setFocus())); + connect(searchShortcut, &QShortcut::activated, ui->filterLineEdit, [this]() { ui->filterLineEdit->setFocus(); }); searchShortcut->setContext(Qt::WidgetWithChildrenShortcut); // Esc to clear the filter entry diff --git a/src/widgets/Omnibar.cpp b/src/widgets/Omnibar.cpp index 9ad2bf0c..369b0963 100644 --- a/src/widgets/Omnibar.cpp +++ b/src/widgets/Omnibar.cpp @@ -24,7 +24,7 @@ Omnibar::Omnibar(MainWindow *main, QWidget *parent) : // Esc clears omnibar QShortcut *clear_shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this); - connect(clear_shortcut, SIGNAL(activated()), this, SLOT(clear())); + connect(clear_shortcut, &QShortcut::activated, this, &Omnibar::clear); clear_shortcut->setContext(Qt::WidgetWithChildrenShortcut); } diff --git a/src/widgets/RegisterRefsWidget.cpp b/src/widgets/RegisterRefsWidget.cpp index 3ed68818..e7a36c01 100644 --- a/src/widgets/RegisterRefsWidget.cpp +++ b/src/widgets/RegisterRefsWidget.cpp @@ -149,14 +149,16 @@ RegisterRefsWidget::RegisterRefsWidget(MainWindow *main) : connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, registerRefProxyModel, &QSortFilterProxyModel::setFilterWildcard); - connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->registerRefTreeView, SLOT(setFocus())); + connect(ui->quickFilterView, &QuickFilterView::filterClosed, ui->registerRefTreeView, [this](){ + ui->registerRefTreeView->setFocus(); + }); setScrollMode(); connect(Core(), &CutterCore::refreshAll, this, &RegisterRefsWidget::refreshRegisterRef); connect(Core(), &CutterCore::registersChanged, this, &RegisterRefsWidget::refreshRegisterRef); - connect(actionCopyValue, &QAction::triggered, [ = ] () { + connect(actionCopyValue, &QAction::triggered, this, [this] () { copyClip(RegisterRefModel::ValueColumn); }); - connect(actionCopyRef, &QAction::triggered, [ = ] () { + connect(actionCopyRef, &QAction::triggered, this, [this] () { copyClip(RegisterRefModel::RefColumn); }); ui->registerRefTreeView->setContextMenuPolicy(Qt::CustomContextMenu); diff --git a/src/widgets/SdbWidget.cpp b/src/widgets/SdbWidget.cpp index 8b01fe86..4b47bea8 100644 --- a/src/widgets/SdbWidget.cpp +++ b/src/widgets/SdbWidget.cpp @@ -16,7 +16,7 @@ SdbWidget::SdbWidget(MainWindow *main) : path.clear(); - connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload())); + connect(Core(), &CutterCore::refreshAll, this, [this](){ reload(); }); reload(); } diff --git a/src/widgets/VTablesWidget.cpp b/src/widgets/VTablesWidget.cpp index 8e566f8e..9b982bb7 100644 --- a/src/widgets/VTablesWidget.cpp +++ b/src/widgets/VTablesWidget.cpp @@ -155,7 +155,7 @@ VTablesWidget::VTablesWidget(MainWindow *main) : connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, proxy, &QSortFilterProxyModel::setFilterWildcard); - connect(ui->quickFilterView, SIGNAL(filterClosed()), ui->vTableTreeView, SLOT(setFocus())); + connect(ui->quickFilterView, &QuickFilterView::filterClosed, ui->vTableTreeView, [this](){ ui->vTableTreeView->setFocus(); }); connect(ui->quickFilterView, &QuickFilterView::filterTextChanged, this, [this] { tree->showItemsNumber(proxy->rowCount());