Add features:

This commit is contained in:
lxsang 2021-03-22 17:21:39 +01:00
parent 26a35a6c70
commit d384a65b73
5 changed files with 152 additions and 9 deletions

Binary file not shown.

View File

@ -61,10 +61,10 @@ namespace OS {
* process in the dock
*
* @private
* @type {application.BaseApplication}
* @type {AppDockItemType}
* @memberof AppDockTag
*/
private _selectedApp: application.BaseApplication;
private _selectedItem: AppDockItemType;
/**
*Creates an instance of AppDockTag.
@ -152,24 +152,39 @@ namespace OS {
* @memberof AppDockTag
*/
set selectedApp(v: application.BaseApplication) {
this._selectedApp = v;
let el = undefined;
for (let it of this.items) {
it.app.blur();
$(it.domel).removeClass();
if (v && v === it.app) {
el = it.domel;
el = it;
}
}
this._selectedItem = el;
if (!el) {
return;
}
$(el).addClass("selected");
$(el.domel).addClass("selected");
($(Ant.OS.GUI.workspace)[0] as FloatListTag).unselect();
}
get selectedApp(): application.BaseApplication {
return this._selectedApp;
if(!this._selectedItem)
return undefined;
return this._selectedItem.app;
}
/**
* Get selected item of the dock
*
* @readonly
* @type {AppDockItemType}
* @memberof AppDockTag
*/
get selectedItem(): AppDockItemType
{
return this._selectedItem;
}
/**
@ -267,6 +282,41 @@ namespace OS {
return m.show(e);
};
announcer.trigger("sysdockloaded", undefined);
GUI.bindKey("CTRL-ALT-2", (e) =>{
if(!this.items || this.items.length === 0)
{
return;
}
let index = this.items.indexOf(this.selectedItem);
if(index < 0)
{
index = 0;
}
else
{
index++;
}
if(index >= this.items.length)
index = 0;
this.items[index].app.trigger("focus");
});
GUI.bindKey("CTRL-ALT-1", (e) =>{
if(!this.items || this.items.length === 0)
{
return;
}
let index = this.items.indexOf(this.selectedItem);
index--;
if(index < 0)
{
index = this.items.length - 1;
}
if(index < 0)
{
return;
}
this.items[index].app.trigger("focus");
});
}
}
define("afx-apps-dock", AppDockTag);

View File

@ -30,6 +30,21 @@ namespace OS {
*/
private _view: boolean;
/**
* Store pending loading task
*
* @private
* @type {number[]}
* @memberof SystemPanelTag
*/
private _pending_task: number[];
/**
* Loading animation check timeout
*
* @memberof SystemPanelTag
*/
private _loading_toh: any;
/**
* Place holder for a private callback function
*
@ -49,6 +64,8 @@ namespace OS {
iconclass: "fa fa-circle",
};
this._view = false;
this._pending_task = [];
this._loading_toh = undefined;
}
/**
@ -342,6 +359,23 @@ namespace OS {
});
}
/**
* Check if the loading tasks ended,
* if it the case, stop the animation
*
* @private
* @memberof SystemPanelTag
*/
private animation_check(): void {
if(this._pending_task.length === 0)
{
$(this.refs.panel).removeClass("loading");
$(GUI.workspace).css("cursor", "auto");
}
if(this._loading_toh)
clearTimeout(this._loading_toh);
this._loading_toh = undefined;
}
/**
* Mount the tag bind some basic event
*
@ -435,6 +469,24 @@ namespace OS {
announcer.observable.on("app-pinned", (d) => {
this.RefreshPinnedApp();
});
announcer.observable.on("loading", (o) => {
this._pending_task.push(o.id);
if(!$(this.refs.panel).hasClass("loading"))
$(this.refs.panel).addClass("loading");
$(GUI.workspace).css("cursor", "wait");
});
announcer.observable.on("loaded", (o) => {
const i = this._pending_task.indexOf(o.id);
if (i >= 0) {
this._pending_task.splice(i, 1);
}
if (this._pending_task.length === 0) {
// set time out
if(!this._loading_toh)
this._loading_toh = setTimeout(() => this.animation_check(),1000);
}
});
this.RefreshPinnedApp();
}
}

View File

@ -75,11 +75,9 @@ namespace OS {
if (b && this.iconclass === "fa fa-bars") {
this.iconclass = "fa fa-spinner fa-spin";
this.update();
$(this._gui.workspace).css("cursor", "wait");
} else if (!b && this.iconclass === "fa fa-spinner fa-spin") {
this.iconclass = "fa fa-bars";
this.update();
$(this._gui.workspace).css("cursor", "auto");
}
}

View File

@ -9,6 +9,49 @@ afx-sys-panel > div{
padding: 0;
position:absolute;
}
afx-sys-panel > div.loading::before{
background-color: orangered;
content: "";
position: absolute;
height: 2px;
width: 0%;
}
afx-sys-panel > div.loading::before {
right: 0;
bottom:0;
animation: sys-loading 1s linear infinite;
}
@keyframes sys-loading {
0% {
right: auto;
left: 0;
width: 25%;
}
25% {
right: auto;
left: 25%;
width: 25%;
}
50% {
right: auto;
left: 50%;
width: 25%;
}
75% {
right: auto;
left: 75%;
width: 25%;
}
100% {
right: auto;
left: 100%;
width: 12.5%;
}
}
afx-sys-panel .afx-panel-os-menu {
padding:0;
margin: 0;