Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/Tooltip.qml
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.0 | 20 | import QtQuick 2.0 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | 22 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | import org.kde.plasma.private.digitalclock 1.0 | | |||
26 | 25 | | |||
27 | Item { | 26 | Item { | ||
28 | id: tooltipContentItem | 27 | id: tooltipContentItem | ||
29 | 28 | | |||
30 | property int preferredTextWidth: units.gridUnit * 20 | 29 | property int preferredTextWidth: units.gridUnit * 20 | ||
31 | 30 | | |||
32 | width: childrenRect.width + units.gridUnit | 31 | width: childrenRect.width + units.gridUnit | ||
33 | height: childrenRect.height + units.gridUnit | 32 | height: childrenRect.height + units.gridUnit | ||
34 | 33 | | |||
35 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | 34 | LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft | ||
36 | LayoutMirroring.childrenInherit: true | 35 | LayoutMirroring.childrenInherit: true | ||
37 | PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup | 36 | PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup | ||
38 | PlasmaCore.ColorScope.inherit: false | 37 | PlasmaCore.ColorScope.inherit: false | ||
39 | 38 | | |||
40 | function timeForZone(zone) { | | |||
41 | var compactRepresentationItem = plasmoid.compactRepresentationItem; | | |||
42 | if (!compactRepresentationItem) { | | |||
43 | return ""; | | |||
44 | } | | |||
45 | | ||||
46 | // get the time for the given timezone from the dataengine | | |||
47 | var now = dataSource.data[zone]["DateTime"]; | | |||
48 | // get current UTC time | | |||
49 | var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000); | | |||
50 | // add the dataengine TZ offset to it | | |||
51 | var dateTime = new Date(msUTC + (dataSource.data[zone]["Offset"] * 1000)); | | |||
52 | | ||||
53 | var formattedTime = Qt.formatTime(dateTime, compactRepresentationItem.timeFormat); | | |||
54 | | ||||
55 | if (dateTime.getDay() !== dataSource.data["Local"]["DateTime"].getDay()) { | | |||
56 | formattedTime += " (" + Qt.formatDate(dateTime, compactRepresentationItem.dateFormat) + ")"; | | |||
57 | } | | |||
58 | | ||||
59 | return formattedTime; | | |||
60 | } | | |||
61 | | ||||
62 | function nameForZone(zone) { | | |||
63 | // add the timezone string to the clock | | |||
64 | var timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[zone]["Timezone Abbreviation"] | | |||
65 | : TimezonesI18n.i18nCity(dataSource.data[zone]["Timezone City"]); | | |||
66 | | ||||
67 | return timezoneString; | | |||
68 | } | | |||
69 | | ||||
70 | RowLayout { | 39 | RowLayout { | ||
71 | anchors { | 40 | anchors { | ||
72 | left: parent.left | 41 | left: parent.left | ||
73 | top: parent.top | 42 | top: parent.top | ||
74 | margins: units.gridUnit / 2 | 43 | margins: units.gridUnit / 2 | ||
75 | } | 44 | } | ||
76 | 45 | | |||
77 | spacing: units.largeSpacing | 46 | spacing: units.largeSpacing | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |