I'm using the IconWidget in the networkmanager plasmoid and in the battery plasmoid. In both cases in horizontal layout, see the list of wlans, and the sleep/hibernate/more buttons in the battery: http://imagebin.ca/view/owpmlw3q.html
In the wlan list in the nm plasmoid, I would want the essids left aligned to the wifi icon, the hit area stretches up to the meter on the right. The text is centered on the buttons, making the buttons that don't have a background by default look disconnected from the icons, and nice alignment in cases like the list of wlans pretty much impossible. (Or?) I've tried to make the text left aligned in the iconwidget, but didn't quite succeed. The left nm popup in the screenshot is without attached patch, right nm popup is with this patch. As you can see, if does have effect, but the text looks still centered, and not left aligned. I'm not completely grokking the layouting code in iconwidget.cpp, maybe someone can have a look at it? Thanks, -- sebas http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9
Index: iconwidget.cpp =================================================================== --- iconwidget.cpp (revision 884327) +++ iconwidget.cpp (working copy) @@ -800,7 +800,9 @@ QFontMetricsF fm(labelLayout->font()); const QRectF textArea = labelRectangle(option, icon, text); QRectF textRect = subtractMargin(textArea, IconWidgetPrivate::TextMargin); - + if (orientation == Qt::Horizontal) { + textRect.moveTopLeft(QPoint(0,0)); + } //kDebug() << this << "text area" << textArea << "text rect" << textRect; // Sizes and constraints for the different text parts QSizeF maxLabelSize = textRect.size(); @@ -829,6 +831,9 @@ infoSize = QSizeF(0, 0); } // Compute the bounding rect of the text + if (orientation == Qt::Horizontal) { + labelLayout->textOption().setAlignment(Qt::AlignLeft);; + } const Qt::Alignment alignment = labelLayout->textOption().alignment(); const QSizeF size(qMax(labelSize.width(), infoSize.width()), labelSize.height() + infoSize.height()); @@ -838,7 +843,7 @@ // Compute the positions where we should draw the layouts labelLayout->setPosition(QPointF(textRect.x(), textBoundingRect->y())); infoLayout->setPosition(QPointF(textRect.x(), textBoundingRect->y() + labelSize.height())); - //kDebug() << "final position is" << labelLayout->position(); + kDebug() << "final position is" << labelLayout->position(); } QBrush IconWidgetPrivate::foregroundBrush(const QStyleOptionGraphicsItem *option) const
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel