forked from qt-creator/qt-creator
Core: Drop Q_OBJECT from OptionsPopup
Not needed. Also slim down header a bit. Change-Id: I6ac828fdfc42173e0b5aeca5d92e920745b424c9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -18,6 +18,21 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Core {
|
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
|
\class Core::OptionsPopup
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
@@ -35,7 +50,7 @@ OptionsPopup::OptionsPopup(QWidget *parent, const QVector<Id> &commands)
|
|||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const Id &command : commands) {
|
for (const Id &command : commands) {
|
||||||
QCheckBox *checkBox = createCheckboxForCommand(command);
|
QCheckBox *checkBox = createCheckboxForCommand(this, command);
|
||||||
if (first) {
|
if (first) {
|
||||||
checkBox->setFocus();
|
checkBox->setFocus();
|
||||||
first = false;
|
first = false;
|
||||||
@@ -73,19 +88,4 @@ bool OptionsPopup::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
return QWidget::eventFilter(obj, 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
|
} // namespace Core
|
||||||
|
@@ -9,25 +9,16 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QCheckBox;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class CORE_EXPORT OptionsPopup : public QWidget
|
class CORE_EXPORT OptionsPopup : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsPopup(QWidget *parent, const QVector<Utils::Id> &commands);
|
OptionsPopup(QWidget *parent, const QVector<Utils::Id> &commands);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *ev) override;
|
bool event(QEvent *ev) override;
|
||||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||||
|
|
||||||
private:
|
|
||||||
QCheckBox *createCheckboxForCommand(Utils::Id id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
Reference in New Issue
Block a user