mirror of https://github.com/keeweb/keeweb.git
fix #45: optional auto-lock on minimize
This commit is contained in:
parent
99baca4b45
commit
a8bdcb2038
|
@ -88,6 +88,9 @@ if (window.process && window.process.versions && window.process.versions.electro
|
|||
Backbone.on('launcher-exit-request', function() {
|
||||
setTimeout(function() { Launcher.exit(); }, 0);
|
||||
});
|
||||
Backbone.on('launcher-minimize', function() {
|
||||
setTimeout(function() { Backbone.trigger('app-minimized'); }, 0);
|
||||
});
|
||||
window.launcherOpen = function(path) {
|
||||
Backbone.trigger('launcher-open-file', path);
|
||||
};
|
||||
|
|
|
@ -18,7 +18,8 @@ var AppSettingsModel = Backbone.Model.extend({
|
|||
idleMinutes: 15,
|
||||
minimizeOnClose: false,
|
||||
tableView: false,
|
||||
colorfulIcons: false
|
||||
colorfulIcons: false,
|
||||
lockOnMinimize: true
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
var Backbone = require('backbone'),
|
||||
GroupCollection = require('../collections/group-collection'),
|
||||
GroupModel = require('./group-model'),
|
||||
Launcher = require('../comp/launcher'),
|
||||
DropboxLink = require('../comp/dropbox-link'),
|
||||
Storage = require('../storage'),
|
||||
LastOpenFiles = require('../comp/last-open-files'),
|
||||
IconUrl = require('../util/icon-url'),
|
||||
|
|
|
@ -64,6 +64,7 @@ var AppView = Backbone.View.extend({
|
|||
this.listenTo(Backbone, 'edit-group', this.editGroup);
|
||||
this.listenTo(Backbone, 'launcher-open-file', this.launcherOpenFile);
|
||||
this.listenTo(Backbone, 'user-idle', this.userIdle);
|
||||
this.listenTo(Backbone, 'app-minimized', this.appMinimized);
|
||||
|
||||
this.listenTo(UpdateModel.instance, 'change:updateReady', this.updateApp);
|
||||
|
||||
|
@ -232,7 +233,6 @@ var AppView = Backbone.View.extend({
|
|||
return 'You have unsaved files, all changes will be lost.';
|
||||
} else if (Launcher && !Launcher.exitRequested && !Launcher.restartPending &&
|
||||
Launcher.canMinimize() && this.model.settings.get('minimizeOnClose')) {
|
||||
this.lockWorkspace(true);
|
||||
Launcher.minimizeApp();
|
||||
return Launcher.preventExit(e);
|
||||
}
|
||||
|
@ -269,6 +269,12 @@ var AppView = Backbone.View.extend({
|
|||
this.lockWorkspace(true);
|
||||
},
|
||||
|
||||
appMinimized: function() {
|
||||
if (this.model.settings.get('lockOnMinimize')) {
|
||||
this.lockWorkspace(true);
|
||||
}
|
||||
},
|
||||
|
||||
lockWorkspace: function(autoInit) {
|
||||
var that = this;
|
||||
if (Alerts.alertDisplayed) {
|
||||
|
|
|
@ -128,7 +128,7 @@ var SettingsAboutView = Backbone.View.extend({
|
|||
if (err) {
|
||||
Alerts.error({
|
||||
header: 'Save error',
|
||||
body: 'Error saving to file ' + path + ': \n' + e
|
||||
body: 'Error saving to file ' + path + ': \n' + err
|
||||
});
|
||||
} else {
|
||||
that.passwordChanged = false;
|
||||
|
|
|
@ -21,6 +21,7 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
'change .settings__general-clipboard': 'changeClipboard',
|
||||
'change .settings__general-auto-save': 'changeAutoSave',
|
||||
'change .settings__general-minimize': 'changeMinimize',
|
||||
'change .settings__general-lock-on-minimize': 'changeLockOnMinimize',
|
||||
'change .settings__general-table-view': 'changeTableView',
|
||||
'change .settings__general-colorful-icons': 'changeColorfulIcons',
|
||||
'click .settings__general-update-btn': 'checkUpdate',
|
||||
|
@ -53,7 +54,8 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
minimizeOnClose: AppSettingsModel.instance.get('minimizeOnClose'),
|
||||
devTools: Launcher && Launcher.devTools,
|
||||
canAutoUpdate: !!Launcher,
|
||||
canMinimizeOnClose: Launcher && Launcher.canMinimize(),
|
||||
canMinimize: Launcher && Launcher.canMinimize(),
|
||||
lockOnMinimize: Launcher && AppSettingsModel.instance.get('lockOnMinimize'),
|
||||
tableView: AppSettingsModel.instance.get('tableView'),
|
||||
canSetTableView: FeatureDetector.isDesktop(),
|
||||
autoUpdate: Updater.getAutoUpdateType(),
|
||||
|
@ -140,6 +142,11 @@ var SettingsGeneralView = Backbone.View.extend({
|
|||
AppSettingsModel.instance.set('minimizeOnClose', minimizeOnClose);
|
||||
},
|
||||
|
||||
changeLockOnMinimize: function(e) {
|
||||
var lockOnMinimize = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnMinimize', lockOnMinimize);
|
||||
},
|
||||
|
||||
changeTableView: function(e) {
|
||||
var tableView = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('tableView', tableView);
|
||||
|
|
|
@ -89,13 +89,18 @@
|
|||
</select>
|
||||
</div>
|
||||
<% } %>
|
||||
<% if (canMinimizeOnClose) { %>
|
||||
<% if (canMinimize) { %>
|
||||
<div>
|
||||
<input type="checkbox" class="settings__input input-base settings__general-minimize" id="settings__general-minimize"
|
||||
<%- minimizeOnClose ? 'checked' : '' %> />
|
||||
<%- minimizeOnClose ? 'checked' : '' %> />
|
||||
<label for="settings__general-minimize">Minimize app instead of close</label>
|
||||
</div>
|
||||
<% } %>
|
||||
<div>
|
||||
<input type="checkbox" class="settings__input input-base settings__general-lock-on-minimize" id="settings__general-lock-on-minimize"
|
||||
<%- lockOnMinimize ? 'checked' : '' %> />
|
||||
<label for="settings__general-lock-on-minimize">Auto-lock on minimize</label>
|
||||
</div>
|
||||
|
||||
<% if (devTools) { %>
|
||||
<h2>Advanced</h2>
|
||||
|
|
|
@ -28,38 +28,32 @@ app.on('window-all-closed', function() {
|
|||
app.removeAllListeners('window-all-closed');
|
||||
app.removeAllListeners('ready');
|
||||
app.removeAllListeners('open-file');
|
||||
app.removeAllListeners('activate');
|
||||
var userDataAppFile = path.join(app.getPath('userData'), 'app.js');
|
||||
delete require.cache[require.resolve('./app.js')];
|
||||
require(userDataAppFile);
|
||||
app.emit('ready');
|
||||
} else {
|
||||
app.quit();
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
});
|
||||
app.on('ready', function() {
|
||||
mainWindow = new BrowserWindow({
|
||||
show: false,
|
||||
width: 1000, height: 700, 'min-width': 600, 'min-height': 300,
|
||||
icon: path.join(__dirname, 'icon.png')
|
||||
});
|
||||
setMenu();
|
||||
mainWindow.loadUrl('file://' + htmlPath);
|
||||
mainWindow.webContents.on('dom-ready', function() {
|
||||
setTimeout(function() {
|
||||
mainWindow.show();
|
||||
ready = true;
|
||||
notifyOpenFile();
|
||||
}, 50);
|
||||
});
|
||||
mainWindow.on('closed', function() {
|
||||
mainWindow = null;
|
||||
});
|
||||
createMainWindow();
|
||||
});
|
||||
app.on('open-file', function(e, path) {
|
||||
e.preventDefault();
|
||||
openFile = path;
|
||||
notifyOpenFile();
|
||||
});
|
||||
app.on('activate', function() {
|
||||
if (process.platform === 'darwin') {
|
||||
if (!mainWindow) {
|
||||
createMainWindow();
|
||||
}
|
||||
}
|
||||
});
|
||||
app.restartApp = function() {
|
||||
restartPending = true;
|
||||
mainWindow.close();
|
||||
|
@ -83,6 +77,29 @@ app.minimizeApp = function() {
|
|||
}
|
||||
};
|
||||
|
||||
function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
show: false,
|
||||
width: 1000, height: 700, 'min-width': 600, 'min-height': 300,
|
||||
icon: path.join(__dirname, 'icon.png')
|
||||
});
|
||||
setMenu();
|
||||
mainWindow.loadUrl('file://' + htmlPath);
|
||||
mainWindow.webContents.on('dom-ready', function() {
|
||||
setTimeout(function() {
|
||||
mainWindow.show();
|
||||
ready = true;
|
||||
notifyOpenFile();
|
||||
}, 50);
|
||||
});
|
||||
mainWindow.on('closed', function() {
|
||||
mainWindow = null;
|
||||
});
|
||||
mainWindow.on('minimize', function() {
|
||||
emitBackboneEvent('launcher-minimize');
|
||||
});
|
||||
}
|
||||
|
||||
function restoreMainWindow() {
|
||||
appIcon.destroy();
|
||||
appIcon = null;
|
||||
|
@ -93,7 +110,11 @@ function restoreMainWindow() {
|
|||
function closeMainWindow() {
|
||||
appIcon.destroy();
|
||||
appIcon = null;
|
||||
mainWindow.webContents.executeJavaScript('Backbone.trigger("launcher-exit-request");');
|
||||
emitBackboneEvent('launcher-exit-request');
|
||||
}
|
||||
|
||||
function emitBackboneEvent(e) {
|
||||
mainWindow.webContents.executeJavaScript('Backbone.trigger("' + e + '");');
|
||||
}
|
||||
|
||||
function setMenu() {
|
||||
|
|
|
@ -4,6 +4,7 @@ Release notes
|
|||
2-way sync
|
||||
`*` disallow opening same files twice
|
||||
`+` #46: option to show colorful icons
|
||||
`+` #45: optional auto-lock on minimize
|
||||
|
||||
##### v0.4.6 (2015-11-25)
|
||||
`-` #32: visual glitches on Windows 10
|
||||
|
|
Loading…
Reference in New Issue