From 4def2d9f0c58ec66b2c8ca11e9a54f6aec527de8 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Sat, 23 Jul 2022 19:10:57 +0800 Subject: [PATCH] applets/analog-clock: improve accessible properties This uses the plasmoid name as Accessible.name, and makes the description more human-readable. --- applets/analog-clock/contents/ui/analogclock.qml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/applets/analog-clock/contents/ui/analogclock.qml b/applets/analog-clock/contents/ui/analogclock.qml index c74f11843..eaf8f6dba 100644 --- a/applets/analog-clock/contents/ui/analogclock.qml +++ b/applets/analog-clock/contents/ui/analogclock.qml @@ -6,7 +6,7 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -import QtQuick 2.0 +import QtQuick 2.15 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 @@ -21,6 +21,9 @@ Item { width: PlasmaCore.Units.gridUnit * 15 height: PlasmaCore.Units.gridUnit * 15 + readonly property string currentTime: Qt.formatTime(dataSource.data["Local"]["DateTime"], Qt.locale().timeFormat(Locale.LongFormat)) + readonly property string currentDate: Qt.formatDate(dataSource.data["Local"]["DateTime"], Qt.locale().dateFormat(Locale.LongFormat).replace(/(^dddd.?\s)|(,?\sdddd$)/, "")) + property int hours property int minutes property int seconds @@ -32,8 +35,8 @@ Item { Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation Plasmoid.toolTipMainText: Qt.formatDate(dataSource.data["Local"]["DateTime"],"dddd") - Plasmoid.toolTipSubText: Qt.formatTime(dataSource.data["Local"]["DateTime"], Qt.locale().timeFormat(Locale.LongFormat)) + "\n" + - Qt.formatDate(dataSource.data["Local"]["DateTime"], Qt.locale().dateFormat(Locale.LongFormat).replace(/(^dddd.?\s)|(,?\sdddd$)/, "")) + Plasmoid.toolTipSubText: `${currentTime}\n${currentDate}` + function dateTimeChanged() { var currentTZOffset = dataSource.data["Local"]["Offset"] / 60; @@ -67,6 +70,12 @@ Item { property bool wasExpanded + activeFocusOnTab: true + + Accessible.name: Plasmoid.title + Accessible.description: i18nc("@info:tooltip", "Current time is %1; Current date is %2", analogclock.currentTime, analogclock.currentDate) + Accessible.role: Accessible.Button + onPressed: wasExpanded = Plasmoid.expanded onClicked: Plasmoid.expanded = !wasExpanded