diff --git a/src/ktitlewidget.h b/src/ktitlewidget.h --- a/src/ktitlewidget.h +++ b/src/ktitlewidget.h @@ -171,6 +171,14 @@ */ void setComment(const QString &comment, MessageType type = PlainMessage); + /** + * Set the icon to display in the header. + * @param icon the icon to display in the header. + * @param alignment alignment of the icon (default is right aligned). + * @since 5.63 + */ + void setIcon(const QIcon &icon, ImageAlignment alignment = ImageRight); + /** * @param pixmap Pixmap displayed in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. @@ -182,15 +190,17 @@ * @param icon name of the icon to display in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() + * @deprecated since 5.63 use setIcon() instead */ - void setPixmap(const QString &icon, ImageAlignment alignment = ImageRight); + KWIDGETSADDONS_DEPRECATED void setPixmap(const QString &icon, ImageAlignment alignment = ImageRight); /** * @param icon the icon to display in the header. The pixmap is by default right, but * @param alignment can be used to display it also left. * @see pixmap() + * @deprecated since 5.63 use setIcon() instead */ - void setPixmap(const QIcon &icon, ImageAlignment alignment = ImageRight); + KWIDGETSADDONS_DEPRECATED void setPixmap(const QIcon &icon, ImageAlignment alignment = ImageRight); /** * @param type the type of message icon to display in the header. The pixmap is by default right, but diff --git a/src/ktitlewidget.cpp b/src/ktitlewidget.cpp --- a/src/ktitlewidget.cpp +++ b/src/ktitlewidget.cpp @@ -262,6 +262,11 @@ show(); } +void KTitleWidget::setIcon(const QIcon &icon, KTitleWidget::ImageAlignment alignment) +{ + setPixmap(icon.pixmap(style()->pixelMetric(QStyle::PM_MessageBoxIconSize)), alignment); +} + void KTitleWidget::setPixmap(const QPixmap &pixmap, ImageAlignment alignment) { d->imageLabel->setVisible(!pixmap.isNull()); @@ -290,17 +295,17 @@ void KTitleWidget::setPixmap(const QString &icon, ImageAlignment alignment) { - setPixmap(QIcon::fromTheme(icon), alignment); + setIcon(QIcon::fromTheme(icon), alignment); } void KTitleWidget::setPixmap(const QIcon &icon, ImageAlignment alignment) { - setPixmap(icon.pixmap(style()->pixelMetric(QStyle::PM_MessageBoxIconSize)), alignment); + setIcon(icon, alignment); } void KTitleWidget::setPixmap(MessageType type, ImageAlignment alignment) { - setPixmap(QIcon::fromTheme(d->iconTypeToIconName(type)), alignment); + setIcon(QIcon::fromTheme(d->iconTypeToIconName(type)), alignment); } int KTitleWidget::autoHideTimeout() const