diff --git a/autotests/ksqueezedtextlabelautotest.cpp b/autotests/ksqueezedtextlabelautotest.cpp --- a/autotests/ksqueezedtextlabelautotest.cpp +++ b/autotests/ksqueezedtextlabelautotest.cpp @@ -224,7 +224,6 @@ QVERIFY(!label->isSqueezed()); label->setProperty(attribute.toLatin1().data(), amount); - QTest::qWaitForWindowExposed(label.data()); QVERIFY(label->isSqueezed()); diff --git a/src/ksqueezedtextlabel.h b/src/ksqueezedtextlabel.h --- a/src/ksqueezedtextlabel.h +++ b/src/ksqueezedtextlabel.h @@ -71,6 +71,8 @@ { Q_OBJECT Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode) + Q_PROPERTY(int indent READ indent WRITE setIndent) + Q_PROPERTY(int margin READ margin WRITE setMargin) public: /** @@ -100,6 +102,36 @@ */ QSize sizeHint() const Q_DECL_OVERRIDE; + /** + * Sets the indentation of the label. + * + * @param indent the amount of indentation in pixels + * + * Reimplementation of QLabel::setIndent(). + * + * @warning The corresponding function in the base class is not virtual. + * Therefore make sure to call this function on objects of type KSqueezedTextLabel, + * as shown in the @ref non-virtual-warning "example in the class description". + * + * @since 5.39 + */ + void setIndent(int indent); + + /** + * Sets the margin of the label. + * + * @param margin the margin size in pixels + * + * Reimplementation of QLabel::setMargin(). + * + * @warning The corresponding function in the base class is not virtual. + * Therefore make sure to call this function on objects of type KSqueezedTextLabel, + * as shown in the @ref non-virtual-warning "example in the class description". + * + * @since 5.39 + */ + void setMargin(int margin); + /** * Overridden for internal reasons; the API remains unaffected. */ diff --git a/src/ksqueezedtextlabel.cpp b/src/ksqueezedtextlabel.cpp --- a/src/ksqueezedtextlabel.cpp +++ b/src/ksqueezedtextlabel.cpp @@ -86,6 +86,18 @@ return QSize(textWidth + chromeWidth, QLabel::sizeHint().height()); } +void KSqueezedTextLabel::setIndent(int indent) +{ + QLabel::setIndent(indent); + squeezeTextToLabel(); +} + +void KSqueezedTextLabel::setMargin(int margin) +{ + QLabel::setMargin(margin); + squeezeTextToLabel(); +} + void KSqueezedTextLabel::setText(const QString &text) { d->fullText = text;