move error_matrixid label below matrixid input, made hide/show for the label, made red underline for invalid input, add to TextField class isValid() setValid() for custom validation

This commit is contained in:
kirillpt 2020-11-23 23:33:53 +03:00
parent 4032f6e113
commit ac73f10eba
3 changed files with 25 additions and 2 deletions

View file

@ -69,6 +69,18 @@ TextField::hasLabel() const
return show_label_;
}
bool
TextField::isValid() const
{
return is_valid_;
}
void
TextField::setValid(bool valid)
{
is_valid_ = valid;
}
void
TextField::setLabelFontSize(qreal size)
{
@ -147,7 +159,7 @@ QColor
TextField::underlineColor() const
{
if (!underline_color_.isValid()) {
if (hasAcceptableInput() || !isModified())
if (TextField::isValid() || !isModified())
return QPalette().color(QPalette::Highlight);
else
return Qt::red;

View file

@ -30,6 +30,7 @@ public:
void setLabelFontSize(qreal size);
void setShowLabel(bool value);
void setUnderlineColor(const QColor &color);
void setValid(bool valid);
QColor inkColor() const;
QColor labelColor() const;
@ -37,6 +38,7 @@ public:
QColor backgroundColor() const;
QString label() const;
bool hasLabel() const;
bool isValid() const;
qreal labelFontSize() const;
protected:
@ -54,6 +56,7 @@ private:
TextFieldLabel *label_;
TextFieldStateMachine *state_machine_;
bool show_label_;
bool is_valid_;
qreal label_font_size_;
};