mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-20 06:56:40 +02:00
app setting model
This commit is contained in:
parent
00291da933
commit
9c3c9d28fa
|
@ -61,7 +61,7 @@ ready(() => {
|
|||
|
||||
function loadConfigs() {
|
||||
return Promise.all([
|
||||
AppSettingsModel.instance.load(),
|
||||
AppSettingsModel.load(),
|
||||
UpdateModel.instance.load(),
|
||||
RuntimeDataModel.instance.load(),
|
||||
FileInfoCollection.instance.load()
|
||||
|
@ -100,7 +100,7 @@ ready(() => {
|
|||
SettingsManager.setBySettings(appModel.settings);
|
||||
})
|
||||
.catch(e => {
|
||||
if (!appModel.settings.get('cacheConfigSettings')) {
|
||||
if (!appModel.settings.cacheConfigSettings) {
|
||||
showSettingsLoadError();
|
||||
throw e;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ ready(() => {
|
|||
function showApp() {
|
||||
return Promise.resolve().then(() => {
|
||||
const skipHttpsWarning =
|
||||
localStorage.skipHttpsWarning || appModel.settings.get('skipHttpsWarning');
|
||||
localStorage.skipHttpsWarning || appModel.settings.skipHttpsWarning;
|
||||
const protocolIsInsecure = ['https:', 'file:', 'app:'].indexOf(location.protocol) < 0;
|
||||
const hostIsInsecure = location.hostname !== 'localhost';
|
||||
if (protocolIsInsecure && hostIsInsecure && !skipHttpsWarning) {
|
||||
|
|
|
@ -65,7 +65,7 @@ const AutoType = {
|
|||
}
|
||||
});
|
||||
|
||||
if (AppSettingsModel.instance.get('lockOnAutoType')) {
|
||||
if (AppSettingsModel.lockOnAutoType) {
|
||||
Events.emit('lock-workspace');
|
||||
}
|
||||
},
|
||||
|
@ -222,7 +222,7 @@ const AutoType = {
|
|||
|
||||
processEventWithFilter(evt) {
|
||||
const entries = evt.filter.getEntries();
|
||||
if (entries.length === 1 && AppSettingsModel.instance.get('directAutotype')) {
|
||||
if (entries.length === 1 && AppSettingsModel.directAutotype) {
|
||||
this.hideWindow(() => {
|
||||
this.runAndHandleResult({ entry: entries.at(0) });
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ const AppRightsChecker = {
|
|||
if (!Features.isDesktop || !Features.isMac) {
|
||||
return;
|
||||
}
|
||||
if (AppSettingsModel.instance.get('skipFolderRightsWarning')) {
|
||||
if (AppSettingsModel.skipFolderRightsWarning) {
|
||||
return;
|
||||
}
|
||||
if (!Launcher.getAppPath().startsWith(this.AppPath)) {
|
||||
|
@ -71,7 +71,7 @@ const AppRightsChecker = {
|
|||
dontAskAnymore() {
|
||||
this.needRunInstaller(needRun => {
|
||||
if (needRun) {
|
||||
AppSettingsModel.instance.set('skipFolderRightsWarning', true);
|
||||
AppSettingsModel.skipFolderRightsWarning = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ DropboxChooser.prototype.choose = function() {
|
|||
DropboxChooser.prototype.buildUrl = function() {
|
||||
const urlParams = {
|
||||
origin: encodeURIComponent(window.location.protocol + '//' + window.location.host),
|
||||
'app_key': AppSettingsModel.instance.get('dropboxAppKey') || ChooserAppKey,
|
||||
'app_key': AppSettingsModel.dropboxAppKey || ChooserAppKey,
|
||||
'link_type': 'direct',
|
||||
trigger: 'js',
|
||||
multiselect: 'false',
|
||||
|
|
|
@ -3,13 +3,13 @@ import { AppSettingsModel } from 'models/app-settings-model';
|
|||
const ExportApi = {
|
||||
settings: {
|
||||
get(key) {
|
||||
return key ? AppSettingsModel.instance.get(key) : AppSettingsModel.instance.toJSON();
|
||||
return key ? AppSettingsModel[key] : Object.assign({}, AppSettingsModel);
|
||||
},
|
||||
set(key, value) {
|
||||
AppSettingsModel.instance.set(key, value);
|
||||
AppSettingsModel[key] = value;
|
||||
},
|
||||
del(key) {
|
||||
AppSettingsModel.instance.unset(key);
|
||||
delete AppSettingsModel[key];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -73,7 +73,7 @@ const GeneratorPresets = {
|
|||
presets.forEach(preset => {
|
||||
preset.builtIn = true;
|
||||
});
|
||||
const setting = AppSettingsModel.instance.get('generatorPresets');
|
||||
const setting = AppSettingsModel.generatorPresets;
|
||||
if (setting) {
|
||||
if (setting.user) {
|
||||
presets = presets.concat(setting.user.map(_.clone));
|
||||
|
@ -104,7 +104,7 @@ const GeneratorPresets = {
|
|||
},
|
||||
|
||||
getOrCreateSetting() {
|
||||
let setting = AppSettingsModel.instance.get('generatorPresets');
|
||||
let setting = AppSettingsModel.generatorPresets;
|
||||
if (!setting) {
|
||||
setting = { user: [] };
|
||||
}
|
||||
|
@ -160,8 +160,8 @@ const GeneratorPresets = {
|
|||
},
|
||||
|
||||
save(setting) {
|
||||
AppSettingsModel.instance.unset('generatorPresets', { silent: true });
|
||||
AppSettingsModel.instance.set('generatorPresets', setting);
|
||||
AppSettingsModel.set({ generatorPresets: undefined }, { silent: true });
|
||||
AppSettingsModel.generatorPresets = setting;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -82,9 +82,7 @@ const Shortcuts = {
|
|||
return this.presentShortcut(this.globalShortcut(type), formatting);
|
||||
},
|
||||
globalShortcut(type) {
|
||||
const appSettingsShortcut = AppSettingsModel.instance.get(
|
||||
this.globalShortcutAppSettingsKey(type)
|
||||
);
|
||||
const appSettingsShortcut = AppSettingsModel[this.globalShortcutAppSettingsKey(type)];
|
||||
if (appSettingsShortcut) {
|
||||
return appSettingsShortcut;
|
||||
}
|
||||
|
@ -102,11 +100,11 @@ const Shortcuts = {
|
|||
throw new Error('Bad shortcut: ' + type);
|
||||
}
|
||||
if (value) {
|
||||
AppSettingsModel.instance.set(this.globalShortcutAppSettingsKey(type), value);
|
||||
AppSettingsModel[this.globalShortcutAppSettingsKey(type)] = value;
|
||||
} else {
|
||||
AppSettingsModel.instance.unset(this.globalShortcutAppSettingsKey(type));
|
||||
delete AppSettingsModel[this.globalShortcutAppSettingsKey(type)];
|
||||
}
|
||||
Launcher.setGlobalShortcuts(AppSettingsModel.instance.attributes);
|
||||
Launcher.setGlobalShortcuts(AppSettingsModel.attributes);
|
||||
},
|
||||
globalShortcutAppSettingsKey(type) {
|
||||
return 'globalShortcut' + StringFormat.capFirst(type);
|
||||
|
|
|
@ -24,7 +24,7 @@ const Updater = {
|
|||
if (!this.enabled) {
|
||||
return false;
|
||||
}
|
||||
let autoUpdate = AppSettingsModel.instance.get('autoUpdate');
|
||||
let autoUpdate = AppSettingsModel.autoUpdate;
|
||||
if (autoUpdate && autoUpdate === true) {
|
||||
autoUpdate = 'install';
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ const CopyPaste = {
|
|||
copy(text) {
|
||||
if (this.simpleCopy) {
|
||||
Launcher.setClipboardText(text);
|
||||
const clipboardSeconds = AppSettingsModel.instance.get('clipboardSeconds');
|
||||
const clipboardSeconds = AppSettingsModel.clipboardSeconds;
|
||||
if (clipboardSeconds > 0) {
|
||||
const clearClipboard = () => {
|
||||
if (Launcher.getClipboardText() === text) {
|
||||
|
|
|
@ -8,7 +8,7 @@ const IdleTracker = {
|
|||
},
|
||||
checkIdle() {
|
||||
const idleMinutes = (Date.now() - this.actionTime) / 1000 / 60;
|
||||
const maxIdleMinutes = AppSettingsModel.instance.get('idleMinutes');
|
||||
const maxIdleMinutes = AppSettingsModel.idleMinutes;
|
||||
if (maxIdleMinutes && idleMinutes > maxIdleMinutes) {
|
||||
Events.emit('user-idle');
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ const SettingsManager = {
|
|||
customLocales: {},
|
||||
|
||||
setBySettings(settings) {
|
||||
if (settings.get('theme')) {
|
||||
this.setTheme(settings.get('theme'));
|
||||
if (settings.theme) {
|
||||
this.setTheme(settings.theme);
|
||||
}
|
||||
this.setFontSize(settings.get('fontSize'));
|
||||
const locale = settings.get('locale');
|
||||
this.setFontSize(settings.fontSize);
|
||||
const locale = settings.locale;
|
||||
try {
|
||||
if (locale) {
|
||||
this.setLocale(settings.get('locale'));
|
||||
this.setLocale(settings.locale);
|
||||
} else {
|
||||
this.setLocale(this.getBrowserLocale());
|
||||
}
|
||||
|
|
|
@ -36,10 +36,7 @@ const Copyable = {
|
|||
tip.hide();
|
||||
}
|
||||
this.fieldCopyTip = null;
|
||||
if (
|
||||
e.source.model.name === '$Password' &&
|
||||
AppSettingsModel.instance.get('lockOnCopy')
|
||||
) {
|
||||
if (e.source.model.name === '$Password' && AppSettingsModel.lockOnCopy) {
|
||||
setTimeout(() => {
|
||||
Events.emit('lock-workspace');
|
||||
}, Timeouts.BeforeAutoLock);
|
||||
|
|
|
@ -33,7 +33,7 @@ const AppModel = Backbone.Model.extend({
|
|||
this.menu = new MenuModel();
|
||||
this.filter = {};
|
||||
this.sort = 'title';
|
||||
this.settings = AppSettingsModel.instance;
|
||||
this.settings = AppSettingsModel;
|
||||
this.activeEntryId = null;
|
||||
this.isBeta = RuntimeInfo.beta;
|
||||
this.advancedSearch = null;
|
||||
|
@ -264,7 +264,7 @@ const AppModel = Backbone.Model.extend({
|
|||
|
||||
setFilter(filter) {
|
||||
this.filter = this.prepareFilter(filter);
|
||||
this.filter.subGroups = this.settings.get('expandGroups');
|
||||
this.filter.subGroups = this.settings.expandGroups;
|
||||
if (!this.filter.advanced && this.advancedSearch) {
|
||||
this.filter.advanced = this.advancedSearch;
|
||||
}
|
||||
|
@ -582,12 +582,9 @@ const AppModel = Backbone.Model.extend({
|
|||
let needLoadKeyFile = false;
|
||||
if (!params.keyFileData && fileInfo && fileInfo.get('keyFileName')) {
|
||||
params.keyFileName = fileInfo.get('keyFileName');
|
||||
if (this.settings.get('rememberKeyFiles') === 'data') {
|
||||
if (this.settings.rememberKeyFiles === 'data') {
|
||||
params.keyFileData = FileModel.createKeyFileWithHash(fileInfo.get('keyFileHash'));
|
||||
} else if (
|
||||
this.settings.get('rememberKeyFiles') === 'path' &&
|
||||
fileInfo.get('keyFilePath')
|
||||
) {
|
||||
} else if (this.settings.rememberKeyFiles === 'path' && fileInfo.get('keyFilePath')) {
|
||||
params.keyFilePath = fileInfo.get('keyFilePath');
|
||||
if (Storage.file.enabled) {
|
||||
needLoadKeyFile = true;
|
||||
|
@ -696,7 +693,7 @@ const AppModel = Backbone.Model.extend({
|
|||
backup: file.get('backup'),
|
||||
fingerprint: file.get('fingerprint')
|
||||
});
|
||||
switch (this.settings.get('rememberKeyFiles')) {
|
||||
switch (this.settings.rememberKeyFiles) {
|
||||
case 'data':
|
||||
fileInfo.set({
|
||||
keyFileName: file.get('keyFileName') || null,
|
||||
|
@ -831,7 +828,7 @@ const AppModel = Backbone.Model.extend({
|
|||
editState: file.getLocalEditState(),
|
||||
syncDate: file.get('syncDate')
|
||||
});
|
||||
if (this.settings.get('rememberKeyFiles') === 'data') {
|
||||
if (this.settings.rememberKeyFiles === 'data') {
|
||||
fileInfo.set({
|
||||
keyFileName: file.get('keyFileName') || null,
|
||||
keyFileHash: file.getKeyFileHash()
|
||||
|
|
|
@ -1,59 +1,11 @@
|
|||
import Backbone from 'backbone';
|
||||
import { Model } from 'framework/model';
|
||||
import { SettingsStore } from 'comp/settings/settings-store';
|
||||
|
||||
const AppSettingsModel = Backbone.Model.extend({
|
||||
defaults: {
|
||||
theme: 'fb',
|
||||
locale: null,
|
||||
expandGroups: true,
|
||||
listViewWidth: null,
|
||||
menuViewWidth: null,
|
||||
tagsViewHeight: null,
|
||||
autoUpdate: 'install',
|
||||
clipboardSeconds: 0,
|
||||
autoSave: true,
|
||||
autoSaveInterval: 0,
|
||||
rememberKeyFiles: false,
|
||||
idleMinutes: 15,
|
||||
minimizeOnClose: false,
|
||||
tableView: false,
|
||||
colorfulIcons: false,
|
||||
directAutotype: true,
|
||||
titlebarStyle: 'default',
|
||||
lockOnMinimize: true,
|
||||
lockOnCopy: false,
|
||||
lockOnAutoType: false,
|
||||
lockOnOsLock: false,
|
||||
helpTipCopyShown: false,
|
||||
templateHelpShown: false,
|
||||
skipOpenLocalWarn: false,
|
||||
hideEmptyFields: false,
|
||||
skipHttpsWarning: false,
|
||||
demoOpened: false,
|
||||
fontSize: 0,
|
||||
tableViewColumns: null,
|
||||
generatorPresets: null,
|
||||
generatorHidePassword: false,
|
||||
cacheConfigSettings: false,
|
||||
|
||||
canOpen: true,
|
||||
canOpenDemo: true,
|
||||
canOpenSettings: true,
|
||||
canCreate: true,
|
||||
canImportXml: true,
|
||||
canRemoveLatest: true,
|
||||
canExportXml: true,
|
||||
canExportHtml: true,
|
||||
|
||||
dropbox: true,
|
||||
webdav: true,
|
||||
gdrive: true,
|
||||
onedrive: true
|
||||
},
|
||||
|
||||
initialize() {
|
||||
this.listenTo(this, 'change', this.save);
|
||||
},
|
||||
class AppSettingsModel extends Model {
|
||||
constructor() {
|
||||
super();
|
||||
this.on('change', () => this.save());
|
||||
}
|
||||
|
||||
load() {
|
||||
return SettingsStore.load('app-settings').then(data => {
|
||||
|
@ -62,22 +14,68 @@ const AppSettingsModel = Backbone.Model.extend({
|
|||
this.set(data, { silent: true });
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
upgrade(data) {
|
||||
if (data.rememberKeyFiles === true) {
|
||||
data.rememberKeyFiles = 'data';
|
||||
}
|
||||
if (data.versionWarningShown) {
|
||||
delete data.versionWarningShown;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
save() {
|
||||
SettingsStore.save('app-settings', this.attributes);
|
||||
SettingsStore.save('app-settings', this);
|
||||
}
|
||||
}
|
||||
|
||||
AppSettingsModel.defineModelProperties({
|
||||
theme: 'fb',
|
||||
locale: null,
|
||||
expandGroups: true,
|
||||
listViewWidth: null,
|
||||
menuViewWidth: null,
|
||||
tagsViewHeight: null,
|
||||
autoUpdate: 'install',
|
||||
clipboardSeconds: 0,
|
||||
autoSave: true,
|
||||
autoSaveInterval: 0,
|
||||
rememberKeyFiles: false,
|
||||
idleMinutes: 15,
|
||||
minimizeOnClose: false,
|
||||
tableView: false,
|
||||
colorfulIcons: false,
|
||||
directAutotype: true,
|
||||
titlebarStyle: 'default',
|
||||
lockOnMinimize: true,
|
||||
lockOnCopy: false,
|
||||
lockOnAutoType: false,
|
||||
lockOnOsLock: false,
|
||||
helpTipCopyShown: false,
|
||||
templateHelpShown: false,
|
||||
skipOpenLocalWarn: false,
|
||||
hideEmptyFields: false,
|
||||
skipHttpsWarning: false,
|
||||
demoOpened: false,
|
||||
fontSize: 0,
|
||||
tableViewColumns: null,
|
||||
generatorPresets: null,
|
||||
generatorHidePassword: false,
|
||||
cacheConfigSettings: false,
|
||||
|
||||
canOpen: true,
|
||||
canOpenDemo: true,
|
||||
canOpenSettings: true,
|
||||
canCreate: true,
|
||||
canImportXml: true,
|
||||
canRemoveLatest: true,
|
||||
canExportXml: true,
|
||||
canExportHtml: true,
|
||||
|
||||
dropbox: true,
|
||||
webdav: true,
|
||||
gdrive: true,
|
||||
onedrive: true
|
||||
});
|
||||
|
||||
AppSettingsModel.instance = new AppSettingsModel();
|
||||
const instance = new AppSettingsModel();
|
||||
|
||||
export { AppSettingsModel };
|
||||
export { instance as AppSettingsModel };
|
||||
|
|
|
@ -412,7 +412,7 @@ const Plugin = Backbone.Model.extend(
|
|||
delete SettingsManager.allLocales[locale.name];
|
||||
delete SettingsManager.customLocales[locale.name];
|
||||
if (SettingsManager.activeLocale === locale.name) {
|
||||
AppSettingsModel.instance.set('locale', 'en');
|
||||
AppSettingsModel.locale = 'en';
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -422,8 +422,8 @@ const Plugin = Backbone.Model.extend(
|
|||
|
||||
removeTheme(theme) {
|
||||
delete SettingsManager.allThemes[theme.name];
|
||||
if (AppSettingsModel.instance.get('theme') === theme.name) {
|
||||
AppSettingsModel.instance.set('theme', 'fb');
|
||||
if (AppSettingsModel.theme === theme.name) {
|
||||
AppSettingsModel.theme = 'fb';
|
||||
}
|
||||
delete BaseLocale[this.getThemeLocaleKey(theme.name)];
|
||||
},
|
||||
|
@ -435,13 +435,12 @@ const Plugin = Backbone.Model.extend(
|
|||
const ts = this.logger.ts();
|
||||
const settingPrefix = this.getSettingPrefix();
|
||||
let settings = null;
|
||||
for (const key of Object.keys(AppSettingsModel.instance.attributes)) {
|
||||
for (const key of Object.keys(AppSettingsModel.attributes)) {
|
||||
if (key.lastIndexOf(settingPrefix, 0) === 0) {
|
||||
if (!settings) {
|
||||
settings = {};
|
||||
}
|
||||
settings[key.replace(settingPrefix, '')] =
|
||||
AppSettingsModel.instance.attributes[key];
|
||||
settings[key.replace(settingPrefix, '')] = AppSettingsModel.attributes[key];
|
||||
}
|
||||
}
|
||||
if (settings) {
|
||||
|
@ -589,9 +588,7 @@ const Plugin = Backbone.Model.extend(
|
|||
if (settings instanceof Array) {
|
||||
return settings.map(setting => {
|
||||
setting = _.clone(setting);
|
||||
const value = AppSettingsModel.instance.get(
|
||||
settingsPrefix + setting.name
|
||||
);
|
||||
const value = AppSettingsModel[settingsPrefix + setting.name];
|
||||
if (value !== undefined) {
|
||||
setting.value = value;
|
||||
}
|
||||
|
@ -607,8 +604,7 @@ const Plugin = Backbone.Model.extend(
|
|||
|
||||
setSettings(settings) {
|
||||
for (const key of Object.keys(settings)) {
|
||||
const value = settings[key];
|
||||
AppSettingsModel.instance.set(this.getSettingPrefix() + key, value);
|
||||
AppSettingsModel[this.getSettingPrefix() + key] = settings[key];
|
||||
}
|
||||
if (this.module.exports.setSettings) {
|
||||
try {
|
||||
|
|
|
@ -19,7 +19,7 @@ const StorageDropbox = StorageBase.extend({
|
|||
backup: true,
|
||||
|
||||
_toFullPath(path) {
|
||||
const rootFolder = this.appSettings.get('dropboxFolder');
|
||||
const rootFolder = this.appSettings.dropboxFolder;
|
||||
if (rootFolder) {
|
||||
path = UrlFormat.fixSlashes('/' + rootFolder + '/' + path);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ const StorageDropbox = StorageBase.extend({
|
|||
},
|
||||
|
||||
_toRelPath(path) {
|
||||
const rootFolder = this.appSettings.get('dropboxFolder');
|
||||
const rootFolder = this.appSettings.dropboxFolder;
|
||||
if (rootFolder) {
|
||||
const ix = path.toLowerCase().indexOf(rootFolder.toLowerCase());
|
||||
if (ix === 0) {
|
||||
|
@ -49,7 +49,7 @@ const StorageDropbox = StorageBase.extend({
|
|||
},
|
||||
|
||||
_getKey() {
|
||||
return this.appSettings.get('dropboxAppKey') || DropboxKeys.AppFolder;
|
||||
return this.appSettings.dropboxAppKey || DropboxKeys.AppFolder;
|
||||
},
|
||||
|
||||
_isValidKey() {
|
||||
|
@ -123,7 +123,7 @@ const StorageDropbox = StorageBase.extend({
|
|||
title: 'dropboxFolder',
|
||||
desc: 'dropboxFolderSettingsDesc',
|
||||
type: 'text',
|
||||
value: this.appSettings.get('dropboxFolder') || ''
|
||||
value: this.appSettings.dropboxFolder || ''
|
||||
};
|
||||
const canUseBuiltInKeys = this._canUseBuiltInKeys();
|
||||
if (canUseBuiltInKeys) {
|
||||
|
@ -189,7 +189,7 @@ const StorageDropbox = StorageBase.extend({
|
|||
default:
|
||||
return;
|
||||
}
|
||||
this.appSettings.set(key, value);
|
||||
this.appSettings[key] = value;
|
||||
},
|
||||
|
||||
getPathForName(fileName) {
|
||||
|
|
|
@ -238,7 +238,7 @@ const StorageGDrive = StorageBase.extend({
|
|||
},
|
||||
|
||||
_getOAuthConfig() {
|
||||
let clientId = this.appSettings.get('gdriveClientId');
|
||||
let clientId = this.appSettings.gdriveClientId;
|
||||
if (!clientId) {
|
||||
clientId =
|
||||
location.origin.indexOf('localhost') >= 0
|
||||
|
|
|
@ -237,7 +237,7 @@ const StorageOneDrive = StorageBase.extend({
|
|||
},
|
||||
|
||||
_getClientId() {
|
||||
let clientId = this.appSettings.get('onedriveClientId');
|
||||
let clientId = this.appSettings.onedriveClientId;
|
||||
if (!clientId) {
|
||||
clientId =
|
||||
location.origin.indexOf('localhost') >= 0
|
||||
|
|
|
@ -39,7 +39,7 @@ const StorageWebDav = StorageBase.extend({
|
|||
id: 'webdavSaveMethod',
|
||||
title: 'webdavSaveMethod',
|
||||
type: 'select',
|
||||
value: this.appSettings.get('webdavSaveMethod') || 'default',
|
||||
value: this.appSettings.webdavSaveMethod || 'default',
|
||||
options: { default: 'webdavSaveMove', put: 'webdavSavePut' }
|
||||
}
|
||||
]
|
||||
|
@ -47,7 +47,7 @@ const StorageWebDav = StorageBase.extend({
|
|||
},
|
||||
|
||||
applySetting(key, value) {
|
||||
this.appSettings.set(key, value);
|
||||
this.appSettings[key] = value;
|
||||
},
|
||||
|
||||
load(path, opts, callback) {
|
||||
|
@ -107,7 +107,7 @@ const StorageWebDav = StorageBase.extend({
|
|||
saveOpts
|
||||
),
|
||||
(err, xhr, stat) => {
|
||||
let useTmpPath = this.appSettings.get('webdavSaveMethod') !== 'put';
|
||||
let useTmpPath = this.appSettings.webdavSaveMethod !== 'put';
|
||||
if (err) {
|
||||
if (!err.notFound) {
|
||||
return cb(err);
|
||||
|
|
|
@ -19,7 +19,7 @@ _.extend(StorageBase.prototype, {
|
|||
uipos: null,
|
||||
|
||||
logger: null,
|
||||
appSettings: AppSettingsModel.instance,
|
||||
appSettings: AppSettingsModel,
|
||||
runtimeData: RuntimeDataModel.instance,
|
||||
|
||||
init() {
|
||||
|
@ -27,7 +27,7 @@ _.extend(StorageBase.prototype, {
|
|||
throw 'Failed to init provider: no name';
|
||||
}
|
||||
if (!this.system) {
|
||||
const enabled = this.appSettings.get(this.name);
|
||||
const enabled = this.appSettings[this.name];
|
||||
if (typeof enabled === 'boolean') {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class AppView extends View {
|
|||
this.views.menu.listenDrag(this.views.menuDrag);
|
||||
this.views.list.listenDrag(this.views.listDrag);
|
||||
|
||||
this.titlebarStyle = this.model.settings.get('titlebarStyle');
|
||||
this.titlebarStyle = this.model.settings.titlebarStyle;
|
||||
|
||||
this.listenTo(this.model.settings, 'change:theme', this.setTheme);
|
||||
this.listenTo(this.model.settings, 'change:locale', this.setLocale);
|
||||
|
@ -351,7 +351,7 @@ class AppView extends View {
|
|||
}
|
||||
if (this.model.files.hasDirtyFiles()) {
|
||||
const exit = () => {
|
||||
if (Launcher.canMinimize() && this.model.settings.get('minimizeOnClose')) {
|
||||
if (Launcher.canMinimize() && this.model.settings.minimizeOnClose) {
|
||||
Launcher.minimizeApp();
|
||||
} else {
|
||||
Launcher.exit();
|
||||
|
@ -362,7 +362,7 @@ class AppView extends View {
|
|||
}
|
||||
if (Launcher) {
|
||||
if (!this.exitAlertShown) {
|
||||
if (this.model.settings.get('autoSave')) {
|
||||
if (this.model.settings.autoSave) {
|
||||
this.saveAndLock(result => {
|
||||
if (result) {
|
||||
exit();
|
||||
|
@ -406,7 +406,7 @@ class AppView extends View {
|
|||
!Launcher.exitRequested &&
|
||||
!Launcher.restartPending &&
|
||||
Launcher.canMinimize() &&
|
||||
this.model.settings.get('minimizeOnClose')
|
||||
this.model.settings.minimizeOnClose
|
||||
) {
|
||||
Launcher.minimizeApp();
|
||||
return Launcher.preventExit(e);
|
||||
|
@ -465,13 +465,13 @@ class AppView extends View {
|
|||
}
|
||||
|
||||
osLocked() {
|
||||
if (this.model.settings.get('lockOnOsLock')) {
|
||||
if (this.model.settings.lockOnOsLock) {
|
||||
this.lockWorkspace(true);
|
||||
}
|
||||
}
|
||||
|
||||
appMinimized() {
|
||||
if (this.model.settings.get('lockOnMinimize')) {
|
||||
if (this.model.settings.lockOnMinimize) {
|
||||
this.lockWorkspace(true);
|
||||
}
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ class AppView extends View {
|
|||
return;
|
||||
}
|
||||
if (this.model.files.hasUnsavedFiles()) {
|
||||
if (this.model.settings.get('autoSave')) {
|
||||
if (this.model.settings.autoSave) {
|
||||
this.saveAndLock();
|
||||
} else {
|
||||
const message = autoInit ? Locale.appCannotLockAutoInit : Locale.appCannotLock;
|
||||
|
@ -498,7 +498,7 @@ class AppView extends View {
|
|||
success: (result, autoSaveChecked) => {
|
||||
if (result === 'save') {
|
||||
if (autoSaveChecked) {
|
||||
this.model.settings.set('autoSave', autoSaveChecked);
|
||||
this.model.settings.autoSave = autoSaveChecked;
|
||||
}
|
||||
this.saveAndLock();
|
||||
} else if (result === 'discard') {
|
||||
|
@ -513,14 +513,14 @@ class AppView extends View {
|
|||
}
|
||||
|
||||
handleAutoSaveTimer() {
|
||||
if (this.model.settings.get('autoSaveInterval') !== 0) {
|
||||
if (this.model.settings.autoSaveInterval !== 0) {
|
||||
// trigger periodical auto save
|
||||
if (this.autoSaveTimeoutId) {
|
||||
clearTimeout(this.autoSaveTimeoutId);
|
||||
}
|
||||
this.autoSaveTimeoutId = setTimeout(
|
||||
this.saveAll.bind(this),
|
||||
this.model.settings.get('autoSaveInterval') * 1000 * 60
|
||||
this.model.settings.autoSaveInterval * 1000 * 60
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ class AppView extends View {
|
|||
}
|
||||
|
||||
syncAllByTimer() {
|
||||
if (this.model.settings.get('autoSave')) {
|
||||
if (this.model.settings.autoSave) {
|
||||
this.saveAll();
|
||||
}
|
||||
}
|
||||
|
@ -751,15 +751,15 @@ class AppView extends View {
|
|||
}
|
||||
|
||||
setTheme() {
|
||||
SettingsManager.setTheme(this.model.settings.get('theme'));
|
||||
SettingsManager.setTheme(this.model.settings.theme);
|
||||
}
|
||||
|
||||
setFontSize() {
|
||||
SettingsManager.setFontSize(this.model.settings.get('fontSize'));
|
||||
SettingsManager.setFontSize(this.model.settings.fontSize);
|
||||
}
|
||||
|
||||
setLocale() {
|
||||
SettingsManager.setLocale(this.model.settings.get('locale'));
|
||||
SettingsManager.setLocale(this.model.settings.locale);
|
||||
if (this.views.settings.isVisible()) {
|
||||
this.hideSettings();
|
||||
this.showSettings();
|
||||
|
|
|
@ -73,7 +73,7 @@ class AutoTypeSelectView extends View {
|
|||
} else {
|
||||
topMessage = Locale.autoTypeMsgNoWindow;
|
||||
}
|
||||
const noColor = AppSettingsModel.instance.get('colorfulIcons') ? '' : 'grayscale';
|
||||
const noColor = AppSettingsModel.colorfulIcons ? '' : 'grayscale';
|
||||
this.entries = this.model.filter.getEntries();
|
||||
this.result = this.entries.first();
|
||||
const presenter = new EntryPresenter(null, noColor, this.result && this.result.id);
|
||||
|
|
|
@ -293,7 +293,7 @@ class DetailsView extends View {
|
|||
}
|
||||
});
|
||||
|
||||
const hideEmptyFields = AppSettingsModel.instance.get('hideEmptyFields');
|
||||
const hideEmptyFields = AppSettingsModel.hideEmptyFields;
|
||||
|
||||
const fieldsMainEl = this.$el.find('.details__body-fields');
|
||||
const fieldsAsideEl = this.$el.find('.details__body-aside');
|
||||
|
@ -364,7 +364,7 @@ class DetailsView extends View {
|
|||
const dropdownView = new DropdownView();
|
||||
this.listenTo(dropdownView, 'cancel', this.toggleMoreOptions);
|
||||
this.listenTo(dropdownView, 'select', this.moreOptionsSelect);
|
||||
const hideEmptyFields = AppSettingsModel.instance.get('hideEmptyFields');
|
||||
const hideEmptyFields = AppSettingsModel.hideEmptyFields;
|
||||
const moreOptions = [];
|
||||
if (hideEmptyFields) {
|
||||
this.fieldViews.forEach(fieldView => {
|
||||
|
@ -430,8 +430,8 @@ class DetailsView extends View {
|
|||
this.addNewField();
|
||||
break;
|
||||
case 'toggle-empty': {
|
||||
const hideEmptyFields = AppSettingsModel.instance.get('hideEmptyFields');
|
||||
AppSettingsModel.instance.set('hideEmptyFields', !hideEmptyFields);
|
||||
const hideEmptyFields = AppSettingsModel.hideEmptyFields;
|
||||
AppSettingsModel.hideEmptyFields = !hideEmptyFields;
|
||||
this.render();
|
||||
break;
|
||||
}
|
||||
|
@ -625,11 +625,11 @@ class DetailsView extends View {
|
|||
if (this.helpTipCopyShown) {
|
||||
return;
|
||||
}
|
||||
this.helpTipCopyShown = AppSettingsModel.instance.get('helpTipCopyShown');
|
||||
this.helpTipCopyShown = AppSettingsModel.helpTipCopyShown;
|
||||
if (this.helpTipCopyShown) {
|
||||
return;
|
||||
}
|
||||
AppSettingsModel.instance.set('helpTipCopyShown', true);
|
||||
AppSettingsModel.helpTipCopyShown = true;
|
||||
this.helpTipCopyShown = true;
|
||||
const label = this.moreView.labelEl;
|
||||
const tip = new Tip(label, { title: Locale.detCopyHint, placement: 'right' });
|
||||
|
|
|
@ -62,7 +62,7 @@ class GeneratorView extends View {
|
|||
this.createPresets();
|
||||
const preset = this.preset;
|
||||
this.gen = _.clone(_.find(this.presets, pr => pr.name === preset));
|
||||
this.hide = AppSettingsModel.instance.get('generatorHidePassword');
|
||||
this.hide = AppSettingsModel.generatorHidePassword;
|
||||
$('body').one('click', this.remove.bind(this));
|
||||
this.listenTo(Events, 'lock-workspace', this.remove.bind(this));
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class GeneratorView extends View {
|
|||
|
||||
hideChange(e) {
|
||||
this.hide = e.target.checked;
|
||||
AppSettingsModel.instance.set('generatorHidePassword', this.hide);
|
||||
AppSettingsModel.generatorHidePassword = this.hide;
|
||||
const label = this.$el.find('.gen__check-hide-label');
|
||||
Tip.updateTip(label[0], { title: this.hide ? Locale.genShowPass : Locale.genHidePass });
|
||||
this.showPassword();
|
||||
|
|
|
@ -85,7 +85,7 @@ class ListView extends View {
|
|||
if (this.items.length) {
|
||||
const itemTemplate = this.getItemTemplate();
|
||||
const itemsTemplate = this.getItemsTemplate();
|
||||
const noColor = AppSettingsModel.instance.get('colorfulIcons') ? '' : 'grayscale';
|
||||
const noColor = AppSettingsModel.colorfulIcons ? '' : 'grayscale';
|
||||
const presenter = new EntryPresenter(
|
||||
this.getDescField(),
|
||||
noColor,
|
||||
|
@ -112,7 +112,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
getItemsTemplate() {
|
||||
if (this.model.settings.get('tableView')) {
|
||||
if (this.model.settings.tableView) {
|
||||
return require('templates/list-table.hbs');
|
||||
} else {
|
||||
return this.renderPlainItems;
|
||||
|
@ -124,7 +124,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
getItemTemplate() {
|
||||
if (this.model.settings.get('tableView')) {
|
||||
if (this.model.settings.tableView) {
|
||||
return require('templates/list-item-table.hbs');
|
||||
} else {
|
||||
return require('templates/list-item-short.hbs');
|
||||
|
@ -175,7 +175,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
createTemplate() {
|
||||
if (!this.model.settings.get('templateHelpShown')) {
|
||||
if (!this.model.settings.templateHelpShown) {
|
||||
Alerts.yesno({
|
||||
icon: 'sticky-note-o',
|
||||
header: Locale.listAddTemplateHeader,
|
||||
|
@ -185,7 +185,7 @@ class ListView extends View {
|
|||
Locale.listAddTemplateBody2.replace('{}', 'Templates'),
|
||||
buttons: [Alerts.buttons.ok, Alerts.buttons.cancel],
|
||||
success: () => {
|
||||
this.model.settings.set('templateHelpShown', true);
|
||||
this.model.settings.templateHelpShown = true;
|
||||
this.createTemplate();
|
||||
}
|
||||
});
|
||||
|
@ -222,13 +222,13 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
setTableView() {
|
||||
const isTable = this.model.settings.get('tableView');
|
||||
const isTable = this.model.settings.tableView;
|
||||
this.dragView.setCoord(isTable ? 'y' : 'x');
|
||||
this.setDefaultSize();
|
||||
}
|
||||
|
||||
setDefaultSize() {
|
||||
this.setSize(this.model.settings.get('listViewWidth'));
|
||||
this.setSize(this.model.settings.listViewWidth);
|
||||
}
|
||||
|
||||
setSize(size) {
|
||||
|
@ -246,7 +246,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
throttleSetViewSizeSetting = _.throttle(size => {
|
||||
AppSettingsModel.instance.set('listViewWidth', size);
|
||||
AppSettingsModel.listViewWidth = size;
|
||||
}, 1000);
|
||||
|
||||
filterChanged(filter) {
|
||||
|
@ -311,7 +311,7 @@ class ListView extends View {
|
|||
}
|
||||
|
||||
readTableColumnsEnabled() {
|
||||
const tableViewColumns = AppSettingsModel.instance.get('tableViewColumns');
|
||||
const tableViewColumns = AppSettingsModel.tableViewColumns;
|
||||
if (tableViewColumns && tableViewColumns.length) {
|
||||
this.tableColumns.forEach(col => {
|
||||
col.enabled = tableViewColumns.indexOf(col.name) >= 0;
|
||||
|
@ -323,7 +323,7 @@ class ListView extends View {
|
|||
const tableViewColumns = this.tableColumns
|
||||
.filter(column => column.enabled)
|
||||
.map(column => column.name);
|
||||
AppSettingsModel.instance.set('tableViewColumns', tableViewColumns);
|
||||
AppSettingsModel.tableViewColumns = tableViewColumns;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class ListWrapView extends View {
|
|||
}
|
||||
|
||||
setListLayout() {
|
||||
const tableView = !!this.model.settings.get('tableView');
|
||||
const tableView = !!this.model.settings.tableView;
|
||||
this.el.classList.toggle('app__list-wrap--table', tableView);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ class MenuSectionView extends View {
|
|||
this.itemViews.push(itemView);
|
||||
});
|
||||
if (this.model.get('drag')) {
|
||||
const height = AppSettingsModel.instance.get('tagsViewHeight');
|
||||
const height = AppSettingsModel.tagsViewHeight;
|
||||
if (typeof height === 'number') {
|
||||
this.$el.height();
|
||||
this.$el.css('flex', '0 0 ' + height + 'px');
|
||||
|
@ -76,7 +76,7 @@ class MenuSectionView extends View {
|
|||
}
|
||||
|
||||
saveViewHeight = _.throttle(size => {
|
||||
AppSettingsModel.instance.set('tagsViewHeight', size);
|
||||
AppSettingsModel.tagsViewHeight = size;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ class MenuView extends View {
|
|||
}
|
||||
this.sectionViews.push(sectionView);
|
||||
}, this);
|
||||
if (typeof AppSettingsModel.instance.get('menuViewWidth') === 'number') {
|
||||
this.$el.width(AppSettingsModel.instance.get('menuViewWidth'));
|
||||
if (typeof AppSettingsModel.menuViewWidth === 'number') {
|
||||
this.$el.width(AppSettingsModel.menuViewWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class MenuView extends View {
|
|||
}
|
||||
|
||||
viewResized = _.throttle(size => {
|
||||
AppSettingsModel.instance.set('menuViewWidth', size);
|
||||
AppSettingsModel.menuViewWidth = size;
|
||||
}, 1000);
|
||||
|
||||
switchVisibility(visible) {
|
||||
|
|
|
@ -83,22 +83,22 @@ class OpenView extends View {
|
|||
}
|
||||
});
|
||||
storageProviders.sort((x, y) => (x.uipos || Infinity) - (y.uipos || Infinity));
|
||||
const showMore = storageProviders.length || this.model.settings.get('canOpenSettings');
|
||||
const showMore = storageProviders.length || this.model.settings.canOpenSettings;
|
||||
const showLogo =
|
||||
!showMore &&
|
||||
!this.model.settings.get('canOpen') &&
|
||||
!this.model.settings.get('canCreate') &&
|
||||
!(this.model.settings.get('canOpenDemo') && !this.model.settings.get('demoOpened'));
|
||||
!this.model.settings.canOpen &&
|
||||
!this.model.settings.canCreate &&
|
||||
!(this.model.settings.canOpenDemo && !this.model.settings.demoOpened);
|
||||
super.render({
|
||||
lastOpenFiles: this.getLastOpenFiles(),
|
||||
canOpenKeyFromDropbox: !Launcher && Storage.dropbox.enabled,
|
||||
demoOpened: this.model.settings.get('demoOpened'),
|
||||
demoOpened: this.model.settings.demoOpened,
|
||||
storageProviders,
|
||||
canOpen: this.model.settings.get('canOpen'),
|
||||
canOpenDemo: this.model.settings.get('canOpenDemo'),
|
||||
canOpenSettings: this.model.settings.get('canOpenSettings'),
|
||||
canCreate: this.model.settings.get('canCreate'),
|
||||
canRemoveLatest: this.model.settings.get('canRemoveLatest'),
|
||||
canOpen: this.model.settings.canOpen,
|
||||
canOpenDemo: this.model.settings.canOpenDemo,
|
||||
canOpenSettings: this.model.settings.canOpenSettings,
|
||||
canCreate: this.model.settings.canCreate,
|
||||
canRemoveLatest: this.model.settings.canRemoveLatest,
|
||||
showMore,
|
||||
showLogo
|
||||
});
|
||||
|
@ -159,7 +159,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
showLocalFileAlert() {
|
||||
if (this.model.settings.get('skipOpenLocalWarn')) {
|
||||
if (this.model.settings.skipOpenLocalWarn) {
|
||||
return;
|
||||
}
|
||||
Alerts.alert({
|
||||
|
@ -176,7 +176,7 @@ class OpenView extends View {
|
|||
success: res => {
|
||||
this.focusInput();
|
||||
if (res === 'skip') {
|
||||
this.model.settings.set('skipOpenLocalWarn', true);
|
||||
this.model.settings.skipOpenLocalWarn = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -243,7 +243,7 @@ class OpenView extends View {
|
|||
case 'keyFileData':
|
||||
this.params.keyFileData = e.target.result;
|
||||
this.params.keyFileName = file.name;
|
||||
if (this.model.settings.get('rememberKeyFiles') === 'path') {
|
||||
if (this.model.settings.rememberKeyFiles === 'path') {
|
||||
this.params.keyFilePath = file.path;
|
||||
}
|
||||
this.displayOpenKeyFile();
|
||||
|
@ -280,7 +280,7 @@ class OpenView extends View {
|
|||
} else {
|
||||
return undefined;
|
||||
}
|
||||
} else if (this.model.settings.get('canImportXml')) {
|
||||
} else if (this.model.settings.canImportXml) {
|
||||
try {
|
||||
const str = kdbxweb.ByteUtils.bytesToString(fileSig).trim();
|
||||
if (str.startsWith('<?xml')) {
|
||||
|
@ -323,7 +323,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
openFile() {
|
||||
if (this.model.settings.get('canOpen') === false) {
|
||||
if (this.model.settings.canOpen === false) {
|
||||
return;
|
||||
}
|
||||
if (!this.busy) {
|
||||
|
@ -455,7 +455,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
dragover(e) {
|
||||
if (this.model.settings.get('canOpen') === false) {
|
||||
if (this.model.settings.canOpen === false) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
|
@ -478,7 +478,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
dragleave() {
|
||||
if (this.model.settings.get('canOpen') === false) {
|
||||
if (this.model.settings.canOpen === false) {
|
||||
return;
|
||||
}
|
||||
if (this.dragTimeout) {
|
||||
|
@ -490,7 +490,7 @@ class OpenView extends View {
|
|||
}
|
||||
|
||||
drop(e) {
|
||||
if (this.model.settings.get('canOpen') === false) {
|
||||
if (this.model.settings.canOpen === false) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
|
@ -511,7 +511,7 @@ class OpenView extends View {
|
|||
keyFile,
|
||||
dataFile.path ? null : this.showLocalFileAlert.bind(this)
|
||||
);
|
||||
} else if (this.model.settings.get('canImportXml')) {
|
||||
} else if (this.model.settings.canImportXml) {
|
||||
const xmlFile = files.find(file => /\.xml$/i.test(file.name));
|
||||
if (xmlFile) {
|
||||
this.setFile(xmlFile, null, this.showLocalFileAlert.bind(this));
|
||||
|
@ -597,8 +597,8 @@ class OpenView extends View {
|
|||
if (!this.model.createDemoFile()) {
|
||||
this.emit('close');
|
||||
}
|
||||
if (!this.model.settings.get('demoOpened')) {
|
||||
this.model.settings.set('demoOpened', true);
|
||||
if (!this.model.settings.demoOpened) {
|
||||
this.model.settings.demoOpened = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,8 +110,8 @@ class SettingsFileView extends View {
|
|||
kdfParameters: this.kdfParametersToUi(this.model.get('kdfParameters')),
|
||||
storageProviders,
|
||||
canBackup,
|
||||
canExportXml: AppSettingsModel.instance.get('canExportXml'),
|
||||
canExportHtml: AppSettingsModel.instance.get('canExportHtml')
|
||||
canExportXml: AppSettingsModel.canExportXml,
|
||||
canExportHtml: AppSettingsModel.canExportHtml
|
||||
});
|
||||
if (!this.model.get('created')) {
|
||||
this.$el
|
||||
|
|
|
@ -67,19 +67,19 @@ class SettingsGeneralView extends View {
|
|||
|
||||
super.render({
|
||||
themes: _.mapObject(SettingsManager.allThemes, theme => Locale[theme]),
|
||||
activeTheme: AppSettingsModel.instance.get('theme'),
|
||||
activeTheme: AppSettingsModel.theme,
|
||||
locales: SettingsManager.allLocales,
|
||||
activeLocale: SettingsManager.activeLocale,
|
||||
fontSize: AppSettingsModel.instance.get('fontSize'),
|
||||
expandGroups: AppSettingsModel.instance.get('expandGroups'),
|
||||
fontSize: AppSettingsModel.fontSize,
|
||||
expandGroups: AppSettingsModel.expandGroups,
|
||||
canClearClipboard: !!Launcher,
|
||||
clipboardSeconds: AppSettingsModel.instance.get('clipboardSeconds'),
|
||||
rememberKeyFiles: AppSettingsModel.instance.get('rememberKeyFiles'),
|
||||
clipboardSeconds: AppSettingsModel.clipboardSeconds,
|
||||
rememberKeyFiles: AppSettingsModel.rememberKeyFiles,
|
||||
supportFiles: !!Launcher,
|
||||
autoSave: AppSettingsModel.instance.get('autoSave'),
|
||||
autoSaveInterval: AppSettingsModel.instance.get('autoSaveInterval'),
|
||||
idleMinutes: AppSettingsModel.instance.get('idleMinutes'),
|
||||
minimizeOnClose: AppSettingsModel.instance.get('minimizeOnClose'),
|
||||
autoSave: AppSettingsModel.autoSave,
|
||||
autoSaveInterval: AppSettingsModel.autoSaveInterval,
|
||||
idleMinutes: AppSettingsModel.idleMinutes,
|
||||
minimizeOnClose: AppSettingsModel.minimizeOnClose,
|
||||
devTools: Launcher && Launcher.devTools,
|
||||
canAutoUpdate: Updater.enabled,
|
||||
canAutoSaveOnClose: !!Launcher,
|
||||
|
@ -87,11 +87,11 @@ class SettingsGeneralView extends View {
|
|||
canDetectMinimize: !!Launcher,
|
||||
canDetectOsSleep: Launcher && Launcher.canDetectOsSleep(),
|
||||
canAutoType: AutoType.enabled,
|
||||
lockOnMinimize: Launcher && AppSettingsModel.instance.get('lockOnMinimize'),
|
||||
lockOnCopy: AppSettingsModel.instance.get('lockOnCopy'),
|
||||
lockOnAutoType: AppSettingsModel.instance.get('lockOnAutoType'),
|
||||
lockOnOsLock: AppSettingsModel.instance.get('lockOnOsLock'),
|
||||
tableView: AppSettingsModel.instance.get('tableView'),
|
||||
lockOnMinimize: Launcher && AppSettingsModel.lockOnMinimize,
|
||||
lockOnCopy: AppSettingsModel.lockOnCopy,
|
||||
lockOnAutoType: AppSettingsModel.lockOnAutoType,
|
||||
lockOnOsLock: AppSettingsModel.lockOnOsLock,
|
||||
tableView: AppSettingsModel.tableView,
|
||||
canSetTableView: !Features.isMobile,
|
||||
autoUpdate: Updater.getAutoUpdateType(),
|
||||
updateInProgress: Updater.updateInProgress(),
|
||||
|
@ -102,10 +102,10 @@ class SettingsGeneralView extends View {
|
|||
updateFound,
|
||||
updateManual,
|
||||
releaseNotesLink: Links.ReleaseNotes,
|
||||
colorfulIcons: AppSettingsModel.instance.get('colorfulIcons'),
|
||||
directAutotype: AppSettingsModel.instance.get('directAutotype'),
|
||||
colorfulIcons: AppSettingsModel.colorfulIcons,
|
||||
directAutotype: AppSettingsModel.directAutotype,
|
||||
supportsTitleBarStyles: Launcher && Features.supportsTitleBarStyles(),
|
||||
titlebarStyle: AppSettingsModel.instance.get('titlebarStyle'),
|
||||
titlebarStyle: AppSettingsModel.titlebarStyle,
|
||||
storageProviders,
|
||||
showReloadApp: Features.isStandalone
|
||||
});
|
||||
|
@ -202,44 +202,44 @@ class SettingsGeneralView extends View {
|
|||
|
||||
changeTheme(e) {
|
||||
const theme = e.target.value;
|
||||
AppSettingsModel.instance.set('theme', theme);
|
||||
AppSettingsModel.theme = theme;
|
||||
}
|
||||
|
||||
changeLocale(e) {
|
||||
const locale = e.target.value;
|
||||
if (locale === '...') {
|
||||
e.target.value = AppSettingsModel.instance.get('locale') || 'en';
|
||||
e.target.value = AppSettingsModel.locale || 'en';
|
||||
this.appModel.menu.select({
|
||||
item: this.appModel.menu.pluginsSection.get('items').first()
|
||||
});
|
||||
return;
|
||||
}
|
||||
AppSettingsModel.instance.set('locale', locale);
|
||||
AppSettingsModel.locale = locale;
|
||||
}
|
||||
|
||||
changeFontSize(e) {
|
||||
const fontSize = +e.target.value;
|
||||
AppSettingsModel.instance.set('fontSize', fontSize);
|
||||
AppSettingsModel.fontSize = fontSize;
|
||||
}
|
||||
|
||||
changeTitlebarStyle(e) {
|
||||
const titlebarStyle = e.target.value;
|
||||
AppSettingsModel.instance.set('titlebarStyle', titlebarStyle);
|
||||
AppSettingsModel.titlebarStyle = titlebarStyle;
|
||||
}
|
||||
|
||||
changeClipboard(e) {
|
||||
const clipboardSeconds = +e.target.value;
|
||||
AppSettingsModel.instance.set('clipboardSeconds', clipboardSeconds);
|
||||
AppSettingsModel.clipboardSeconds = clipboardSeconds;
|
||||
}
|
||||
|
||||
changeIdleMinutes(e) {
|
||||
const idleMinutes = +e.target.value;
|
||||
AppSettingsModel.instance.set('idleMinutes', idleMinutes);
|
||||
AppSettingsModel.idleMinutes = idleMinutes;
|
||||
}
|
||||
|
||||
changeAutoUpdate(e) {
|
||||
const autoUpdate = e.target.value || false;
|
||||
AppSettingsModel.instance.set('autoUpdate', autoUpdate);
|
||||
AppSettingsModel.autoUpdate = autoUpdate;
|
||||
if (autoUpdate) {
|
||||
Updater.scheduleNextCheck();
|
||||
}
|
||||
|
@ -251,60 +251,60 @@ class SettingsGeneralView extends View {
|
|||
|
||||
changeAutoSave(e) {
|
||||
const autoSave = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('autoSave', autoSave);
|
||||
AppSettingsModel.autoSave = autoSave;
|
||||
}
|
||||
|
||||
changeAutoSaveInterval(e) {
|
||||
const autoSaveInterval = Number(e.target.value) || 0;
|
||||
AppSettingsModel.instance.set('autoSaveInterval', autoSaveInterval);
|
||||
AppSettingsModel.autoSaveInterval = autoSaveInterval;
|
||||
}
|
||||
|
||||
changeRememberKeyFiles(e) {
|
||||
const rememberKeyFiles = e.target.value || false;
|
||||
AppSettingsModel.instance.set('rememberKeyFiles', rememberKeyFiles);
|
||||
AppSettingsModel.rememberKeyFiles = rememberKeyFiles;
|
||||
this.appModel.clearStoredKeyFiles();
|
||||
}
|
||||
|
||||
changeMinimize(e) {
|
||||
const minimizeOnClose = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('minimizeOnClose', minimizeOnClose);
|
||||
AppSettingsModel.minimizeOnClose = minimizeOnClose;
|
||||
}
|
||||
|
||||
changeLockOnMinimize(e) {
|
||||
const lockOnMinimize = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnMinimize', lockOnMinimize);
|
||||
AppSettingsModel.lockOnMinimize = lockOnMinimize;
|
||||
}
|
||||
|
||||
changeLockOnCopy(e) {
|
||||
const lockOnCopy = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnCopy', lockOnCopy);
|
||||
AppSettingsModel.lockOnCopy = lockOnCopy;
|
||||
}
|
||||
|
||||
changeLockOnAutoType(e) {
|
||||
const lockOnAutoType = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnAutoType', lockOnAutoType);
|
||||
AppSettingsModel.lockOnAutoType = lockOnAutoType;
|
||||
}
|
||||
|
||||
changeLockOnOsLock(e) {
|
||||
const lockOnOsLock = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('lockOnOsLock', lockOnOsLock);
|
||||
AppSettingsModel.lockOnOsLock = lockOnOsLock;
|
||||
}
|
||||
|
||||
changeTableView(e) {
|
||||
const tableView = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('tableView', tableView);
|
||||
AppSettingsModel.tableView = tableView;
|
||||
Events.emit('refresh');
|
||||
}
|
||||
|
||||
changeColorfulIcons(e) {
|
||||
const colorfulIcons = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('colorfulIcons', colorfulIcons);
|
||||
AppSettingsModel.colorfulIcons = colorfulIcons;
|
||||
Events.emit('refresh');
|
||||
}
|
||||
|
||||
changeDirectAutotype(e) {
|
||||
const directAutotype = e.target.checked || false;
|
||||
AppSettingsModel.instance.set('directAutotype', directAutotype);
|
||||
AppSettingsModel.directAutotype = directAutotype;
|
||||
Events.emit('refresh');
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ class SettingsGeneralView extends View {
|
|||
|
||||
changeExpandGroups(e) {
|
||||
const expand = e.target.checked;
|
||||
AppSettingsModel.instance.set('expandGroups', expand);
|
||||
AppSettingsModel.expandGroups = expand;
|
||||
Events.emit('refresh');
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ class SettingsGeneralView extends View {
|
|||
const storage = Storage[$(e.target).data('storage')];
|
||||
if (storage) {
|
||||
storage.setEnabled(e.target.checked);
|
||||
AppSettingsModel.instance.set(storage.name, storage.enabled);
|
||||
AppSettingsModel.storage.name = storage.enabled;
|
||||
this.$el
|
||||
.find('.settings__general-' + storage.name)
|
||||
.toggleClass('hide', !e.target.checked);
|
||||
|
|
|
@ -188,12 +188,12 @@ class SettingsPluginsView extends View {
|
|||
|
||||
useLocaleClick(e) {
|
||||
const locale = $(e.target).data('locale');
|
||||
AppSettingsModel.instance.set('locale', locale);
|
||||
AppSettingsModel.locale = locale;
|
||||
}
|
||||
|
||||
useThemeClick(e) {
|
||||
const theme = $(e.target).data('theme');
|
||||
AppSettingsModel.instance.set('theme', theme);
|
||||
AppSettingsModel.theme = theme;
|
||||
}
|
||||
|
||||
galleryInstallClick(e) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user