diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins')
-rw-r--r-- | src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp | 16 |
1 files changed, 9 insertions, 7 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 7c059844..bdf9b27e 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -88,24 +88,26 @@ void LClock::updateTime(bool adjustformat){ label.replace("\n",", "); } if(adjustformat){ + QFont font = LSession::handle()->font(); + font.setBold(true); + button->setFont(font); //Check the font/spacing for the display and adjust as necessary QStringList lines = label.split("/n"); + QFontMetrics metrics(font); if(this->layout()->direction()==QBoxLayout::LeftToRight){ //horizontal layout int wid = 0; int lwid; for(int i=0; i<lines.length(); i++){ - lwid = button->fontMetrics().width(lines[i]); + lwid = metrics.width(lines[i]); if(lwid>wid){ wid = lwid; } } - if(lines.length()==1){ wid+=6; } //need some extra margins for single-line - else{ wid-=6; } // need to remove some margins for multi-line - this->setMinimumWidth( wid - (4*button->fontMetrics().width("O")) ); - this->setMaximumWidth(wid + (4*button->fontMetrics().width("O"))); + this->setMinimumWidth( wid - (4*metrics.width("O")) ); + this->setMaximumWidth(wid + (4*metrics.width("O"))); }else{ //vertical layout - this->setMinimumHeight(button->fontMetrics().lineSpacing() * lines.length()); - this->setMaximumHeight( (lines.length()+4)*button->fontMetrics().height() ); + this->setMinimumHeight(metrics.lineSpacing() * lines.length()); + this->setMaximumHeight( (lines.length()+4)*metrics.height() ); } } button->setText(label); |