Commit f0a4ad1b authored by Victor Heng's avatar Victor Heng Committed by Victor Heng

JsonWizard: Hide label when widget is hidden in Field Page

Setting "visible" of a widget (such as TextField) to false in a Field
Page hides the widget, but leaves it's label visible. Modified each
field to update it's label visibility when the widget is shown/hidden.

Change-Id: Idf20c624b6aad09a2be159e2fc697fcb24bd2bc5
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent d381c6e0
......@@ -117,6 +117,7 @@ JsonFieldPage::Field::Field() : d(new FieldPrivate)
JsonFieldPage::Field::~Field()
{
delete d->m_widget;
delete d->m_label;
delete d;
}
......@@ -178,12 +179,14 @@ void JsonFieldPage::Field::createWidget(JsonFieldPage *page)
w->setObjectName(name());
QFormLayout *layout = page->layout();
if (suppressName())
if (suppressName()) {
layout->addWidget(w);
else if (hasSpan())
} else if (hasSpan()) {
layout->addRow(w);
else
layout->addRow(displayName(), w);
} else {
d->m_label = new QLabel(displayName());
layout->addRow(d->m_label, w);
}
setup(page, name());
}
......@@ -205,6 +208,8 @@ void JsonFieldPage::Field::setEnabled(bool e)
void JsonFieldPage::Field::setVisible(bool v)
{
QTC_ASSERT(d->m_widget, return);
if (d->m_label)
d->m_label->setVisible(v);
d->m_widget->setVisible(v);
}
......
......@@ -53,6 +53,7 @@ public:
QVariant m_isCompleteExpando;
QString m_isCompleteExpandoMessage;
QLabel *m_label = nullptr;
QWidget *m_widget = nullptr;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment