[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/nowplaying
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-12-29 12:29:02
Message-ID: 1230553742.560489.11014.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 902838 by mart:

elide long labels in the middle
BUG:179011


 M  +8 -3      infopanel.cpp  


--- trunk/KDE/kdeplasma-addons/applets/nowplaying/infopanel.cpp #902837:902838
@@ -19,6 +19,7 @@
 #include "infopanel.h"
 
 #include <Plasma/Label>
+#include <Plasma/Theme>
 
 #include <QGraphicsGridLayout>
 #include <QLabel>
@@ -73,9 +74,13 @@
 
 void InfoPanel::updateLabels()
 {
-    m_artistText->setText(m_metadata["Artist"]);
-    m_albumText->setText(m_metadata["Album"]);
-    m_titleText->setText(m_metadata["Title"]);
+    Plasma::Theme *theme = Plasma::Theme::defaultTheme();
+    QFont font = theme->font(Plasma::Theme::DefaultFont);
+    QFontMetricsF fm(font);
+
+    m_artistText->setText(fm.elidedText(m_metadata["Artist"], Qt::ElideMiddle, \
m_artistText->size().width())); +    \
m_albumText->setText(fm.elidedText(m_metadata["Album"], Qt::ElideMiddle, \
m_artistText->size().width())); +    \
m_titleText->setText(fm.elidedText(m_metadata["Title"], Qt::ElideMiddle, \
m_artistText->size().width()));  m_timeText->setText(m_metadata["Time"]);
 
     // dirty hack to make sure the Artist: label is in line


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic