From 5867d986a8360dcf8d9d62678b3ce61de8bc4fbd Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 28 Jun 2023 10:48:37 +0200 Subject: [PATCH] Core: Drop Q_OBJECT from OptionsPopup Not needed. Also slim down header a bit. Change-Id: I6ac828fdfc42173e0b5aeca5d92e920745b424c9 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/find/optionspopup.cpp | 32 ++++++++++---------- src/plugins/coreplugin/find/optionspopup.h | 9 ------ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/plugins/coreplugin/find/optionspopup.cpp b/src/plugins/coreplugin/find/optionspopup.cpp index af2e306037c..9f5f11ad2d0 100644 --- a/src/plugins/coreplugin/find/optionspopup.cpp +++ b/src/plugins/coreplugin/find/optionspopup.cpp @@ -18,6 +18,21 @@ using namespace Utils; namespace Core { +static QCheckBox *createCheckboxForCommand(QObject *owner, Id id) +{ + QAction *action = ActionManager::command(id)->action(); + QCheckBox *checkbox = new QCheckBox(action->text()); + checkbox->setToolTip(action->toolTip()); + checkbox->setChecked(action->isChecked()); + checkbox->setEnabled(action->isEnabled()); + checkbox->installEventFilter(owner); // enter key handling + QObject::connect(checkbox, &QCheckBox::clicked, action, &QAction::setChecked); + QObject::connect(action, &QAction::changed, checkbox, [action, checkbox] { + checkbox->setEnabled(action->isEnabled()); + }); + return checkbox; +} + /*! \class Core::OptionsPopup \inmodule QtCreator @@ -35,7 +50,7 @@ OptionsPopup::OptionsPopup(QWidget *parent, const QVector &commands) bool first = true; for (const Id &command : commands) { - QCheckBox *checkBox = createCheckboxForCommand(command); + QCheckBox *checkBox = createCheckboxForCommand(this, command); if (first) { checkBox->setFocus(); first = false; @@ -73,19 +88,4 @@ bool OptionsPopup::eventFilter(QObject *obj, QEvent *ev) return QWidget::eventFilter(obj, ev); } -QCheckBox *OptionsPopup::createCheckboxForCommand(Id id) -{ - QAction *action = ActionManager::command(id)->action(); - QCheckBox *checkbox = new QCheckBox(action->text()); - checkbox->setToolTip(action->toolTip()); - checkbox->setChecked(action->isChecked()); - checkbox->setEnabled(action->isEnabled()); - checkbox->installEventFilter(this); // enter key handling - QObject::connect(checkbox, &QCheckBox::clicked, action, &QAction::setChecked); - QObject::connect(action, &QAction::changed, checkbox, [action, checkbox] { - checkbox->setEnabled(action->isEnabled()); - }); - return checkbox; -} - } // namespace Core diff --git a/src/plugins/coreplugin/find/optionspopup.h b/src/plugins/coreplugin/find/optionspopup.h index 6331de8914f..3356dc50556 100644 --- a/src/plugins/coreplugin/find/optionspopup.h +++ b/src/plugins/coreplugin/find/optionspopup.h @@ -9,25 +9,16 @@ #include -QT_BEGIN_NAMESPACE -class QCheckBox; -QT_END_NAMESPACE - namespace Core { class CORE_EXPORT OptionsPopup : public QWidget { - Q_OBJECT - public: OptionsPopup(QWidget *parent, const QVector &commands); protected: bool event(QEvent *ev) override; bool eventFilter(QObject *obj, QEvent *ev) override; - -private: - QCheckBox *createCheckboxForCommand(Utils::Id id); }; } // namespace Core