Commit 2130c848 authored by Nate Graham's avatar Nate Graham 🔩

[applet/digital-clock] Show time zones in expanded representation too

Summary:
Right now time zones are only shown in the tooltip, which is annoying since the tooltip
times out aftew a few seconds, so it often closes before I can find the timezone I'm
looking for.

This patch adds a view for the current tomezones in the expanded representation, and
implements a mockup in https://bugs.kde.org/show_bug.cgi?id=395655 showing a proposal
for how to present this information.

The Expanded Representation is also ported to Layouts in order to make this task easier.

FEATURE: 395655
FIXED-IN: 5.19.0

Test Plan:
Just calendar: {F8157434}

Calendar + events: {F8157435}

Calendar + time zones: {F8157436}

Calendar + events + time zones: {F8157437}

Reviewers: #vdg, #plasma, cblack

Reviewed By: #vdg, cblack

Subscribers: cblack, apol, plasma-devel

Tags: #plasma

Maniphest Tasks: T9222

Differential Revision: https://phabricator.kde.org/D27903
parent 85f646eb
......@@ -22,7 +22,6 @@ import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.private.digitalclock 1.0
Item {
id: tooltipContentItem
......@@ -37,36 +36,6 @@ Item {
PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup
PlasmaCore.ColorScope.inherit: false
function timeForZone(zone) {
var compactRepresentationItem = plasmoid.compactRepresentationItem;
if (!compactRepresentationItem) {
return "";
}
// get the time for the given timezone from the dataengine
var now = dataSource.data[zone]["DateTime"];
// get current UTC time
var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000);
// add the dataengine TZ offset to it
var dateTime = new Date(msUTC + (dataSource.data[zone]["Offset"] * 1000));
var formattedTime = Qt.formatTime(dateTime, compactRepresentationItem.timeFormat);
if (dateTime.getDay() !== dataSource.data["Local"]["DateTime"].getDay()) {
formattedTime += " (" + Qt.formatDate(dateTime, compactRepresentationItem.dateFormat) + ")";
}
return formattedTime;
}
function nameForZone(zone) {
// add the timezone string to the clock
var timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[zone]["Timezone Abbreviation"]
: TimezonesI18n.i18nCity(dataSource.data[zone]["Timezone City"]);
return timezoneString;
}
RowLayout {
anchors {
left: parent.left
......
......@@ -50,6 +50,36 @@ Item {
root.allTimezones = tz.concat(plasmoid.configuration.selectedTimeZones);
}
function timeForZone(zone) {
var compactRepresentationItem = plasmoid.compactRepresentationItem;
if (!compactRepresentationItem) {
return "";
}
// get the time for the given timezone from the dataengine
var now = dataSource.data[zone]["DateTime"];
// get current UTC time
var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000);
// add the dataengine TZ offset to it
var dateTime = new Date(msUTC + (dataSource.data[zone]["Offset"] * 1000));
var formattedTime = Qt.formatTime(dateTime, compactRepresentationItem.timeFormat);
if (dateTime.getDay() !== dataSource.data["Local"]["DateTime"].getDay()) {
formattedTime += " (" + Qt.formatDate(dateTime, compactRepresentationItem.dateFormat) + ")";
}
return formattedTime;
}
function nameForZone(zone) {
// add the timezone string to the clock
var timezoneString = plasmoid.configuration.displayTimezoneAsCode ? dataSource.data[zone]["Timezone Abbreviation"]
: TimezonesI18n.i18nCity(dataSource.data[zone]["Timezone City"]);
return timezoneString;
}
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
Plasmoid.compactRepresentation: DigitalClock { }
Plasmoid.fullRepresentation: CalendarView { }
......
Markdown is supported
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