Skip to content

Commit

Permalink
UILoad basic function works
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Jul 30, 2017
1 parent b39c442 commit af23821
Show file tree
Hide file tree
Showing 17 changed files with 56,034 additions and 55,150 deletions.
7 changes: 5 additions & 2 deletions demos/demo1/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {mainwindowJson} from "./mainwindow"
import {Settings} from "./settings"
import {SettingsUI} from "./settings-ui"

import {ViewModel} from "../../../src/mvvm/view-model"
import {DemoApplication} from "../../src/demo-application";

window.onload = function() {
var app = new DemoApplication("demo", mainwindowJson);
var app = new DemoApplication("demo", SettingsUI, new ViewModel(new Settings()));
app.start();
}
118 changes: 62 additions & 56 deletions demos/demo1/src/mainwindow.ts → demos/demo1/src/settings-ui.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export var mainwindowJson = {
export var SettingsUI = {
"ui": {
"version":"4.0",
"version":"4.0",
"class":"MainWindow",
"layoutdefault": {
"spacing":"6",
"margin":"11",
"spacing":"6",
"margin":"11",
},
"resources": {
},
"connections": {
},
"widgets" : [
{
"class":"QMainWindow",
"name":"MainWindow",
"class":"QMainWindow",
"name":"MainWindow",
"geometry": {
"rect": {
"x":0,
Expand All @@ -27,54 +27,54 @@ export var mainwindowJson = {
},
"actions" : [
{
"name":"actionSave",
"name":"actionSave",
"text": {
"string":"Save",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{Save}",
},
},
{
"name":"actionExit",
"name":"actionExit",
"text": {
"string":"Exit",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{xxx,CloseWindow=True}",
},
},
{
"name":"actionEnglish",
"name":"actionEnglish",
"text": {
"string":"English",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{SetLanguage, Args=en}",
},
},
{
"name":"actionChanese",
"name":"actionChanese",
"text": {
"string":"Chinese",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{SetLanguage, Args=zh}",
},
},
],
"widgets" : [
{
"class":"QWidget",
"name":"centralwidget",
"class":"QWidget",
"name":"centralwidget",
"widgets" : [
{
"class":"QLineEdit",
"name":"lineEdit_2",
"class":"QLineEdit",
"name":"lineEdit_2",
"geometry": {
"rect": {
"x":250,
Expand All @@ -88,8 +88,8 @@ export var mainwindowJson = {
},
},
{
"class":"QPushButton",
"name":"pushButton",
"class":"QPushButton",
"name":"pushButton",
"geometry": {
"rect": {
"x":80,
Expand All @@ -100,20 +100,20 @@ export var mainwindowJson = {
},
"styleSheet": {
"string": {
"notr":"true",
"notr":"true",
},
},
"text": {
"string":"OK",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{Save, CloseWindow=True}",
},
},
{
"class":"QLineEdit",
"name":"lineEdit_4",
"class":"QLineEdit",
"name":"lineEdit_4",
"geometry": {
"rect": {
"x":249,
Expand All @@ -127,8 +127,8 @@ export var mainwindowJson = {
},
},
{
"class":"QLabel",
"name":"label_path",
"class":"QLabel",
"name":"label_path",
"geometry": {
"rect": {
"x":50,
Expand All @@ -142,8 +142,8 @@ export var mainwindowJson = {
},
},
{
"class":"QLineEdit",
"name":"lineEdit_3",
"class":"QLineEdit",
"name":"lineEdit_3",
"geometry": {
"rect": {
"x":250,
Expand All @@ -157,8 +157,8 @@ export var mainwindowJson = {
},
},
{
"class":"QPushButton",
"name":"pushButton_2",
"class":"QPushButton",
"name":"pushButton_2",
"geometry": {
"rect": {
"x":330,
Expand All @@ -171,13 +171,13 @@ export var mainwindowJson = {
"string":"Cancel",
},
"binding.command": {
"stdset":"0",
"stdset":"0",
"string":"{cancel, CloseWindow=True}",
},
},
{
"class":"QLabel",
"name":"label_name",
"class":"QLabel",
"name":"label_name",
"geometry": {
"rect": {
"x":50,
Expand All @@ -191,8 +191,8 @@ export var mainwindowJson = {
},
},
{
"class":"QLabel",
"name":"label_fullpath",
"class":"QLabel",
"name":"label_fullpath",
"geometry": {
"rect": {
"x":50,
Expand All @@ -208,8 +208,8 @@ export var mainwindowJson = {
],
},
{
"class":"QMenuBar",
"name":"menubar",
"class":"QMenuBar",
"name":"menubar",
"geometry": {
"rect": {
"x":0,
Expand All @@ -219,53 +219,59 @@ export var mainwindowJson = {
},
},
"addactions" : [
"addaction",
"addaction",
"menuFile",
"menuLanguage",
],
"widgets" : [
{
"class":"QMenu",
"name":"menuFile",
"class":"QMenu",
"name":"menuFile",
"title": {
"string":"File",
},
"addactions" : [
"addaction",
"addaction",
"addaction",
"separator",
"actionSave",
"actionExit",
],
},
{
"class":"QMenu",
"name":"menuLanguage",
"class":"QMenu",
"name":"menuLanguage",
"title": {
"string":"Language",
},
"addactions" : [
"addaction",
"addaction",
"addaction",
"separator",
"actionEnglish",
"actionChanese",
],
},
],
},
{
"class":"QStatusBar",
"name":"statusbar",
"class":"QStatusBar",
"name":"statusbar",
"binding.value": {
"stdset":"0",
"stdset":"0",
"string":"{\"Full Path Is: \"+path($path+$name)}",
},
},
{
"class":"QToolBar",
"name":"toolBar",
"class":"QToolBar",
"name":"toolBar",
"windowTitle": {
"string":"toolBar",
},
"toolBarArea": {
"enum":"TopToolBarArea",
},
"toolBarBreak": {
"bool":false,
},
"addactions" : [
"addaction",
"addaction",
"actionSave",
"actionExit",
],
},
],
Expand Down
21 changes: 21 additions & 0 deletions demos/demo1/src/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class Settings {
constructor() {
this.name = "demo";
this.path = "/home/jim/";
this.fullpath = this.path + this.name;
}

public canSave(args:string) : boolean {
return true;
}

public save(args:string) : boolean {
console.log("save clicked.");
return true;
}

public name : string;
public path : string;
public fullpath : string;
}

Loading

0 comments on commit af23821

Please sign in to comment.