@ -18,7 +18,7 @@
* along with this program . If not , see < http: / / w w w . g n u . o r g / l i c e n s e s / > .
* /
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
@ -50,6 +50,7 @@ Item {
Locale . NarrowFormat
property string lastDate: ""
property string timeFormat
property int tzOffset
onShowSecondsChanged: {
timeFormatCorrection ( Qt . locale ( ) . timeFormat ( Locale . ShortFormat ) )
@ -156,26 +157,40 @@ Item {
timeFormatString = timeFormatString + " t" ;
}
main . timeFormat = timeFormatString ;
}
function dateTimeChanged ( )
{
if ( ! main . showDate ) {
return ;
/ / c o n s o l e . l o g ( " D a t e / t i m e c h a n g e d ! " ) ;
var doCorrections = false ;
if ( main . showDate ) {
/ / I f t h e d a t e h a s c h a n g e d , f o r c e s i z e r e c a l c u l a t i o n , b e c a u s e t h e d a y n a m e
/ / o r t h e m o n t h n a m e c a n n o w b e l o n g e r / s h o r t e r , s o w e n e e d t o a d j u s t a p p l e t s i z e
var currentDate = Qt . formatDateTime ( dataSource . data [ "Local" ] [ "DateTime" ] , "yyyy-mm-dd" ) ;
if ( main . lastDate != currentDate ) {
doCorrections = true ;
main . lastDate = currentDate
}
}
var currentTZOffset = dataSource . data [ "Local" ] [ "Offset" ] / 60 ;
if ( currentTZOffset != tzOffset ) {
doCorrections = true ;
tzOffset = currentTZOffset ;
/ / c o n s o l e . l o g ( " T Z o f f s e t c h a n g e d : " + t z O f f s e t ) ;
Date . timeZoneUpdated ( ) ; / / i n f o r m t h e Q M L J S e n g i n e a b o u t T Z c h a n g e
}
/ / I f t h e d a t e h a s c h a n g e d , f o r c e s i z e r e c a l c u l a t i o n , b e c a u s e t h e d a y n a m e
/ / o r t h e m o n t h n a m e c a n n o w b e l o n g e r / s h o r t e r , s o w e n e e d t o a d j u s t a p p l e t s i z e
var currentDate = Qt . formatDateTime ( dataSource . data [ "Local" ] [ "DateTime" ] , "yyyy-mm-dd" ) ;
if ( main . lastDate != currentDate ) {
if ( doCorrections ) {
timeFormatCorrection ( main . timeFormat ) ;
main . lastDate = currentDate
}
}
Component.onCompleted: {
tzOffset = new Date ( ) . getTimezoneOffset ( ) ;
/ / c o n s o l e . l o g ( " I n i t i a l T Z o f f s e t : " + t z O f f s e t ) ;
timeFormatCorrection ( Qt . locale ( ) . timeFormat ( Locale . ShortFormat ) )
dataSource . onDataChanged . connect ( dateTimeChanged ) ;
}