align text to the left when the icon is horizontal
svn path=/trunk/KDE/kdelibs/; revision=923738
This commit is contained in:
parent
3685f819cc
commit
501b3bfe1c
@ -466,7 +466,7 @@ QSizeF IconWidgetPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option
|
||||
}
|
||||
|
||||
QTextLayout layout;
|
||||
setLayoutOptions(layout, option);
|
||||
setLayoutOptions(layout, option, q->orientation());
|
||||
QSizeF size = layoutText(layout, option, label, QSizeF(textWidth, maxHeight));
|
||||
|
||||
return addMargin(size, TextMargin);
|
||||
@ -815,7 +815,7 @@ void IconWidgetPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
||||
{
|
||||
bool showInformation = false;
|
||||
|
||||
setLayoutOptions(*labelLayout, option);
|
||||
setLayoutOptions(*labelLayout, option, q->orientation());
|
||||
|
||||
QFontMetricsF fm(labelLayout->font());
|
||||
const QRectF textArea = labelRectangle(option, icon, text);
|
||||
@ -950,6 +950,8 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
// Draw text last because it is overlayed
|
||||
QTextLayout labelLayout, infoLayout;
|
||||
QRectF textBoundingRect;
|
||||
|
||||
|
||||
d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &textBoundingRect);
|
||||
|
||||
QImage shadow(textBoundingRect.size().toSize() + QSize(4, 4),
|
||||
|
@ -141,7 +141,8 @@ public:
|
||||
QTextLayout *infoLayout, QRectF *textBoundingRect) const;
|
||||
|
||||
inline void setLayoutOptions(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *options) const;
|
||||
const QStyleOptionGraphicsItem *options,
|
||||
const Qt::Orientation orientation) const;
|
||||
|
||||
inline Qt::LayoutDirection iconDirection(const QStyleOptionGraphicsItem *option) const;
|
||||
|
||||
@ -226,11 +227,17 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(IconWidgetPrivate::IconWidgetStates)
|
||||
|
||||
// Inline methods
|
||||
void IconWidgetPrivate::setLayoutOptions(QTextLayout &layout,
|
||||
const QStyleOptionGraphicsItem *option) const
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
const Qt::Orientation orientation) const
|
||||
{
|
||||
QTextOption textoption;
|
||||
textoption.setTextDirection(option->direction);
|
||||
textoption.setAlignment(Qt::AlignCenter); // NOTE: assumption
|
||||
if (orientation == Qt::Horizontal) {
|
||||
textoption.setAlignment(Qt::Alignment(Qt::AlignLeft|Qt::AlignVCenter));
|
||||
} else {
|
||||
textoption.setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
textoption.setWrapMode(QTextOption::WordWrap); // NOTE: assumption as well
|
||||
|
||||
layout.setFont(QApplication::font()); // NOTE: find better ways to get the font
|
||||
|
Loading…
Reference in New Issue
Block a user