This patch is also on reviewboard but anonsvn is down and therefor reviewboard 
doesn't work.

While I was updating the kuiserver applet to use the new progress-bar design I 
suddenly had the need to obtain the size of a label in the progress-bar svg. 
JobWidget displays the filename elided ("file://home/...ample.png") and for 
this to work the width of the label is needed. This patch is pretty 
straightforward, but I didn't want to add something to public api without 
approval from other members of the plasma team.
The new progress-bar look is very lovely btw. Only thing left to be done is 
merge this applet into systemtray...

Regards,
Rob
Index: widgets/meter.cpp
===================================================================
--- widgets/meter.cpp	(revision 880023)
+++ widgets/meter.cpp	(working copy)
@@ -268,6 +268,18 @@
     return d->fonts[index];
 }
 
+QSizeF Meter::labelSize(int index) const
+{
+    QString elementID = QString("label%1").arg(index);
+
+    if (d->image->hasElement(elementID)) {
+        QRectF elementRect = d->image->elementRect(elementID);
+        return elementRect.size();
+    } else {
+        return QSizeF(0, 0);
+    }
+}
+
 void Meter::setLabelAlignment(int index, Qt::Alignment alignment)
 {
     while (d->alignments.count() <= index) {
Index: widgets/meter.h
===================================================================
--- widgets/meter.h	(revision 880023)
+++ widgets/meter.h	(working copy)
@@ -189,6 +189,12 @@
      */
     Qt::Alignment labelAlignment(int index) const;
 
+    /**
+     * @param index label index
+     * @return the size of this label.
+     */
+    QSizeF labelSize(int index) const;
+
 public Q_SLOTS:
     /**
      * Used when connecting to a DataEngine
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to