Commit 4def2d9f authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/analog-clock: improve accessible properties

This uses the plasmoid name as Accessible.name, and makes the
description more human-readable.
parent 0cf0de17
Pipeline #208645 passed with stage
in 12 minutes and 47 seconds
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment