From 2095ffee98a4376e16036f395d173ba674570626 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 14 Aug 2017 16:47:22 -0400 Subject: Fix the clock width detection/setting. Had a typo in the delimiter.... --- .../core/lumina-desktop/panel-plugins/clock/LClock.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src-qt5/core/lumina-desktop') 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 db661841..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; isize().height() < 2*this->fontMetrics().height() ){ + }else if( this->size().height() < lines.length()*this->fontMetrics().height() ){ label.replace("\n",", "); } if(adjustformat){ @@ -92,16 +93,17 @@ 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; iwid){ wid = lwid; } } + qDebug() << "Verify Clock width:" << lines.length() << wid << lines; this->setMinimumWidth(wid); this->setMaximumWidth(wid + (4*metrics.width("O"))); }else{ -- cgit