Update major applications to support AntOS v2.0.x

This commit is contained in:
DanyLE
2023-01-01 01:54:04 +01:00
parent 695044704b
commit 7171a7eb3b
212 changed files with 2135 additions and 3806 deletions

View File

@ -0,0 +1,7 @@
# Preview
Image and PDF file viewer for AntOS
## Change logs
* v0.1.2-a: support AntOS v2.0.x
* v0.1.0-a: add depends on libpdfjs, user the default PDFJS viewer

BIN
Preview/build/debug/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,47 @@
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"]
{
display: block;
overflow:auto;
background-image: url("bg.jpg");
background-repeat: repeat;
}
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"]
{
background-color: transparent;
border-bottom: 1px solid #cbcbcb;
}
afx-app-window[data-id = "preview-win"] div[data-id="status"]
{
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
}
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] button,
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] input
{
height: 24px;
}
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] canvas{
margin-left: auto;
margin-right: auto;
display: block;
}
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div.pdf-page {
margin-bottom: 5px;
}
/*
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"].image
{
display: flex;
align-items: center;
justify-content: center;
}*/
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"].pdf
{
overflow: hidden;
}

View File

@ -0,0 +1 @@
(function(){var i;i=class extends this.OS.application.BaseApplication{constructor(i){super("Preview",i)}main(){return this.currfile=void 0,this.args&&this.args.length>0&&(this.currfile=this.args[0].path.asFileHandle()),this.view=this.find("view"),this.status=this.find("status"),this.zoom=this.find("zoom"),this.btreset=this.find("btreset"),this.zoom.onvaluechange=i=>this.setViewScale(i.data),this.btreset.onbtclick=i=>(this.zoom.value=100,this.setViewScale(100)),this.img=void 0,this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-X",()=>this.actionFile(this.name+"-Close")),this.zoom.max=200,this.zoom.value=100,this.open(this.currfile)}open(i){if(i)return this.currfile!==i&&(this.currfile=i),i.onready().then(()=>(i.info.size=(i.info.size/1024).toFixed(2),this.renderFile())).catch(t=>this.error(__("File not found {0}",i.path),t))}renderFile(){var i;if(i=this.currfile.info.mime)return this.img=void 0,$(this.view).empty(),this.zoom.value=100,this.scheme.apptitle=this.currfile.info.name,i.match(/^[^\/]+\/.*pdf.*/g)?this.renderPDF():i.match(/image\/.*svg.*/g)?this.renderSVG():i.match(/image\/.*/g)?this.renderImage():this.notify(__("Mime type {0} is not supported",file.info.mime))}setStatus(i){return $(this.status).html(i)}setViewScale(i){var t,e,s,h,r,a;if(this.currfile){if(r=i/100,(h=this.currfile.info.mime).match(/image\/.*svg.*/g))return $($(this.view).children()[0]).css("width",Math.round(i)+"%").css("height",Math.round(i)+"%");if(h.match(/image\/.*/g)){if(!this.img)return;return e=(t=$(this.view).children()[0]).getContext("2d"),a=this.img.width*r,s=this.img.height*r,t.height=s,t.width=a,e.clearRect(0,0,t.width,t.height),e.scale(r,r),e.drawImage(this.img,0,0)}}}renderPDF(){var i;return $(this.find("statcontainer")).hide(),this.trigger("resize"),$(this.view).attr("class","pdf"),i=$("<iframe/>").css("width","100%").css("height","100%"),$(this.view).append(i[0]),i[0].src="pkg://libpdfjs/web/viewer.html".asFileHandle().getlink()+"?file="+this.currfile.getlink()}renderSVG(){return $(this.find("statcontainer")).show(),this.trigger("resize"),$(this.view).attr("class","image"),this.currfile.read().then(i=>(this.view.innerHTML=i,$($(this.view).children()[0]).css("width","100%").css("height","100%"))).catch(i=>this.error(__("Unable to read file: {0}",this.currfile.path),i))}renderImage(){return $(this.find("statcontainer")).show(),this.trigger("resize"),$(this.view).attr("class","image"),this.currfile.read("binary").then(i=>{var t,e,s;return s=new Image,e=$("<canvas/>")[0],$(this.view).append(e),s.onload=()=>{var i;return i=e.getContext("2d"),e.height=s.height,e.width=s.width,this.img=s,i.drawImage(s,0,0),this.setStatus(`${this.currfile.info.size} Kb - ${s.width}x${s.height}`)},t=new Blob([i],{type:this.currfile.info.mime}),s.src=URL.createObjectURL(t)}).catch(i=>this.error(__("Unable to read file: {0}",this.currfile.path),i))}menu(){return[{text:"__(File)",nodes:[{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Close)",dataid:this.name+"-Close",shortcut:"C-X"}],onchildselect:i=>this.actionFile(i.data.item.data.dataid)}]}actionFile(i){switch(i){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file"),mimes:this.meta().mimes}).then(i=>this.open(i.file.path.asFileHandle()));case this.name+"-Close":return this.quit()}}},this.OS.register("Preview",i)}).call(this);

View File

@ -0,0 +1,14 @@
{
"app":"Preview",
"name":"Preview",
"description":"Media files viewer",
"info":{
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.1.2-a",
"category":"Graphics",
"iconclass":"fa fa-eye",
"mimes":["[^\/]*/.*pdf", "image/.*"],
"dependencies": ["libpdfjs@2.6.347-r"]
}

View File

@ -0,0 +1,12 @@
<afx-app-window data-id = "preview-win" apptitle="Preview" width="600" height="400">
<afx-vbox data-id = "container">
<div data-id="view" ></div>
<afx-hbox data-height = "35" data-id = "statcontainer" >
<afx-button iconclass="fa fa-arrows-alt" data-id="btreset" data-width="content"></afx-button>
<div data-width = "5" ></div>
<afx-slider data-width="150" data-id="zoom" ></afx-slider>
<div data-id = "status" style="text-align: right;"></div>
<div data-width = "10" ></div>
</afx-hbox>
</afx-vbox>
</afx-app-window>