Add features:

- allow pinning apps in Setting
- pinned apps in system pannel
- Services manager in Setting
- Fix and impprove some CSS bug
This commit is contained in:
lxsang
2021-03-15 19:20:42 +01:00
parent 26c397838b
commit 7cd2f97b75
18 changed files with 354 additions and 44 deletions

View File

@ -134,7 +134,7 @@ namespace OS {
return this.trigger("exit", undefined);
}
});
this.on("apptitlechange", () => this.sysdock.update(undefined));
this.on("apptitlechange", () => this.sysdock.update(this));
this.updateLocale(this.systemsetting.system.locale);
return this.loadScheme();
}

View File

@ -619,9 +619,9 @@ namespace OS {
data.iconclass = "fa fa-cogs";
}
const dock = $("#sysdock")[0] as tag.AppDockTag;
app.sysdock = dock;
app.init();
app.observable.one("rendered", function () {
app.sysdock = dock;
app.appmenu = $(
"[data-id = 'appmenu']",
"#syspanel"
@ -815,6 +815,7 @@ namespace OS {
if (arr.length > 1) {
tip = arr[1];
}
console.log(el);
const offset = $(el).offset();
const w = $(el).width();
const h = $(el).height();
@ -829,6 +830,10 @@ namespace OS {
left = offset.left + w / 2 - $(label).width() / 2;
top = offset.top - $(label).height() - 5;
break;
case "cb": // center bottom
left = offset.left + w / 2 - $(label).width() / 2;
top = offset.top + $(label).height() + 10;
break;
default:
if (!e) {
return;
@ -944,7 +949,7 @@ namespace OS {
$("#systooltip")[0].uify(undefined);
$("#contextmenu")[0].uify(undefined);
$("#workspace").on("contextmenu",(e) => bindContextMenu(e));
$("#wrapper").on("contextmenu",(e) => bindContextMenu(e));
// tooltip
$(document).on("mouseover", function (e) {
const el: any = $(e.target).closest("[tooltip]");

View File

@ -356,6 +356,13 @@ namespace OS {
* @type {string[]}
*/
services: string[];
/**
* List of pinned applications
*
* @type {string[]}
*/
pinned: string[];
};
}
/**
@ -476,6 +483,7 @@ namespace OS {
startup: {
apps: [],
services: ["Syslog/PushNotification", "Syslog/Calendar"],
pinned: [],
},
};
}
@ -530,7 +538,7 @@ namespace OS {
for (let k in setting.system.packages) {
const v = setting.system.packages[k];
if (v.app) {
var e, k1, v1;
var e: any, k1: string, v1: { [x: string]: any; detail?: any; path?: any; complex?: any; };
if (
v.name.match(term) ||
(v.description && v.description.match(term))

View File

@ -83,7 +83,25 @@ namespace OS {
* @param {*} [d]
* @memberof AppDockTag
*/
protected reload(d?: any): void {}
protected reload(d?: any): void {
let app: application.BaseApplication = d as application.BaseApplication;
if(!app)
{
return;
}
let i = -1;
const iterable = this.items;
for (let k = 0; k < iterable.length; k++) {
const v = iterable[k];
if (v.app.pid === app.pid) {
i = k;
break;
}
}
if (i !== -1) {
$(this.items[i].domel).attr("tooltip", `cr:${app.title()}`);
}
}
/**
* Init the tag before mounting
@ -171,10 +189,8 @@ namespace OS {
el[0].uify(this.observable);
bt.set(item);
bt.data = item.app;
$(el).on("mouseover", (e) =>{
el.attr("tooltip", `cr:${item.app.title()}`);
});
item.domel = bt;
$(bt).attr("tooltip", `cr:${item.app.title()}`);
bt.onbtclick = (e) => {
e.id = this.aid;
//e.data.item = item;

View File

@ -57,7 +57,7 @@ namespace OS {
* @protected
* @memberof SystemPanelTag
*/
protected init(): void {}
protected init(): void { }
/**
* Do nothing
@ -66,7 +66,7 @@ namespace OS {
* @param {*} [d]
* @memberof SystemPanelTag
*/
protected reload(d?: any): void {}
protected reload(d?: any): void { }
/**
* Attach a service to the system tray on the pannel,
@ -178,6 +178,11 @@ namespace OS {
ref: "osmenu",
class: "afx-panel-os-menu",
},
{
el: "afx-menu",
ref: "pinned",
class: "afx-panel-os-pinned-app",
},
{
el: "afx-menu",
id: "appmenu",
@ -305,9 +310,30 @@ namespace OS {
* @memberof SystemPanelTag
*/
calibrate(): void {
(this.refs.overlay as OverlayTag).height = `${
$(window).height() - $(this.refs.panel).height()
}px`;
(this.refs.overlay as OverlayTag).height = `${$(window).height() - $(this.refs.panel).height()
}px`;
}
/**
* Refresh the pinned applications menu
*
* @private
* @memberof SystemPanelTag
*/
private RefreshPinnedApp(): void
{
if(!setting.system.startup.pinned)
return;
(this.refs.pinned as GUI.tag.MenuTag).items = setting.system.startup.pinned.map((name) => {
const app = setting.system.packages[name];
return {
icon: app.icon,
iconclass: app.iconclass,
app: app.app,
tooltip: `cb:${app.name}`
};
});
}
/**
@ -358,11 +384,11 @@ namespace OS {
return this.toggle(true);
};
$(this.refs.search).on("keyup",(e) => {
$(this.refs.search).on("keyup", (e) => {
return this.search(e);
});
$(this.refs.applist).on("click",(e) => {
$(this.refs.applist).on("click", (e) => {
return this.open();
});
Ant.OS.GUI.bindKey("CTRL- ", (e) => {
@ -378,6 +404,32 @@ namespace OS {
.css("top", `${$(this.refs.panel).height()}px`)
.css("bottom", "0")
.hide();
(this.refs.pinned as GUI.tag.MenuTag).onmenuselect = (e) => {
const app = e.data.item.data.app;
if(!app)
return;
GUI.launch(app, []);
};
this.refs.appmenu.contextmenuHandle = (e, m) => { }
this.refs.osmenu.contextmenuHandle = (e, m) => { }
this.refs.systray.contextmenuHandle = (e, m) => { }
this.refs.pinned.contextmenuHandle = (e, m) => { }
this.refs.panel.contextmenuHandle = (e, m) => {
let menu = [
{ text: __("Applications and services setting"), dataid: "app&srv" }
];
m.items = menu;
m.onmenuselect = function (
evt: TagEventType<tag.MenuEventData>
) {
GUI.launch("Setting",[]);
}
m.show(e);
};
announcer.observable.on("app-pinned", (d) => {
this.RefreshPinnedApp();
});
this.RefreshPinnedApp();
}
}

View File

@ -209,6 +209,7 @@ namespace OS {
$(this).attr("apptitle", v.__());
if (v) {
(this.refs["txtTitle"] as LabelTag).text = v;
this.observable.trigger("apptitlechange", this);
}
}
get apptitle(): string | FormattedString {