QCommandLinkButton: Don't reset icon on change to QStyleSheetStyle
d4c518b210ad56cb51c17e6e1b4a81b0deb7253c has implemented a reset of the icon on a style change. This has caused a regression, because it overrode an icon set by a style sheet. Do not reset the icon if the new style is a QStyleSheetStyle. Amdends d4c518b210ad56cb51c17e6e1b4a81b0deb7253c. Fixes: QTBUG-137011 Pick-to: 6.10 6.9 6.8 Change-Id: Ib77faa03c867b2660a45bdc3ab94e7d739eed4f8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
2e0dc22bdb
commit
839d569dc2
@ -11,6 +11,7 @@
|
|||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
#include "private/qpushbutton_p.h"
|
#include "private/qpushbutton_p.h"
|
||||||
|
#include "private/qstylesheetstyle_p.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -277,9 +278,18 @@ QCommandLinkButton::~QCommandLinkButton()
|
|||||||
bool QCommandLinkButton::event(QEvent *e)
|
bool QCommandLinkButton::event(QEvent *e)
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::StyleChange) {
|
if (e->type() == QEvent::StyleChange) {
|
||||||
QStyleOptionButton opt;
|
// If the new style is a QStyleSheetStyle, don't reset the icon, because:
|
||||||
initStyleOption(&opt);
|
// - either it has been explicitly set, in which case we want to keep it.
|
||||||
setIcon(style()->standardIcon(QStyle::SP_CommandLink, &opt, this));
|
// - or it has been initialised by the previous style, which is now the base style,
|
||||||
|
// in which case we want to keep it as well.
|
||||||
|
// - or it has been set in the style sheet, in which case we don't want to override it here.
|
||||||
|
// When a style sheet with an icon is replaced by one without an icon, the old icon
|
||||||
|
// will be reset, when baseStyle()->repolish() is called.
|
||||||
|
if (!qobject_cast<QStyleSheetStyle *>(style())) {
|
||||||
|
QStyleOptionButton opt;
|
||||||
|
initStyleOption(&opt);
|
||||||
|
setIcon(style()->standardIcon(QStyle::SP_CommandLink, &opt, this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPushButton::event(e);
|
return QPushButton::event(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user