From 108297fe1b81733fe47b129a21abd2c9dc2f09a9 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 12 Apr 2019 21:06:01 +0200 Subject: [PATCH] Section for editing keyboard shortcuts is reasonably complete. --- src/common/components/action-alt.vue | 2 +- src/options/App.vue | 41 +++++++++--- src/options/common/ConfirmationPopup.vue | 66 +++++++++++++++++++ .../add-edit-action-popup.vue | 16 ++--- .../command-builder/command-add-edit.vue | 14 ---- .../controls-settings/controls-settings.vue | 35 +++++++++- .../scope-settings.vue | 2 +- 7 files changed, 140 insertions(+), 36 deletions(-) create mode 100644 src/options/common/ConfirmationPopup.vue diff --git a/src/common/components/action-alt.vue b/src/common/components/action-alt.vue index d50fa94..f1c1c0e 100644 --- a/src/common/components/action-alt.vue +++ b/src/common/components/action-alt.vue @@ -6,7 +6,7 @@
- 🗙 + 🗙 🖉 {{action.name}}
diff --git a/src/options/App.vue b/src/options/App.vue index f3b82e1..a34ee76 100644 --- a/src/options/App.vue +++ b/src/options/App.vue @@ -11,6 +11,11 @@ @close="closePopups()" > + @@ -21,7 +26,7 @@
- Ultrawidify Vue + Ultrawidify
@@ -39,11 +44,11 @@ > Autodetection
- @@ -109,6 +110,7 @@ import Settings from '../ext/lib/Settings.js'; import GeneralSettings from './general-settings'; import ControlsSettings from './controls-settings/controls-settings'; import AddEditActionPopup from './controls-settings/add-edit-action-popup'; +import ConfirmPopup from './common/ConfirmationPopup'; import AutodetectionSettings from './autodetection-settings'; @@ -124,6 +126,10 @@ export default { editActionPopupVisible: false, editActionIndex: -1, anyOpenedPopups: false, + removeConfirmationDialog: '', + messages: { + removeAction: "Are you sure you want to remove this action?" + }, } }, async created () { @@ -136,6 +142,7 @@ export default { ControlsSettings, AddEditActionPopup, AutodetectionSettings, + ConfirmPopup, }, methods: { setSelectedTab(newTab) { @@ -162,9 +169,24 @@ export default { this.editActionIndex = event; this.anyOpenedPopups = true; }, + showRemoveActionPopup(indexToRemove) { + this.editActionIndex = indexToRemove; + this.anyOpenedPopups = true; + this.confirmationDialogText = this.messages.removeAction; + }, closePopups(){ this.anyOpenedPopups = false; this.editActionPopupVisible = false; + this.confirmationDialogText = ''; + }, + confirm(){ + if (this.confirmationDialogText === this.messages.removeAction) { + this.settings.active.actions.splice(this.editActionIndex, 1); + this.settings.save(); + } + + + this.closePopups(); } } }; @@ -182,6 +204,9 @@ export default { width: 100%; height: 100%; z-index: 1000; + display: flex; + justify-content: center; + align-content: center; } .blur { diff --git a/src/options/common/ConfirmationPopup.vue b/src/options/common/ConfirmationPopup.vue new file mode 100644 index 0000000..fcca86c --- /dev/null +++ b/src/options/common/ConfirmationPopup.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/src/options/controls-settings/add-edit-action-popup.vue b/src/options/controls-settings/add-edit-action-popup.vue index fdb6c2e..d8c7472 100644 --- a/src/options/controls-settings/add-edit-action-popup.vue +++ b/src/options/controls-settings/add-edit-action-popup.vue @@ -1,6 +1,6 @@ diff --git a/src/options/controls-settings/controls-settings.vue b/src/options/controls-settings/controls-settings.vue index 731a670..ac480ce 100644 --- a/src/options/controls-settings/controls-settings.vue +++ b/src/options/controls-settings/controls-settings.vue @@ -1,6 +1,28 @@ @@ -24,6 +47,7 @@ :key="index" :action="action" @edit="changeShortcut(index)" + @remove="removeAction(index)" > @@ -37,6 +61,7 @@ :key="index" :action="action" @edit="changeShortcut(index)" + @remove="removeAction(index)" > @@ -55,6 +80,7 @@ :key="index" :action="action" @edit="changeShortcut(index)" + @remove="removeAction(index)" > @@ -76,6 +102,7 @@ :key="index" :action="action" @edit="changeShortcut(index)" + @remove="removeAction(index)" > @@ -114,6 +141,12 @@ export default { } }, methods: { + removeAction(index) { + this.$emit('remove-event', index) + }, + addAction() { + this.$emit('edit-event', -1); + }, changeShortcut(index) { this.$emit('edit-event', index); } diff --git a/src/options/controls-settings/scope-settings-component/scope-settings.vue b/src/options/controls-settings/scope-settings-component/scope-settings.vue index fce2112..c9f3653 100644 --- a/src/options/controls-settings/scope-settings-component/scope-settings.vue +++ b/src/options/controls-settings/scope-settings-component/scope-settings.vue @@ -7,7 +7,7 @@