mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(ui): show empty status as placeholder instead of as status
This commit is contained in:
parent
190680158c
commit
e9f8795197
|
@ -663,7 +663,7 @@
|
|||
<property name="accessibleDescription">
|
||||
<string>Set your status message that will be shown to others</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<property name="placeholderText">
|
||||
<string>Your status</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
|
|
|
@ -85,6 +85,12 @@ void CroppingLabel::setText(const QString& text)
|
|||
setElidedText();
|
||||
}
|
||||
|
||||
void CroppingLabel::setPlaceholderText(const QString& text)
|
||||
{
|
||||
textEdit->setPlaceholderText(text);
|
||||
setElidedText();
|
||||
}
|
||||
|
||||
void CroppingLabel::resizeEvent(QResizeEvent* ev)
|
||||
{
|
||||
setElidedText();
|
||||
|
@ -129,8 +135,12 @@ void CroppingLabel::setElidedText()
|
|||
setToolTip(Qt::convertFromPlainText(origText, Qt::WhiteSpaceNormal));
|
||||
else
|
||||
setToolTip(QString());
|
||||
|
||||
QLabel::setText(elidedText);
|
||||
if (!elidedText.isEmpty()) {
|
||||
QLabel::setText(elidedText);
|
||||
} else {
|
||||
// NOTE: it would be nice if the label had custom styling when it was default
|
||||
QLabel::setText(textEdit->placeholderText());
|
||||
}
|
||||
}
|
||||
|
||||
void CroppingLabel::hideTextEdit()
|
||||
|
|
|
@ -39,6 +39,7 @@ public slots:
|
|||
|
||||
public slots:
|
||||
void setText(const QString& text);
|
||||
void setPlaceholderText(const QString& text);
|
||||
void minimizeMaximumWidth();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -909,16 +909,11 @@ void Widget::onStatusMessageChanged(const QString& newStatusMessage)
|
|||
|
||||
void Widget::setStatusMessage(const QString& statusMessage)
|
||||
{
|
||||
if (statusMessage.isEmpty()) {
|
||||
ui->statusLabel->setText(tr("Your status"));
|
||||
ui->statusLabel->setToolTip(tr("Your status"));
|
||||
} else {
|
||||
ui->statusLabel->setText(statusMessage);
|
||||
// escape HTML from tooltips and preserve newlines
|
||||
// TODO: move newspace preservance to a generic function
|
||||
ui->statusLabel->setToolTip("<p style='white-space:pre'>" + statusMessage.toHtmlEscaped()
|
||||
+ "</p>");
|
||||
}
|
||||
ui->statusLabel->setText(statusMessage);
|
||||
// escape HTML from tooltips and preserve newlines
|
||||
// TODO: move newspace preservance to a generic function
|
||||
ui->statusLabel->setToolTip("<p style='white-space:pre'>" + statusMessage.toHtmlEscaped()
|
||||
+ "</p>");
|
||||
}
|
||||
|
||||
void Widget::reloadHistory()
|
||||
|
|
Loading…
Reference in New Issue
Block a user