10 #include <QVBoxLayout>
22 setObjectName(
"CPluginSelector");
24 QVBoxLayout *layout =
new QVBoxLayout;
33 SWIFT_VERIFY_X(!identifier.isEmpty(), Q_FUNC_INFO,
"Missing identifier");
34 if (identifier.isEmpty()) {
return; }
36 QWidget *pw =
new QWidget;
37 QHBoxLayout *layout =
new QHBoxLayout;
38 layout->setContentsMargins(0, 0, 0, 0);
39 pw->setLayout(layout);
41 QCheckBox *cb =
new QCheckBox(name);
42 cb->setObjectName(identifier);
43 cb->setProperty(
"pluginIdentifier", identifier);
44 connect(cb, &QCheckBox::stateChanged,
this, &CPluginSelector::handlePluginStateChange);
45 if (enabled) { cb->setCheckState(Qt::Checked); }
46 else { cb->setCheckState(Qt::Unchecked); }
48 pw->layout()->addWidget(cb);
53 config->setToolTip(
"Plugin configuration");
54 m_configButtonMapper->setMapping(config, identifier);
55 connect(config, &QPushButton::clicked, m_configButtonMapper, qOverload<>(&QSignalMapper::map));
56 pw->layout()->addWidget(config);
59 layout->setStretch(0, 1);
60 layout->setStretch(1, 0);
62 this->layout()->addWidget(pw);
67 QCheckBox *cb = findChild<QCheckBox *>(identifier);
69 cb->setChecked(enabled);
72 void CPluginSelector::handlePluginStateChange()
74 QCheckBox *cb = qobject_cast<QCheckBox *>(sender());
77 bool enabled = cb->checkState() != Qt::Unchecked;
78 Q_ASSERT(cb->property(
"pluginIdentifier").isValid());
79 const QString identifier = cb->property(
"pluginIdentifier").toString();
80 Q_ASSERT(!identifier.isEmpty());
void addPlugin(const QString &identifier, const QString &name, bool hasConfig=false, bool enabled=true)
Adds the new plugin to the list.
void setEnabled(const QString &identifier, bool enabled)
Enables/disabled the given plugin.
void pluginStateChanged(const QString &identifier, bool enabled)
Emitted when user enables/disables the particular plugin.
CPluginSelector(QWidget *parent=nullptr)
Constructor.
void pluginConfigRequested(const QString &identifier)
Emitted when user clicks the "Settings" button.
static const QPixmap & wrench16()
Wrench.
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.