fire default action on notification text click
This commit is contained in:
parent
76ccc99e17
commit
a2966f51ab
1 changed files with 91 additions and 66 deletions
|
|
@ -125,79 +125,104 @@ Item {
|
|||
anchors.topMargin: 8
|
||||
spacing: 2
|
||||
|
||||
// App name + time row (optional)
|
||||
Row {
|
||||
visible: root.showAppName
|
||||
// Text section — tappable for default action
|
||||
Item {
|
||||
id: _textSection
|
||||
width: parent.width
|
||||
height: _textCol.implicitHeight
|
||||
implicitHeight: _textCol.implicitHeight
|
||||
|
||||
Text {
|
||||
text: root.notif?.appName ?? "Notification"
|
||||
color: M.Theme.base04
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
width: parent.width - _timeText.implicitWidth - 4
|
||||
elide: Text.ElideRight
|
||||
TapHandler {
|
||||
cursorShape: root.notif?.actions?.some(a => a.identifier === "default") ? Qt.PointingHandCursor : undefined
|
||||
onTapped: {
|
||||
const def = root.notif?.actions?.find(a => a.identifier === "default");
|
||||
if (def) {
|
||||
def.invoke();
|
||||
root.dismissRequested();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _timeText
|
||||
text: root.notif?.timeStr ?? ""
|
||||
color: M.Theme.base03
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
Column {
|
||||
id: _textCol
|
||||
width: parent.width
|
||||
spacing: 2
|
||||
|
||||
// App name + time row (optional)
|
||||
Row {
|
||||
visible: root.showAppName
|
||||
width: parent.width
|
||||
|
||||
Text {
|
||||
text: root.notif?.appName ?? "Notification"
|
||||
color: M.Theme.base04
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
width: parent.width - _timeText.implicitWidth - 4
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _timeText
|
||||
text: root.notif?.timeStr ?? ""
|
||||
color: M.Theme.base03
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
// Summary (with inline time when app name row is hidden)
|
||||
Row {
|
||||
visible: !root.showAppName
|
||||
width: parent.width
|
||||
|
||||
Text {
|
||||
text: root.notif?.summary ?? ""
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
width: parent.width - _inlineTime.implicitWidth - 4
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _inlineTime
|
||||
text: root.notif?.timeStr ?? ""
|
||||
color: M.Theme.base03
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: root.showAppName
|
||||
width: parent.width
|
||||
text: root.notif?.summary ?? ""
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 2
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.notif?.body ?? ""
|
||||
color: M.Theme.base04
|
||||
font.pixelSize: M.Theme.fontSize - 1
|
||||
font.family: M.Theme.fontFamily
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: root.bodyMaxLines
|
||||
visible: text !== ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Summary (with inline time when app name row is hidden)
|
||||
Row {
|
||||
visible: !root.showAppName
|
||||
width: parent.width
|
||||
|
||||
Text {
|
||||
text: root.notif?.summary ?? ""
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
width: parent.width - _inlineTime.implicitWidth - 4
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _inlineTime
|
||||
text: root.notif?.timeStr ?? ""
|
||||
color: M.Theme.base03
|
||||
font.pixelSize: M.Theme.fontSize - 2
|
||||
font.family: M.Theme.fontFamily
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: root.showAppName
|
||||
width: parent.width
|
||||
text: root.notif?.summary ?? ""
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
font.bold: true
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 2
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
text: root.notif?.body ?? ""
|
||||
color: M.Theme.base04
|
||||
font.pixelSize: M.Theme.fontSize - 1
|
||||
font.family: M.Theme.fontFamily
|
||||
elide: Text.ElideRight
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: root.bodyMaxLines
|
||||
visible: text !== ""
|
||||
}
|
||||
|
||||
// Action buttons — filter "default" (click-notification convention) and empty labels
|
||||
Row {
|
||||
spacing: 6
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue