Skip to content

Commit 6c54e2b

Browse files
committed
Initial import
0 parents  commit 6c54e2b

File tree

9 files changed

+159
-0
lines changed

9 files changed

+159
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules/
2+
coverage/
3+
tmp/
4+
.idea/
5+
*~
6+
*.bak
7+
*.log
8+
.*.swp
9+
.*.swo
10+
*.kdev4
11+
*kate-swp
12+
.arcconfig
13+
.project

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Authors ordered by first contribution.
2+
3+
Сковорода Никита Андреевич <chalkerx@gmail.com>

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
QmlWeb-Viewer is licensed under the MIT license, as follows:
2+
3+
"""
4+
MIT License
5+
6+
Copyright (c) 2016 QmlWeb contributors
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy of
9+
this software and associated documentation files (the "Software"), to deal in
10+
the Software without restriction, including without limitation the rights to
11+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12+
the Software, and to permit persons to whom the Software is furnished to do so,
13+
subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in all
16+
copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
"""

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# QmlWeb-based QML viewer
2+
3+
[![Join the chat at https://gitter.im/qmlweb/qmlweb](https://badges.gitter.im/qmlweb/qmlweb.svg)](https://gitter.im/qmlweb/qmlweb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
5+
[![npm](https://img.shields.io/npm/v/qmlweb-viewer.svg)](https://www.npmjs.com/package/qmlweb-viewer)
6+
[![GitHub tag](https://img.shields.io/github/tag/qmlweb/qmlweb-viewer.svg)](https://github.com/qmlweb/qmlweb-viewer/releases)
7+
8+
This is a QmlWeb-based GUI viewer for `*.qml` files.
9+
10+
Based on [QmlWeb](https://github.com/qmlweb/qmlweb) and [Electron](https://github.com/electron/electron).
11+
12+
This is not a replacement to Qt QML by any means and should not be used in
13+
production.
14+
15+
The only purpose of this tool is to test QmlWeb and visually compare the rendered
16+
results with Qt QML output (e.g. `qmlscene`).
17+
18+
## License
19+
20+
QmlWeb-Viewer is licensed under the MIT license, see
21+
[LICENSE](https://github.com/qmlweb/qmlweb-parser/blob/master/LICENSE).

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>QmlWeb</title>
5+
</head>
6+
<body style="margin:0">
7+
</body>
8+
<script>
9+
require('qmlweb/lib/qt.js');
10+
const qmlweb_parser = require('qmlweb/lib/qmlweb.parser.js');
11+
window.qmlweb_parse = qmlweb_parser.qmlweb_parse;
12+
window.qmlweb_jsparse = qmlweb_parser.qmlweb_jsparse;
13+
require('./renderer')
14+
</script>
15+
</html>

main.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const electron = require('electron');
2+
3+
const argument = process.argv[process.argv.length - 1];
4+
if (argument.substr(-4) !== '.qml') {
5+
console.error(new Error('you should specify a *.qml file.'));
6+
process.exit(0);
7+
}
8+
9+
global.qmlwebViewer = {
10+
argument
11+
};
12+
13+
const app = electron.app;
14+
const BrowserWindow = electron.BrowserWindow;
15+
let mainWindow;
16+
17+
function createWindow () {
18+
mainWindow = new BrowserWindow({width: 20, height: 20});
19+
mainWindow.setMenu(null);
20+
mainWindow.loadURL(`file://${__dirname}/index.html`);
21+
//mainWindow.webContents.openDevTools();
22+
mainWindow.on('closed', () => { mainWindow = null });
23+
}
24+
25+
app.on('ready', createWindow)
26+
27+
app.on('window-all-closed', () => {
28+
// On OS X it is common for applications and their menu bar
29+
// to stay active until the user quits explicitly with Cmd + Q
30+
if (process.platform !== 'darwin') {
31+
app.quit()
32+
}
33+
});
34+
35+
app.on('activate', () => {
36+
// On OS X it's common to re-create a window in the app when the
37+
// dock icon is clicked and there are no other windows open.
38+
if (mainWindow === null) {
39+
createWindow()
40+
}
41+
});

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "qmlweb-viewer",
3+
"version": "0.0.0",
4+
"description": "Bringing QmlWeb to your desktop",
5+
"license": "MIT",
6+
"repository": "qmlweb/qmlweb-viewer",
7+
"main": "main.js",
8+
"bin": {
9+
"qmlweb-viewer" : "qmlweb-viewer.js"
10+
},
11+
"scripts": {
12+
"start": "electron ."
13+
},
14+
"dependencies": {
15+
"electron-prebuilt": "^1.2.0",
16+
"qmlweb": "^0.1.0"
17+
},
18+
"files": [
19+
"AUTHORS",
20+
"LICENSE",
21+
"README.md",
22+
"*.html",
23+
"*.js"
24+
]
25+
}

qmlweb-viewer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
3+
const child_process = require('child_process');
4+
const path = require('path');
5+
6+
const electron = path.join(__dirname, '..', '.bin', 'electron');
7+
child_process.execFileSync(electron, [__dirname, path.resolve(process.argv[2] || '')]);

renderer.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const remote = require('electron').remote;
2+
const qmlwebViewer = remote.getGlobal('qmlwebViewer');
3+
4+
const engine = new QMLEngine();
5+
engine.loadFile(qmlwebViewer.argument);
6+
engine.start();
7+
const qml = engine.rootObject;
8+
9+
const window = remote.getCurrentWindow();
10+
window.setSize(qml.width, qml.height);

0 commit comments

Comments
 (0)