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;
labelFontSize = 9.5;
showLabel = false;
showUnderline = true;
showInputLine = true;
useThemeColors = true;
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);
d->underlineColor = color;
d->inputLineColor = color;
MATERIAL_DISABLE_THEME_COLORS
d->stateMachine->setupProperties();
}
QColor QtMaterialTextField::underlineColor() const
QColor QtMaterialTextField::inputLineColor() const
{
Q_D(const QtMaterialTextField);
if (d->useThemeColors || !d->underlineColor.isValid()) {
if (d->useThemeColors || !d->inputLineColor.isValid()) {
return QtMaterialStyle::instance().themeColor("border");
} else {
return d->underlineColor;
return d->inputLineColor;
}
}
void QtMaterialTextField::setShowUnderline(bool value)
void QtMaterialTextField::setShowInputLine(bool value)
{
Q_D(QtMaterialTextField);
if (d->showUnderline == value) {
if (d->showInputLine == value) {
return;
}
d->showUnderline = value;
d->showInputLine = value;
update();
}
bool QtMaterialTextField::hasUnderline() const
bool QtMaterialTextField::hasInputLine() const
{
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 wd = width()-5;
if (d->showUnderline)
if (d->showInputLine)
{
QPen pen;
pen.setWidth(1);
pen.setColor(underlineColor());
pen.setColor(inputLineColor());
painter.setPen(pen);
painter.setOpacity(1);
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 inkColor WRITE setInkColor READ inkColor)
Q_PROPERTY(QColor underlineColor WRITE setUnderlineColor READ underlineColor)
Q_PROPERTY(QColor inputLineColor WRITE setInputLineColor READ inputLineColor)
public:
explicit QtMaterialTextField(QWidget *parent = 0);
@ -39,11 +39,11 @@ public:
void setInkColor(const QColor &color);
QColor inkColor() const;
void setUnderlineColor(const QColor &color);
QColor underlineColor() const;
void setInputLineColor(const QColor &color);
QColor inputLineColor() const;
void setShowUnderline(bool value);
bool hasUnderline() const;
void setShowInputLine(bool value);
bool hasInputLine() const;
protected:
bool event(QEvent *event) Q_DECL_OVERRIDE;

View File

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

View File

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

View File

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