diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue
index 0412273f..1b75773e 100644
--- a/client/components/Reader/SettingsPage/SettingsPage.vue
+++ b/client/components/Reader/SettingsPage/SettingsPage.vue
@@ -156,7 +156,6 @@ class SettingsPage extends Vue {
serverStorageKeyVisible = false;
toolButtons = [];
rstore = {};
-testCode = 'Добавить сочетание';
created() {
this.commit = this.$store.commit;
@@ -365,17 +364,6 @@ testCode = 'Добавить сочетание';
this.showToolButton = Object.assign({}, this.showToolButton, {[buttonName]: !this.showToolButton[buttonName]});
}
- async addHotKeyCode() {
- try {
- const result = await this.$root.stdDialog.getHotKey('Нажмите сочетание клавиш:', '');
- if (result) {
- this.testCode = result;
- }
- } catch (e) {
- //
- }
- }
-
async addProfile() {
try {
if (Object.keys(this.profiles).length >= 100) {
diff --git a/client/components/Reader/SettingsPage/UserHotKeys/UserHotKeys.vue b/client/components/Reader/SettingsPage/UserHotKeys/UserHotKeys.vue
index 5d5759e3..e98a4408 100644
--- a/client/components/Reader/SettingsPage/UserHotKeys/UserHotKeys.vue
+++ b/client/components/Reader/SettingsPage/UserHotKeys/UserHotKeys.vue
@@ -24,7 +24,12 @@
{{ rstore.readerActions[action] }}
-
+
{{ code }}
@@ -75,6 +80,7 @@ export default @Component({
this.updateTableData();
},
value: function() {
+ this.checkCollisions();
this.updateTableData();
}
},
@@ -83,12 +89,14 @@ class UserHotKeys extends UserHotKeysProps {
search = '';
rstore = {};
tableData = [];
+ collisions = {};
created() {
this.rstore = rstore;
}
mounted() {
+ this.checkCollisions();
this.updateTableData();
}
@@ -113,16 +121,83 @@ class UserHotKeys extends UserHotKeysProps {
this.tableData = result;
}
+ checkCollisions() {
+ const cols = {};
+ for (const [action, codes] of Object.entries(this.value)) {
+ codes.forEach(code => {
+ if (!cols[code])
+ cols[code] = [];
+ if (cols[code].indexOf(action) < 0)
+ cols[code].push(action);
+ });
+ }
+
+ const result = {};
+ for (const [code, actions] of Object.entries(cols)) {
+ if (actions.length > 1)
+ result[code] = actions;
+ }
+
+ this.collisions = result;
+ }
+
+ collisionWarning(code) {
+ if (this.collisions[code]) {
+ const descs = this.collisions[code].map(action => `
${rstore.readerActions[action]}`);
+ this.$root.stdDialog.alert(`Сочетание '${code}' одновременно назначено
следующим действиям:
${descs.join('
')}`, 'Предупреждение');
+ }
+ }
+
removeCode(action, code) {
+ let codes = Array.from(this.value[action]);
+ const index = codes.indexOf(code);
+ if (index >= 0) {
+ codes.splice(index, 1);
+ const newValue = Object.assign({}, this.value, {[action]: codes});
+ this.$emit('input', newValue);
+ }
}
- addHotKey(action) {
+ async addHotKey(action) {
+ try {
+ const result = await this.$root.stdDialog.getHotKey(`Добавить сочетание для:
${rstore.readerActions[action]}`, '');
+ if (result) {
+ let codes = Array.from(this.value[action]);
+ if (codes.indexOf(result) < 0) {
+ codes.push(result);
+ const newValue = Object.assign({}, this.value, {[action]: codes});
+ this.$emit('input', newValue);
+ this.$nextTick(() => {
+ this.collisionWarning(result);
+ });
+ }
+ }
+ } catch (e) {
+ //
+ }
}
- defaultHotKey(action) {
+ async defaultHotKey(action) {
+ try {
+ if (await this.$root.stdDialog.confirm(`Подтвердите установку клавиш по умолчанию для:
${rstore.readerActions[action]}`, ' ')) {
+ const codes = Array.from(rstore.settingDefaults.userHotKeys[action]);
+ const newValue = Object.assign({}, this.value, {[action]: codes});
+ this.$emit('input', newValue);
+ }
+ } catch (e) {
+ //
+ }
}
- defaultHotKeyAll() {
+ async defaultHotKeyAll() {
+ try {
+ if (await this.$root.stdDialog.confirm('Подтвердите установку ВСЕХ
сочетаний клавиш по умолчанию:', ' ')) {
+ const newValue = Object.assign({}, rstore.settingDefaults.userHotKeys);
+ this.$emit('input', newValue);
+ }
+ } catch (e) {
+ //
+ }
}
}
//-----------------------------------------------------------------------------
diff --git a/client/components/Reader/SettingsPage/include/KeysTab.inc b/client/components/Reader/SettingsPage/include/KeysTab.inc
index 6e53e36c..d3915aeb 100644
--- a/client/components/Reader/SettingsPage/include/KeysTab.inc
+++ b/client/components/Reader/SettingsPage/include/KeysTab.inc
@@ -7,11 +7,6 @@
-