Rename underscore to underline

This commit is contained in:
johanneshilden 2017-10-05 17:35:22 +03:00
parent 85310163dd
commit 776e089399
3 changed files with 25 additions and 19 deletions

View File

@ -29,7 +29,7 @@ void QtMaterialTextFieldPrivate::init()
label = 0; label = 0;
labelFontSize = 9.5; labelFontSize = 9.5;
showLabel = false; showLabel = false;
showUnderscore = true; showUnderline = true;
useThemeColors = true; useThemeColors = true;
q->setFrame(false); q->setFrame(false);
@ -232,19 +232,24 @@ QColor QtMaterialTextField::underlineColor() const
} }
} }
void QtMaterialTextField::setShowUnderscore(bool value) void QtMaterialTextField::setShowUnderline(bool value)
{ {
Q_D(QtMaterialTextField); Q_D(QtMaterialTextField);
if (d->showUnderscore == value) { if (d->showUnderline == value) {
return; return;
} }
d->showUnderscore = value; d->showUnderline = value;
update(); update();
} }
bool QtMaterialTextField::hasUnderline() const
{
Q_D(const QtMaterialTextField);
return d->showUnderline;
}
/*! /*!
* \reimp * \reimp
@ -289,8 +294,7 @@ void QtMaterialTextField::paintEvent(QPaintEvent *event)
const int y = height()-1; const int y = height()-1;
const int wd = width()-5; const int wd = width()-5;
if (d->showUnderline)
if( d->showUnderscore )
{ {
QPen pen; QPen pen;
pen.setWidth(1); pen.setWidth(1);
@ -299,16 +303,16 @@ void QtMaterialTextField::paintEvent(QPaintEvent *event)
painter.setOpacity(1); painter.setOpacity(1);
painter.drawLine(2.5, y, wd, y); painter.drawLine(2.5, y, wd, y);
QBrush brush; QBrush brush;
brush.setStyle(Qt::SolidPattern); brush.setStyle(Qt::SolidPattern);
brush.setColor(inkColor()); brush.setColor(inkColor());
if (progress > 0) if (progress > 0)
{ {
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(brush); painter.setBrush(brush);
const int w = (1-progress)*static_cast<qreal>(wd/2); const int w = (1-progress)*static_cast<qreal>(wd/2);
painter.drawRect(w+2.5, height()-2, wd-w*2, 2); painter.drawRect(w+2.5, height()-2, wd-w*2, 2);
} }
} }
} }

View File

@ -41,7 +41,9 @@ public:
void setUnderlineColor(const QColor &color); void setUnderlineColor(const QColor &color);
QColor underlineColor() const; QColor underlineColor() const;
void setShowUnderscore(bool value);
void setShowUnderline(bool value);
bool hasUnderline() const;
protected: protected:
bool event(QEvent *event) Q_DECL_OVERRIDE; bool event(QEvent *event) Q_DECL_OVERRIDE;

View File

@ -29,7 +29,7 @@ public:
QString labelString; QString labelString;
qreal labelFontSize; qreal labelFontSize;
bool showLabel; bool showLabel;
bool showUnderscore; bool showUnderline;
bool useThemeColors; bool useThemeColors;
}; };