@ -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
@ -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 ( )
{
/ / 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 ;
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
}
if ( doCorrections ) {
timeFormatCorrection ( main . timeFormat ) ;
}
}
Component.onCompleted: {
timeFormatCorrection ( Qt . locale ( ) . timeFormat ( Locale . ShortFormat ) )
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 ) ;
}
}