mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 03:09:45 +02:00
Finish package setting & add FR language
This commit is contained in:
@ -7,7 +7,7 @@ class AppearanceHandler extends SettingHandler
|
||||
@wpsize = @find "wpsize"
|
||||
@wprepeat = @find "wprepeat"
|
||||
@themelist = @find "theme-list"
|
||||
|
||||
@syswp = undefined
|
||||
@wplist.set "onlistselect", (e) ->
|
||||
$(me.wpreview).css("background-image", "url(#{me.parent._api.handler.get}/#{e.data.path})" )
|
||||
.css("background-size", "cover")
|
||||
@ -15,7 +15,13 @@ class AppearanceHandler extends SettingHandler
|
||||
me.parent._gui.wallpaper()
|
||||
|
||||
@wplist.set "buttons", [
|
||||
{ text: "+", onbtclick: (e) -> console.log "click +" }
|
||||
{
|
||||
text: "+", onbtclick: (e) ->
|
||||
me.parent.openDialog "FileDiaLog", (d, n, p) ->
|
||||
me.parent.systemsetting.appearance.wps.push p
|
||||
me.render()
|
||||
, __("Select image file"), { mimes: ["image/.*"] }
|
||||
}
|
||||
]
|
||||
|
||||
@wpsize.set "onlistselect", (e) ->
|
||||
@ -42,13 +48,31 @@ class AppearanceHandler extends SettingHandler
|
||||
me.parent._gui.wallpaper()
|
||||
|
||||
@themelist.set "items" , [{ text: "antos", selected: true }]
|
||||
|
||||
render: () ->
|
||||
me = @
|
||||
path = "os://resources/themes/system/wp"
|
||||
path.asFileHandler().read (d) ->
|
||||
me.parent.error __("Cannot read wallpaper list from {0}", path) if d.error
|
||||
for v in d.result
|
||||
v.text = v.filename
|
||||
v.selected = true if v.path is me.parent.systemsetting.appearance.wp.url
|
||||
v.iconclass = "fa fa-file-image-o"
|
||||
me.wplist.set "items", d.result
|
||||
if not @syswp
|
||||
path = "os://resources/themes/system/wp"
|
||||
path.asFileHandler().read (d) ->
|
||||
me.parent.error __("Cannot read wallpaper list from {0}", path) if d.error
|
||||
for v in d.result
|
||||
v.text = v.filename
|
||||
v.selected = true if v.path is me.parent.systemsetting.appearance.wp.url
|
||||
v.iconclass = "fa fa-file-image-o"
|
||||
me.syswp = d.result
|
||||
me.wplist.set "items", me.getwplist()
|
||||
else
|
||||
|
||||
me.wplist.set "items", me.getwplist()
|
||||
|
||||
getwplist: () ->
|
||||
list = []
|
||||
for v in @parent.systemsetting.appearance.wps
|
||||
file = v.asFileHandler()
|
||||
list.push
|
||||
text: file.basename,
|
||||
path: file.path
|
||||
selected: file.path is @parent.systemsetting.appearance.wp.url,
|
||||
iconclass: "fa fa-file-image-o"
|
||||
list = list.concat @syswp
|
||||
return list
|
21
src/packages/Setting/LocaleHandler.coffee
Normal file
21
src/packages/Setting/LocaleHandler.coffee
Normal file
@ -0,0 +1,21 @@
|
||||
class LocaleHandler extends SettingHandler
|
||||
constructor:(scheme, parent) ->
|
||||
super(scheme, parent)
|
||||
me = @
|
||||
@lglist = @find "lglist"
|
||||
@localelist = undefined
|
||||
@lglist.set "onlistselect", (e) ->
|
||||
me.parent._api.setLocale e.data.text
|
||||
render: () ->
|
||||
me = @
|
||||
if not @localelist
|
||||
path = "os://resources/languages"
|
||||
path.asFileHandler().read (d) ->
|
||||
return me.parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
|
||||
for v in d.result
|
||||
v.text = v.filename.replace /\.json$/g, ""
|
||||
v.selected = v.text is me.parent.systemsetting.system.locale
|
||||
me.localelist = d.result
|
||||
me.lglist.set "items", me.localelist
|
||||
else
|
||||
me.lglist.set "items", me.localelist
|
@ -1,4 +1,4 @@
|
||||
coffee_files = main.coffee AppearanceHandler.coffee
|
||||
coffee_files = main.coffee AppearanceHandler.coffee VFSHandler.coffee LocaleHandler.coffee StartupHandler.coffee
|
||||
|
||||
jsfiles =
|
||||
|
||||
|
76
src/packages/Setting/StartupHandler.coffee
Normal file
76
src/packages/Setting/StartupHandler.coffee
Normal file
@ -0,0 +1,76 @@
|
||||
class StartupHandler extends SettingHandler
|
||||
constructor:(scheme, parent) ->
|
||||
super(scheme, parent)
|
||||
me = @
|
||||
@srvlist = @find "srvlist"
|
||||
@applist = @find "applist"
|
||||
@srvlist.set "buttons", [
|
||||
{
|
||||
text: "+", onbtclick: (e) ->
|
||||
services = []
|
||||
for k, v of me.parent.systemsetting.system.packages
|
||||
if v.services
|
||||
srvs = ({ text: "#{k}/#{x}", iconclass:"fa fa-tasks" } for x in v.services)
|
||||
services = services.concat srvs
|
||||
me.parent.openDialog me.mkdialog(), (d) ->
|
||||
me.parent.systemsetting.system.startup.services.push d
|
||||
me.render()
|
||||
, "__(Add service)", services
|
||||
},
|
||||
{
|
||||
text: "-", onbtclick: (e) ->
|
||||
selidx = me.srvlist.get "selidx"
|
||||
return unless selidx >= 0
|
||||
me.parent.systemsetting.system.startup.services.splice selidx,1
|
||||
me.render()
|
||||
}
|
||||
]
|
||||
|
||||
@applist.set "buttons", [
|
||||
{
|
||||
text: "+", onbtclick: (e) ->
|
||||
apps = ( { text: k, iconclass: v.iconclass } for k, v of me.parent.systemsetting.system.packages )
|
||||
me.parent.openDialog me.mkdialog(), (d) ->
|
||||
me.parent.systemsetting.system.startup.apps.push d
|
||||
me.render()
|
||||
, "__(Add application)", apps
|
||||
},
|
||||
{
|
||||
text: "-", onbtclick: (e) ->
|
||||
selidx = me.applist.get "selidx"
|
||||
return unless selidx >= 0
|
||||
me.parent.systemsetting.system.startup.apps.splice selidx,1
|
||||
me.render()
|
||||
}
|
||||
]
|
||||
|
||||
render: () ->
|
||||
@srvlist.set "items", ( { text:v } for v in @parent.systemsetting.system.startup.services )
|
||||
@applist.set "items", ( { text:v } for v in @parent.systemsetting.system.startup.apps )
|
||||
|
||||
|
||||
mkdialog: () ->
|
||||
return @parent._gui.mkdialog {
|
||||
name: "StartupDialog",
|
||||
layout: {
|
||||
tags: [
|
||||
{ tag: "afx-list-view" }
|
||||
],
|
||||
width: 250,
|
||||
height: 200,
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
label: "__(Ok)", onclick: (d) ->
|
||||
sel = (d.find "content0").get "selected"
|
||||
return d.error __("Please select an entry") unless sel
|
||||
d.handler(sel.text) if d.handler
|
||||
d.quit()
|
||||
},
|
||||
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
|
||||
],
|
||||
filldata: (dia) ->
|
||||
|
||||
(dia.find "content0").set "items", dia.data if dia.data
|
||||
}
|
||||
}
|
99
src/packages/Setting/VFSHandler.coffee
Normal file
99
src/packages/Setting/VFSHandler.coffee
Normal file
@ -0,0 +1,99 @@
|
||||
class VFSHandler extends SettingHandler
|
||||
constructor:(scheme, parent) ->
|
||||
super(scheme, parent)
|
||||
me = @
|
||||
@mplist = @find "mplist"
|
||||
@dpath = @find "dpath"
|
||||
@ppath = @find "ppath"
|
||||
@mplist.set "buttons", [
|
||||
{
|
||||
text: "+",
|
||||
onbtclick: (e) ->
|
||||
me.parent.openDialog me.mkdialog(), (d) ->
|
||||
me.parent.systemsetting.VFS.mountpoints.push {
|
||||
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
|
||||
}
|
||||
me.render()
|
||||
, "__(Add mount point)"
|
||||
},
|
||||
{
|
||||
text: "-",
|
||||
onbtclick: (e) ->
|
||||
selidx = me.mplist.get "selidx"
|
||||
sel = me.mplist.get "selected"
|
||||
return unless selidx >= 0
|
||||
me.parent.openDialog "YesNoDialog", (d) ->
|
||||
return unless d
|
||||
me.parent.systemsetting.VFS.mountpoints.splice selidx, 1
|
||||
me.render()
|
||||
, "__(Remove)", { text: __("Remove: {0}?", sel.text) }
|
||||
},
|
||||
{
|
||||
text: "",
|
||||
iconclass: "fa fa-pencil",
|
||||
onbtclick: (e) ->
|
||||
sel = me.mplist.get "selected"
|
||||
return unless sel
|
||||
me.parent.openDialog me.mkdialog(), (d) ->
|
||||
d.el.text = d.name
|
||||
d.el.path = d.path
|
||||
me.render()
|
||||
, "__(Edit mount point)", sel
|
||||
}
|
||||
]
|
||||
(@find "btndpath").set 'onbtclick', (e) ->
|
||||
me.parent.openDialog "FileDiaLog", (d, n, p) ->
|
||||
me.parent.systemsetting.desktop.path = p
|
||||
me.parent._gui.refreshDesktop()
|
||||
me.render()
|
||||
, "__(Select a directory)", { mimes: ["dir"], hidden: true }
|
||||
|
||||
(@find "btnppath").set 'onbtclick', (e) ->
|
||||
me.parent.openDialog "FileDiaLog", (d, n, p) ->
|
||||
me.parent.systemsetting.system.pkgpaths.user = p
|
||||
me.render()
|
||||
, "__(Select a directory)", { mimes: ["dir"], hidden: true }
|
||||
render: () ->
|
||||
me = @
|
||||
@mplist.set "items", @parent.systemsetting.VFS.mountpoints
|
||||
@dpath.set "text", @parent.systemsetting.desktop.path
|
||||
@ppath.set "text", @parent.systemsetting.system.pkgpaths.user
|
||||
|
||||
mkdialog: () ->
|
||||
return @parent._gui.mkdialog {
|
||||
name: "MountPointDialog",
|
||||
layout: {
|
||||
tags: [
|
||||
{ tag: "afx-label", att: 'text="__(Name)" data-height="20"' },
|
||||
{ tag: "input", att: "type='text' data-height='25'" },
|
||||
{ tag: "afx-label", att: 'text="__(Path)" data-height="20"' },
|
||||
{ tag: "input", att: "type='text' data-height='25'" }
|
||||
],
|
||||
width: 250,
|
||||
height: 150,
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
label: "__(Ok)", onclick: (d) ->
|
||||
data = {
|
||||
name: (d.find "content1").value,
|
||||
path: (d.find "content3").value,
|
||||
el: d.data
|
||||
}
|
||||
return d.error __("Please enter mount point name") unless data.name and data.name isnt ""
|
||||
return d.error __("Please select a directory") unless data.path and data.path isnt ""
|
||||
d.handler(data) if d.handler
|
||||
d.quit()
|
||||
},
|
||||
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
|
||||
],
|
||||
filldata: (dia) ->
|
||||
$(dia.find "content3").click (e) ->
|
||||
dia.openDialog "FileDiaLog", (d, n, p) ->
|
||||
(dia.find "content3").value = p
|
||||
, "__(Select a directory)", { mimes: ["dir"], hidden: true }
|
||||
return unless dia.data
|
||||
(dia.find "content1").value = dia.data.text if dia.data.text
|
||||
(dia.find "content3").value = dia.data.path if dia.data.path
|
||||
}
|
||||
}
|
@ -16,22 +16,37 @@ class Setting extends this.OS.GUI.BaseApplication
|
||||
@container = @find "container"
|
||||
@container.setTabs [
|
||||
{
|
||||
text: "Appearance",
|
||||
text: "__(Appearance)",
|
||||
iconclass: "fa fa-paint-brush",
|
||||
url: "#{@path()}/schemes/appearance.html",
|
||||
handler: (sch) ->
|
||||
me.appearance = new AppearanceHandler(sch, me)
|
||||
me.appearance
|
||||
new AppearanceHandler sch, me
|
||||
},
|
||||
{
|
||||
text: "VFS",
|
||||
text: "__(VFS)",
|
||||
iconclass: "fa fa-inbox" ,
|
||||
url: "#{@path()}/schemes/vfs.html" ,
|
||||
handler: (sch) ->
|
||||
render: () ->
|
||||
console.log "finish init VFS"
|
||||
|
||||
new VFSHandler sch, me
|
||||
},
|
||||
{
|
||||
text: "__(Languages)",
|
||||
iconclass: "fa fa-globe",
|
||||
url: "#{@path()}/schemes/locale.html",
|
||||
handler: (sch) ->
|
||||
new LocaleHandler sch, me
|
||||
},
|
||||
{
|
||||
text: "__(Startup)",
|
||||
iconclass: "fa fa-cog",
|
||||
url: "#{@path()}/schemes/startup.html",
|
||||
handler: (sch) ->
|
||||
new StartupHandler sch,me
|
||||
}
|
||||
]
|
||||
(@find "btnsave").set "onbtclick", (e) ->
|
||||
me._api.setting (d) ->
|
||||
return me.error __("Cannot save system setting: {0}", d.error) if d.error
|
||||
me.notify __("System setting saved")
|
||||
Setting.singleton = true
|
||||
this.OS.register "Setting", Setting
|
@ -13,7 +13,9 @@ afx-app-window[data-id = "setting-window"] afx-tab-container div[data-ref="cont
|
||||
afx-app-window[data-id = "setting-window"] afx-label.header{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "setting-window"] div.footer{
|
||||
border-right: 1px solid #cbcbcb;
|
||||
}
|
||||
/*APPEARANCE*/
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="appearance"] div[data-id = "wp-preview"]{
|
||||
display: block;
|
||||
@ -29,4 +31,25 @@ afx-app-window[data-id = "setting-window"] afx-vbox[data-id="appearance"] afx-li
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="appearance"] afx-resizer{
|
||||
border:0;
|
||||
background-color: transparent;
|
||||
}
|
||||
/*VFS*/
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="vfs"] afx-list-view[data-id="mplist"]
|
||||
{
|
||||
border: 1px solid #cbcbcb;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="vfs"] afx-button.btnsel button{
|
||||
border-radius: 0;
|
||||
padding-top:2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
/*LANGUAGES*/
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="locale"] afx-list-view[data-id="lglist"]
|
||||
{
|
||||
border: 1px solid #cbcbcb;
|
||||
}
|
||||
/*STARTUP*/
|
||||
afx-app-window[data-id = "setting-window"] afx-vbox[data-id="startup"] afx-list-view
|
||||
{
|
||||
border: 1px solid #cbcbcb;
|
||||
}
|
@ -1,5 +1,12 @@
|
||||
<afx-app-window data-id = "setting-window" apptitle="Setting" width="600" height="400">
|
||||
<afx-vbox>
|
||||
<afx-tab-container data-id = "container" barwidth="120" bar="left"></afx-tab-container>
|
||||
<afx-hbox data-height="35">
|
||||
<div data-width = "120" class = "footer"></div>
|
||||
<div style="text-align:right" >
|
||||
<afx-button text="__(Save)" data-id="btnsave" iconclass="fa fa-save" style="margin-right:10px;" ></afx-button>
|
||||
</div>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
@ -5,7 +5,7 @@
|
||||
<afx-vbox>
|
||||
<afx-label text = "__(Wallpaper)" iconclass = "fa fa-image" class = "header" data-height="23"></afx-label>
|
||||
<afx-hbox>
|
||||
<afx-list-view data-width="120" data-id="wplist"></afx-list-view>
|
||||
<afx-list-view data-width="150" data-id="wplist"></afx-list-view>
|
||||
<afx-resizer data-width="5"></afx-resizer>
|
||||
<afx-vbox>
|
||||
<div data-id = "wp-preview"></div>
|
||||
@ -24,9 +24,4 @@
|
||||
</afx-vbox>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="30" >
|
||||
<div style="text-align:right;"><afx-button text="__(Save)" iconclass="fa fa-save"></afx-button></div>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
<div data-height="5"></div>
|
||||
</afx-vbox>
|
12
src/packages/Setting/schemes/locale.html
Normal file
12
src/packages/Setting/schemes/locale.html
Normal file
@ -0,0 +1,12 @@
|
||||
<afx-vbox data-id="locale">
|
||||
<div data-height="5"></div>
|
||||
<afx-hbox>
|
||||
<div data-width="10"></div>
|
||||
<afx-vbox>
|
||||
<afx-label text = "__(System locale)" iconclass = "fa fa-globe" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="lglist"></afx-list-view>
|
||||
<div data-height="10"></div>
|
||||
</afx-vbox>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
15
src/packages/Setting/schemes/startup.html
Normal file
15
src/packages/Setting/schemes/startup.html
Normal file
@ -0,0 +1,15 @@
|
||||
<afx-vbox data-id="startup">
|
||||
<div data-height="5"></div>
|
||||
<afx-hbox>
|
||||
<div data-width="10"></div>
|
||||
<afx-vbox>
|
||||
<afx-label text = "__(Startup services)" iconclass = "fa fa-tasks" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="srvlist"></afx-list-view>
|
||||
<div data-height="5"></div>
|
||||
<afx-label text = "__(Startup applications)" iconclass = "fa fa-adn" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="applist"></afx-list-view>
|
||||
<div data-height="10"></div>
|
||||
</afx-vbox>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
@ -1 +1,26 @@
|
||||
<afx-label text = "example2" ></afx-label>
|
||||
<afx-vbox data-id="vfs">
|
||||
<div data-height="5"></div>
|
||||
<afx-hbox>
|
||||
<div data-width="10"></div>
|
||||
<afx-vbox>
|
||||
<afx-label text = "__(Mount points)" iconclass = "fa fa-folder" class = "header" data-height="23"></afx-label>
|
||||
<afx-list-view data-id="mplist"></afx-list-view>
|
||||
<div data-height="5"></div>
|
||||
<afx-label text = "__(Desktop path)" iconclass = "fa fa-desktop" class = "header" data-height="23"></afx-label>
|
||||
<afx-hbox data-height = "25" >
|
||||
<div data-width="16"></div>
|
||||
<afx-label data-id="dpath"></afx-label>
|
||||
<afx-button text="" iconclass = "fa fa-arrow-up" data-id="btndpath" data-width="20" class="btnsel"></afx-button>
|
||||
</afx-hbox>
|
||||
<div data-height="5"></div>
|
||||
<afx-label text = "__(Local packages path)" iconclass = "fa fa-cube" class = "header" data-height="23"></afx-label>
|
||||
<afx-hbox data-height = "25" >
|
||||
<div data-width="16"></div>
|
||||
<afx-label data-id="ppath"></afx-label>
|
||||
<afx-button text="" data-id="btnppath" iconclass = "fa fa-arrow-up" data-width="20" class="btnsel"></afx-button>
|
||||
</afx-hbox>
|
||||
<div data-height="10"></div>
|
||||
</afx-vbox>
|
||||
<div data-width="10"></div>
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
Reference in New Issue
Block a user