new themes + notif dnd
This commit is contained in:
@@ -19,15 +19,18 @@ Rectangle {
|
||||
property int barMargin: Cfg.Config.margin
|
||||
readonly property var t: Cfg.Config.theme
|
||||
|
||||
property int unreadCount: 0
|
||||
property bool historyOpen: historyPopup.popupOpen
|
||||
property int unreadCount: 0
|
||||
property bool doNotDisturb: false
|
||||
property bool historyOpen: historyPopup.popupOpen
|
||||
|
||||
width: 35
|
||||
height: 40
|
||||
radius: panelRadius
|
||||
|
||||
color: hoverHandler.hovered ? t.notifBgHover : t.notifBg
|
||||
border.color: (hoverHandler.hovered || historyOpen) ? t.notifBorderActive : t.notifBorder
|
||||
border.color: root.doNotDisturb
|
||||
? t.notifDnd
|
||||
: ((hoverHandler.hovered || historyOpen) ? t.notifBorderActive : t.notifBorder)
|
||||
border.width: borderWidth
|
||||
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
@@ -54,8 +57,10 @@ Rectangle {
|
||||
Text {
|
||||
id: bellIcon
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
color: root.unreadCount > 0 ? t.notifIconActive : t.notifIcon
|
||||
text: root.doNotDisturb ? "" : ""
|
||||
color: root.doNotDisturb
|
||||
? t.notifDnd
|
||||
: (root.unreadCount > 0 ? t.notifIconActive : t.notifIcon)
|
||||
font.pixelSize: Cfg.Config.notifIconSize
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
}
|
||||
@@ -149,10 +154,11 @@ Rectangle {
|
||||
timeStr: timeStr,
|
||||
timeout: finalTimeout
|
||||
}
|
||||
if (toastLayer.atBottom) activeToasts.append(toastEntry)
|
||||
else activeToasts.insert(0, toastEntry)
|
||||
|
||||
if (!root.historyOpen) root.unreadCount++
|
||||
if (!root.doNotDisturb) {
|
||||
if (toastLayer.atBottom) activeToasts.append(toastEntry)
|
||||
else activeToasts.insert(0, toastEntry)
|
||||
if (!root.historyOpen) root.unreadCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,6 +303,45 @@ Rectangle {
|
||||
Layout.fillWidth: true; Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
// ── Do Not Disturb toggle ─────────────────────────────
|
||||
Rectangle {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
width: dndRow.implicitWidth + 16
|
||||
height: 24
|
||||
radius: 12
|
||||
color: root.doNotDisturb
|
||||
? Qt.rgba(t.notifDnd.r, t.notifDnd.g, t.notifDnd.b, 0.18)
|
||||
: (dndHover.hovered ? t.notifHistoryHover : "transparent")
|
||||
border.color: root.doNotDisturb ? t.notifDnd : "transparent"
|
||||
border.width: Cfg.Config.popupBorderWidth
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
Behavior on border.color { ColorAnimation { duration: 150 } }
|
||||
|
||||
Row {
|
||||
id: dndRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
Text {
|
||||
text: ""
|
||||
color: root.doNotDisturb ? t.notifDnd : t.notifToastDim
|
||||
font.pixelSize: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
}
|
||||
Text {
|
||||
text: root.doNotDisturb ? "On" : "Off"
|
||||
color: root.doNotDisturb ? t.notifDnd : t.notifToastDim
|
||||
font.pixelSize: 11
|
||||
font.bold: root.doNotDisturb
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler { id: dndHover; cursorShape: Qt.PointingHandCursor }
|
||||
TapHandler { onTapped: root.doNotDisturb = !root.doNotDisturb }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: notifHistory.count > 0
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
@@ -308,7 +353,7 @@ Rectangle {
|
||||
|
||||
Text { id: clearText; anchors.centerIn: parent; text: "Clear all"; color: t.notifToastDim; font.pixelSize: 11 }
|
||||
HoverHandler { id: clearHover; cursorShape: Qt.PointingHandCursor }
|
||||
TapHandler { onTapped: { notifHistory.clear(); root.unreadCount = 0 } }
|
||||
TapHandler { onTapped: clearAllAnim.start() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,10 +363,31 @@ Rectangle {
|
||||
anchors.topMargin: 12; height: 1; color: t.notifSeparator
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: clearAllAnim
|
||||
ParallelAnimation {
|
||||
NumberAnimation {
|
||||
target: histCol; property: "opacity"
|
||||
to: 0; duration: 220; easing.type: Easing.OutCubic
|
||||
}
|
||||
NumberAnimation {
|
||||
target: clearShift; property: "y"
|
||||
to: -16; duration: 220; easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
ScriptAction {
|
||||
script: { notifHistory.clear(); root.unreadCount = 0 }
|
||||
}
|
||||
ParallelAnimation {
|
||||
NumberAnimation { target: histCol; property: "opacity"; to: 1; duration: 0 }
|
||||
NumberAnimation { target: clearShift; property: "y"; to: 0; duration: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: histFlick
|
||||
anchors { left: parent.left; right: parent.right; top: histDivider.bottom; bottom: parent.bottom }
|
||||
anchors.leftMargin: 8; anchors.rightMargin: 8
|
||||
anchors.leftMargin: 2; anchors.rightMargin: 8
|
||||
anchors.topMargin: 6; anchors.bottomMargin: 8; clip: true
|
||||
contentHeight: histCol.implicitHeight
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
@@ -329,7 +395,9 @@ Rectangle {
|
||||
|
||||
Column {
|
||||
id: histCol
|
||||
width: histFlick.width; spacing: 2; topPadding: 4; bottomPadding: 4; leftPadding: 8; rightPadding: 8
|
||||
opacity: 1
|
||||
transform: Translate { id: clearShift; y: 0 }
|
||||
width: histFlick.width; spacing: 2; topPadding: 4; bottomPadding: 4; leftPadding: 2; rightPadding: 8
|
||||
|
||||
Item {
|
||||
width: histCol.width - 16; height: 90; visible: notifHistory.count === 0
|
||||
@@ -343,7 +411,7 @@ Rectangle {
|
||||
Repeater {
|
||||
model: notifHistory
|
||||
Notif.HistoryCard {
|
||||
width: histCol.width - 16; x: 8; itemIndex: index
|
||||
width: histCol.width - 10; x: 2; itemIndex: index
|
||||
appName: model.appName; summary: model.summary; body: model.body; urgency: model.urgency; timeStr: model.timeStr
|
||||
t: root.t; urgencyColor: root.urgencyColor; urgencyIcon: root.urgencyIcon
|
||||
onDismissed: (idx) => notifHistory.remove(idx)
|
||||
@@ -355,3 +423,4 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user