Widgets/Stylesheets: Remove double negations for stylehseet feature

Replace ifndef QT_NO_STYLE_STYLESHEET antipattern by
if QT_CONFIG(style_stylesheet).

Pick-to: 6.9
Task-number: QTBUG-136341
Change-Id: I8f5d5ff0b7b5cce010df167977214bc92a9443b7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Christian Ehrlicher 2025-04-29 20:53:23 +02:00
parent e19607611c
commit a1612886ba
5 changed files with 25 additions and 25 deletions

View File

@ -316,7 +316,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
void qt_init_tooltip_palette();
QStyle *QApplicationPrivate::app_style = nullptr; // default application style
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr;
@ -385,7 +385,7 @@ void QApplicationPrivate::process_cmdline()
++arg;
if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
// obsolete argument
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
} else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
styleSheet = "file:///"_L1;
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
@ -878,7 +878,7 @@ bool QApplication::autoSipEnabled() const
return QApplicationPrivate::autoSipEnabled;
}
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
QString QApplication::styleSheet() const
{
@ -938,7 +938,7 @@ QStyle *QApplication::style()
QGuiApplicationPrivate::updatePalette();
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (!QApplicationPrivate::styleSheet.isEmpty()) {
qApp->setStyleSheet(QApplicationPrivate::styleSheet);
} else
@ -996,7 +996,7 @@ void QApplication::setStyle(QStyle *style)
QStyle *old = QApplicationPrivate::app_style; // save
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (!QApplicationPrivate::styleSheet.isEmpty() && !qt_styleSheet(style)) {
// we have a stylesheet already and a new style is being set
QStyleSheetStyle *newStyleSheetStyle = new QStyleSheetStyle(style);
@ -1029,7 +1029,7 @@ void QApplication::setStyle(QStyle *style)
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
if (w->style() == QApplicationPrivate::app_style)
QApplicationPrivate::app_style->polish(w); // repolish
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
else
w->setStyleSheet(w->styleSheet()); // touch
#endif
@ -1046,7 +1046,7 @@ void QApplication::setStyle(QStyle *style)
}
}
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle *oldStyleSheetStyle = qt_styleSheet(old)) {
oldStyleSheetStyle->deref();
} else

View File

@ -120,7 +120,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
public slots:
/** \internal
Cleanup the _q_stylesheet_parent property.
@ -143,7 +143,7 @@ QTipLabel *QTipLabel::instance = nullptr;
QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
: QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
, styleSheetParent(nullptr)
#endif
, widget(nullptr)
@ -178,7 +178,7 @@ void QTipLabel::restartExpireTimer(int msecDisplayTime)
void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
{
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (styleSheetParent){
disconnect(styleSheetParent, &QWidget::destroyed,
this, &QTipLabel::styleSheetParentDestroyed);
@ -346,7 +346,7 @@ QScreen *QTipLabel::getTipScreen(const QPoint &pos, QWidget *w)
void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
{
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (testAttribute(Qt::WA_StyleSheet) || (w && qt_styleSheet(w->style()))) {
//the stylesheet need to know the real parent
QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
@ -365,7 +365,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
// correct content margin.
QTipLabel::instance->updateSize(pos);
}
#endif //QT_NO_STYLE_STYLESHEET
#endif //QT_CONFIG(style_stylesheet)
QPoint p = pos;
const QScreen *screen = getTipScreen(pos, w);

View File

@ -1682,7 +1682,7 @@ void QWidgetPrivate::deleteExtra()
{
if (extra) { // if exists
deleteSysExtra();
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
// dereference the stylesheet style
if (QStyleSheetStyle *proxy = qt_styleSheet(extra->style))
proxy->deref();
@ -2542,7 +2542,7 @@ void QWidget::setScreen(QScreen *screen)
d->setScreen(screen);
}
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
/*!
\property QWidget::styleSheet
@ -2647,7 +2647,7 @@ void QWidget::setStyle(QStyle *style)
Q_D(QWidget);
setAttribute(Qt::WA_SetStyle, style != nullptr);
d->createExtra();
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) {
//if for some reason someone try to set a QStyleSheetStyle, ref it
//(this may happen for example in QButtonDialogBox which propagates its style)
@ -2668,7 +2668,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
createExtra();
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
QPointer<QStyle> origStyle = extra->style;
#endif
extra->style = newStyle;
@ -2689,7 +2689,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
}
}
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (!qt_styleSheet(newStyle)) {
if (const QStyleSheetStyle* cssStyle = qt_styleSheet(origStyle)) {
cssStyle->clearWidgetFont(q);
@ -2700,7 +2700,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
QEvent e(QEvent::StyleChange);
QCoreApplication::sendEvent(q, &e);
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
// dereference the old stylesheet style
if (QStyleSheetStyle *proxy = qt_styleSheet(origStyle))
proxy->deref();
@ -2710,7 +2710,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
// Inherits style from the current parent and propagates it as necessary
void QWidgetPrivate::inheritStyle()
{
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
Q_Q(QWidget);
QStyle *extraStyle = extra ? (QStyle*)extra->style : nullptr;
@ -4688,7 +4688,7 @@ void QWidget::setFont(const QFont &font)
{
Q_D(QWidget);
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
const QStyleSheetStyle* style;
if (d->extra && (style = qt_styleSheet(d->extra->style)))
style->saveWidgetFont(this, font);
@ -4797,7 +4797,7 @@ void QWidgetPrivate::resolveFont()
void QWidgetPrivate::updateFont(const QFont &font)
{
Q_Q(QWidget);
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
const QStyleSheetStyle* cssStyle;
cssStyle = extra ? qt_styleSheet(extra->style) : nullptr;
const bool useStyleSheetPropagationInWidgetStyles =
@ -4827,7 +4827,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
QWidget *w = qobject_cast<QWidget*>(children.at(i));
if (w) {
if (0) {
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
} else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
// Style sheets follow a different font propagation scheme.
if (cssStyle)
@ -4842,7 +4842,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
}
}
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
cssStyle->updateStyleSheetFont(q);
}

View File

@ -983,7 +983,7 @@ void QLabel::paintEvent(QPaintEvent *)
QRectF lr = d->layoutRect().toAlignedRect();
QStyleOption opt;
opt.initFrom(this);
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style))
cssStyle->styleSheetPalette(this, &opt, &opt.palette);
#endif

View File

@ -2070,7 +2070,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
// draw text, selections and cursors
#ifndef QT_NO_STYLE_STYLESHEET
#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style())) {
cssStyle->styleSheetPalette(this, &panel, &pal);
}