diff options
author | Kris Moore <kris@pcbsd.org> | 2014-09-04 11:42:13 -0400 |
---|---|---|
committer | Kris Moore <kris@pcbsd.org> | 2014-09-04 11:42:13 -0400 |
commit | 71737f70949bd25f9aa8bc4e7d03039ba83c6cb1 (patch) | |
tree | ab29e864d1ae59d10cc6875af9541e3ad306b2fb /lumina-desktop/panel-plugins/clock/LClock.cpp | |
parent | Initial commit (diff) | |
download | lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.gz lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.bz2 lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.zip |
Initial import of the lumina code from pcbsd git repo
Diffstat (limited to 'lumina-desktop/panel-plugins/clock/LClock.cpp')
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp new file mode 100644 index 00000000..a61eb75d --- /dev/null +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -0,0 +1,35 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2012, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LClock.h" + +LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ + //Setup the widget + label = new QLabel(this); + label->setAlignment(Qt::AlignCenter); + this->layout()->setContentsMargins(3,0,3,0); //reserve some space on left/right + this->layout()->addWidget(label); + + //Setup the timer + timer = new QTimer(); + timer->setInterval(1000); //update once a second + connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); + updateTime(); + timer->start(); +} + +LClock::~LClock(){ + timer->stop(); + 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())); +} |