ctrl+w=close window & minor fixes

This commit is contained in:
bordun 2020-03-12 11:01:59 +01:00
parent 17ac77ce9e
commit 1750909f24
5 changed files with 26 additions and 19 deletions

View file

@ -1,6 +1,4 @@
var html = require('nanohtml'),
UiModal = require('./ui-modal'),
notifications = require('./notifications'),
var notifications = require('./notifications'),
loading = null, timeout = null
module.exports = function uiLoading(title) {
@ -8,7 +6,6 @@ module.exports = function uiLoading(title) {
if (title === false && loading) {
clearTimeout(timeout)
timeout = setTimeout(()=>{
console.log('stop')
notifications.remove(loading)
loading = null
}, 500)

View file

@ -103,7 +103,7 @@ class Keys extends Widget {
keyUp(e) {
if (e.target && e.target.classList.contains('no-keybinding')) return
if (e.target && (e.target.tagName === 'INPUT' || e.target.tabName === 'TEXTAREA' || e.target.tabName === 'SELECT')) return
e.preventDefault()

View file

@ -1,4 +1,4 @@
var {app, Menu, shell} = require('electron'),
var {app, Menu, shell, BrowserWindow} = require('electron'),
settings = require('./settings'),
infos = require('../package.json')
@ -31,7 +31,7 @@ var template = [{
}]
if (process.platform === 'darwin') {
// Add app menu (OS X)
// Add app menu (macOs)
template.unshift({
label: settings.read('appName'),
submenu: [
@ -54,7 +54,7 @@ if (process.platform === 'darwin') {
},
{
label: 'Quit',
accelerator: 'Command+Q',
accelerator: 'CmdOrCtrl+Q',
click: ()=>app.quit()
}
]
@ -72,10 +72,21 @@ if (process.platform === 'darwin') {
{
type: 'separator'
},
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
click: ()=>{
var win = BrowserWindow.getFocusedWindow()
if (win) win.close()
}
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
},
]
},
{

View file

@ -57,16 +57,8 @@ module.exports = function(options={}) {
shell.openExternal(url)
})
// window.webContents.on('dom-ready', ()=>{
// window.webContents.executeJavaScript(`
// window.ELECTRON = true
// `)
// })
if (options.zoom === false) {
window.webContents.setVisualZoomLevelLimits(1, 1)
}
window.webContents.setVisualZoomLevelLimits(1, 1)
window.on('closed', function() {
window = null
@ -76,6 +68,13 @@ module.exports = function(options={}) {
window.loadURL(options.address)
if (process.platform !== 'darwin') {
// already registered in app menu on macOs
shortcut.register(window,'CmdOrCtrl+W',function(){
window.close()
})
}
if (options.shortcuts) {
shortcut.register(window,'CmdOrCtrl+R',function(){

View file

@ -70,7 +70,7 @@ function openClient() {
address += settings.read('urlOptions')
var launch = ()=>{
var win = require('./electron-window')({address:address, shortcuts:true, zoom:false, fullscreen: settings.read('fullScreen')})
var win = require('./electron-window')({address:address, shortcuts:true, fullscreen: settings.read('fullScreen')})
win.on('error', ()=>{
console.log('ERR')
})