Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(ui): show empty status as placeholder instead of as status
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonybilinski committed May 7, 2019
1 parent 1906801 commit e9f8795
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
14 changes: 12 additions & 2 deletions src/widget/tool/croppinglabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/widget/tool/croppinglabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public slots:

public slots:
void setText(const QString& text);
void setPlaceholderText(const QString& text);
void minimizeMaximumWidth();

signals:
Expand Down
15 changes: 5 additions & 10 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e9f8795

Please sign in to comment.