shift-shell/components/mobileshell/qml/widgets/notifications/NotificationTimeText.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.6 KiB
QML
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
* SPDX-FileCopyrightText: 2018-2019 Kai Uwe Broulik <kde@privat.broulik.de>
2024-07-27 03:47:44 +00:00
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.8
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.clock
import org.kde.plasma.components 3.0 as PlasmaComponents
2023-09-27 06:06:24 +00:00
import org.kde.kirigami as Kirigami
import org.kde.notificationmanager as NotificationManager
import org.kde.coreaddons 1.0 as KCoreAddons
PlasmaComponents.Label {
id: ageLabel
2024-07-27 03:47:44 +00:00
property int notificationType: model.type
property int jobState
property QtObject jobDetails
2024-07-27 03:47:44 +00:00
property var time
property Clock clockSource
2024-07-27 03:47:44 +00:00
// notification created/updated time changed
onTimeChanged: updateAgoText()
2024-07-27 03:47:44 +00:00
Connections {
target: clockSource
// clock time changed
function onTimeChanged() {
ageLabel.updateAgoText()
}
}
2024-07-27 03:47:44 +00:00
Component.onCompleted: updateAgoText()
2024-07-27 03:47:44 +00:00
function updateAgoText() {
ageLabel.agoText = MobileShell.NotificationsUtils.generateNotificationHeaderAgoText(time, jobState);
}
2024-07-27 03:47:44 +00:00
font.pixelSize: Kirigami.Theme.defaultFont.pixelSize * 0.8
// the "n minutes ago" text, for jobs we show remaining time instead
// updated periodically by a Timer hence this property with generate() function
property string agoText: ""
visible: text !== ""
opacity: 0.6
text: MobileShell.NotificationsUtils.generateNotificationHeaderRemainingText(notificationType, jobState, jobDetails) || agoText
}