2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Add unread badge to Discuss button.

This commit is contained in:
John Preston
2019-05-26 14:08:34 +02:00
parent a64c8c52b4
commit e8a99a854d
5 changed files with 118 additions and 16 deletions

View File

@@ -14,9 +14,18 @@ namespace Ui {
void UnreadBadge::setText(const QString &text, bool active) {
_text = text;
_active = active;
const auto st = Dialogs::Layout::UnreadBadgeStyle();
resize(
std::max(st.font->width(text) + 2 * st.padding, st.size),
st.size);
update();
}
int UnreadBadge::textBaseline() const {
const auto st = Dialogs::Layout::UnreadBadgeStyle();
return ((st.size - st.font->height) / 2) + st.font->ascent;
}
void UnreadBadge::paintEvent(QPaintEvent *e) {
if (_text.isEmpty()) {
return;

View File

@@ -16,6 +16,7 @@ public:
using RpWidget::RpWidget;
void setText(const QString &text, bool active);
int textBaseline() const;
protected:
void paintEvent(QPaintEvent *e) override;