mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
qmlfmt with 4 space
This commit is contained in:
@@ -5,97 +5,109 @@ import qs.Widgets
|
||||
|
||||
DankListView {
|
||||
id: listView
|
||||
|
||||
|
||||
property var keyboardController: null
|
||||
property bool keyboardActive: false
|
||||
property bool autoScrollDisabled: false
|
||||
|
||||
|
||||
onIsUserScrollingChanged: {
|
||||
if (isUserScrolling && keyboardController && keyboardController.keyboardNavigationActive) {
|
||||
if (isUserScrolling && keyboardController
|
||||
&& keyboardController.keyboardNavigationActive) {
|
||||
autoScrollDisabled = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function enableAutoScroll() {
|
||||
autoScrollDisabled = false
|
||||
}
|
||||
|
||||
|
||||
property alias count: listView.count
|
||||
property alias listContentHeight: listView.contentHeight
|
||||
|
||||
|
||||
clip: true
|
||||
model: NotificationService.groupedNotifications
|
||||
spacing: Theme.spacingL
|
||||
|
||||
|
||||
Timer {
|
||||
id: positionPreservationTimer
|
||||
interval: 200
|
||||
running: keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled
|
||||
running: keyboardController
|
||||
&& keyboardController.keyboardNavigationActive
|
||||
&& !autoScrollDisabled
|
||||
repeat: true
|
||||
onTriggered: {
|
||||
if (keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled) {
|
||||
if (keyboardController
|
||||
&& keyboardController.keyboardNavigationActive
|
||||
&& !autoScrollDisabled) {
|
||||
keyboardController.ensureVisible()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NotificationEmptyState {
|
||||
visible: listView.count === 0
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
|
||||
onModelChanged: {
|
||||
if (keyboardController && keyboardController.keyboardNavigationActive) {
|
||||
keyboardController.rebuildFlatNavigation()
|
||||
Qt.callLater(function() {
|
||||
if (keyboardController && keyboardController.keyboardNavigationActive && !autoScrollDisabled) {
|
||||
Qt.callLater(function () {
|
||||
if (keyboardController
|
||||
&& keyboardController.keyboardNavigationActive
|
||||
&& !autoScrollDisabled) {
|
||||
keyboardController.ensureVisible()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delegate: Item {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
readonly property bool isExpanded: NotificationService.expandedGroups[modelData?.key] || false
|
||||
|
||||
|
||||
readonly property bool isExpanded: NotificationService.expandedGroups[modelData?.key]
|
||||
|| false
|
||||
|
||||
width: ListView.view.width
|
||||
height: notificationCardWrapper.height
|
||||
|
||||
|
||||
Item {
|
||||
id: notificationCardWrapper
|
||||
width: parent.width
|
||||
height: notificationCard.height
|
||||
|
||||
|
||||
NotificationCard {
|
||||
id: notificationCard
|
||||
width: parent.width
|
||||
notificationGroup: modelData
|
||||
|
||||
|
||||
isGroupSelected: {
|
||||
if (!keyboardController || !keyboardController.keyboardNavigationActive) return false
|
||||
if (!keyboardController
|
||||
|| !keyboardController.keyboardNavigationActive)
|
||||
return false
|
||||
keyboardController.selectionVersion
|
||||
if (!listView.keyboardActive) return false
|
||||
if (!listView.keyboardActive)
|
||||
return false
|
||||
const selection = keyboardController.getCurrentSelection()
|
||||
return selection.type === "group" && selection.groupIndex === index
|
||||
return selection.type === "group"
|
||||
&& selection.groupIndex === index
|
||||
}
|
||||
selectedNotificationIndex: {
|
||||
if (!keyboardController || !keyboardController.keyboardNavigationActive) return -1
|
||||
if (!keyboardController
|
||||
|| !keyboardController.keyboardNavigationActive)
|
||||
return -1
|
||||
keyboardController.selectionVersion
|
||||
if (!listView.keyboardActive) return -1
|
||||
if (!listView.keyboardActive)
|
||||
return -1
|
||||
const selection = keyboardController.getCurrentSelection()
|
||||
return (selection.type === "notification" && selection.groupIndex === index)
|
||||
? selection.notificationIndex : -1
|
||||
return (selection.type === "notification"
|
||||
&& selection.groupIndex === index) ? selection.notificationIndex : -1
|
||||
}
|
||||
keyboardNavigationActive: listView.keyboardActive
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
function onGroupedNotificationsChanged() {
|
||||
@@ -104,11 +116,11 @@ DankListView {
|
||||
keyboardController.rebuildFlatNavigation()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
keyboardController.rebuildFlatNavigation()
|
||||
|
||||
|
||||
if (keyboardController.keyboardNavigationActive) {
|
||||
Qt.callLater(function() {
|
||||
Qt.callLater(function () {
|
||||
if (!autoScrollDisabled) {
|
||||
keyboardController.ensureVisible()
|
||||
}
|
||||
@@ -116,28 +128,29 @@ DankListView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onExpandedGroupsChanged() {
|
||||
if (keyboardController && keyboardController.keyboardNavigationActive) {
|
||||
Qt.callLater(function() {
|
||||
if (keyboardController
|
||||
&& keyboardController.keyboardNavigationActive) {
|
||||
Qt.callLater(function () {
|
||||
if (!autoScrollDisabled) {
|
||||
keyboardController.ensureVisible()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onExpandedMessagesChanged() {
|
||||
if (keyboardController && keyboardController.keyboardNavigationActive) {
|
||||
Qt.callLater(function() {
|
||||
if (keyboardController
|
||||
&& keyboardController.keyboardNavigationActive) {
|
||||
Qt.callLater(function () {
|
||||
if (!autoScrollDisabled) {
|
||||
keyboardController.ensureVisible()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
target: NotificationService
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,193 +10,200 @@ import qs.Widgets
|
||||
import qs.Modules.Notifications.Center
|
||||
|
||||
DankPopout {
|
||||
id: root
|
||||
id: root
|
||||
|
||||
property bool notificationHistoryVisible: false
|
||||
property string triggerSection: "right"
|
||||
property var triggerScreen: null
|
||||
|
||||
NotificationKeyboardController {
|
||||
id: keyboardController
|
||||
listView: null
|
||||
isOpen: notificationHistoryVisible
|
||||
onClose: function() { notificationHistoryVisible = false }
|
||||
}
|
||||
|
||||
property bool notificationHistoryVisible: false
|
||||
property string triggerSection: "right"
|
||||
property var triggerScreen: null
|
||||
|
||||
function setTriggerPosition(x, y, width, section, screen) {
|
||||
triggerX = x
|
||||
triggerY = y
|
||||
triggerWidth = width
|
||||
triggerSection = section
|
||||
triggerScreen = screen
|
||||
}
|
||||
|
||||
popupWidth: 400
|
||||
popupHeight: contentLoader.item ? contentLoader.item.implicitHeight : 400
|
||||
triggerX: Screen.width - 400 - Theme.spacingL
|
||||
triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingXS
|
||||
triggerWidth: 40
|
||||
positioning: "center"
|
||||
WlrLayershell.namespace: "quickshell-notifications"
|
||||
screen: triggerScreen
|
||||
shouldBeVisible: notificationHistoryVisible
|
||||
visible: shouldBeVisible
|
||||
|
||||
onNotificationHistoryVisibleChanged: {
|
||||
if (notificationHistoryVisible) {
|
||||
open()
|
||||
} else {
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
onShouldBeVisibleChanged: {
|
||||
if (shouldBeVisible) {
|
||||
NotificationService.disablePopups(true)
|
||||
// Set up keyboard controller when content is loaded
|
||||
Qt.callLater(function() {
|
||||
if (contentLoader.item) {
|
||||
contentLoader.item.externalKeyboardController = keyboardController
|
||||
|
||||
// Find the notification list and set up the connection
|
||||
var notificationList = findChild(contentLoader.item, "notificationList")
|
||||
var notificationHeader = findChild(contentLoader.item, "notificationHeader")
|
||||
|
||||
if (notificationList) {
|
||||
keyboardController.listView = notificationList
|
||||
notificationList.keyboardController = keyboardController
|
||||
}
|
||||
if (notificationHeader) {
|
||||
notificationHeader.keyboardController = keyboardController
|
||||
}
|
||||
|
||||
keyboardController.reset()
|
||||
keyboardController.rebuildFlatNavigation()
|
||||
NotificationKeyboardController {
|
||||
id: keyboardController
|
||||
listView: null
|
||||
isOpen: notificationHistoryVisible
|
||||
onClose: function () {
|
||||
notificationHistoryVisible = false
|
||||
}
|
||||
})
|
||||
} else {
|
||||
NotificationService.disablePopups(false)
|
||||
// Reset keyboard state when closing
|
||||
keyboardController.keyboardNavigationActive = false
|
||||
}
|
||||
}
|
||||
|
||||
function findChild(parent, objectName) {
|
||||
if (parent.objectName === objectName) {
|
||||
return parent
|
||||
|
||||
function setTriggerPosition(x, y, width, section, screen) {
|
||||
triggerX = x
|
||||
triggerY = y
|
||||
triggerWidth = width
|
||||
triggerSection = section
|
||||
triggerScreen = screen
|
||||
}
|
||||
for (var i = 0; i < parent.children.length; i++) {
|
||||
var child = parent.children[i]
|
||||
var result = findChild(child, objectName)
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Rectangle {
|
||||
id: notificationContent
|
||||
|
||||
property var externalKeyboardController: null
|
||||
property real cachedHeaderHeight: 32
|
||||
|
||||
implicitHeight: {
|
||||
let baseHeight = Theme.spacingL * 2
|
||||
baseHeight += cachedHeaderHeight
|
||||
baseHeight += (notificationSettings.expanded ? notificationSettings.contentHeight : 0)
|
||||
baseHeight += Theme.spacingM * 2
|
||||
let listHeight = notificationList.listContentHeight
|
||||
if (NotificationService.groupedNotifications.length === 0)
|
||||
listHeight = 200
|
||||
baseHeight += Math.min(listHeight, 600)
|
||||
return Math.max(300, Math.min(baseHeight, root.screen ? root.screen.height * 0.8 : Screen.height * 0.8))
|
||||
}
|
||||
|
||||
color: Theme.popupBackground()
|
||||
radius: Theme.cornerRadius
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
focus: true
|
||||
popupWidth: 400
|
||||
popupHeight: contentLoader.item ? contentLoader.item.implicitHeight : 400
|
||||
triggerX: Screen.width - 400 - Theme.spacingL
|
||||
triggerY: Theme.barHeight - 4 + SettingsData.topBarSpacing + Theme.spacingXS
|
||||
triggerWidth: 40
|
||||
positioning: "center"
|
||||
WlrLayershell.namespace: "quickshell-notifications"
|
||||
screen: triggerScreen
|
||||
shouldBeVisible: notificationHistoryVisible
|
||||
visible: shouldBeVisible
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.shouldBeVisible)
|
||||
forceActiveFocus()
|
||||
}
|
||||
|
||||
Keys.onPressed: function(event) {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
root.close()
|
||||
event.accepted = true
|
||||
} else if (externalKeyboardController) {
|
||||
externalKeyboardController.handleKey(event)
|
||||
onNotificationHistoryVisibleChanged: {
|
||||
if (notificationHistoryVisible) {
|
||||
open()
|
||||
} else {
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onShouldBeVisibleChanged() {
|
||||
if (root.shouldBeVisible)
|
||||
onShouldBeVisibleChanged: {
|
||||
if (shouldBeVisible) {
|
||||
NotificationService.disablePopups(true)
|
||||
// Set up keyboard controller when content is loaded
|
||||
Qt.callLater(function () {
|
||||
notificationContent.forceActiveFocus()
|
||||
if (contentLoader.item) {
|
||||
contentLoader.item.externalKeyboardController = keyboardController
|
||||
|
||||
// Find the notification list and set up the connection
|
||||
var notificationList = findChild(contentLoader.item,
|
||||
"notificationList")
|
||||
var notificationHeader = findChild(contentLoader.item,
|
||||
"notificationHeader")
|
||||
|
||||
if (notificationList) {
|
||||
keyboardController.listView = notificationList
|
||||
notificationList.keyboardController = keyboardController
|
||||
}
|
||||
if (notificationHeader) {
|
||||
notificationHeader.keyboardController = keyboardController
|
||||
}
|
||||
|
||||
keyboardController.reset()
|
||||
keyboardController.rebuildFlatNavigation()
|
||||
}
|
||||
})
|
||||
else
|
||||
notificationContent.focus = false
|
||||
} else {
|
||||
NotificationService.disablePopups(false)
|
||||
// Reset keyboard state when closing
|
||||
keyboardController.keyboardNavigationActive = false
|
||||
}
|
||||
target: root
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: contentColumn
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
focus: true
|
||||
|
||||
Column {
|
||||
id: contentColumnInner
|
||||
anchors.fill: parent
|
||||
spacing: Theme.spacingM
|
||||
|
||||
NotificationHeader {
|
||||
id: notificationHeader
|
||||
objectName: "notificationHeader"
|
||||
onHeightChanged: notificationContent.cachedHeaderHeight = height
|
||||
}
|
||||
|
||||
NotificationSettings {
|
||||
id: notificationSettings
|
||||
expanded: notificationHeader.showSettings
|
||||
}
|
||||
|
||||
KeyboardNavigatedNotificationList {
|
||||
id: notificationList
|
||||
objectName: "notificationList"
|
||||
|
||||
width: parent.width
|
||||
height: parent.height - notificationContent.cachedHeaderHeight - notificationSettings.height - contentColumnInner.spacing * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotificationKeyboardHints {
|
||||
id: keyboardHints
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
showHints: externalKeyboardController ? externalKeyboardController.showKeyboardHints : false
|
||||
z: 200
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
NumberAnimation {
|
||||
duration: 180
|
||||
easing.type: Easing.OutQuart
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findChild(parent, objectName) {
|
||||
if (parent.objectName === objectName) {
|
||||
return parent
|
||||
}
|
||||
for (var i = 0; i < parent.children.length; i++) {
|
||||
var child = parent.children[i]
|
||||
var result = findChild(child, objectName)
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Rectangle {
|
||||
id: notificationContent
|
||||
|
||||
property var externalKeyboardController: null
|
||||
property real cachedHeaderHeight: 32
|
||||
|
||||
implicitHeight: {
|
||||
let baseHeight = Theme.spacingL * 2
|
||||
baseHeight += cachedHeaderHeight
|
||||
baseHeight += (notificationSettings.expanded ? notificationSettings.contentHeight : 0)
|
||||
baseHeight += Theme.spacingM * 2
|
||||
let listHeight = notificationList.listContentHeight
|
||||
if (NotificationService.groupedNotifications.length === 0)
|
||||
listHeight = 200
|
||||
baseHeight += Math.min(listHeight, 600)
|
||||
return Math.max(
|
||||
300, Math.min(
|
||||
baseHeight,
|
||||
root.screen ? root.screen.height * 0.8 : Screen.height * 0.8))
|
||||
}
|
||||
|
||||
color: Theme.popupBackground()
|
||||
radius: Theme.cornerRadius
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
focus: true
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.shouldBeVisible)
|
||||
forceActiveFocus()
|
||||
}
|
||||
|
||||
Keys.onPressed: function (event) {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
root.close()
|
||||
event.accepted = true
|
||||
} else if (externalKeyboardController) {
|
||||
externalKeyboardController.handleKey(event)
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onShouldBeVisibleChanged() {
|
||||
if (root.shouldBeVisible)
|
||||
Qt.callLater(function () {
|
||||
notificationContent.forceActiveFocus()
|
||||
})
|
||||
else
|
||||
notificationContent.focus = false
|
||||
}
|
||||
target: root
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: contentColumn
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
focus: true
|
||||
|
||||
Column {
|
||||
id: contentColumnInner
|
||||
anchors.fill: parent
|
||||
spacing: Theme.spacingM
|
||||
|
||||
NotificationHeader {
|
||||
id: notificationHeader
|
||||
objectName: "notificationHeader"
|
||||
onHeightChanged: notificationContent.cachedHeaderHeight = height
|
||||
}
|
||||
|
||||
NotificationSettings {
|
||||
id: notificationSettings
|
||||
expanded: notificationHeader.showSettings
|
||||
}
|
||||
|
||||
KeyboardNavigatedNotificationList {
|
||||
id: notificationList
|
||||
objectName: "notificationList"
|
||||
|
||||
width: parent.width
|
||||
height: parent.height - notificationContent.cachedHeaderHeight
|
||||
- notificationSettings.height - contentColumnInner.spacing * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotificationKeyboardHints {
|
||||
id: keyboardHints
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
showHints: externalKeyboardController ? externalKeyboardController.showKeyboardHints : false
|
||||
z: 200
|
||||
}
|
||||
|
||||
Behavior on implicitHeight {
|
||||
NumberAnimation {
|
||||
duration: 180
|
||||
easing.type: Easing.OutQuart
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,33 +4,33 @@ import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
id: root
|
||||
id: root
|
||||
|
||||
width: parent.width
|
||||
height: 200
|
||||
visible: NotificationService.notifications.length === 0
|
||||
width: parent.width
|
||||
height: 200
|
||||
visible: NotificationService.notifications.length === 0
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
width: parent.width * 0.8
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
width: parent.width * 0.8
|
||||
|
||||
DankIcon {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
name: "notifications_none"
|
||||
size: Theme.iconSizeLarge + 16
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.3)
|
||||
DankIcon {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
name: "notifications_none"
|
||||
size: Theme.iconSizeLarge + 16
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.3)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Nothing to see here"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.3)
|
||||
font.weight: Font.Medium
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Nothing to see here"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g,
|
||||
Theme.surfaceText.b, 0.3)
|
||||
font.weight: Font.Medium
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,161 +5,165 @@ import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property var keyboardController: null
|
||||
property bool showSettings: false
|
||||
id: root
|
||||
|
||||
width: parent.width
|
||||
height: 32
|
||||
property var keyboardController: null
|
||||
property bool showSettings: false
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: "Notifications"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: doNotDisturbButton
|
||||
|
||||
iconName: SessionData.doNotDisturb ? "notifications_off" : "notifications"
|
||||
iconColor: SessionData.doNotDisturb ? Theme.error : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
|
||||
|
||||
Rectangle {
|
||||
id: doNotDisturbTooltip
|
||||
|
||||
width: tooltipText.contentWidth + Theme.spacingS * 2
|
||||
height: tooltipText.contentHeight + Theme.spacingXS * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceContainer
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
anchors.bottom: parent.top
|
||||
anchors.bottomMargin: Theme.spacingS
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: doNotDisturbButton.children[1].containsMouse // Access StateLayer's containsMouse
|
||||
opacity: visible ? 1 : 0
|
||||
|
||||
StyledText {
|
||||
id: tooltipText
|
||||
|
||||
text: "Do Not Disturb"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.centerIn: parent
|
||||
font.hintingPreference: Font.PreferFullHinting
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
// Keyboard help button
|
||||
DankActionButton {
|
||||
id: helpButton
|
||||
iconName: "info"
|
||||
iconColor: keyboardController && keyboardController.showKeyboardHints ? Theme.primary : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
visible: keyboardController !== null
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: {
|
||||
if (keyboardController) {
|
||||
keyboardController.showKeyboardHints = !keyboardController.showKeyboardHints
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings button
|
||||
DankActionButton {
|
||||
id: settingsButton
|
||||
iconName: "settings"
|
||||
iconColor: root.showSettings ? Theme.primary : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: root.showSettings = !root.showSettings
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: clearAllButton
|
||||
|
||||
width: 120
|
||||
height: 28
|
||||
radius: Theme.cornerRadius
|
||||
visible: NotificationService.notifications.length > 0
|
||||
color: clearArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g,
|
||||
Theme.primary.b, 0.12) : Qt.rgba(
|
||||
Theme.surfaceVariant.r,
|
||||
Theme.surfaceVariant.g,
|
||||
Theme.surfaceVariant.b, 0.3)
|
||||
border.color: clearArea.containsMouse ? Theme.primary : Qt.rgba(
|
||||
Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
width: parent.width
|
||||
height: 32
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankIcon {
|
||||
name: "delete_sweep"
|
||||
size: Theme.iconSizeSmall
|
||||
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
StyledText {
|
||||
text: "Clear All"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
StyledText {
|
||||
text: "Notifications"
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: doNotDisturbButton
|
||||
|
||||
iconName: SessionData.doNotDisturb ? "notifications_off" : "notifications"
|
||||
iconColor: SessionData.doNotDisturb ? Theme.error : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
|
||||
|
||||
Rectangle {
|
||||
id: doNotDisturbTooltip
|
||||
|
||||
width: tooltipText.contentWidth + Theme.spacingS * 2
|
||||
height: tooltipText.contentHeight + Theme.spacingXS * 2
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceContainer
|
||||
border.color: Theme.outline
|
||||
border.width: 1
|
||||
anchors.bottom: parent.top
|
||||
anchors.bottomMargin: Theme.spacingS
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: doNotDisturbButton.children[1].containsMouse // Access StateLayer's containsMouse
|
||||
opacity: visible ? 1 : 0
|
||||
|
||||
StyledText {
|
||||
id: tooltipText
|
||||
|
||||
text: "Do Not Disturb"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.centerIn: parent
|
||||
font.hintingPreference: Font.PreferFullHinting
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
MouseArea {
|
||||
id: clearArea
|
||||
// Keyboard help button
|
||||
DankActionButton {
|
||||
id: helpButton
|
||||
iconName: "info"
|
||||
iconColor: keyboardController
|
||||
&& keyboardController.showKeyboardHints ? Theme.primary : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
visible: keyboardController !== null
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: {
|
||||
if (keyboardController) {
|
||||
keyboardController.showKeyboardHints = !keyboardController.showKeyboardHints
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: NotificationService.clearAllNotifications()
|
||||
}
|
||||
// Settings button
|
||||
DankActionButton {
|
||||
id: settingsButton
|
||||
iconName: "settings"
|
||||
iconColor: root.showSettings ? Theme.primary : Theme.surfaceText
|
||||
buttonSize: 28
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onClicked: root.showSettings = !root.showSettings
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: clearAllButton
|
||||
|
||||
Behavior on border.color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
width: 120
|
||||
height: 28
|
||||
radius: Theme.cornerRadius
|
||||
visible: NotificationService.notifications.length > 0
|
||||
color: clearArea.containsMouse ? Qt.rgba(Theme.primary.r,
|
||||
Theme.primary.g,
|
||||
Theme.primary.b,
|
||||
0.12) : Qt.rgba(
|
||||
Theme.surfaceVariant.r,
|
||||
Theme.surfaceVariant.g,
|
||||
Theme.surfaceVariant.b, 0.3)
|
||||
border.color: clearArea.containsMouse ? Theme.primary : Qt.rgba(
|
||||
Theme.outline.r,
|
||||
Theme.outline.g,
|
||||
Theme.outline.b, 0.08)
|
||||
border.width: 1
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankIcon {
|
||||
name: "delete_sweep"
|
||||
size: Theme.iconSizeSmall
|
||||
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: "Clear All"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: clearArea.containsMouse ? Theme.primary : Theme.surfaceText
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: clearArea
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: NotificationService.clearAllNotifications()
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on border.color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,114 +4,124 @@ import qs.Services
|
||||
|
||||
QtObject {
|
||||
id: controller
|
||||
|
||||
|
||||
property var listView: null
|
||||
property bool isOpen: false
|
||||
property var onClose: null
|
||||
|
||||
|
||||
property int selectionVersion: 0
|
||||
|
||||
|
||||
property bool keyboardNavigationActive: false
|
||||
property int selectedFlatIndex: 0
|
||||
property var flatNavigation: []
|
||||
property bool showKeyboardHints: false
|
||||
|
||||
|
||||
property string selectedNotificationId: ""
|
||||
property string selectedGroupKey: ""
|
||||
property string selectedItemType: ""
|
||||
property bool isTogglingGroup: false
|
||||
property bool isRebuilding: false
|
||||
|
||||
|
||||
function rebuildFlatNavigation() {
|
||||
isRebuilding = true
|
||||
|
||||
|
||||
var nav = []
|
||||
var groups = NotificationService.groupedNotifications
|
||||
|
||||
|
||||
for (var i = 0; i < groups.length; i++) {
|
||||
var group = groups[i]
|
||||
var isExpanded = NotificationService.expandedGroups[group.key] || false
|
||||
|
||||
var isExpanded = NotificationService.expandedGroups[group.key]
|
||||
|| false
|
||||
|
||||
// Add the group itself
|
||||
nav.push({
|
||||
type: "group",
|
||||
groupIndex: i,
|
||||
notificationIndex: -1,
|
||||
groupKey: group.key,
|
||||
notificationId: ""
|
||||
})
|
||||
|
||||
"type": "group",
|
||||
"groupIndex": i,
|
||||
"notificationIndex": -1,
|
||||
"groupKey": group.key,
|
||||
"notificationId": ""
|
||||
})
|
||||
|
||||
// If expanded, add individual notifications
|
||||
if (isExpanded) {
|
||||
var notifications = group.notifications || []
|
||||
for (var j = 0; j < notifications.length; j++) {
|
||||
var notifId = String(notifications[j]?.notification?.id || "")
|
||||
var notifId = String(
|
||||
notifications[j]?.notification?.id || "")
|
||||
nav.push({
|
||||
type: "notification",
|
||||
groupIndex: i,
|
||||
notificationIndex: j,
|
||||
groupKey: group.key,
|
||||
notificationId: notifId
|
||||
})
|
||||
"type": "notification",
|
||||
"groupIndex": i,
|
||||
"notificationIndex": j,
|
||||
"groupKey": group.key,
|
||||
"notificationId": notifId
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flatNavigation = nav
|
||||
updateSelectedIndexFromId()
|
||||
isRebuilding = false
|
||||
}
|
||||
|
||||
|
||||
function updateSelectedIndexFromId() {
|
||||
if (!keyboardNavigationActive) return
|
||||
|
||||
if (!keyboardNavigationActive)
|
||||
return
|
||||
|
||||
// Find the index that matches our selected ID/key
|
||||
for (var i = 0; i < flatNavigation.length; i++) {
|
||||
var item = flatNavigation[i]
|
||||
|
||||
if (selectedItemType === "group" && item.type === "group" && item.groupKey === selectedGroupKey) {
|
||||
|
||||
if (selectedItemType === "group" && item.type === "group"
|
||||
&& item.groupKey === selectedGroupKey) {
|
||||
selectedFlatIndex = i
|
||||
selectionVersion++ // Trigger UI update
|
||||
selectionVersion++ // Trigger UI update
|
||||
return
|
||||
} else if (selectedItemType === "notification" && item.type === "notification" && String(item.notificationId) === String(selectedNotificationId)) {
|
||||
} else if (selectedItemType === "notification"
|
||||
&& item.type === "notification" && String(
|
||||
item.notificationId) === String(
|
||||
selectedNotificationId)) {
|
||||
selectedFlatIndex = i
|
||||
selectionVersion++ // Trigger UI update
|
||||
selectionVersion++ // Trigger UI update
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If not found, try to find the same group but select the group header instead
|
||||
if (selectedItemType === "notification") {
|
||||
for (var j = 0; j < flatNavigation.length; j++) {
|
||||
var groupItem = flatNavigation[j]
|
||||
if (groupItem.type === "group" && groupItem.groupKey === selectedGroupKey) {
|
||||
if (groupItem.type === "group"
|
||||
&& groupItem.groupKey === selectedGroupKey) {
|
||||
selectedFlatIndex = j
|
||||
selectedItemType = "group"
|
||||
selectedNotificationId = ""
|
||||
selectionVersion++ // Trigger UI update
|
||||
selectionVersion++ // Trigger UI update
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If still not found, clamp to valid range and update
|
||||
if (flatNavigation.length > 0) {
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex, flatNavigation.length - 1)
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex,
|
||||
flatNavigation.length - 1)
|
||||
selectedFlatIndex = Math.max(selectedFlatIndex, 0)
|
||||
updateSelectedIdFromIndex()
|
||||
selectionVersion++ // Trigger UI update
|
||||
selectionVersion++ // Trigger UI update
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateSelectedIdFromIndex() {
|
||||
if (selectedFlatIndex >= 0 && selectedFlatIndex < flatNavigation.length) {
|
||||
if (selectedFlatIndex >= 0
|
||||
&& selectedFlatIndex < flatNavigation.length) {
|
||||
var item = flatNavigation[selectedFlatIndex]
|
||||
selectedItemType = item.type
|
||||
selectedGroupKey = item.groupKey
|
||||
selectedNotificationId = item.notificationId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function reset() {
|
||||
selectedFlatIndex = 0
|
||||
keyboardNavigationActive = false
|
||||
@@ -122,87 +132,100 @@ QtObject {
|
||||
}
|
||||
rebuildFlatNavigation()
|
||||
}
|
||||
|
||||
|
||||
function selectNext() {
|
||||
keyboardNavigationActive = true
|
||||
if (flatNavigation.length === 0) return
|
||||
|
||||
if (flatNavigation.length === 0)
|
||||
return
|
||||
|
||||
// Re-enable auto-scrolling when arrow keys are used
|
||||
if (listView && listView.enableAutoScroll) {
|
||||
listView.enableAutoScroll()
|
||||
}
|
||||
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex + 1, flatNavigation.length - 1)
|
||||
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex + 1,
|
||||
flatNavigation.length - 1)
|
||||
updateSelectedIdFromIndex()
|
||||
selectionVersion++
|
||||
ensureVisible()
|
||||
}
|
||||
|
||||
|
||||
function selectPrevious() {
|
||||
keyboardNavigationActive = true
|
||||
if (flatNavigation.length === 0) return
|
||||
|
||||
if (flatNavigation.length === 0)
|
||||
return
|
||||
|
||||
// Re-enable auto-scrolling when arrow keys are used
|
||||
if (listView && listView.enableAutoScroll) {
|
||||
listView.enableAutoScroll()
|
||||
}
|
||||
|
||||
|
||||
selectedFlatIndex = Math.max(selectedFlatIndex - 1, 0)
|
||||
updateSelectedIdFromIndex()
|
||||
selectionVersion++
|
||||
ensureVisible()
|
||||
}
|
||||
|
||||
|
||||
function toggleGroupExpanded() {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
const groups = NotificationService.groupedNotifications
|
||||
const group = groups[currentItem.groupIndex]
|
||||
if (!group) return
|
||||
|
||||
if (!group)
|
||||
return
|
||||
|
||||
// Prevent expanding groups with < 2 notifications
|
||||
const notificationCount = group.notifications ? group.notifications.length : 0
|
||||
if (notificationCount < 2) return
|
||||
|
||||
const wasExpanded = NotificationService.expandedGroups[group.key] || false
|
||||
if (notificationCount < 2)
|
||||
return
|
||||
|
||||
const wasExpanded = NotificationService.expandedGroups[group.key]
|
||||
|| false
|
||||
const groupIndex = currentItem.groupIndex
|
||||
|
||||
|
||||
isTogglingGroup = true
|
||||
NotificationService.toggleGroupExpansion(group.key)
|
||||
rebuildFlatNavigation()
|
||||
|
||||
|
||||
// Smart selection after toggle
|
||||
if (!wasExpanded) {
|
||||
// Just expanded - move to first notification in the group
|
||||
for (let i = 0; i < flatNavigation.length; i++) {
|
||||
if (flatNavigation[i].type === "notification" && flatNavigation[i].groupIndex === groupIndex) {
|
||||
for (var i = 0; i < flatNavigation.length; i++) {
|
||||
if (flatNavigation[i].type === "notification"
|
||||
&& flatNavigation[i].groupIndex === groupIndex) {
|
||||
selectedFlatIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Just collapsed - stay on the group header
|
||||
for (let i = 0; i < flatNavigation.length; i++) {
|
||||
if (flatNavigation[i].type === "group" && flatNavigation[i].groupIndex === groupIndex) {
|
||||
for (var i = 0; i < flatNavigation.length; i++) {
|
||||
if (flatNavigation[i].type === "group"
|
||||
&& flatNavigation[i].groupIndex === groupIndex) {
|
||||
selectedFlatIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
isTogglingGroup = false
|
||||
ensureVisible()
|
||||
}
|
||||
|
||||
|
||||
function handleEnterKey() {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
const groups = NotificationService.groupedNotifications
|
||||
const group = groups[currentItem.groupIndex]
|
||||
if (!group) return
|
||||
|
||||
if (!group)
|
||||
return
|
||||
|
||||
if (currentItem.type === "group") {
|
||||
const notificationCount = group.notifications ? group.notifications.length : 0
|
||||
if (notificationCount >= 2) {
|
||||
@@ -214,100 +237,117 @@ QtObject {
|
||||
executeAction(0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleTextExpanded() {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
const groups = NotificationService.groupedNotifications
|
||||
const group = groups[currentItem.groupIndex]
|
||||
if (!group) return
|
||||
|
||||
if (!group)
|
||||
return
|
||||
|
||||
var messageId = ""
|
||||
|
||||
|
||||
if (currentItem.type === "group") {
|
||||
messageId = group.latestNotification?.notification?.id + "_desc"
|
||||
} else if (currentItem.type === "notification" && currentItem.notificationIndex >= 0 && currentItem.notificationIndex < group.notifications.length) {
|
||||
messageId = group.notifications[currentItem.notificationIndex]?.notification?.id + "_desc"
|
||||
} else if (currentItem.type === "notification"
|
||||
&& currentItem.notificationIndex >= 0
|
||||
&& currentItem.notificationIndex < group.notifications.length) {
|
||||
messageId = group.notifications[currentItem.notificationIndex]?.notification?.id
|
||||
+ "_desc"
|
||||
}
|
||||
|
||||
|
||||
if (messageId) {
|
||||
NotificationService.toggleMessageExpansion(messageId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function executeAction(actionIndex) {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
const groups = NotificationService.groupedNotifications
|
||||
const group = groups[currentItem.groupIndex]
|
||||
if (!group) return
|
||||
|
||||
if (!group)
|
||||
return
|
||||
|
||||
var actions = []
|
||||
|
||||
|
||||
if (currentItem.type === "group") {
|
||||
actions = group.latestNotification?.actions || []
|
||||
} else if (currentItem.type === "notification" && currentItem.notificationIndex >= 0 && currentItem.notificationIndex < group.notifications.length) {
|
||||
actions = group.notifications[currentItem.notificationIndex]?.actions || []
|
||||
} else if (currentItem.type === "notification"
|
||||
&& currentItem.notificationIndex >= 0
|
||||
&& currentItem.notificationIndex < group.notifications.length) {
|
||||
actions = group.notifications[currentItem.notificationIndex]?.actions
|
||||
|| []
|
||||
}
|
||||
|
||||
|
||||
if (actionIndex >= 0 && actionIndex < actions.length) {
|
||||
const action = actions[actionIndex]
|
||||
if (action.invoke) {
|
||||
action.invoke()
|
||||
if (onClose) onClose()
|
||||
if (onClose)
|
||||
onClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clearSelected() {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
const groups = NotificationService.groupedNotifications
|
||||
const group = groups[currentItem.groupIndex]
|
||||
if (!group) return
|
||||
|
||||
if (!group)
|
||||
return
|
||||
|
||||
// Save current state for smart navigation
|
||||
const currentGroupKey = group.key
|
||||
const isNotification = currentItem.type === "notification"
|
||||
const notificationIndex = currentItem.notificationIndex
|
||||
const totalNotificationsInGroup = group.notifications ? group.notifications.length : 0
|
||||
const isLastNotificationInGroup = isNotification && totalNotificationsInGroup === 1
|
||||
const isLastNotificationInList = isNotification && notificationIndex === totalNotificationsInGroup - 1
|
||||
|
||||
const isLastNotificationInGroup = isNotification
|
||||
&& totalNotificationsInGroup === 1
|
||||
const isLastNotificationInList = isNotification
|
||||
&& notificationIndex === totalNotificationsInGroup - 1
|
||||
|
||||
// Store what to select next BEFORE clearing
|
||||
let nextTargetType = ""
|
||||
let nextTargetGroupKey = ""
|
||||
let nextTargetNotificationIndex = -1
|
||||
|
||||
|
||||
if (currentItem.type === "group") {
|
||||
NotificationService.dismissGroup(group.key)
|
||||
|
||||
|
||||
// Look for next group
|
||||
for (let i = currentItem.groupIndex + 1; i < groups.length; i++) {
|
||||
for (var i = currentItem.groupIndex + 1; i < groups.length; i++) {
|
||||
nextTargetType = "group"
|
||||
nextTargetGroupKey = groups[i].key
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
if (!nextTargetGroupKey && currentItem.groupIndex > 0) {
|
||||
nextTargetType = "group"
|
||||
nextTargetGroupKey = groups[currentItem.groupIndex - 1].key
|
||||
}
|
||||
|
||||
} else if (isNotification) {
|
||||
const notification = group.notifications[notificationIndex]
|
||||
NotificationService.dismissNotification(notification)
|
||||
|
||||
|
||||
if (isLastNotificationInGroup) {
|
||||
for (let i = currentItem.groupIndex + 1; i < groups.length; i++) {
|
||||
for (var i = currentItem.groupIndex + 1; i < groups.length; i++) {
|
||||
nextTargetType = "group"
|
||||
nextTargetGroupKey = groups[i].key
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
if (!nextTargetGroupKey && currentItem.groupIndex > 0) {
|
||||
nextTargetType = "group"
|
||||
nextTargetGroupKey = groups[currentItem.groupIndex - 1].key
|
||||
@@ -331,66 +371,77 @@ QtObject {
|
||||
nextTargetNotificationIndex = notificationIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rebuildFlatNavigation()
|
||||
|
||||
|
||||
// Find and select the target we identified
|
||||
if (flatNavigation.length === 0) {
|
||||
selectedFlatIndex = 0
|
||||
updateSelectedIdFromIndex()
|
||||
} else if (nextTargetGroupKey) {
|
||||
let found = false
|
||||
for (let i = 0; i < flatNavigation.length; i++) {
|
||||
for (var i = 0; i < flatNavigation.length; i++) {
|
||||
const item = flatNavigation[i]
|
||||
|
||||
if (nextTargetType === "group" && item.type === "group" && item.groupKey === nextTargetGroupKey) {
|
||||
|
||||
if (nextTargetType === "group" && item.type === "group"
|
||||
&& item.groupKey === nextTargetGroupKey) {
|
||||
selectedFlatIndex = i
|
||||
found = true
|
||||
break
|
||||
} else if (nextTargetType === "notification" && item.type === "notification" &&
|
||||
item.groupKey === nextTargetGroupKey && item.notificationIndex === nextTargetNotificationIndex) {
|
||||
} else if (nextTargetType === "notification"
|
||||
&& item.type === "notification"
|
||||
&& item.groupKey === nextTargetGroupKey
|
||||
&& item.notificationIndex === nextTargetNotificationIndex) {
|
||||
selectedFlatIndex = i
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!found) {
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex, flatNavigation.length - 1)
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex,
|
||||
flatNavigation.length - 1)
|
||||
}
|
||||
|
||||
|
||||
updateSelectedIdFromIndex()
|
||||
} else {
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex, flatNavigation.length - 1)
|
||||
selectedFlatIndex = Math.min(selectedFlatIndex,
|
||||
flatNavigation.length - 1)
|
||||
updateSelectedIdFromIndex()
|
||||
}
|
||||
|
||||
|
||||
ensureVisible()
|
||||
}
|
||||
|
||||
|
||||
function ensureVisible() {
|
||||
if (flatNavigation.length === 0 || selectedFlatIndex >= flatNavigation.length || !listView) return
|
||||
|
||||
if (flatNavigation.length === 0
|
||||
|| selectedFlatIndex >= flatNavigation.length || !listView)
|
||||
return
|
||||
|
||||
const currentItem = flatNavigation[selectedFlatIndex]
|
||||
|
||||
if (keyboardNavigationActive && currentItem && currentItem.groupIndex >= 0) {
|
||||
|
||||
if (keyboardNavigationActive && currentItem
|
||||
&& currentItem.groupIndex >= 0) {
|
||||
// Always center the selected item for better visibility
|
||||
// This ensures the selected item stays in view even when new notifications arrive
|
||||
if (currentItem.type === "notification") {
|
||||
// For individual notifications, center on the group but bias towards the notification
|
||||
listView.positionViewAtIndex(currentItem.groupIndex, ListView.Center)
|
||||
listView.positionViewAtIndex(currentItem.groupIndex,
|
||||
ListView.Center)
|
||||
} else {
|
||||
// For group headers, center on the group
|
||||
listView.positionViewAtIndex(currentItem.groupIndex, ListView.Center)
|
||||
listView.positionViewAtIndex(currentItem.groupIndex,
|
||||
ListView.Center)
|
||||
}
|
||||
|
||||
|
||||
// Force immediate update
|
||||
listView.forceLayout()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleKey(event) {
|
||||
if ((event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) && (event.modifiers & Qt.ShiftModifier)) {
|
||||
if ((event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace)
|
||||
&& (event.modifiers & Qt.ShiftModifier)) {
|
||||
NotificationService.clearAllNotifications()
|
||||
rebuildFlatNavigation()
|
||||
if (flatNavigation.length === 0) {
|
||||
@@ -406,19 +457,20 @@ QtObject {
|
||||
event.accepted = true
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
if (keyboardNavigationActive) {
|
||||
keyboardNavigationActive = false
|
||||
event.accepted = true
|
||||
} else {
|
||||
if (onClose) onClose()
|
||||
if (onClose)
|
||||
onClose()
|
||||
event.accepted = true
|
||||
}
|
||||
} else if (event.key === Qt.Key_Down || event.key === 16777237) {
|
||||
if (!keyboardNavigationActive) {
|
||||
keyboardNavigationActive = true
|
||||
rebuildFlatNavigation() // Ensure we have fresh navigation data
|
||||
rebuildFlatNavigation() // Ensure we have fresh navigation data
|
||||
selectedFlatIndex = 0
|
||||
updateSelectedIdFromIndex()
|
||||
// Set keyboardActive on listView to show highlight
|
||||
@@ -435,7 +487,7 @@ QtObject {
|
||||
} else if (event.key === Qt.Key_Up || event.key === 16777235) {
|
||||
if (!keyboardNavigationActive) {
|
||||
keyboardNavigationActive = true
|
||||
rebuildFlatNavigation() // Ensure we have fresh navigation data
|
||||
rebuildFlatNavigation() // Ensure we have fresh navigation data
|
||||
selectedFlatIndex = 0
|
||||
updateSelectedIdFromIndex()
|
||||
// Set keyboardActive on listView to show highlight
|
||||
@@ -462,13 +514,15 @@ QtObject {
|
||||
if (event.key === Qt.Key_Space) {
|
||||
toggleGroupExpanded()
|
||||
event.accepted = true
|
||||
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||
} else if (event.key === Qt.Key_Return
|
||||
|| event.key === Qt.Key_Enter) {
|
||||
handleEnterKey()
|
||||
event.accepted = true
|
||||
} else if (event.key === Qt.Key_E) {
|
||||
toggleTextExpanded()
|
||||
event.accepted = true
|
||||
} else if (event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) {
|
||||
} else if (event.key === Qt.Key_Delete
|
||||
|| event.key === Qt.Key_Backspace) {
|
||||
clearSelected()
|
||||
event.accepted = true
|
||||
} else if (event.key >= Qt.Key_1 && event.key <= Qt.Key_9) {
|
||||
@@ -477,19 +531,28 @@ QtObject {
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (event.key === Qt.Key_F10) {
|
||||
showKeyboardHints = !showKeyboardHints
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get current selection info for UI
|
||||
function getCurrentSelection() {
|
||||
if (!keyboardNavigationActive || selectedFlatIndex < 0 || selectedFlatIndex >= flatNavigation.length) {
|
||||
return { type: "", groupIndex: -1, notificationIndex: -1 }
|
||||
if (!keyboardNavigationActive || selectedFlatIndex < 0
|
||||
|| selectedFlatIndex >= flatNavigation.length) {
|
||||
return {
|
||||
"type": "",
|
||||
"groupIndex": -1,
|
||||
"notificationIndex": -1
|
||||
}
|
||||
}
|
||||
const result = flatNavigation[selectedFlatIndex] || {
|
||||
"type": "",
|
||||
"groupIndex": -1,
|
||||
"notificationIndex": -1
|
||||
}
|
||||
const result = flatNavigation[selectedFlatIndex] || { type: "", groupIndex: -1, notificationIndex: -1 }
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ Rectangle {
|
||||
|
||||
height: 80
|
||||
radius: Theme.cornerRadius
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.95)
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g,
|
||||
Theme.surfaceContainer.b, 0.95)
|
||||
border.color: Theme.primary
|
||||
border.width: 2
|
||||
opacity: showHints ? 1 : 0
|
||||
@@ -39,7 +40,6 @@ Rectangle {
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
@@ -47,7 +47,5 @@ Rectangle {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,19 +6,21 @@ import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
|
||||
property bool expanded: false
|
||||
readonly property real contentHeight: contentColumn.height + Theme.spacingL * 2
|
||||
|
||||
|
||||
width: parent.width
|
||||
height: expanded ? Math.min(contentHeight, 400) : 0
|
||||
visible: expanded
|
||||
clip: true
|
||||
radius: Theme.cornerRadius
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.3)
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g,
|
||||
Theme.surfaceContainer.b, 0.3)
|
||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.1)
|
||||
border.width: 1
|
||||
|
||||
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
duration: Anims.durShort
|
||||
@@ -26,48 +28,74 @@ Rectangle {
|
||||
easing.bezierCurve: Anims.emphasized
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ensure smooth opacity transition
|
||||
opacity: expanded ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Anims.durShort
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Anims.emphasized
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var timeoutOptions: [
|
||||
{ text: "Never", value: 0 },
|
||||
{ text: "1 second", value: 1000 },
|
||||
{ text: "3 seconds", value: 3000 },
|
||||
{ text: "5 seconds", value: 5000 },
|
||||
{ text: "8 seconds", value: 8000 },
|
||||
{ text: "10 seconds", value: 10000 },
|
||||
{ text: "15 seconds", value: 15000 },
|
||||
{ text: "30 seconds", value: 30000 },
|
||||
{ text: "1 minute", value: 60000 },
|
||||
{ text: "2 minutes", value: 120000 },
|
||||
{ text: "5 minutes", value: 300000 },
|
||||
{ text: "10 minutes", value: 600000 }
|
||||
]
|
||||
|
||||
|
||||
readonly property var timeoutOptions: [{
|
||||
"text": "Never",
|
||||
"value": 0
|
||||
}, {
|
||||
"text": "1 second",
|
||||
"value": 1000
|
||||
}, {
|
||||
"text": "3 seconds",
|
||||
"value": 3000
|
||||
}, {
|
||||
"text": "5 seconds",
|
||||
"value": 5000
|
||||
}, {
|
||||
"text": "8 seconds",
|
||||
"value": 8000
|
||||
}, {
|
||||
"text": "10 seconds",
|
||||
"value": 10000
|
||||
}, {
|
||||
"text": "15 seconds",
|
||||
"value": 15000
|
||||
}, {
|
||||
"text": "30 seconds",
|
||||
"value": 30000
|
||||
}, {
|
||||
"text": "1 minute",
|
||||
"value": 60000
|
||||
}, {
|
||||
"text": "2 minutes",
|
||||
"value": 120000
|
||||
}, {
|
||||
"text": "5 minutes",
|
||||
"value": 300000
|
||||
}, {
|
||||
"text": "10 minutes",
|
||||
"value": 600000
|
||||
}]
|
||||
|
||||
function getTimeoutText(value) {
|
||||
if (value === undefined || value === null || isNaN(value)) {
|
||||
return "5 seconds"
|
||||
}
|
||||
|
||||
for (let i = 0; i < timeoutOptions.length; i++) {
|
||||
|
||||
for (var i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].value === value) {
|
||||
return timeoutOptions[i].text
|
||||
}
|
||||
}
|
||||
if (value === 0) return "Never"
|
||||
if (value < 1000) return value + "ms"
|
||||
if (value < 60000) return Math.round(value / 1000) + " seconds"
|
||||
if (value === 0)
|
||||
return "Never"
|
||||
if (value < 1000)
|
||||
return value + "ms"
|
||||
if (value < 60000)
|
||||
return Math.round(value / 1000) + " seconds"
|
||||
return Math.round(value / 60000) + " minutes"
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
anchors.top: parent.top
|
||||
@@ -75,30 +103,30 @@ Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingM
|
||||
|
||||
|
||||
StyledText {
|
||||
text: "Notification Settings"
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Bold
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingM
|
||||
|
||||
|
||||
DankIcon {
|
||||
name: SessionData.doNotDisturb ? "notifications_off" : "notifications"
|
||||
size: Theme.iconSizeSmall
|
||||
color: SessionData.doNotDisturb ? Theme.error : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
|
||||
StyledText {
|
||||
text: "Do Not Disturb"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
@@ -106,28 +134,30 @@ Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DankToggle {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: SessionData.doNotDisturb
|
||||
onToggled: SessionData.setDoNotDisturb(!SessionData.doNotDisturb)
|
||||
onToggled: SessionData.setDoNotDisturb(
|
||||
!SessionData.doNotDisturb)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.1)
|
||||
}
|
||||
|
||||
|
||||
StyledText {
|
||||
text: "Notification Timeouts"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
|
||||
DankDropdown {
|
||||
width: parent.width
|
||||
text: "Low Priority"
|
||||
@@ -135,15 +165,16 @@ Rectangle {
|
||||
currentValue: getTimeoutText(SettingsData.notificationTimeoutLow)
|
||||
options: timeoutOptions.map(opt => opt.text)
|
||||
onValueChanged: value => {
|
||||
for (let i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutLow(timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutLow(
|
||||
timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DankDropdown {
|
||||
width: parent.width
|
||||
text: "Normal Priority"
|
||||
@@ -151,63 +182,67 @@ Rectangle {
|
||||
currentValue: getTimeoutText(SettingsData.notificationTimeoutNormal)
|
||||
options: timeoutOptions.map(opt => opt.text)
|
||||
onValueChanged: value => {
|
||||
for (let i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutNormal(timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutNormal(
|
||||
timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DankDropdown {
|
||||
width: parent.width
|
||||
text: "Critical Priority"
|
||||
description: "Timeout for critical priority notifications"
|
||||
currentValue: getTimeoutText(SettingsData.notificationTimeoutCritical)
|
||||
currentValue: getTimeoutText(
|
||||
SettingsData.notificationTimeoutCritical)
|
||||
options: timeoutOptions.map(opt => opt.text)
|
||||
onValueChanged: value => {
|
||||
for (let i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutCritical(timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < timeoutOptions.length; i++) {
|
||||
if (timeoutOptions[i].text === value) {
|
||||
SettingsData.setNotificationTimeoutCritical(
|
||||
timeoutOptions[i].value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.1)
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.1)
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingM
|
||||
|
||||
|
||||
DankIcon {
|
||||
name: "notifications_active"
|
||||
size: Theme.iconSizeSmall
|
||||
color: SettingsData.notificationOverlayEnabled ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
spacing: 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
|
||||
StyledText {
|
||||
text: "Notification Overlay"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
|
||||
StyledText {
|
||||
text: "Display all priorities over fullscreen apps"
|
||||
font.pixelSize: Theme.fontSizeSmall - 1
|
||||
@@ -215,13 +250,14 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DankToggle {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: SettingsData.notificationOverlayEnabled
|
||||
onToggled: (toggled) => SettingsData.setNotificationOverlayEnabled(toggled)
|
||||
onToggled: toggled => SettingsData.setNotificationOverlayEnabled(
|
||||
toggled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user