Skip to content

Commit

Permalink
Add initial window settings for electron
Browse files Browse the repository at this point in the history
  • Loading branch information
amarullz committed Aug 21, 2024
1 parent bcdf57a commit cd6ba9a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
49 changes: 49 additions & 0 deletions app/src/main/assets/view/m.js
Original file line number Diff line number Diff line change
Expand Up @@ -5962,6 +5962,11 @@ const pb={
'Open sidebar before exit',
'Sidebar to login screen'
],
cfginitwinstate_name:[
'Normal',
'Maximize',
'Fullscreen'
],
cfg_save:function(){
_JSAPI.storeSet(_API.user_prefix+'pb_cfg',JSON.stringify(pb.cfg_data));
},
Expand Down Expand Up @@ -5999,6 +6004,13 @@ const pb={
}
el.lastElementChild.innerHTML=pb.cfgexitmode_name[ls];
}
else if (key=='initwinstate'){
var ls=toInt(_JSAPI.varGet("initwinstate","0"));
if (ls<0||ls>2){
ls=0;
}
el.lastElementChild.innerHTML=pb.cfginitwinstate_name[ls];
}
else if (key=='cachesz'){
el.lastElementChild.innerHTML=_JSAPI.getCacheSz()+" MB";
}
Expand Down Expand Up @@ -6239,6 +6251,10 @@ const pb={
pb.cfg_update_el('loginscreen');
pb.cfg_update_el('exitmode');

if (_ISELECTRON){
pb.cfg_update_el('initwinstate');
}

pb.cfg_update_el('uifontsize');
pb.cfg_update_el('seekvalue');
pb.cfg_update_el('httpclient');
Expand Down Expand Up @@ -8006,6 +8022,25 @@ const pb={
}
);
}
else if (key=="initwinstate"){
var ls=toInt(_JSAPI.varGet("initwinstate","0"));
if (ls<0||ls>2){
ls=0;
}
listOrder.showList(
"Initial Window State",
pb.cfginitwinstate_name,
ls,
function(chval){
if (chval!=null){
ls=toInt(chval);
_JSAPI.storeSet("initwinstate",ls+"");
_JSAPI.varSet("initwinstate",ls+"");
pb.cfg_update_el(key);
}
}
);
}

else if (key=="httpclient"){
// pb.state=0;
Expand Down Expand Up @@ -13169,6 +13204,20 @@ const home={
home.settings.performance.P,
'<c class="check">clear</c><c>brand_awareness</c> Navigation Sound'
);


if (_ISELECTRON){
if (home.profiles.isadmin()){
home.settings.tools._s_initwinstate=$n(
'div','',{
action:'*initwinstate',
s_desc:"Set initial window state when app is launching"
},
home.settings.performance.P,
'<c>fullscreen</c> Initial Window State<span class="value"></span>'
);
}
}


home.settings.tools._s_homylist=$n(
Expand Down
24 changes: 17 additions & 7 deletions electron/src/animetv.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ const main={
var mainDisplay = screen.getPrimaryDisplay();
var dw = mainDisplay.size.width * 3 / 4;
var dh = mainDisplay.size.height * 3 / 4;

/* init values */
if ('__sd' in common.config){
main.vars.sd=common.config.__sd;
}
if ('initwinstate' in common.config){
main.vars.initwinstate=common.config.initwinstate;
main.vars.fullscreen=(main.vars.initwinstate==2);
}
main.vars.dns=common.dns;

/* Create new window */
main.win=new BrowserWindow({
fullscreen: false,
fullscreen: main.vars.fullscreen,
autoHideMenuBar: true,
show: false,
width: dw,
Expand All @@ -64,6 +74,11 @@ const main={
preload: common.path("/electron/src/preload.js"),
}
});
if (main.vars.initwinstate==1){
/* maximized */
main.win.maximize();
}
main.win.setMenu(null);
main.win.webContents.setUserAgent(common.UAG);

/* Init all handlers */
Expand All @@ -86,12 +101,6 @@ const main={
main.initialized=true;
}

/* init values */
if ('__sd' in common.config){
main.vars.sd=common.config.__sd;
}
main.vars.dns=common.dns;

/* Go home & show */
// main.win.setContentSize(dw, dh);
main.goHome();
Expand All @@ -110,6 +119,7 @@ const main={
httpclient:0,
sd_domain:'',
fullscreen:false,
initwinstate:0,
},
handlerIntent(e,d){
shell.openExternal(d);
Expand Down

0 comments on commit cd6ba9a

Please sign in to comment.