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:
@@ -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;
|
||||
|
@@ -16,6 +16,7 @@ public:
|
||||
using RpWidget::RpWidget;
|
||||
|
||||
void setText(const QString &text, bool active);
|
||||
int textBaseline() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
Reference in New Issue
Block a user