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.
This commit is contained in:
Simon Edwards 2022-04-16 21:49:33 +02:00
parent 7d8fb77481
commit e2ccec9ba3
2 changed files with 22 additions and 10 deletions

View File

@ -67,9 +67,13 @@ export class QApplication extends NodeObject<QApplicationSignals> {
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();

View File

@ -369,10 +369,14 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> 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<Signals>): void {
const flexLayout = parentLayout as FlexLayout;
@ -612,9 +616,13 @@ export abstract class NodeWidget<Signals extends QWidgetSignals> 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);