Merge pull request #1721 from enter-is/develop

Option to minimize KeeWeb on copy
This commit is contained in:
Dimitri Witkowski 2021-02-26 18:46:43 +01:00 committed by GitHub
commit 78f0bc6f02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 2 deletions

View File

@ -13,6 +13,7 @@ const DefaultAppSettings = {
rememberKeyFiles: 'path', // remember keyfiles selected on the Open screen
idleMinutes: 15, // app lock timeout after inactivity, minutes
minimizeOnClose: false, // minimise the app instead of closing
minimizeOnFieldCopy: false, // minimise the app on copy
tableView: false, // view entries as a table instead of list
colorfulIcons: false, // use colorful custom icons instead of grayscale
useMarkdown: true, // use Markdown in Notes field

View File

@ -443,6 +443,7 @@
"setGenClearSeconds": "In {} seconds",
"setGenClearMinute": "In a minute",
"setGenMinInstead": "Minimize the app instead of close",
"setGenMinOnFieldCopy": "Minimize on field copy",
"setGenLock": "Auto lock",
"setGenLockMinimize": "When the app is minimized",
"setGenLockCopy": "On password copy",

View File

@ -29,6 +29,7 @@ import { isEqual } from 'util/fn';
import template from 'templates/details/details.hbs';
import emptyTemplate from 'templates/details/details-empty.hbs';
import groupTemplate from 'templates/details/details-group.hbs';
import { Launcher } from 'comp/launcher';
class DetailsView extends View {
parent = '.app__details';
@ -157,7 +158,7 @@ class DetailsView extends View {
fieldView.parent = views === fieldViews ? fieldsMainEl[0] : fieldsAsideEl[0];
fieldView.render();
fieldView.on('change', this.fieldChanged.bind(this));
fieldView.on('copy', this.fieldCopied.bind(this));
fieldView.on('copy', (e) => this.copyFieldValue(e));
fieldView.on('autotype', (e) => this.autoType(e.source.model.sequence));
if (hideEmptyFields) {
const value = fieldView.model.value();
@ -484,7 +485,8 @@ class DetailsView extends View {
CopyPaste.createHiddenInput(fieldText);
}
const copyRes = CopyPaste.copy(fieldText);
this.fieldCopied({ source: editView, copyRes });
this.copyFieldValue({ source: editView, copyRes });
return true;
}
return false;
@ -1006,6 +1008,13 @@ class DetailsView extends View {
this.views.issues.render();
}
}
copyFieldValue(e) {
this.fieldCopied(e);
if (AppSettingsModel.minimizeOnFieldCopy) {
Launcher.minimizeApp();
}
}
}
Object.assign(DetailsView.prototype, Scrollable);

View File

@ -36,6 +36,7 @@ class SettingsGeneralView extends View {
'change .settings__general-auto-save-interval': 'changeAutoSaveInterval',
'change .settings__general-remember-key-files': 'changeRememberKeyFiles',
'change .settings__general-minimize': 'changeMinimize',
'change .settings__general-minimize-on-field-copy': 'changeMinimizeOnFieldCopy',
'change .settings__general-audit-passwords': 'changeAuditPasswords',
'change .settings__general-audit-password-entropy': 'changeAuditPasswordEntropy',
'change .settings__general-exclude-pins-from-audit': 'changeExcludePinsFromAudit',
@ -99,6 +100,7 @@ class SettingsGeneralView extends View {
autoSaveInterval: AppSettingsModel.autoSaveInterval,
idleMinutes: AppSettingsModel.idleMinutes,
minimizeOnClose: AppSettingsModel.minimizeOnClose,
minimizeOnFieldCopy: AppSettingsModel.minimizeOnFieldCopy,
devTools: Launcher && Launcher.devTools,
canAutoUpdate: Updater.enabled,
canAutoSaveOnClose: !!Launcher,
@ -341,6 +343,11 @@ class SettingsGeneralView extends View {
AppSettingsModel.minimizeOnClose = minimizeOnClose;
}
changeMinimizeOnFieldCopy(e) {
const minimizeOnFieldCopy = e.target.checked || false;
AppSettingsModel.minimizeOnFieldCopy = minimizeOnFieldCopy;
}
changeAuditPasswords(e) {
const auditPasswords = e.target.checked || false;
AppSettingsModel.auditPasswords = auditPasswords;

View File

@ -154,6 +154,11 @@
{{#if minimizeOnClose}}checked{{/if}} />
<label for="settings__general-minimize">{{res 'setGenMinInstead'}}</label>
</div>
<div>
<input type="checkbox" class="settings__input input-base settings__general-minimize-on-field-copy" id="settings__general-minimize-on-field-copy"
{{#if minimizeOnFieldCopy}}checked{{/if}} />
<label for="settings__general-minimize-on-field-copy">{{res 'setGenMinOnFieldCopy'}}</label>
</div>
{{/if}}
{{#if canAutoType}}
<div>

View File

@ -174,6 +174,11 @@ main.restartAndUpdate = function (updateFilePath) {
};
main.minimizeApp = function (menuItemLabels) {
let imagePath;
// a workaround to correctly restore focus on windows platform
// without this workaround, focus is not restored to the previously focused field
if (process.platform === 'win32') {
mainWindow.minimize();
}
mainWindow.hide();
if (process.platform === 'darwin') {
main.dock.hide();