Skip to content

Commit

Permalink
add default app again
Browse files Browse the repository at this point in the history
  • Loading branch information
freemountain authored and freemountain committed Feb 3, 2017
1 parent 2542736 commit eee4860
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build
dist
default
/default
node_modules
/.qmake.cache
/.qmake.stash
Expand Down
45 changes: 45 additions & 0 deletions examples/default/ActionRect.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import QtQuick 2.6
import QtQuick.Controls 2.0

Item {
id: item
property string text: ""

property color color

signal action(string url)

Rectangle {
id: background;
color: item.color
anchors.fill: parent

DropArea {
anchors.fill: parent;

onEntered: {
background.color = Qt.darker(item.color)

drag.accept (Qt.CopyAction);
}

onDropped: {
item.action(drop.urls[0].slice(7));

background.color = item.color;
}

onExited: {
background.color = item.color;
}
}

Label {
text: item.text
font.pointSize: 24
font.bold: true
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}
}
23 changes: 23 additions & 0 deletions examples/default/default.qbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import qbs.base
import qbs.FileInfo
import qbs.File
import qbs.Probes
import qbs.ModUtils

QNodeNpmPkg {
name: "default"

Group {
name: "out"
fileTagsFilter: ["npm_pkg.default"]
qbs.install: true
qbs.installSourceBase: product.destinationDirectory
qbs.installDir: "default"
}

Group {
name: "input"
files: ["./**"]
fileTags: ["npm_pkg_input"]
}
}
74 changes: 74 additions & 0 deletions examples/default/index.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import QtQuick 2.6
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Dialogs 1.1
import Quark 1.0

ApplicationWindow {
visible: true
width: 300
height: 200
id:window

Gluon {
id: store
}

ActionRect {
id: run;
height: window.height / 2
width: window.width
anchors.top: window.top
color: "lightsteelblue"
text: "Run"

onAction: {
store.trigger("startProcess", url);
}
}

ActionRect {
id: deploy
color: "steelblue"
height: window.height / 2
width: window.width
anchors.top: run.bottom
text: "Deploy"

property var pkgPath
property var targetPath

onAction: {
fd.visible = true;
deploy.pkgPath = url
}

FileDialog {
id: fd
title: "Please choose output directory"
folder: shortcuts.home
selectFolder: true

onAccepted: {
deploy.targetPath = fd.fileUrls[0].slice(7) // contains file:///User/..
md.visible = true;
fd.visible = false;

store.trigger("deployApp", {
pkg: deploy.pkgPath,
target: deploy.targetPath
});
}

onRejected: {
fd.visible = false;
}
}

MessageDialog {
id: md
title: "Bundling..."
text: "Deplyed " + deploy.pkgPath + " to " + deploy.targetPath
}
}
}
46 changes: 46 additions & 0 deletions examples/default/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const Quark = require("quark");
const path = require("path");

// require("shelljs/global");

const app = Quark.of({
initialState: {
apps: []
},
mappings: {
startProcess: "onStart",
deployApp: "onDeploy"
},
intents: {
onStart(state, dir) {
console.error("start");
return state.update("processes", processes => processes.concat(dir));
},

onDeploy(state, program) {
console.error("deploy");
return state.update("apps", apps => apps.concat(program))
}
}
});

app.listen("processes").on("data", console.error.bind(console));
// app.listen("apps").on("data", console.error.bind(console));
//
/*
onDeploy: function() {
bundle: path.join(path.dirname(options.shellPath), '..', '..')
const pkgJson = require(pkg);
const name = pkgJson.name || "quark";
const target = path.join(targetBase, `${name}.app`);
const pkgBase = path.dirname(pkg);
const appBase = path.join(target, "Contents", "Resources", "app");
console.error("pkbBase", pkgBase);
console.error("appBase", appBase);
cp("-R", bundle, target);
rm("-rf", appBase)
cp("-R", pkgBase, appBase);
}
*/
9 changes: 9 additions & 0 deletions examples/default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "quark-default",
"version": "0.1.0",
"main": "main.js",
"initialQml": "index.qml",
"dependencies": {
"shelljs": "^0.7.5"
}
}

0 comments on commit eee4860

Please sign in to comment.