backport fix date/time display after timezone changes

one has to instruct the JS QML engine that the local timezone
changed (e.g. after editting it in kcm clock); keep track of the tzOffset
and do a recalc if it changes
wilder-5.14
Lukáš Tinkl 12 years ago
parent 0cb77e7d46
commit a52a6c44a2
  1. 27
      applets/digital-clock/package/contents/ui/DigitalClock.qml

@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import QtQuick 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as Components
@ -45,6 +45,7 @@ Item {
property bool showSeconds: plasmoid.configuration.showSeconds
property bool showTimezone: plasmoid.configuration.showTimezone
property string timeFormat
property int tzOffset
onShowSecondsChanged: {
timeFormatCorrection(Qt.locale().timeFormat(Locale.ShortFormat))
@ -147,11 +148,31 @@ Item {
timeFormatString = timeFormatString + " t";
}
main.timeFormat = timeFormatString;
}
function dateTimeChanged()
{
//console.log("Date/time changed!");
var doCorrections = false;
var currentTZOffset = dataSource.data["Local"]["Offset"] / 60;
if (currentTZOffset != tzOffset) {
doCorrections = true;
tzOffset = currentTZOffset;
//console.log("TZ offset changed: " + tzOffset);
Date.timeZoneUpdated(); // inform the QML JS engine about TZ change
}
if (doCorrections) {
timeFormatCorrection(main.timeFormat);
}
}
Component.onCompleted: {
timeFormatCorrection(Qt.locale().timeFormat(Locale.ShortFormat))
tzOffset = new Date().getTimezoneOffset();
//console.log("Initial TZ offset: " + tzOffset);
timeFormatCorrection(Qt.locale().timeFormat(Locale.ShortFormat));
dataSource.onDataChanged.connect(dateTimeChanged);
}
}

Loading…
Cancel
Save