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
|
anchors.topMargin: 8
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
// App name + time row (optional)
|
// Text section — tappable for default action
|
||||||
Row {
|
Item {
|
||||||
visible: root.showAppName
|
id: _textSection
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
height: _textCol.implicitHeight
|
||||||
|
implicitHeight: _textCol.implicitHeight
|
||||||
|
|
||||||
Text {
|
TapHandler {
|
||||||
text: root.notif?.appName ?? "Notification"
|
cursorShape: root.notif?.actions?.some(a => a.identifier === "default") ? Qt.PointingHandCursor : undefined
|
||||||
color: M.Theme.base04
|
onTapped: {
|
||||||
font.pixelSize: M.Theme.fontSize - 2
|
const def = root.notif?.actions?.find(a => a.identifier === "default");
|
||||||
font.family: M.Theme.fontFamily
|
if (def) {
|
||||||
width: parent.width - _timeText.implicitWidth - 4
|
def.invoke();
|
||||||
elide: Text.ElideRight
|
root.dismissRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Column {
|
||||||
id: _timeText
|
id: _textCol
|
||||||
text: root.notif?.timeStr ?? ""
|
width: parent.width
|
||||||
color: M.Theme.base03
|
spacing: 2
|
||||||
font.pixelSize: M.Theme.fontSize - 2
|
|
||||||
font.family: M.Theme.fontFamily
|
// 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
|
// Action buttons — filter "default" (click-notification convention) and empty labels
|
||||||
Row {
|
Row {
|
||||||
spacing: 6
|
spacing: 6
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue