Widgets/Stylesheets: Remove double negations for stylehseet feature
Replace ifndef QT_NO_STYLE_STYLESHEET antipattern by if QT_CONFIG(style_stylesheet). Task-number: QTBUG-136341 Change-Id: I8f5d5ff0b7b5cce010df167977214bc92a9443b7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit a1612886bade6192fecad33d0dacb1d24792e315) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
72153bf6ef
commit
093ab48adf
@ -318,7 +318,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
|
|||||||
void qt_init_tooltip_palette();
|
void qt_init_tooltip_palette();
|
||||||
|
|
||||||
QStyle *QApplicationPrivate::app_style = nullptr; // default application style
|
QStyle *QApplicationPrivate::app_style = nullptr; // default application style
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
QString QApplicationPrivate::styleSheet; // default application stylesheet
|
QString QApplicationPrivate::styleSheet; // default application stylesheet
|
||||||
#endif
|
#endif
|
||||||
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr;
|
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr;
|
||||||
@ -387,7 +387,7 @@ void QApplicationPrivate::process_cmdline()
|
|||||||
++arg;
|
++arg;
|
||||||
if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
|
if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
|
||||||
// obsolete argument
|
// obsolete argument
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
} else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
|
} else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
|
||||||
styleSheet = "file:///"_L1;
|
styleSheet = "file:///"_L1;
|
||||||
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
|
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
|
||||||
@ -872,7 +872,7 @@ bool QApplication::autoSipEnabled() const
|
|||||||
return QApplicationPrivate::autoSipEnabled;
|
return QApplicationPrivate::autoSipEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
|
|
||||||
QString QApplication::styleSheet() const
|
QString QApplication::styleSheet() const
|
||||||
{
|
{
|
||||||
@ -932,7 +932,7 @@ QStyle *QApplication::style()
|
|||||||
|
|
||||||
QGuiApplicationPrivate::updatePalette();
|
QGuiApplicationPrivate::updatePalette();
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (!QApplicationPrivate::styleSheet.isEmpty()) {
|
if (!QApplicationPrivate::styleSheet.isEmpty()) {
|
||||||
qApp->setStyleSheet(QApplicationPrivate::styleSheet);
|
qApp->setStyleSheet(QApplicationPrivate::styleSheet);
|
||||||
} else
|
} else
|
||||||
@ -990,7 +990,7 @@ void QApplication::setStyle(QStyle *style)
|
|||||||
|
|
||||||
QStyle *old = QApplicationPrivate::app_style; // save
|
QStyle *old = QApplicationPrivate::app_style; // save
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (!QApplicationPrivate::styleSheet.isEmpty() && !qt_styleSheet(style)) {
|
if (!QApplicationPrivate::styleSheet.isEmpty() && !qt_styleSheet(style)) {
|
||||||
// we have a stylesheet already and a new style is being set
|
// we have a stylesheet already and a new style is being set
|
||||||
QStyleSheetStyle *newStyleSheetStyle = new QStyleSheetStyle(style);
|
QStyleSheetStyle *newStyleSheetStyle = new QStyleSheetStyle(style);
|
||||||
@ -1023,7 +1023,7 @@ void QApplication::setStyle(QStyle *style)
|
|||||||
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
|
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
|
||||||
if (w->style() == QApplicationPrivate::app_style)
|
if (w->style() == QApplicationPrivate::app_style)
|
||||||
QApplicationPrivate::app_style->polish(w); // repolish
|
QApplicationPrivate::app_style->polish(w); // repolish
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
else
|
else
|
||||||
w->setStyleSheet(w->styleSheet()); // touch
|
w->setStyleSheet(w->styleSheet()); // touch
|
||||||
#endif
|
#endif
|
||||||
@ -1040,7 +1040,7 @@ void QApplication::setStyle(QStyle *style)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (QStyleSheetStyle *oldStyleSheetStyle = qt_styleSheet(old)) {
|
if (QStyleSheetStyle *oldStyleSheetStyle = qt_styleSheet(old)) {
|
||||||
oldStyleSheetStyle->deref();
|
oldStyleSheetStyle->deref();
|
||||||
} else
|
} else
|
||||||
|
@ -122,7 +122,7 @@ protected:
|
|||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
public slots:
|
public slots:
|
||||||
/** \internal
|
/** \internal
|
||||||
Cleanup the _q_stylesheet_parent property.
|
Cleanup the _q_stylesheet_parent property.
|
||||||
@ -145,7 +145,7 @@ QTipLabel *QTipLabel::instance = nullptr;
|
|||||||
|
|
||||||
QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
|
QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
|
||||||
: QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
|
: QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
, styleSheetParent(nullptr)
|
, styleSheetParent(nullptr)
|
||||||
#endif
|
#endif
|
||||||
, widget(nullptr)
|
, widget(nullptr)
|
||||||
@ -180,7 +180,7 @@ void QTipLabel::restartExpireTimer(int msecDisplayTime)
|
|||||||
|
|
||||||
void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
|
void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (styleSheetParent){
|
if (styleSheetParent){
|
||||||
disconnect(styleSheetParent, &QWidget::destroyed,
|
disconnect(styleSheetParent, &QWidget::destroyed,
|
||||||
this, &QTipLabel::styleSheetParentDestroyed);
|
this, &QTipLabel::styleSheetParentDestroyed);
|
||||||
@ -348,7 +348,7 @@ QScreen *QTipLabel::getTipScreen(const QPoint &pos, QWidget *w)
|
|||||||
|
|
||||||
void QTipLabel::placeTip(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()))) {
|
if (testAttribute(Qt::WA_StyleSheet) || (w && qt_styleSheet(w->style()))) {
|
||||||
//the stylesheet need to know the real parent
|
//the stylesheet need to know the real parent
|
||||||
QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
|
QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
|
||||||
@ -367,7 +367,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
|
|||||||
// correct content margin.
|
// correct content margin.
|
||||||
QTipLabel::instance->updateSize(pos);
|
QTipLabel::instance->updateSize(pos);
|
||||||
}
|
}
|
||||||
#endif //QT_NO_STYLE_STYLESHEET
|
#endif //QT_CONFIG(style_stylesheet)
|
||||||
|
|
||||||
QPoint p = pos;
|
QPoint p = pos;
|
||||||
const QScreen *screen = getTipScreen(pos, w);
|
const QScreen *screen = getTipScreen(pos, w);
|
||||||
|
@ -1694,7 +1694,7 @@ void QWidgetPrivate::deleteExtra()
|
|||||||
{
|
{
|
||||||
if (extra) { // if exists
|
if (extra) { // if exists
|
||||||
deleteSysExtra();
|
deleteSysExtra();
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
// dereference the stylesheet style
|
// dereference the stylesheet style
|
||||||
if (QStyleSheetStyle *proxy = qt_styleSheet(extra->style))
|
if (QStyleSheetStyle *proxy = qt_styleSheet(extra->style))
|
||||||
proxy->deref();
|
proxy->deref();
|
||||||
@ -2554,7 +2554,7 @@ void QWidget::setScreen(QScreen *screen)
|
|||||||
d->setScreen(screen);
|
d->setScreen(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QWidget::styleSheet
|
\property QWidget::styleSheet
|
||||||
@ -2659,7 +2659,7 @@ void QWidget::setStyle(QStyle *style)
|
|||||||
Q_D(QWidget);
|
Q_D(QWidget);
|
||||||
setAttribute(Qt::WA_SetStyle, style != nullptr);
|
setAttribute(Qt::WA_SetStyle, style != nullptr);
|
||||||
d->createExtra();
|
d->createExtra();
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) {
|
if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) {
|
||||||
//if for some reason someone try to set a QStyleSheetStyle, ref it
|
//if for some reason someone try to set a QStyleSheetStyle, ref it
|
||||||
//(this may happen for example in QButtonDialogBox which propagates its style)
|
//(this may happen for example in QButtonDialogBox which propagates its style)
|
||||||
@ -2680,7 +2680,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
|
|||||||
|
|
||||||
createExtra();
|
createExtra();
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
QPointer<QStyle> origStyle = extra->style;
|
QPointer<QStyle> origStyle = extra->style;
|
||||||
#endif
|
#endif
|
||||||
extra->style = newStyle;
|
extra->style = newStyle;
|
||||||
@ -2701,7 +2701,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (!qt_styleSheet(newStyle)) {
|
if (!qt_styleSheet(newStyle)) {
|
||||||
if (const QStyleSheetStyle* cssStyle = qt_styleSheet(origStyle)) {
|
if (const QStyleSheetStyle* cssStyle = qt_styleSheet(origStyle)) {
|
||||||
cssStyle->clearWidgetFont(q);
|
cssStyle->clearWidgetFont(q);
|
||||||
@ -2712,7 +2712,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
|
|||||||
QEvent e(QEvent::StyleChange);
|
QEvent e(QEvent::StyleChange);
|
||||||
QCoreApplication::sendEvent(q, &e);
|
QCoreApplication::sendEvent(q, &e);
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
// dereference the old stylesheet style
|
// dereference the old stylesheet style
|
||||||
if (QStyleSheetStyle *proxy = qt_styleSheet(origStyle))
|
if (QStyleSheetStyle *proxy = qt_styleSheet(origStyle))
|
||||||
proxy->deref();
|
proxy->deref();
|
||||||
@ -2722,7 +2722,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
|
|||||||
// Inherits style from the current parent and propagates it as necessary
|
// Inherits style from the current parent and propagates it as necessary
|
||||||
void QWidgetPrivate::inheritStyle()
|
void QWidgetPrivate::inheritStyle()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
Q_Q(QWidget);
|
Q_Q(QWidget);
|
||||||
|
|
||||||
QStyle *extraStyle = extra ? (QStyle*)extra->style : nullptr;
|
QStyle *extraStyle = extra ? (QStyle*)extra->style : nullptr;
|
||||||
@ -4700,7 +4700,7 @@ void QWidget::setFont(const QFont &font)
|
|||||||
{
|
{
|
||||||
Q_D(QWidget);
|
Q_D(QWidget);
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
const QStyleSheetStyle* style;
|
const QStyleSheetStyle* style;
|
||||||
if (d->extra && (style = qt_styleSheet(d->extra->style)))
|
if (d->extra && (style = qt_styleSheet(d->extra->style)))
|
||||||
style->saveWidgetFont(this, font);
|
style->saveWidgetFont(this, font);
|
||||||
@ -4809,7 +4809,7 @@ void QWidgetPrivate::resolveFont()
|
|||||||
void QWidgetPrivate::updateFont(const QFont &font)
|
void QWidgetPrivate::updateFont(const QFont &font)
|
||||||
{
|
{
|
||||||
Q_Q(QWidget);
|
Q_Q(QWidget);
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
const QStyleSheetStyle* cssStyle;
|
const QStyleSheetStyle* cssStyle;
|
||||||
cssStyle = extra ? qt_styleSheet(extra->style) : nullptr;
|
cssStyle = extra ? qt_styleSheet(extra->style) : nullptr;
|
||||||
const bool useStyleSheetPropagationInWidgetStyles =
|
const bool useStyleSheetPropagationInWidgetStyles =
|
||||||
@ -4839,7 +4839,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
|
|||||||
QWidget *w = qobject_cast<QWidget*>(children.at(i));
|
QWidget *w = qobject_cast<QWidget*>(children.at(i));
|
||||||
if (w) {
|
if (w) {
|
||||||
if (0) {
|
if (0) {
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
} else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
|
} else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
|
||||||
// Style sheets follow a different font propagation scheme.
|
// Style sheets follow a different font propagation scheme.
|
||||||
if (cssStyle)
|
if (cssStyle)
|
||||||
@ -4854,7 +4854,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
|
if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
|
||||||
cssStyle->updateStyleSheetFont(q);
|
cssStyle->updateStyleSheetFont(q);
|
||||||
}
|
}
|
||||||
|
@ -985,7 +985,7 @@ void QLabel::paintEvent(QPaintEvent *)
|
|||||||
QRectF lr = d->layoutRect().toAlignedRect();
|
QRectF lr = d->layoutRect().toAlignedRect();
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
opt.initFrom(this);
|
opt.initFrom(this);
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style))
|
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style))
|
||||||
cssStyle->styleSheetPalette(this, &opt, &opt.palette);
|
cssStyle->styleSheetPalette(this, &opt, &opt.palette);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2071,7 +2071,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
|
|||||||
QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
|
QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
|
||||||
|
|
||||||
// draw text, selections and cursors
|
// draw text, selections and cursors
|
||||||
#ifndef QT_NO_STYLE_STYLESHEET
|
#if QT_CONFIG(style_stylesheet)
|
||||||
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style())) {
|
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style())) {
|
||||||
cssStyle->styleSheetPalette(this, &panel, &pal);
|
cssStyle->styleSheetPalette(this, &panel, &pal);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user