diff options
author | Weblate <noreply@weblate.org> | 2017-08-17 16:02:53 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2017-08-17 16:02:53 +0000 |
commit | e22937e90e6be7820e11cc9eba47bd0fb1b394e9 (patch) | |
tree | bb65904fd9aeee5e6325d12675e10f58cee25b80 /src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp | |
parent | Translated using Weblate (Spanish) (diff) | |
parent | Merge remote-tracking branch 'origin/master' (diff) | |
download | lumina-e22937e90e6be7820e11cc9eba47bd0fb1b394e9.tar.gz lumina-e22937e90e6be7820e11cc9eba47bd0fb1b394e9.tar.bz2 lumina-e22937e90e6be7820e11cc9eba47bd0fb1b394e9.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp index bdf9b27e..2972ea86 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -25,14 +25,14 @@ LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, calAct->setDefaultWidget(calendar); TZMenu = new QMenu(this); connect(TZMenu, SIGNAL(triggered(QAction*)), this, SLOT(ChangeTZ(QAction*)) ); - + //Now assemble the menu button->menu()->addAction(calAct); button->menu()->addMenu(TZMenu); - + this->layout()->setContentsMargins(0,0,0,0); //reserve some space on left/right this->layout()->addWidget(button); - + //Setup the timer timer = new QTimer(); //Load all the initial settings @@ -71,10 +71,11 @@ void LClock::updateTime(bool adjustformat){ }else if(datetimeorder == "datetime"){ label = datelabel + "\n" + timelabel; button->setToolTip(""); - }else{ + }else{ label = timelabel; button->setToolTip(datelabel); } + QStringList lines = label.split("\n"); if( this->layout()->direction() == QBoxLayout::TopToBottom ){ //different routine for vertical text (need newlines instead of spaces) for(int i=0; i<label.count("\n")+1; i++){ @@ -84,7 +85,7 @@ void LClock::updateTime(bool adjustformat){ } } //label.replace(" ","\n"); - }else if( this->size().height() < 2*this->fontMetrics().height() ){ + }else if( this->size().height() < lines.length()*this->fontMetrics().height() ){ label.replace("\n",", "); } if(adjustformat){ @@ -92,17 +93,18 @@ void LClock::updateTime(bool adjustformat){ font.setBold(true); button->setFont(font); //Check the font/spacing for the display and adjust as necessary - QStringList lines = label.split("/n"); + QStringList lines = label.split("\n"); QFontMetrics metrics(font); if(this->layout()->direction()==QBoxLayout::LeftToRight){ //horizontal layout int wid = 0; - int lwid; + int lwid = 0; for(int i=0; i<lines.length(); i++){ lwid = metrics.width(lines[i]); if(lwid>wid){ wid = lwid; } } - this->setMinimumWidth( wid - (4*metrics.width("O")) ); + qDebug() << "Verify Clock width:" << lines.length() << wid << lines; + this->setMinimumWidth(wid); this->setMaximumWidth(wid + (4*metrics.width("O"))); }else{ //vertical layout |