fixed visibility bug
the icon could be sometimes seen when the option was unvisable
Dieser Commit ist enthalten in:
Ursprung
83bd3e6054
Commit
9088aa42da
@ -35,31 +35,56 @@ InterfaceItemNameLabel::InterfaceItemNameLabel(InterfaceItem& item, QWidget* par
|
|||||||
layout->setSpacing(2);
|
layout->setSpacing(2);
|
||||||
layout->addWidget(m_label);
|
layout->addWidget(m_label);
|
||||||
|
|
||||||
// Create help button if needed
|
const bool visible = m_item.getAttributeBool(AttributeName::Visible, true);
|
||||||
|
m_label->setVisible(visible);
|
||||||
m_helpBtn = nullptr;
|
m_helpBtn = nullptr;
|
||||||
const QString help = m_item.helpText();
|
const QString help = m_item.helpText();
|
||||||
if (!help.isEmpty())
|
if (!help.isEmpty() && visible)
|
||||||
{
|
{
|
||||||
m_helpBtn = new QToolButton(this);
|
m_helpBtn = new QToolButton(this);
|
||||||
m_helpBtn->setIcon(Theme::getIcon("help")); // portable icon
|
m_helpBtn->setIcon(Theme::getIcon("help"));
|
||||||
m_helpBtn->setToolTip(help);
|
m_helpBtn->setToolTip(help);
|
||||||
m_helpBtn->setAutoRaise(true);
|
m_helpBtn->setAutoRaise(true);
|
||||||
m_helpBtn->setCursor(Qt::PointingHandCursor);
|
m_helpBtn->setCursor(Qt::PointingHandCursor);
|
||||||
m_helpBtn->setIconSize(QSize(12, 12));
|
m_helpBtn->setIconSize(QSize(12, 12));
|
||||||
layout->addWidget(m_helpBtn, 0, Qt::AlignTop);
|
layout->addWidget(m_helpBtn, 0, Qt::AlignTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
|
|
||||||
// Capture layout too
|
|
||||||
connect(&m_item, &InterfaceItem::attributeChanged, this,
|
connect(&m_item, &InterfaceItem::attributeChanged, this,
|
||||||
[this, layout](AttributeName name, const QVariant&)
|
[this, layout](AttributeName name, const QVariant&)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case AttributeName::Visible:
|
case AttributeName::Visible:
|
||||||
m_label->setVisible(m_item.getAttributeBool(AttributeName::Visible, true));
|
{
|
||||||
|
const bool isVisible = m_item.getAttributeBool(AttributeName::Visible, true);
|
||||||
|
m_label->setVisible(isVisible);
|
||||||
|
|
||||||
|
const QString helpText = m_item.helpText();
|
||||||
|
|
||||||
|
if (isVisible)
|
||||||
|
{
|
||||||
|
if (!m_helpBtn && !helpText.isEmpty())
|
||||||
|
{
|
||||||
|
m_helpBtn = new QToolButton(this);
|
||||||
|
m_helpBtn->setIcon(Theme::getIcon("help"));
|
||||||
|
m_helpBtn->setToolTip(helpText);
|
||||||
|
m_helpBtn->setAutoRaise(true);
|
||||||
|
m_helpBtn->setCursor(Qt::PointingHandCursor);
|
||||||
|
m_helpBtn->setIconSize(QSize(12, 12));
|
||||||
|
layout->insertWidget(1, m_helpBtn, 0, Qt::AlignTop); // insert next to label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (m_helpBtn)
|
||||||
|
{
|
||||||
|
m_helpBtn->setVisible(isVisible);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case AttributeName::DisplayName:
|
case AttributeName::DisplayName:
|
||||||
case AttributeName::Help:
|
case AttributeName::Help:
|
||||||
|
|||||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren