From e2ccec9ba332daee3100de9fe63efe4ced0f57e6 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sat, 16 Apr 2022 21:49:33 +0200 Subject: [PATCH] Make it possible to set stylesheets and bypass postcss Sometimes the extra CSS properties produced by postcss are applied to the normal QWidgets which are not subclassed with the Yoga stuff included. This produces nasty warnings, regardless of whether you are using Yoga/flex or not. --- src/lib/QtGui/QApplication.ts | 10 +++++++--- src/lib/QtWidgets/QWidget.ts | 22 +++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/lib/QtGui/QApplication.ts b/src/lib/QtGui/QApplication.ts index 1d35fedce..c4200db03 100644 --- a/src/lib/QtGui/QApplication.ts +++ b/src/lib/QtGui/QApplication.ts @@ -67,9 +67,13 @@ export class QApplication extends NodeObject { setQuitOnLastWindowClosed(quit: boolean): void { this.native.setQuitOnLastWindowClosed(quit); } - setStyleSheet(styleSheet: string): void { - const preparedSheet = StyleSheet.create(styleSheet); - this.native.setStyleSheet(preparedSheet); + setStyleSheet(styleSheet: string, postprocess = true): void { + if (postprocess) { + const preparedSheet = StyleSheet.create(styleSheet); + this.native.setStyleSheet(preparedSheet); + } else { + this.native.setStyleSheet(styleSheet); + } } static clipboard(): QClipboard | null { const clipboardNative = addon.QApplication.clipboard(); diff --git a/src/lib/QtWidgets/QWidget.ts b/src/lib/QtWidgets/QWidget.ts index ecae15647..dc8126459 100644 --- a/src/lib/QtWidgets/QWidget.ts +++ b/src/lib/QtWidgets/QWidget.ts @@ -369,10 +369,14 @@ export abstract class NodeWidget extends YogaWid this.native.setGraphicsEffect(effect.native); } // TODO: void setInputMethodHints(Qt::InputMethodHints hints) - setInlineStyle(style: string): void { - this._rawInlineStyle = style; - const preparedSheet = prepareInlineStyleSheet(this, style); - this.native.setStyleSheet(preparedSheet); + setInlineStyle(style: string, postprocess = true): void { + if (postprocess) { + this._rawInlineStyle = style; + const preparedSheet = prepareInlineStyleSheet(this, style); + this.native.setStyleSheet(preparedSheet); + } else { + this.native.setStyleSheet(style); + } } setLayout(parentLayout: NodeLayout): void { const flexLayout = parentLayout as FlexLayout; @@ -612,9 +616,13 @@ export abstract class NodeWidget extends YogaWid setHidden(hidden: boolean): void { this.native.setHidden(hidden); } - setStyleSheet(styleSheet: string): void { - const preparedSheet = StyleSheet.create(styleSheet); - this.native.setStyleSheet(preparedSheet); + setStyleSheet(styleSheet: string, postprocess = true): void { + if (postprocess) { + const preparedSheet = StyleSheet.create(styleSheet); + this.native.setStyleSheet(preparedSheet); + } else { + this.native.setStyleSheet(styleSheet); + } } setVisible(visible: boolean): void { this.native.setVisible(visible);