Option to minimize KeeWeb on copy

Code review changes: https://github.com/keeweb/keeweb/pull/1721

https://github.com/keeweb/keeweb/issues/1718
This commit is contained in:
is 2021-02-23 08:43:01 +02:00
parent 7c4326939a
commit ad3f5afeba
8 changed files with 24 additions and 18 deletions

View File

@ -13,7 +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
minimizeOnCopy: false, // minimise the app on copy
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

@ -19,11 +19,6 @@ const Copyable = {
const msg = clipboardTime
? Locale.detFieldCopiedTime.replace('{}', clipboardTime)
: Locale.detFieldCopied;
if (AppSettingsModel.minimizeOnCopy) {
setTimeout(() => {
Events.emit('minimize-app');
}, 0);
}
let tip;
if (!this.isHidden()) {
tip = Tip.createTip(fieldLabel[0], {

View File

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

View File

@ -69,7 +69,6 @@ class AppView extends View {
this.listenTo(Events, 'select-all', this.selectAll);
this.listenTo(Events, 'menu-select', this.menuSelect);
this.listenTo(Events, 'lock-workspace', this.lockWorkspace);
this.listenTo(Events, 'minimize-app', this.minimizeApp);
this.listenTo(Events, 'show-file', this.showFileSettings);
this.listenTo(Events, 'open-file', this.toggleOpenFile);
this.listenTo(Events, 'save-all', this.saveAll);
@ -604,10 +603,6 @@ class AppView extends View {
}
}
minimizeApp() {
Launcher.minimizeApp();
}
closeAllFilesAndShowFirst() {
let fileToShow = this.model.files.find(
(file) => !file.demo && !file.created && !file.external

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,7 +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-copy': 'changeMinimizeOnCopy',
'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',
@ -100,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,
@ -342,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

@ -155,9 +155,9 @@
<label for="settings__general-minimize">{{res 'setGenMinInstead'}}</label>
</div>
<div>
<input type="checkbox" class="settings__input input-base settings__general-minimize-on-copy" id="settings__general-minimize-on-copy"
{{#if minimizeOnCopy}}checked{{/if}} />
<label for="settings__general-minimize-on-copy">{{res 'setGenMinOnCopy'}}</label>
<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}}

View File

@ -175,6 +175,7 @@ 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();
}