diff options
author | lbartoletti <l.bartoletti@free.fr> | 2019-10-22 21:07:16 +0200 |
---|---|---|
committer | lbartoletti <l.bartoletti@free.fr> | 2019-10-22 21:07:16 +0200 |
commit | 7e07c3980607d8c6e394520ea2e5ea37cb8860b7 (patch) | |
tree | 7600ec29bfb937bcf2148a8a02772127fcd27013 /src-qt5/core | |
parent | fix lumina-screenshot/MainUI.cpp (diff) | |
download | lumina-7e07c3980607d8c6e394520ea2e5ea37cb8860b7.tar.gz lumina-7e07c3980607d8c6e394520ea2e5ea37cb8860b7.tar.bz2 lumina-7e07c3980607d8c6e394520ea2e5ea37cb8860b7.zip |
fontMetrics().width -> fontMetrics().horizontalAdvance
Diffstat (limited to 'src-qt5/core')
8 files changed, 15 insertions, 15 deletions
diff --git a/src-qt5/core/libLumina/obsolete/RootSubWindow.cpp b/src-qt5/core/libLumina/obsolete/RootSubWindow.cpp index 5040f2f9..dfc26516 100644 --- a/src-qt5/core/libLumina/obsolete/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/obsolete/RootSubWindow.cpp @@ -417,7 +417,7 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList if(vals[i].toSize().isValid()){ //Just larger than titlebar, with enough space for 8 characters in the titlebar (+4 buttons) //qDebug() << "Got invalid Min Size: Set a reasonable default minimum"; - WinWidget->setMinimumSize( QSize( this->fontMetrics().height()*4 + this->fontMetrics().width("O")*10, this->fontMetrics().height()*10) ); + WinWidget->setMinimumSize( QSize( this->fontMetrics().height()*4 + this->fontMetrics().horizontalAdvance("O")*10, this->fontMetrics().height()*10) ); WIN->setProperty(NativeWindow::MinSize, WinWidget->minimumSize()); }else{ WinWidget->setMinimumSize(vals[i].toSize()); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h index 95b6c1cb..6a33605c 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h @@ -33,8 +33,8 @@ private slots: //Note: This is horribly inefficient, but due to the inherently short length of textL it is acceptable int min = -1; int index = -1; for(int i=1; i<textL.length(); i++){ - int combined = button->fontMetrics().width(textL[i-1]+" "+textL[i]); - int tmp = button->fontMetrics().width(textL[i]); + int combined = button->fontMetrics().horizontalAdvance(textL[i-1]+" "+textL[i]); + int tmp = button->fontMetrics().horizontalAdvance(textL[i]); if( max>combined && (min<0 || tmp<min)){ min = tmp; index = i; } } if(index>0){ textL[index-1] = textL[index-1]+" "+textL[index]; textL.removeAt(index); } @@ -43,7 +43,7 @@ private slots: //Need to get a lot more complicated - need to break up sections mid-word based on widget width // NOT WORKING - can cause infinite loop somehow (perhaps max is 0 on init?) /*for(int i=0; i<textL.length(); i++){ - int tmp = button->fontMetrics().width(textL[i]); + int tmp = button->fontMetrics().horizontalAdvance(textL[i]); if(tmp>max){ //qDebug() << "CLOCK:" << i << tmp << max << textL[i]; QString tmps = button->fontMetrics().elidedText(textL[i], Qt::ElideRight, max).section("...",0,-2); //remove the three dots at end diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h index 6ba18b22..bdde5ba2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Text.h @@ -50,7 +50,7 @@ public: text->setFont(QFont("Courier", 24, QFont::Bold)); text->setText(display); QFontMetrics metrics(text->font()); - text->setMinimumSize(QSize( metrics.width(text->text())+10, metrics.height()*text->text().count("\n") +10)); + text->setMinimumSize(QSize( metrics.horizontalAdvance(text->text())+10, metrics.height()*text->text().count("\n") +10)); movement = new QPropertyAnimation(text); movement->setPropertyName("pos"); diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 88f535de..f954ec4f 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -168,7 +168,7 @@ void AppLauncherPlugin::loadButton(){ //Now adjust the visible text as necessary based on font/grid sizing if(button->toolTip().isEmpty()){ button->setToolTip(txt); } //Double check that the visual icon size matches the requested size - otherwise upscale the icon - if(button->fontMetrics().width(txt) > (button->width()-OUTMARGIN) ){ + if(button->fontMetrics().horizontalAdvance(txt) > (button->width()-OUTMARGIN) ){ //Text too long, try to show it on two lines //txt = button->fontMetrics().elidedText(txt, Qt::ElideRight, 2*(button->width()-OUTMARGIN), Qt::TextWordWrap); txt =txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks @@ -177,7 +177,7 @@ void AppLauncherPlugin::loadButton(){ //need to check each line QStringList txtL = txt.split("\n"); for(int i=0; i<txtL.length(); i++){ - if(( i+1<txtL.length()) && (button->fontMetrics().width(txtL[i]) < button->width()/2) ){ + if(( i+1<txtL.length()) && (button->fontMetrics().horizontalAdvance(txtL[i]) < button->width()/2) ){ txtL[i] = txtL[i]+" "+txtL[i+1]; txtL.removeAt(i+1); } diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h index 24410e75..0febe40f 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h @@ -76,13 +76,13 @@ protected: else{outC.setHsl(textC.hue(), textC.hslSaturation(), 255, 50); } //qDebug() << "Outline Color Values:" << outC; //Now get the size of the outline border (need to scale for high-res monitors) - qreal OWidth = opt.fontMetrics.width("o")/2.0; + qreal OWidth = opt.fontMetrics.horizontalAdvance("o")/2.0; //qDebug() << "Outline Width:" << OWidth; //Now generate a QPainterPath for the text QPainterPath path; QStringList txt = this->text().split("\n"); //need each line independently, the newline actually gets painted otherwise for(int i=0; i<txt.length(); i++){ - path.addText(box.center().x() - (opt.fontMetrics.width(txt[i])/2), box.y()+((i+1)*(box.height()/txt.length()))-opt.fontMetrics.descent(), opt.font, txt[i] ); + path.addText(box.center().x() - (opt.fontMetrics.horizontalAdvance(txt[i])/2), box.y()+((i+1)*(box.height()/txt.length()))-opt.fontMetrics.descent(), opt.font, txt[i] ); } path.setFillRule(Qt::WindingFill); //Now paint the text diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index 90f3374b..6f4d62d6 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -180,8 +180,8 @@ void DesktopViewPlugin::updateContents(){ } //Now adjust the visible text as necessary based on font/grid sizing it->setToolTip(txt); - if(this->fontMetrics().width(txt) > (gridSZ.width()-4) ){ - //int dash = this->fontMetrics().width("-"); + if(this->fontMetrics().horizontalAdvance(txt) > (gridSZ.width()-4) ){ + //int dash = this->fontMetrics().horizontalAdvance("-"); //Text too long, try to show it on two lines txt = txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks if(txt.contains("\n")){ 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 2972ea86..d45853d1 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -79,7 +79,7 @@ void LClock::updateTime(bool adjustformat){ 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++){ - if(this->size().width() < (this->fontMetrics().width(label.section("\n",i,i))+10 )&& label.section("\n",i,i).contains(" ")){ + if(this->size().width() < (this->fontMetrics().horizontalAdvance(label.section("\n",i,i))+10 )&& label.section("\n",i,i).contains(" ")){ label.replace(label.section("\n",i,i), label.section("\n",i,i).replace(" ", "\n")); i--; } @@ -100,12 +100,12 @@ void LClock::updateTime(bool adjustformat){ int wid = 0; int lwid = 0; for(int i=0; i<lines.length(); i++){ - lwid = metrics.width(lines[i]); + lwid = metrics.horizontalAdvance(lines[i]); if(lwid>wid){ wid = lwid; } } qDebug() << "Verify Clock width:" << lines.length() << wid << lines; this->setMinimumWidth(wid); - this->setMaximumWidth(wid + (4*metrics.width("O"))); + this->setMaximumWidth(wid + (4*metrics.horizontalAdvance("O"))); }else{ //vertical layout this->setMinimumHeight(metrics.lineSpacing() * lines.length()); diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index 5acd9721..49fdeeaf 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -30,7 +30,7 @@ LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizon connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); QRect screenSize = QApplication::desktop()->availableGeometry(this); - QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize",QSize(this->fontMetrics().width("x")*30 ,screenSize.height()/1.8)).toSize(); + QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize",QSize(this->fontMetrics().horizontalAdvance("x")*30 ,screenSize.height()/1.8)).toSize(); //qDebug() << "Got Start Menu Saved Size:" << saved; if(!saved.isNull() && saved.isValid()){ startmenu->setFixedSize(saved); } //re-load the previously saved value menu->setContents(startmenu); |