QtMaterialTextField: implemeted hiding of underscore
This commit is contained in:
parent
a624aa4653
commit
1c7892d8b1
|
@ -29,6 +29,7 @@ void QtMaterialTextFieldPrivate::init()
|
||||||
label = 0;
|
label = 0;
|
||||||
labelFontSize = 9.5;
|
labelFontSize = 9.5;
|
||||||
showLabel = false;
|
showLabel = false;
|
||||||
|
showUnderscore = true;
|
||||||
useThemeColors = true;
|
useThemeColors = true;
|
||||||
|
|
||||||
q->setFrame(false);
|
q->setFrame(false);
|
||||||
|
@ -231,6 +232,20 @@ QColor QtMaterialTextField::underlineColor() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtMaterialTextField::setShowUnderscore(bool value)
|
||||||
|
{
|
||||||
|
Q_D(QtMaterialTextField);
|
||||||
|
|
||||||
|
if (d->showUnderscore == value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->showUnderscore = value;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \reimp
|
* \reimp
|
||||||
*/
|
*/
|
||||||
|
@ -274,12 +289,15 @@ 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;
|
||||||
|
|
||||||
QPen pen;
|
|
||||||
pen.setWidth(1);
|
if( d->showUnderscore )
|
||||||
pen.setColor(underlineColor());
|
{
|
||||||
painter.setPen(pen);
|
QPen pen;
|
||||||
painter.setOpacity(1);
|
pen.setWidth(1);
|
||||||
painter.drawLine(2.5, y, wd, y);
|
pen.setColor(underlineColor());
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.setOpacity(1);
|
||||||
|
painter.drawLine(2.5, y, wd, y);
|
||||||
|
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
|
@ -292,4 +310,5 @@ void QtMaterialTextField::paintEvent(QPaintEvent *event)
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
|
|
||||||
void setUnderlineColor(const QColor &color);
|
void setUnderlineColor(const QColor &color);
|
||||||
QColor underlineColor() const;
|
QColor underlineColor() const;
|
||||||
|
void setShowUnderscore(bool value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
QString labelString;
|
QString labelString;
|
||||||
qreal labelFontSize;
|
qreal labelFontSize;
|
||||||
bool showLabel;
|
bool showLabel;
|
||||||
|
bool showUnderscore;
|
||||||
bool useThemeColors;
|
bool useThemeColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ TextFieldSettingsEditor::TextFieldSettingsEditor(QWidget *parent)
|
||||||
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->underlineColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
|
||||||
connect(ui->labelColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
|
connect(ui->labelColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
|
||||||
|
connect(ui->underscoreCheckBox, SIGNAL(toggled(bool)), this, SLOT(setShowUnderscore()));
|
||||||
|
|
||||||
connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupForm()));
|
connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupForm()));
|
||||||
}
|
}
|
||||||
|
@ -58,6 +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->underscoreCheckBox->setChecked( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFieldSettingsEditor::updateWidget()
|
void TextFieldSettingsEditor::updateWidget()
|
||||||
|
@ -68,6 +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->setShowUnderscore(ui->underscoreCheckBox->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFieldSettingsEditor::selectColor()
|
void TextFieldSettingsEditor::selectColor()
|
||||||
|
@ -92,3 +95,8 @@ void TextFieldSettingsEditor::selectColor()
|
||||||
}
|
}
|
||||||
setupForm();
|
setupForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextFieldSettingsEditor::setShowUnderscore()
|
||||||
|
{
|
||||||
|
m_textField->setShowUnderscore( ui->underscoreCheckBox->isChecked() );
|
||||||
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ protected slots:
|
||||||
void setupForm();
|
void setupForm();
|
||||||
void updateWidget();
|
void updateWidget();
|
||||||
void selectColor();
|
void selectColor();
|
||||||
|
void setShowUnderscore();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TextFieldSettingsForm *const ui;
|
Ui::TextFieldSettingsForm *const ui;
|
||||||
|
|
|
@ -167,6 +167,16 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="10" column="0">
|
||||||
|
<widget class="QLabel" name="labelShowUnderscore">
|
||||||
|
<property name="text">
|
||||||
|
<string>Underscore</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="1">
|
||||||
|
<widget class="QCheckBox" name="underscoreCheckBox"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in New Issue