From 4db607caef815c73c4f0cd9e4cb2d54601b8678e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Mon, 26 Dec 2016 22:28:04 +0300 Subject: [PATCH 1/3] Engine: support .pragma library for js files Fixes: https://github.com/qmlweb/qmlweb/issues/375 --- src/engine/QMLEngine.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/engine/QMLEngine.js b/src/engine/QMLEngine.js index 80d79f837..0c298c2e8 100644 --- a/src/engine/QMLEngine.js +++ b/src/engine/QMLEngine.js @@ -583,9 +583,24 @@ class QMLEngine { ${jsData.exports.map(sym => `$context.${sym} = ${sym};`).join("")} `); - this.js[file] = contextSetter; + if (jsData.pragma && jsData.pragma.indexOf("library") !== -1) { + // For .pragma library, execute the code once in a clean context and + // return a function that imports getters/setters to other contexts + const jsContext = {}; + contextSetter(jsContext); + this.js[file] = context => { + jsData.exports.forEach(sym => QmlWeb.setupGetterSetter(context, sym, + () => jsContext[sym], + val => { + jsContext[sym] = val; + } + )); + }; + } else { + this.js[file] = contextSetter; + } - return contextSetter; + return this.js[file]; } $registerStart(f) { From c0b3569016eda5789329c3c64d67efa96bf7f9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sat, 31 Dec 2016 16:02:35 +0300 Subject: [PATCH 2/3] Timer: make parent not read-only for now Some parts of QmlWeb set .parent property directly, that was causing a conflict and an exception was being thrown. Long-term, we should create a better fix, but this fixes the immediate problem for now, and properties not being read-only when they should causes much less damage than unexpected exceptions on valid qml code. --- src/modules/QtQml/Timer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/QtQml/Timer.js b/src/modules/QtQml/Timer.js index a1b154a9f..95a9edbbe 100644 --- a/src/modules/QtQml/Timer.js +++ b/src/modules/QtQml/Timer.js @@ -5,7 +5,7 @@ QmlWeb.registerQmlType({ baseClass: "QtObject", properties: { interval: { type: "int", initialValue: 1000 }, - parent: { type: "QtObject", readOnly: true }, + parent: { type: "QtObject" }, // TODO ro repeat: "bool", running: "bool", triggeredOnStart: "bool" From 6daad50549651de015aecbfa8ec602fc68a942b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Tue, 3 Jan 2017 16:43:18 +0300 Subject: [PATCH 3/3] Item: support transformOrigin Testcase is still needed here. --- src/modules/QtQuick/Item.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/modules/QtQuick/Item.js b/src/modules/QtQuick/Item.js index 7688b3453..0c112165e 100644 --- a/src/modules/QtQuick/Item.js +++ b/src/modules/QtQuick/Item.js @@ -3,6 +3,13 @@ QmlWeb.registerQmlType({ name: "Item", versions: /.*/, baseClass: "QtQml.QtObject", + enums: { + Item: { + TopLeft: 0, Top: 1, TopRight: 2, + Left: 3, Center: 4, Right: 5, + BottomLeft: 6, Bottom: 7, BottomRight: 8 + } + }, properties: { $opacity: { type: "real", initialValue: 1 }, parent: "Item", @@ -14,6 +21,7 @@ QmlWeb.registerQmlType({ children: "list", resources: "list", transform: "list", + transformOrigin: { type: "enum", initialValue: 4 }, // Item.Center x: "real", y: "real", z: "real", @@ -122,6 +130,7 @@ QmlWeb.registerQmlType({ this.rotationChanged.connect(this, this.$updateTransform); this.scaleChanged.connect(this, this.$updateTransform); this.transformChanged.connect(this, this.$updateTransform); + this.transformOriginChanged.connect(this, this.$onTransformOriginChanged); this.Component.completed.connect(this, this.Component$onCompleted_); this.opacityChanged.connect(this, this.$calculateOpacity); @@ -374,6 +383,20 @@ QmlWeb.registerQmlType({ this.dom.style.filter = filter; this.dom.style.webkitFilter = filter; // Chrome, Safari and Opera } + $onTransformOriginChanged(newVal) { + const map = [ + 'left top', // 0 - TopLeft + 'center top', // 1 - Top + 'right top', // 2 - TopRight + 'left center', // 3 - Left + '', // 4 - Center + 'right center', // 5 - Right + 'left bottom', // 6 - BottomLeft + 'center bottom', // 7 - Bottom + 'right bottom', // 8 - BottomRight + ]; + this.dom.style.transformOrigin = map[newVal]; + } Component$onCompleted_() { this.$calculateOpacity(); }