Improve unread counters theming & default look

This commit is contained in:
miruka
2020-09-23 05:38:07 -04:00
parent bb8f394b78
commit 2480603ee2
3 changed files with 88 additions and 13 deletions

View File

@@ -5,12 +5,18 @@ import QtQuick 2.12
import "../Base"
HLabel {
id: root
property QtObject indicatorTheme
property int unreads: 0
property int highlights: 0
property bool localUnreads: false
property bool localHighlights: false
readonly property bool useHighlightStyle:
highlights || (! unreads && localUnreads && localHighlights)
text:
unreads >= 1000000 ? Math.floor(unreads / 1000000) + "M" :
unreads >= 1000 ? Math.floor(unreads / 1000) + "K" :
@@ -18,25 +24,50 @@ HLabel {
localUnreads ? "!" :
""
color:
useHighlightStyle ?
indicatorTheme.highlightText :
indicatorTheme.text
font.pixelSize: theme.fontSize.small
font.bold: text === "!"
font.bold:
useHighlightStyle ?
indicatorTheme.highlightBold :
indicatorTheme.bold
verticalAlignment: Qt.AlignVCenter
leftPadding: theme.spacing / 4
leftPadding: theme.spacing / 3
rightPadding: leftPadding
scale: text ? 1 : 0
visible: text !== ""
background: Rectangle {
radius:
useHighlightStyle ?
indicatorTheme.highlightRadius :
indicatorTheme.radius
color:
highlights || (! unreads && localUnreads && localHighlights) ?
indicatorTheme.mentionBackground :
useHighlightStyle ?
indicatorTheme.highlightBackground :
indicatorTheme.background
radius: theme.radius / 4
border.width:
useHighlightStyle ?
indicatorTheme.highlightBorderWidth :
indicatorTheme.borderWidth
border.color:
useHighlightStyle ?
indicatorTheme.highlightBorder :
indicatorTheme.border
Behavior on radius { HColorAnimation {} }
Behavior on color { HColorAnimation {} }
Behavior on border.color { HColorAnimation {} }
}
Behavior on scale { HNumberAnimation {} }
Behavior on color { HColorAnimation {} }
}