diff options
Diffstat (limited to 'lumina-desktop/panel-plugins')
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 23 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.h | 5 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index a61eb75d..e66d83c2 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -6,6 +6,8 @@ //=========================================== #include "LClock.h" +#include "LSession.h" + LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ //Setup the widget label = new QLabel(this); @@ -15,9 +17,11 @@ LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, //Setup the timer timer = new QTimer(); - timer->setInterval(1000); //update once a second - connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); + timer->setInterval(1000); //update once a second + updateFormats(); updateTime(); + connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); + connect(QApplication::instance(), SIGNAL(SessionConfigChanged()), this, SLOT(updateFormats()) ); timer->start(); } @@ -26,10 +30,19 @@ LClock::~LClock(){ delete timer; } + void LClock::updateTime(){ QDateTime CT = QDateTime::currentDateTime(); //Now update the display - QLocale sys = QLocale::system(); - label->setText( "<b>"+CT.toString(sys.timeFormat(QLocale::ShortFormat))+"</b>" ); - label->setToolTip(CT.toString(sys.dateFormat())); + if(deftime){ label->setText( "<b>"+CT.time().toString(Qt::SystemLocaleShortDate)+"</b>" ); } + else{ label->setText( "<b>"+CT.toString(timefmt)+"</b>" ); } + if(defdate){ label->setToolTip(CT.date().toString(Qt::SystemLocaleLongDate)); } + else{ label->setToolTip(CT.toString(datefmt)); } } + +void LClock::updateFormats(){ + timefmt = LSession::handle()->sessionSettings()->value("TimeFormat","").toString(); + datefmt = LSession::handle()->sessionSettings()->value("DateFormat","").toString(); + deftime = timefmt.simplified().isEmpty(); + defdate = datefmt.simplified().isEmpty(); +}
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/clock/LClock.h b/lumina-desktop/panel-plugins/clock/LClock.h index d4de917c..8f7e38eb 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.h +++ b/lumina-desktop/panel-plugins/clock/LClock.h @@ -25,9 +25,12 @@ public: private: QTimer *timer; QLabel *label; - + QString timefmt, datefmt; + bool deftime, defdate; + private slots: void updateTime(); + void updateFormats(); }; |