fix scheme load bug

This commit is contained in:
Xuan Sang LE 2018-03-20 15:05:41 +01:00
parent 857b2167c5
commit 988993483f
6 changed files with 42 additions and 11 deletions

View File

@ -25,13 +25,14 @@ class BaseApplication extends this.OS.GUI.BaseModel
CTRL: {}
SHIFT: {}
META: {}
init: ->
me = @
# first register some base event to the app
@subscribe "appregistry"
, ( m ) ->
me.applySetting m.data.m if (m.name is me.name)
init: ->
me = @
@off "*"
@on "exit", () -> me.quit()
# first register some base event to the app
@on "focus", () ->
me.sysdock.set "selectedApp", me
me.appmenu.pid = me.pid
@ -48,6 +49,7 @@ class BaseApplication extends this.OS.GUI.BaseModel
when "#{me.name}-about" then me.openDialog "AboutDialog", ()->
when "#{me.name}-exit" then me.trigger "exit"
@loadScheme()
loadScheme: () ->
#now load the scheme
path = "#{@meta().path}/scheme.html"

View File

@ -52,7 +52,9 @@ class BaseModel
one: (e, f) -> @observable.one e, f
on: (e, f) -> @observable.on e, f
off: (e, f) ->
return @observable.off e unless f
@observable.off e, f
trigger: (e, d) -> @observable.trigger e, d
subscribe: (e, f) ->

View File

@ -37,6 +37,7 @@ self.OS.GUI =
]
htmlToScheme: (html, app, parent) ->
scheme = $.parseHTML html
$(app.scheme).remove() if app.scheme
($ parent).append scheme
riot.mount ($ scheme), { observable: app.observable }
@ -186,11 +187,11 @@ self.OS.GUI =
# so that it can be themed
data.iconclass = "fa fa-cogs" if (not meta.icon) and (not meta.iconclass)
dock = $ "#sysdock"
app.init()
app.one "rendered", () ->
dock.get(0).newapp data
app.sysdock = dock.get(0)
app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0]
app.init()
toggleFullscreen: () ->
el = ($ "body")[0]

View File

@ -31,7 +31,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication
(@find "btnnewprj").set "onbtclick", () ->
me.newProject (path) ->
me.prjfile = "#{path}/project.apj".asFileHandler()
me.loadScheme()
me.init()
(@find "btnopenprj").set "onbtclick", () ->
me.actionProject "#{me.name}-Open"
return
@ -208,7 +208,32 @@ class AntOSDK extends this.OS.GUI.BaseApplication
},
{
path: "#{rpath}/README.md",
content: "##{n}"
content: """
# #{n}
This is an example project, generated by AntOS Development Kit
## Howto
1. Open the project.apj file with AntOSDK (simply double Click on it)
2. Modify the UI in *assets/scheme.html*
3. Modify application code in *coffees/main.coffee*
4. Modify CSS style in *css/main.css*
5. Other files need to be copied: put in to assets
## Set up build target
Click **Menu> Build > Build Option** or simply hit **ALT-Y**
In the build options dialog, add or remove files that need to be
included into the build
Click **Save**
## Build application
* To build: **Menu > Build > Build** or **ALT-C**
* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
* To release: **Menu > Build > Build release** or **ALT-P**
"""
},
{
path: "#{rpath}/project.apj",
@ -264,7 +289,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication
me.log "INFO", __("Opening {0}", me.prjfile.path)
me.tabarea.set "selected", -1
me.tabarea.set "items", []
me.currfile = "#{d.root}/coffees/main.coffee".asFileHandler()
me.currfile = "#{d.root}/README.md".asFileHandler()
me.currfile.dirty = false
me.chdir d.root if d.root
me.prjfile.cache = d
@ -272,7 +297,7 @@ class AntOSDK extends this.OS.GUI.BaseApplication
me.open me.currfile
,"json"
else
me.loadScheme()
me.init()
open: (file) ->
#find table

View File

@ -16,6 +16,7 @@ afx-app-window[data-id="antOSDK"] afx-resizer[data-id="botrz"]
z-index: 9;
border-top: 1px solid #a6a6a6;
background-color: #2f3129;
border-right: 0;
}
afx-app-window[data-id="antOSDK"] div.welcome-cnt {

View File

@ -2,7 +2,7 @@
<afx-vbox>
<afx-hbox >
<div class = "welcome-cnt">
<afx-label text="__(Wecome to AntOSDK)" class="wmsg"></afx-label>
<afx-label text="__(Welcome to AntOSDK)" class="wmsg"></afx-label>
<p>
<afx-button data-id="btnnewprj" iconclass= "fa fa-plus-circle" text = "__(New project)"></afx-button>
<afx-button data-id="btnopenprj" iconclass = "fa fa-folder-open" text = "__(Open project)"></afx-button>