Warning, /plasma/plasma-workspace/applets/digital-clock/package/contents/ui/Tooltip.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
0003
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQml
0008 import QtQuick 2.0
0009 import QtQuick.Layouts 1.1
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.plasma.plasmoid 2.0
0012 import org.kde.kirigami 2.20 as Kirigami
0013
0014 Item {
0015 id: tooltipContentItem
0016
0017 property int preferredTextWidth: Kirigami.Units.gridUnit * 20
0018
0019 implicitWidth: mainLayout.implicitWidth + Kirigami.Units.gridUnit
0020 implicitHeight: mainLayout.implicitHeight + Kirigami.Units.gridUnit
0021
0022 LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
0023 LayoutMirroring.childrenInherit: true
0024 Kirigami.Theme.colorSet: Kirigami.Theme.Window
0025 Kirigami.Theme.inherit: false
0026
0027 /**
0028 * These accessible properties are used in the compact representation,
0029 * not here.
0030 */
0031 Accessible.name: i18nc("@info:tooltip %1 is a localized long date", "Today is %1", tooltipSubtext.text)
0032 Accessible.description: {
0033 let description = tooltipSubLabelText.visible ? [tooltipSubLabelText.text] : [];
0034 for (let i = 0; i < timezoneRepeater.count; i += 2) {
0035 description.push(`${timezoneRepeater.itemAt(i).text}: ${timezoneRepeater.itemAt(i + 1).text}`);
0036 }
0037 return description.join('; ');
0038 }
0039
0040 ColumnLayout {
0041 id: mainLayout
0042
0043 anchors {
0044 left: parent.left
0045 top: parent.top
0046 margins: Kirigami.Units.largeSpacing
0047 }
0048
0049 spacing: 0
0050
0051 Kirigami.Heading {
0052 id: tooltipMaintext
0053
0054 Layout.minimumWidth: Math.min(implicitWidth, preferredTextWidth)
0055 Layout.maximumWidth: preferredTextWidth
0056
0057 level: 3
0058 elide: Text.ElideRight
0059 // keep this consistent with toolTipMainText in analog-clock
0060 text: clocks.visible ? Qt.formatDate(tzDate, Locale.LongFormat) : Qt.formatDate(tzDate,"dddd")
0061 textFormat: Text.PlainText
0062 }
0063
0064 PlasmaComponents3.Label {
0065 id: tooltipSubtext
0066
0067 Layout.minimumWidth: Math.min(implicitWidth, preferredTextWidth)
0068 Layout.maximumWidth: preferredTextWidth
0069
0070 text: {
0071 if (Plasmoid.configuration.showSeconds === 0) {
0072 return Qt.formatDate(tzDate, dateFormatString);
0073 } else {
0074 return "%1\n%2"
0075 .arg(Qt.formatTime(tzDate, Qt.locale().timeFormat(Locale.LongFormat)))
0076 .arg(Qt.formatDate(tzDate, Qt.formatDate(tzDate, dateFormatString)))
0077 }
0078 }
0079 textFormat: Text.PlainText
0080 opacity: 0.6
0081 visible: !clocks.visible
0082 }
0083
0084 PlasmaComponents3.Label {
0085 id: tooltipSubLabelText
0086 Layout.minimumWidth: Math.min(implicitWidth, preferredTextWidth)
0087 Layout.maximumWidth: preferredTextWidth
0088 text: root.fullRepresentationItem ? root.fullRepresentationItem.monthView.todayAuxilliaryText : ""
0089 textFormat: Text.PlainText
0090 opacity: 0.6
0091 visible: !clocks.visible && text.length > 0
0092 }
0093
0094 GridLayout {
0095 id: clocks
0096
0097 Layout.minimumWidth: Math.min(implicitWidth, preferredTextWidth)
0098 Layout.maximumWidth: preferredTextWidth
0099 Layout.minimumHeight: childrenRect.height
0100 visible: timezoneRepeater.count > 2
0101 columns: 2
0102 rowSpacing: 0
0103
0104 Repeater {
0105 id: timezoneRepeater
0106
0107 model: {
0108 let timezones = [];
0109 for (let i = 0; i < Plasmoid.configuration.selectedTimeZones.length; i++) {
0110 let thisTzData = Plasmoid.configuration.selectedTimeZones[i];
0111
0112 /* Don't add this item if it's the same as the local time zone, which
0113 * would indicate that the user has deliberately added a dedicated entry
0114 * for the city of their normal time zone. This is not an error condition
0115 * because the user may have done this on purpose so that their normal
0116 * local time zone shows up automatically while they're traveling and
0117 * they've switched the current local time zone to something else. But
0118 * with this use case, when they're back in their normal local time zone,
0119 * the clocks list would show two entries for the same city. To avoid
0120 * this, let's suppress the duplicate.
0121 */
0122 if (!(thisTzData !== "Local" && nameForZone(thisTzData) === nameForZone("Local"))) {
0123 timezones.push(thisTzData);
0124 timezones.push(thisTzData);
0125 }
0126 }
0127
0128 return timezones;
0129 }
0130
0131 PlasmaComponents3.Label {
0132 // Layout.fillWidth is buggy here
0133 Layout.alignment: index % 2 === 0 ? Qt.AlignRight : Qt.AlignLeft
0134 text: {
0135 if (index % 2 === 0) {
0136 return i18nc("@label %1 is a city or time zone name", "%1:", nameForZone(modelData));
0137 } else {
0138 return timeForZone(modelData, Plasmoid.configuration.showSeconds > 0);
0139 }
0140 }
0141 textFormat: Text.PlainText
0142 font.weight: modelData === Plasmoid.configuration.lastSelectedTimezone ? Font.Bold : Font.Normal
0143 wrapMode: Text.NoWrap
0144 elide: Text.ElideNone
0145 }
0146 }
0147 }
0148 }
0149 }