This commit is contained in:
johanneshilden 2017-10-06 08:29:38 +03:00
parent 2971360d7e
commit 0e999a564c
6 changed files with 37 additions and 37 deletions

View File

@ -29,7 +29,7 @@ void QtMaterialTextFieldPrivate::init()
label = 0; label = 0;
labelFontSize = 9.5; labelFontSize = 9.5;
showLabel = false; showLabel = false;
showUnderline = true; showInputLine = true;
useThemeColors = true; useThemeColors = true;
q->setFrame(false); q->setFrame(false);
@ -211,44 +211,44 @@ QColor QtMaterialTextField::inkColor() const
} }
} }
void QtMaterialTextField::setUnderlineColor(const QColor &color) void QtMaterialTextField::setInputLineColor(const QColor &color)
{ {
Q_D(QtMaterialTextField); Q_D(QtMaterialTextField);
d->underlineColor = color; d->inputLineColor = color;
MATERIAL_DISABLE_THEME_COLORS MATERIAL_DISABLE_THEME_COLORS
d->stateMachine->setupProperties(); d->stateMachine->setupProperties();
} }
QColor QtMaterialTextField::underlineColor() const QColor QtMaterialTextField::inputLineColor() const
{ {
Q_D(const QtMaterialTextField); Q_D(const QtMaterialTextField);
if (d->useThemeColors || !d->underlineColor.isValid()) { if (d->useThemeColors || !d->inputLineColor.isValid()) {
return QtMaterialStyle::instance().themeColor("border"); return QtMaterialStyle::instance().themeColor("border");
} else { } else {
return d->underlineColor; return d->inputLineColor;
} }
} }
void QtMaterialTextField::setShowUnderline(bool value) void QtMaterialTextField::setShowInputLine(bool value)
{ {
Q_D(QtMaterialTextField); Q_D(QtMaterialTextField);
if (d->showUnderline == value) { if (d->showInputLine == value) {
return; return;
} }
d->showUnderline = value; d->showInputLine = value;
update(); update();
} }
bool QtMaterialTextField::hasUnderline() const bool QtMaterialTextField::hasInputLine() const
{ {
Q_D(const QtMaterialTextField); Q_D(const QtMaterialTextField);
return d->showUnderline; return d->showInputLine;
} }
/*! /*!
@ -294,11 +294,11 @@ 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->showInputLine)
{ {
QPen pen; QPen pen;
pen.setWidth(1); pen.setWidth(1);
pen.setColor(underlineColor()); pen.setColor(inputLineColor());
painter.setPen(pen); painter.setPen(pen);
painter.setOpacity(1); painter.setOpacity(1);
painter.drawLine(QLineF(2.5, y, wd, y)); painter.drawLine(QLineF(2.5, y, wd, y));

View File

@ -12,7 +12,7 @@ class QtMaterialTextField : public QLineEdit
Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor) Q_PROPERTY(QColor textColor WRITE setTextColor READ textColor)
Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor) Q_PROPERTY(QColor inkColor WRITE setInkColor READ inkColor)
Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor) Q_PROPERTY(QColor inputLineColor WRITE setInputLineColor READ inputLineColor)
public: public:
explicit QtMaterialTextField(QWidget *parent = 0); explicit QtMaterialTextField(QWidget *parent = 0);
@ -39,11 +39,11 @@ public:
void setInkColor(const QColor &color); void setInkColor(const QColor &color);
QColor inkColor() const; QColor inkColor() const;
void setUnderlineColor(const QColor &color); void setInputLineColor(const QColor &color);
QColor underlineColor() const; QColor inputLineColor() const;
void setShowUnderline(bool value); void setShowInputLine(bool value);
bool hasUnderline() const; bool hasInputLine() const;
protected: protected:
bool event(QEvent *event) Q_DECL_OVERRIDE; bool event(QEvent *event) Q_DECL_OVERRIDE;

View File

@ -25,11 +25,11 @@ public:
QColor textColor; QColor textColor;
QColor labelColor; QColor labelColor;
QColor inkColor; QColor inkColor;
QColor underlineColor; QColor inputLineColor;
QString labelString; QString labelString;
qreal labelFontSize; qreal labelFontSize;
bool showLabel; bool showLabel;
bool showUnderline; bool showInputLine;
bool useThemeColors; bool useThemeColors;
}; };

View File

@ -39,9 +39,9 @@ TextFieldSettingsEditor::TextFieldSettingsEditor(QWidget *parent)
connect(ui->useThemeColorsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget())); connect(ui->useThemeColorsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
connect(ui->textColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor())); connect(ui->textColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->inkColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor())); connect(ui->inkColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->underlineColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor())); connect(ui->inputLineColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->labelColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor())); connect(ui->labelColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->underlineCheckBox, SIGNAL(toggled(bool)), this, SLOT(setShowUnderline())); connect(ui->inputLineCheckBox, SIGNAL(toggled(bool)), this, SLOT(setShowInputLine()));
connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupForm())); connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupForm()));
} }
@ -59,7 +59,7 @@ void TextFieldSettingsEditor::setupForm()
ui->labelCheckBox->setChecked(m_textField->hasLabel()); ui->labelCheckBox->setChecked(m_textField->hasLabel());
ui->labelTextLineEdit->setText(m_textField->label()); ui->labelTextLineEdit->setText(m_textField->label());
ui->useThemeColorsCheckBox->setChecked(m_textField->useThemeColors()); ui->useThemeColorsCheckBox->setChecked(m_textField->useThemeColors());
ui->underlineCheckBox->setChecked(m_textField->hasUnderline()); ui->inputLineCheckBox->setChecked(m_textField->hasInputLine());
} }
void TextFieldSettingsEditor::updateWidget() void TextFieldSettingsEditor::updateWidget()
@ -70,7 +70,7 @@ void TextFieldSettingsEditor::updateWidget()
m_textField->setLabel(ui->labelTextLineEdit->text()); m_textField->setLabel(ui->labelTextLineEdit->text());
m_textField->setShowLabel(ui->labelCheckBox->isChecked()); m_textField->setShowLabel(ui->labelCheckBox->isChecked());
m_textField->setUseThemeColors(ui->useThemeColorsCheckBox->isChecked()); m_textField->setUseThemeColors(ui->useThemeColorsCheckBox->isChecked());
m_textField->setShowUnderline(ui->underlineCheckBox->isChecked()); m_textField->setShowInputLine(ui->inputLineCheckBox->isChecked());
} }
void TextFieldSettingsEditor::selectColor() void TextFieldSettingsEditor::selectColor()
@ -85,9 +85,9 @@ void TextFieldSettingsEditor::selectColor()
} else if ("inkColorToolButton" == senderName) { } else if ("inkColorToolButton" == senderName) {
m_textField->setInkColor(color); m_textField->setInkColor(color);
ui->inkColorLineEdit->setText(color.name(QColor::HexRgb)); ui->inkColorLineEdit->setText(color.name(QColor::HexRgb));
} else if ("underlineColorToolButton" == senderName) { } else if ("inputLineColorToolButton" == senderName) {
m_textField->setUnderlineColor(color); m_textField->setInputLineColor(color);
ui->underlineColorLineEdit->setText(color.name(QColor::HexRgb)); ui->inputLineColorLineEdit->setText(color.name(QColor::HexRgb));
} else if ("labelColorToolButton" == senderName) { } else if ("labelColorToolButton" == senderName) {
m_textField->setLabelColor(color); m_textField->setLabelColor(color);
ui->labelColorLineEdit->setText(color.name(QColor::HexRgb)); ui->labelColorLineEdit->setText(color.name(QColor::HexRgb));
@ -96,7 +96,7 @@ void TextFieldSettingsEditor::selectColor()
setupForm(); setupForm();
} }
void TextFieldSettingsEditor::setShowUnderline() void TextFieldSettingsEditor::setShowInputLine()
{ {
m_textField->setShowUnderline( ui->underlineCheckBox->isChecked() ); m_textField->setShowInputLine( ui->inputLineCheckBox->isChecked() );
} }

View File

@ -18,7 +18,7 @@ protected slots:
void setupForm(); void setupForm();
void updateWidget(); void updateWidget();
void selectColor(); void selectColor();
void setShowUnderline(); void setShowInputLine();
private: private:
Ui::TextFieldSettingsForm *const ui; Ui::TextFieldSettingsForm *const ui;

View File

@ -126,19 +126,19 @@
</layout> </layout>
</item> </item>
<item row="8" column="0"> <item row="8" column="0">
<widget class="QLabel" name="underlineColorLabel"> <widget class="QLabel" name="inputLineColorLabel">
<property name="text"> <property name="text">
<string>Underline color</string> <string>Input line color</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="8" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<widget class="QLineEdit" name="underlineColorLineEdit"/> <widget class="QLineEdit" name="inputLineColorLineEdit"/>
</item> </item>
<item> <item>
<widget class="QToolButton" name="underlineColorToolButton"> <widget class="QToolButton" name="inputLineColorToolButton">
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
@ -168,14 +168,14 @@
</layout> </layout>
</item> </item>
<item row="10" column="0"> <item row="10" column="0">
<widget class="QLabel" name="labelShowUnderline"> <widget class="QLabel" name="labelShowInputLine">
<property name="text"> <property name="text">
<string>Underline</string> <string>Input line</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="10" column="1">
<widget class="QCheckBox" name="underlineCheckBox"/> <widget class="QCheckBox" name="inputLineCheckBox"/>
</item> </item>
</layout> </layout>
</widget> </widget>