diff options
author | Ken Moore <ken@pcbsd.org> | 2015-02-17 15:30:57 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-02-17 15:30:57 -0500 |
commit | e61ae03e13b44295c966e135c720d8bca9457946 (patch) | |
tree | 8a97b937793a781b6d2829ce72d11c026125888e /lumina-desktop/panel-plugins | |
parent | Clean up how the lumina-desktop closes down: (diff) | |
download | lumina-e61ae03e13b44295c966e135c720d8bca9457946.tar.gz lumina-e61ae03e13b44295c966e135c720d8bca9457946.tar.bz2 lumina-e61ae03e13b44295c966e135c720d8bca9457946.zip |
Have the clock panel plugin try to use vertical space rather than horizontal if the panel is vertical.
Diffstat (limited to 'lumina-desktop/panel-plugins')
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 25 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.h | 7 |
2 files changed, 21 insertions, 11 deletions
diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index e66d83c2..e91a3a71 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -10,10 +10,12 @@ LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ //Setup the widget - label = new QLabel(this); - label->setAlignment(Qt::AlignCenter); + labelWidget = new QLabel(this); + labelWidget->setAlignment(Qt::AlignCenter); + labelWidget->setStyleSheet("font-weight: bold;"); + labelWidget->setWordWrap(true); this->layout()->setContentsMargins(3,0,3,0); //reserve some space on left/right - this->layout()->addWidget(label); + this->layout()->addWidget(labelWidget); //Setup the timer timer = new QTimer(); @@ -34,10 +36,16 @@ LClock::~LClock(){ void LClock::updateTime(){ QDateTime CT = QDateTime::currentDateTime(); //Now update the display - 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)); } + 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)); } + if( this->layout()->direction() == QBoxLayout::TopToBottom ){ + //different routine for vertical text (need newlines instead of spaces) + label.replace(" ","\n"); + } + labelWidget->setText(label); } void LClock::updateFormats(){ @@ -45,4 +53,5 @@ void LClock::updateFormats(){ 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 8f7e38eb..1e4c8294 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.h +++ b/lumina-desktop/panel-plugins/clock/LClock.h @@ -24,14 +24,15 @@ public: private: QTimer *timer; - QLabel *label; + QLabel *labelWidget; QString timefmt, datefmt; bool deftime, defdate; - + private slots: void updateTime(); void updateFormats(); - + + }; #endif |