From d7ff36cb030fb6798d352998d645ab85c5d0fc62 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Sun, 19 Apr 2015 10:15:19 +0200 Subject: 4 time display modes for panel clock: timeonly (default): display time, date as tooltip dateonly : display date, time as tooltip datetime : display date first then time timedate : display time first then date LSession option: DateTimeOrder (no UI yet) --- lumina-desktop/panel-plugins/clock/LClock.cpp | 21 +++++++++++++++++---- lumina-desktop/panel-plugins/clock/LClock.h | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'lumina-desktop/panel-plugins') diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index 79cae84b..c3eb1451 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -38,10 +38,22 @@ void LClock::updateTime(){ if(useTZ){ CT = CT.toTimeZone(TZ); } //Now update the display QString label; - if(deftime){ label = CT.time().toString(Qt::SystemLocaleShortDate) ; } - else{ label=CT.toString(timefmt); } - if(defdate){ labelWidget->setToolTip(CT.date().toString(Qt::SystemLocaleLongDate)); } - else{ labelWidget->setToolTip(CT.toString(datefmt)); } + QString timelabel; + QString datelabel; + if(deftime){ timelabel = CT.time().toString(Qt::SystemLocaleShortDate) ; } + else{ timelabel=CT.toString(timefmt); } + if(defdate){ datelabel = CT.date().toString(Qt::SystemLocaleLongDate); } + else{ datelabel = CT.toString(datefmt); } + if(datetimeorder == "dateonly"){ + label = datelabel; + labelWidget->setToolTip(timelabel); + }else if(datetimeorder == "timedate"){ + label = timelabel + " " + datelabel; + }else if(datetimeorder == "datetime"){ + label = datelabel + " " + timelabel; + }else{ label = timelabel; + labelWidget->setToolTip(datelabel); + } if( this->layout()->direction() == QBoxLayout::TopToBottom ){ //different routine for vertical text (need newlines instead of spaces) label.replace(" ","\n"); @@ -54,6 +66,7 @@ void LClock::updateFormats(){ datefmt = LSession::handle()->sessionSettings()->value("DateFormat","").toString(); deftime = timefmt.simplified().isEmpty(); defdate = datefmt.simplified().isEmpty(); + datetimeorder = LSession::handle()->sessionSettings()->value("DateTimeOrder", "timeonly").toString(); useTZ = LSession::handle()->sessionSettings()->value("CustomTimeZone",false).toBool(); if(useTZ){ TZ = QTimeZone( LSession::handle()->sessionSettings()->value("TimeZoneByteCode", QByteArray()).toByteArray() ); } diff --git a/lumina-desktop/panel-plugins/clock/LClock.h b/lumina-desktop/panel-plugins/clock/LClock.h index 8156e7d8..31bf13d6 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.h +++ b/lumina-desktop/panel-plugins/clock/LClock.h @@ -26,7 +26,7 @@ public: private: QTimer *timer; QLabel *labelWidget; - QString timefmt, datefmt; + QString timefmt, datefmt, datetimeorder; bool deftime, defdate, useTZ; QTimeZone TZ; -- cgit