aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-05-01 09:30:43 -0400
committerKen Moore <ken@ixsystems.com>2017-05-01 09:30:43 -0400
commit58779ad78cf80423c8cf207fc72295b302fb2035 (patch)
treedb98c5847f976a95466052e8304a6a917e16cb01 /src-qt5
parentMake sure the cut/delete options for desktop icons are still possible if the ... (diff)
downloadlumina-58779ad78cf80423c8cf207fc72295b302fb2035.tar.gz
lumina-58779ad78cf80423c8cf207fc72295b302fb2035.tar.bz2
lumina-58779ad78cf80423c8cf207fc72295b302fb2035.zip
Fix up the auto-resizing of the clock on the panel when changing the date/time formats.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp22
1 files changed, 9 insertions, 13 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 b370c536..c96d0c45 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp
@@ -89,23 +89,19 @@ void LClock::updateTime(bool adjustformat){
}
if(adjustformat){
//Check the font/spacing for the display and adjust as necessary
- /*double efflines = label.count("\n")+1; //effective lines (with wordwrap)
- if( (button->fontMetrics().height()*efflines) > button->height() ){
- //Force a pixel metric font size to fit everything
- int szH = qRound( (button->height() - button->fontMetrics().lineSpacing() )/efflines );
- //Need to supply a *width* pixel, not a height metric
- int szW = qRound( (szH*button->fontMetrics().maxWidth())/( (double) button->fontMetrics().height()) );
- qDebug() << "Change Clock font:" << button->height() << szH << szW << efflines << button->fontMetrics().height() << button->fontMetrics().lineSpacing();
- button->setStyleSheet("font-weight: bold; font-size: "+QString::number(szW)+"px;");
- }else{
- button->setStyleSheet("font-weight: bold;");
- }*/
+ QStringList lines = label.split("/n");
if(this->layout()->direction()==QBoxLayout::LeftToRight){
//horizontal layout
- this->setFixedWidth( this->sizeHint().width() +6);
+ int wid = 0;
+ int lwid;
+ for(int i=0; i<lines.length(); i++){
+ int lwid = button->fontMetrics().width(lines[i]);
+ if(lwid>wid){ wid = lwid; }
+ }
+ this->setFixedWidth( wid );
}else{
//vertical layout
- this->setMaximumWidth(100000);
+ this->setMaximumWidth(button->fontMetrics().lineSpacing() * lines.length());
}
}
button->setText(label);
bgstack15