Changeset View
Changeset View
Standalone View
Standalone View
applets/digital-clock/package/contents/ui/main.qml
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 29 | Item { | |||
---|---|---|---|---|---|
45 | function initTimezones() { | 45 | function initTimezones() { | ||
46 | var tz = Array() | 46 | var tz = Array() | ||
47 | if (plasmoid.configuration.selectedTimeZones.indexOf("Local") === -1) { | 47 | if (plasmoid.configuration.selectedTimeZones.indexOf("Local") === -1) { | ||
48 | tz.push("Local"); | 48 | tz.push("Local"); | ||
49 | } | 49 | } | ||
50 | root.allTimezones = tz.concat(plasmoid.configuration.selectedTimeZones); | 50 | root.allTimezones = tz.concat(plasmoid.configuration.selectedTimeZones); | ||
51 | } | 51 | } | ||
52 | 52 | | |||
53 | function timeForZone(zone) { | ||||
54 | var compactRepresentationItem = plasmoid.compactRepresentationItem; | ||||
55 | if (!compactRepresentationItem) { | ||||
56 | return ""; | ||||
57 | } | ||||
58 | | ||||
59 | // get the time for the given timezone from the dataengine | ||||
60 | var now = dataSource.data[zone]["DateTime"]; | ||||
61 | // get current UTC time | ||||
62 | var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000); | ||||
cblack: This variable is only used in the following statement, so I would move it into there. Would… | |||||
63 | // add the dataengine TZ offset to it | ||||
64 | var dateTime = new Date(msUTC + (dataSource.data[zone]["Offset"] * 1000)); | ||||
65 | | ||||
66 | var formattedTime = Qt.formatTime(dateTime, compactRepresentationItem.timeFormat); | ||||
67 | | ||||
68 | if (dateTime.getDay() !== dataSource.data["Local"]["DateTime"].getDay()) { | ||||
69 | formattedTime += " (" + Qt.formatDate(dateTime, compactRepresentationItem.dateFormat) + ")"; | ||||
Style change: use arg() instead of string concatenation so it's easier to see what the end string will look like cblack: Style change: use arg() instead of string concatenation so it's easier to see what the end… | |||||
apol: I don't think that's fair. I wouldn't say arg makes it more readable. | |||||
70 | } | ||||
71 | | ||||
72 | return formattedTime; | ||||
73 | } | ||||
74 | | ||||
75 | function nameForZone(zone) { | ||||
76 | // add the timezone string to the clock | ||||
77 | var timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[zone]["Timezone Abbreviation"] | ||||
78 | : TimezonesI18n.i18nCity(dataSource.data[zone]["Timezone City"]); | ||||
79 | | ||||
80 | return timezoneString; | ||||
cblack: Declaring a variable and then returning it immediately seems redundant. | |||||
81 | } | ||||
82 | | ||||
53 | Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation | 83 | Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation | ||
54 | Plasmoid.compactRepresentation: DigitalClock { } | 84 | Plasmoid.compactRepresentation: DigitalClock { } | ||
55 | Plasmoid.fullRepresentation: CalendarView { } | 85 | Plasmoid.fullRepresentation: CalendarView { } | ||
56 | 86 | | |||
57 | Plasmoid.toolTipItem: Loader { | 87 | Plasmoid.toolTipItem: Loader { | ||
58 | id: tooltipLoader | 88 | id: tooltipLoader | ||
59 | 89 | | |||
60 | Layout.minimumWidth: item ? item.width : 0 | 90 | Layout.minimumWidth: item ? item.width : 0 | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
This variable is only used in the following statement, so I would move it into there. Would probably make it multiple lines to not hurt readability.