various changes:
All checks were successful
gitea-sync/antos-frontend/pipeline/head This commit looks good

- ESC (alone) key is now considered as function key for binding (global or application)
- Improve app launcher event handling
- Convention: Global announcement events are in upper case, local window events is in lower case
This commit is contained in:
DL 2024-06-24 17:38:49 +02:00
parent 9fa3ab92bf
commit 147353327b
11 changed files with 9288 additions and 9263 deletions

18470
d.ts/antos.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -127,7 +127,7 @@ namespace OS {
}
});
this.on("apptitlechange", () => this.sysdock.update(this));
this.subscribe("appregistry", (m) => {
this.subscribe("APP-REGISTRY", (m) => {
if (m.name === this.name) {
this.applySetting(m.message as string);
}
@ -222,7 +222,7 @@ namespace OS {
f: (e: JQuery.KeyboardEventBase) => void
): void {
const arr = k.toUpperCase().split("-");
const c = arr.pop();
let c = arr.pop();
let fnk = "";
if (arr.includes("META")) {
fnk += "META";
@ -236,7 +236,10 @@ namespace OS {
if (arr.includes("SHIFT")) {
fnk += "SHIFT";
}
if (fnk == "" && arr.length == 0 && c == "ESC") {
fnk = "ESC";
c = String.fromCharCode(27).toUpperCase();
}
if ( fnk == "") {
return;
}

View File

@ -297,7 +297,7 @@ namespace OS {
this.host = this._gui.desktop();
this.dialog = undefined;
// relay global events to local events
this.subscribe("desktopresize", (e) => this.observable.trigger("desktopresize", e));
this.subscribe("DESKTOP-RESIZE", (e) => this.observable.trigger("desktopresize", e));
}
/**

View File

@ -1711,7 +1711,7 @@ namespace OS {
* Set the current system locale: This function will
* find and load the locale dictionary definition file in the
* system asset resource, then trigger the global event
* `systemlocalechange` to translated all translatable text
* `SYSTEM-LOCALE-CHANGED` to translated all translatable text
* to the target language
*
* @export
@ -1725,7 +1725,7 @@ namespace OS {
const d = await API.get(path, "json");
OS.setting.system.locale = name;
API.lang = d;
announcer.ostrigger("systemlocalechange", name);
announcer.ostrigger("SYSTEM-LOCALE-CHANGED", name);
return resolve(d);
} catch (e) {
return reject(__e(e));

View File

@ -542,7 +542,7 @@ namespace OS {
if(OS.setting.system.startup.apps)
OS.setting.system.startup.apps = OS.setting.system.startup.apps.filter((e) => e != app);
// refresh pinned list
announcer.ostrigger("app-pinned", "app-pinned", undefined);
announcer.ostrigger("APP-PINNED", "APP-PINNED", undefined);
// remove application setting
if(OS.setting.applications[app])
delete OS.setting.applications[app];
@ -581,6 +581,11 @@ namespace OS {
* @returns {Promise<string>}
*/
function loadApp(app: string): Promise<string> {
const ann: API.AnnouncementDataType<Promise<any>> = {} as API.AnnouncementDataType<Promise<any>>;
ann.name = "OS";
ann.message = app;
ann.id = Math.floor(Math.random() * 1e6);
announcer.trigger("APP-LOADING",ann);
return new Promise(async function (resolve, reject) {
let path: string = undefined;
try {
@ -630,8 +635,10 @@ namespace OS {
application[app].style = el[0];
}
} catch(e_1){}
announcer.trigger("APP-LOADED", ann);
return resolve(app);
} catch (e) {
announcer.trigger("APP-LOAD-ERROR", ann);
return reject(__e(e));
}
});
@ -759,7 +766,7 @@ namespace OS {
data.message = key;
data.iconclass = mt?mt.iconclass:undefined;
data.u_data = undefined;
return announcer.trigger("appregistry", data);
return announcer.trigger("APP-REGISTRY", data);
});
const p = await PM.createProcess(
app,
@ -939,7 +946,7 @@ namespace OS {
force: boolean = true
): void {
const arr = k.toUpperCase().split("-");
const c = arr.pop();
let c = arr.pop();
let fnk = "";
if (arr.includes("META")) {
fnk += "META";
@ -953,7 +960,10 @@ namespace OS {
if (arr.includes("SHIFT")) {
fnk += "SHIFT";
}
if (fnk == "" && arr.length == 0 && c == "ESC") {
fnk = "ESC";
c = String.fromCharCode(27).toUpperCase();
}
if (fnk == "") {
return;
}
@ -1052,7 +1062,7 @@ namespace OS {
const scheme = $.parseHTML(schemes.ws);
$("#wrapper").append(scheme);
announcer.one("sysdockloaded", () => {
announcer.one("SYS-DOCK-LOADED", () => {
$(window).on("keydown", function (event) {
const dock = systemDock();
if (!dock) {
@ -1074,6 +1084,9 @@ namespace OS {
if (event.shiftKey) {
fnk += "SHIFT";
}
if (fnk == "" && event.which == 27) {
fnk = "ESC";
}
//console.log(fnk, c);
if (fnk == "") {
return;
@ -1195,8 +1208,8 @@ namespace OS {
// load theme
loadTheme(setting.appearance.theme, true);
wallpaper(undefined);
OS.announcer.one("syspanelloaded", async function () {
OS.announcer.on("systemlocalechange", (_) =>
OS.announcer.one("SYS-PANEL-LOADED", async function () {
OS.announcer.on("SYSTEM-LOCALE-CHANGED", (_) =>
$("#syspanel")[0].update()
);

View File

@ -67,7 +67,7 @@ namespace OS {
obj.birth = new Date().getTime();
PM.pidalloc++;
obj.pid = PM.pidalloc;
obj.subscribe("systemlocalechange", (d) => {
obj.subscribe("SYSTEM-LOCALE-CHANGED", (d) => {
obj.updateLocale(d.message as string);
return obj.update();
});

View File

@ -166,7 +166,7 @@ namespace OS {
id: this.aid,
data: v
};
announcer.trigger("appselect", evt);
announcer.trigger("APP-SELECT", evt);
}
get selectedApp(): application.BaseApplication {
@ -403,7 +403,7 @@ namespace OS {
.css("bottom", $(this).height());
return m.show();
};
announcer.trigger("sysdockloaded", undefined);
announcer.trigger("SYS-DOCK-LOADED", undefined);
GUI.bindKey("CTRL-ALT-2", (e) =>{
if(!this.items || this.items.length === 0)
{
@ -455,7 +455,7 @@ namespace OS {
this.addEventListener("wheel", (evt)=>{
(this as any).scrollLeft += (evt as WheelEvent).deltaY;
},{ passive: true});
announcer.on("app-pinned", (_) => {
announcer.on("APP-PINNED", (_) => {
this.refresh_pinned_app();
});
this.refresh_pinned_app();

View File

@ -107,7 +107,7 @@ namespace OS {
height: $(this).height()
}
}
announcer.trigger("desktopresize", evt);
announcer.trigger("DESKTOP-RESIZE", evt);
this.calibrate();
};
@ -190,7 +190,7 @@ namespace OS {
return this.refresh();
}
});
return announcer.ostrigger("desktoploaded", undefined);
return announcer.ostrigger("DESKTOP-LOADED", undefined);
};
super.mount();
}

View File

@ -40,7 +40,7 @@ namespace OS {
private _pending_task: Promise<any>[];
/**
* Flag indicate where the selected application shall be openned
* Flag indicate where the selected application shall be opened
*
* @private
* @type {boolean}
@ -117,7 +117,7 @@ namespace OS {
protected reload(d?: any): void { }
/**
* Attach a service to the system tray on the pannel,
* Attach a service to the system tray on the panel,
* this operation is performed when a service is started
*
* @param {BaseService} s
@ -384,7 +384,7 @@ namespace OS {
(this.refs.search as HTMLInputElement).value = "";
if(!OS.mobile)
{
$(this.refs.search).focus();
$(this.refs.search).trigger("focus");
}
} else {
@ -498,6 +498,11 @@ namespace OS {
return this.toggle(false);
}
});
Ant.OS.GUI.bindKey("ESC", (e) => {
if (this._view === true) {
return this.toggle(false);
}
});
const catlist = (this.refs.catlist as tag.TabBarTag);
catlist.ontabselect = (e) => {
const applist = (this.refs.applist as ListViewTag);
@ -554,14 +559,18 @@ namespace OS {
remove_task(o.u_data);
});
announcer.on("desktopresize", (e) => {
announcer.on("DESKTOP-RESIZE", (e) => {
this.calibrate();
});
announcer.on("appselect", (e) => {
announcer.on("APP-SELECT", (e) => {
if(this._view)
this.toggle(false);
});
Ant.OS.announcer.trigger("syspanelloaded", undefined);
announcer.on("APP-LOADING", (e) => {
if(this._view)
this.toggle(false);
});
Ant.OS.announcer.trigger("SYS-PANEL-LOADED", undefined);
}
}

View File

@ -161,7 +161,7 @@ namespace OS {
}
return result1;
})();
announcer.ostrigger("app-pinned", "app-pinned", this.applist.data);
announcer.ostrigger("APP-PINNED", "APP-PINNED", this.applist.data);
}
}
App.AppAndServiceHandle = AppAndServiceHandle;

View File

@ -1,14 +1,14 @@
afx-tab-bar[dir="row"] afx-list-view > div.list-container > ul > afx-list-item > li.selected
{
background-color: var(--background-tertiary);
background-color: var(--background-quaternary);
color:var(--text-primary);
border-bottom:2px solid var(--border-tertiary); /* #262626;*/
}
afx-tab-bar[dir="column"] afx-list-view > div.list-container > ul > afx-list-item > li.selected
{
background-color: var(--background-tertiary);
background-color: var(--background-quaternary);
color:var(--text-primary);
border-right:2px solid var(--border-tertiary); /* #262626;*/
}