Commit 1c9da743 authored by Simon Hausmann's avatar Simon Hausmann
Browse files

Port photoviewer example to use a ES module for the script code


... instead of the proprietary .pragma library syntax.

Change-Id: Ic5add04d6446a3c221eb3be6ec5a2240f0f80691
Reviewed-by: default avatarPaul Wicking <paul.wicking@qt.io>
Reviewed-by: default avatarMitch Curtis <mitch.curtis@qt.io>
Showing with 6 additions and 8 deletions
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.0 import QtQuick 2.0
import "script/script.js" as Script import "script/script.mjs" as Script
Package { Package {
Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
......
...@@ -48,22 +48,20 @@ ...@@ -48,22 +48,20 @@
** **
****************************************************************************/ ****************************************************************************/
.pragma library export function getWidth(string) {
function getWidth(string) {
return (string.match(/width=\"([0-9]+)\"/))[1] return (string.match(/width=\"([0-9]+)\"/))[1]
} }
function getHeight(string) { export function getHeight(string) {
return (string.match(/height=\"([0-9]+)\"/))[1] return (string.match(/height=\"([0-9]+)\"/))[1]
} }
function getImagePath(string) { export function getImagePath(string) {
var pattern = /src=\"http:\/\/(\S+)\"/ var pattern = /src=\"http:\/\/(\S+)\"/
return (string.match(pattern))[1] return (string.match(pattern))[1]
} }
function calculateScale(width, height, cellSize) { export function calculateScale(width, height, cellSize) {
var widthScale = (cellSize * 1.0) / width var widthScale = (cellSize * 1.0) / width
var heightScale = (cellSize * 1.0) / height var heightScale = (cellSize * 1.0) / height
var scale = 0 var scale = 0
......
...@@ -28,7 +28,7 @@ RESOURCES += main.qml \ ...@@ -28,7 +28,7 @@ RESOURCES += main.qml \
PhotoViewerCore/images/box-shadow.png \ PhotoViewerCore/images/box-shadow.png \
PhotoViewerCore/images/busy.png \ PhotoViewerCore/images/busy.png \
PhotoViewerCore/images/cardboard.png \ PhotoViewerCore/images/cardboard.png \
PhotoViewerCore/script/script.js \ PhotoViewerCore/script/script.mjs \
target.path = $$[QT_INSTALL_EXAMPLES]/demos/photoviewer target.path = $$[QT_INSTALL_EXAMPLES]/demos/photoviewer
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment