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 2a64aef024
8 changed files with 9278 additions and 9253 deletions

18346
d.ts/antos.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -222,7 +222,7 @@ namespace OS {
f: (e: JQuery.KeyboardEventBase) => void f: (e: JQuery.KeyboardEventBase) => void
): void { ): void {
const arr = k.toUpperCase().split("-"); const arr = k.toUpperCase().split("-");
const c = arr.pop(); let c = arr.pop();
let fnk = ""; let fnk = "";
if (arr.includes("META")) { if (arr.includes("META")) {
fnk += "META"; fnk += "META";
@ -236,7 +236,10 @@ namespace OS {
if (arr.includes("SHIFT")) { if (arr.includes("SHIFT")) {
fnk += "SHIFT"; fnk += "SHIFT";
} }
if (fnk == "" && arr.length == 0 && c == "ESC") {
fnk = "ESC";
c = String.fromCharCode(27).toUpperCase();
}
if ( fnk == "") { if ( fnk == "") {
return; return;
} }

View File

@ -297,7 +297,7 @@ namespace OS {
this.host = this._gui.desktop(); this.host = this._gui.desktop();
this.dialog = undefined; this.dialog = undefined;
// relay global events to local events // 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

@ -581,6 +581,11 @@ namespace OS {
* @returns {Promise<string>} * @returns {Promise<string>}
*/ */
function loadApp(app: string): 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) { return new Promise(async function (resolve, reject) {
let path: string = undefined; let path: string = undefined;
try { try {
@ -630,8 +635,10 @@ namespace OS {
application[app].style = el[0]; application[app].style = el[0];
} }
} catch(e_1){} } catch(e_1){}
announcer.trigger("APP-LOADED", ann);
return resolve(app); return resolve(app);
} catch (e) { } catch (e) {
announcer.trigger("APP-LOAD-ERROR", ann);
return reject(__e(e)); return reject(__e(e));
} }
}); });
@ -939,7 +946,7 @@ namespace OS {
force: boolean = true force: boolean = true
): void { ): void {
const arr = k.toUpperCase().split("-"); const arr = k.toUpperCase().split("-");
const c = arr.pop(); let c = arr.pop();
let fnk = ""; let fnk = "";
if (arr.includes("META")) { if (arr.includes("META")) {
fnk += "META"; fnk += "META";
@ -953,7 +960,10 @@ namespace OS {
if (arr.includes("SHIFT")) { if (arr.includes("SHIFT")) {
fnk += "SHIFT"; fnk += "SHIFT";
} }
if (fnk == "" && arr.length == 0 && c == "ESC") {
fnk = "ESC";
c = String.fromCharCode(27).toUpperCase();
}
if (fnk == "") { if (fnk == "") {
return; return;
} }
@ -1052,7 +1062,7 @@ namespace OS {
const scheme = $.parseHTML(schemes.ws); const scheme = $.parseHTML(schemes.ws);
$("#wrapper").append(scheme); $("#wrapper").append(scheme);
announcer.one("sysdockloaded", () => { announcer.one("SYS-DOCK-LOADED", () => {
$(window).on("keydown", function (event) { $(window).on("keydown", function (event) {
const dock = systemDock(); const dock = systemDock();
if (!dock) { if (!dock) {
@ -1074,6 +1084,9 @@ namespace OS {
if (event.shiftKey) { if (event.shiftKey) {
fnk += "SHIFT"; fnk += "SHIFT";
} }
if (fnk == "" && event.which == 27) {
fnk = "ESC";
}
//console.log(fnk, c); //console.log(fnk, c);
if (fnk == "") { if (fnk == "") {
return; return;
@ -1195,7 +1208,7 @@ namespace OS {
// load theme // load theme
loadTheme(setting.appearance.theme, true); loadTheme(setting.appearance.theme, true);
wallpaper(undefined); wallpaper(undefined);
OS.announcer.one("syspanelloaded", async function () { OS.announcer.one("SYS-PANEL-LOADED", async function () {
OS.announcer.on("systemlocalechange", (_) => OS.announcer.on("systemlocalechange", (_) =>
$("#syspanel")[0].update() $("#syspanel")[0].update()
); );

View File

@ -166,7 +166,7 @@ namespace OS {
id: this.aid, id: this.aid,
data: v data: v
}; };
announcer.trigger("appselect", evt); announcer.trigger("APP-SELECT", evt);
} }
get selectedApp(): application.BaseApplication { get selectedApp(): application.BaseApplication {
@ -403,7 +403,7 @@ namespace OS {
.css("bottom", $(this).height()); .css("bottom", $(this).height());
return m.show(); return m.show();
}; };
announcer.trigger("sysdockloaded", undefined); announcer.trigger("SYS-DOCK-LOADED", undefined);
GUI.bindKey("CTRL-ALT-2", (e) =>{ GUI.bindKey("CTRL-ALT-2", (e) =>{
if(!this.items || this.items.length === 0) if(!this.items || this.items.length === 0)
{ {

View File

@ -107,7 +107,7 @@ namespace OS {
height: $(this).height() height: $(this).height()
} }
} }
announcer.trigger("desktopresize", evt); announcer.trigger("DESKTOP-RESIZE", evt);
this.calibrate(); this.calibrate();
}; };

View File

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

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