minimize to tray on windows

This commit is contained in:
Antelle 2015-11-21 10:29:49 +03:00
commit 7df0328e1d
8 changed files with 55 additions and 15 deletions

View File

@ -4,7 +4,7 @@
Nov
- [x] desktop dropbox
- [x] lock flow, auto-lock
- [ ] minimize to tray
- [x] minimize to tray
- [ ] trim history by rules
- [ ] custom icons, favicons
- [x] drag to trash

View File

@ -77,6 +77,12 @@ if (window.process && window.process.versions && window.process.versions.electro
},
clearClipboardText: function() {
return this.req('clipboard').clear();
},
minimizeApp: function() {
this.remReq('app').minimizeApp();
},
canMinimize: function() {
return process.platform === 'win32';
}
};
window.launcherOpen = function(path) {

View File

@ -15,7 +15,8 @@ var AppSettingsModel = Backbone.Model.extend({
autoUpdate: 'install',
clipboardSeconds: 0,
autoSave: true,
idleMinutes: 15
idleMinutes: 15,
minimizeOnClose: false
},
initialize: function() {

View File

@ -223,6 +223,10 @@ var AppView = Backbone.View.extend({
return Launcher.preventExit(e);
}
return 'You have unsaved files, all changes will be lost.';
} else if (Launcher && !Launcher.exitRequested && Launcher.canMinimize() && this.model.settings.get('minimizeOnClose')) {
this.lockWorkspace(true);
Launcher.minimizeApp();
return Launcher.preventExit(e);
}
},

View File

@ -19,6 +19,7 @@ var SettingsGeneralView = Backbone.View.extend({
'change .settings__general-idle-minutes': 'changeIdleMinutes',
'change .settings__general-clipboard': 'changeClipboard',
'change .settings__general-auto-save': 'changeAutoSave',
'change .settings__general-minimize': 'changeMinimize',
'click .settings__general-update-btn': 'checkUpdate',
'click .settings__general-restart-btn': 'restartApp',
'click .settings__general-download-update-btn': 'downloadUpdate',
@ -46,8 +47,10 @@ var SettingsGeneralView = Backbone.View.extend({
clipboardSeconds: AppSettingsModel.instance.get('clipboardSeconds'),
autoSave: AppSettingsModel.instance.get('autoSave'),
idleMinutes: AppSettingsModel.instance.get('idleMinutes'),
minimizeOnClose: AppSettingsModel.instance.get('minimizeOnClose'),
devTools: Launcher && Launcher.devTools,
canAutoUpdate: !!Launcher,
canMinimizeOnClose: Launcher && Launcher.canMinimize(),
autoUpdate: Updater.getAutoUpdateType(),
updateInProgress: Updater.updateInProgress(),
updateInfo: this.getUpdateInfo(),
@ -126,6 +129,11 @@ var SettingsGeneralView = Backbone.View.extend({
AppSettingsModel.instance.set('autoSave', autoSave);
},
changeMinimize: function(e) {
var minimizeOnClose = e.target.checked || false;
AppSettingsModel.instance.set('minimizeOnClose', minimizeOnClose);
},
restartApp: function() {
if (Launcher) {
Launcher.requestRestart();

View File

@ -52,18 +52,6 @@
</div>
<h2>Function</h2>
<% if (canClearClipboard) { %>
<div>
<label for="settings__general-clipboard">Clear clipboard after copy:</label>
<select class="settings__general-clipboard settings__select input-base" id="settings__general-clipboard">
<option value="0" <%= clipboardSeconds ? '' : 'selected' %>>Don't clear</option>
<option value="5" <%= clipboardSeconds === 5 ? 'selected' : '' %>>In 5 seconds</option>
<option value="10" <%= clipboardSeconds === 10 ? 'selected' : '' %>>In 10 seconds</option>
<option value="15" <%= clipboardSeconds === 15 ? 'selected' : '' %>>In 15 seconds</option>
<option value="60" <%= clipboardSeconds === 60 ? 'selected' : '' %>>In a minute</option>
</select>
</div>
<% } %>
<div>
<input type="checkbox" class="settings__input input-base settings__general-auto-save" id="settings__general-auto-save"
<%- autoSave ? 'checked' : '' %> />
@ -79,6 +67,25 @@
<option value="60" <%= idleMinutes === 60 ? 'selected' : '' %>>In an hour</option>
</select>
</div>
<% if (canClearClipboard) { %>
<div>
<label for="settings__general-clipboard">Clear clipboard after copy:</label>
<select class="settings__general-clipboard settings__select input-base" id="settings__general-clipboard">
<option value="0" <%= clipboardSeconds ? '' : 'selected' %>>Don't clear</option>
<option value="5" <%= clipboardSeconds === 5 ? 'selected' : '' %>>In 5 seconds</option>
<option value="10" <%= clipboardSeconds === 10 ? 'selected' : '' %>>In 10 seconds</option>
<option value="15" <%= clipboardSeconds === 15 ? 'selected' : '' %>>In 15 seconds</option>
<option value="60" <%= clipboardSeconds === 60 ? 'selected' : '' %>>In a minute</option>
</select>
</div>
<% } %>
<% if (canMinimizeOnClose) { %>
<div>
<input type="checkbox" class="settings__input input-base settings__general-minimize" id="settings__general-minimize"
<%- minimizeOnClose ? 'checked' : '' %> />
<label for="settings__general-minimize">Minimize app instead of close</label>
</div>
<% } %>
<% if (devTools) { %>
<h2>Advanced</h2>

View File

@ -6,7 +6,8 @@
var app = require('app'),
BrowserWindow = require('browser-window'),
path = require('path'),
Menu = require('menu');
Menu = require('menu'),
Tray = require('tray');
var mainWindow = null,
openFile = process.argv.filter(function(arg) { return /\.kdbx$/i.test(arg); })[0],
@ -60,6 +61,18 @@ app.quitAndRestart = function() {
app.openWindow = function(opts) {
return new BrowserWindow(opts);
};
app.minimizeApp = function() {
if (process.platform === 'win32') {
mainWindow.minimize();
mainWindow.setSkipTaskbar(true);
var appIcon = new Tray(path.join(__dirname, 'icon.png'));
appIcon.on('clicked', function () {
mainWindow.restore();
mainWindow.setSkipTaskbar(false);
});
appIcon.setToolTip('KeeWeb');
}
};
function setMenu() {
if (process.platform === 'darwin') {

View File

@ -3,6 +3,7 @@ Release notes
##### vNext
Locking, better Dropbox, security enhancements, bugfixes
`+` lock flow, auto-lock
`+` minimize to tray on windows
`-` fixed tag list scrolling
`+` desktop Dropbox
`+` Dropbox notification in self-hosted apps