Skip to content

Commit

Permalink
macro and group settings extended
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeKeck committed Aug 5, 2024
1 parent 9c7aa55 commit c637256
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 9 deletions.
58 changes: 56 additions & 2 deletions src/components/settings/macros/MacroCategoryDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<app-dialog
v-model="open"
:title="title"
max-width="350"
max-width="480"
@save="handleSave"
>
<v-card-text class="pa-0">
Expand Down Expand Up @@ -51,6 +51,45 @@
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.hide_while_printing')"
>
<v-switch
v-model="newHideWhilePrinting"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.hide_while_paused')"
>
<v-switch
v-model="newHideWhilePaused"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.hide_while_standby')"
>
<v-switch
v-model="newHideWhileStandby"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>
</v-card-text>
</app-dialog>
</template>
Expand Down Expand Up @@ -79,25 +118,40 @@ export default class MacroCategoryDialog extends Vue {
@Prop({ type: Boolean, required: true })
readonly visible!: boolean
@Prop({ type: Boolean, required: true })
readonly hideWhilePrinting!: boolean
@Prop({ type: Boolean, required: true })
readonly hideWhilePaused!: boolean
@Prop({ type: Boolean, required: true })
readonly hideWhileStandby!: boolean
@Prop({ type: Array<InputValidationRules> })
readonly rules?: InputValidationRules[]
newName = ''
newColor = ''
newVisible = true
newHideWhilePrinting = true
newHideWhilePaused = true
newHideWhileStandby = true
mounted () {
this.newName = this.name
this.newColor = this.color
this.newVisible = this.visible
this.newHideWhilePrinting = this.hideWhilePrinting
this.newHideWhilePaused = this.hideWhilePaused
this.newHideWhileStandby = this.hideWhileStandby
}
get categories () {
return this.$store.getters['macros/getCategories']
}
handleSave () {
this.$emit('save', this.newName, this.newColor, this.newVisible)
this.$emit('save', this.newName, this.newColor, this.newVisible, this.newHideWhilePrinting, this.newHideWhilePaused, this.newHideWhileStandby)
this.open = false
}
Expand Down
19 changes: 17 additions & 2 deletions src/components/settings/macros/MacroSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
:name="categoryDialogState.name"
:color="categoryDialogState.color"
:visible="categoryDialogState.visible"
:hide-while-printing="categoryDialogState.hideWhilePrinting"
:hide-while-paused="categoryDialogState.hideWhilePaused"
:hide-while-standby="categoryDialogState.hideWhileStandby"
:rules="categoryDialogState.rules"
@save="categoryDialogState.handler"
/>
Expand Down Expand Up @@ -147,6 +150,9 @@ export default class MacroSettings extends Mixins(StateMixin) {
name: '',
color: '',
visible: true,
hideWhilePrinting: false,
hideWhilePaused: false,
hideWhileStandby: false,
rules: [],
handler: this.handleAddCategory
}
Expand Down Expand Up @@ -178,6 +184,9 @@ export default class MacroSettings extends Mixins(StateMixin) {
name: '',
color: '',
visible: true,
hideWhilePrinting: false,
hideWhilePaused: false,
hideWhileStandby: false,
rules: [
this.$rules.required,
this.customRules.uniqueName
Expand All @@ -195,6 +204,9 @@ export default class MacroSettings extends Mixins(StateMixin) {
name: category.name,
color: category.color ?? '',
visible: category.visible,
hideWhilePrinting: category.hideWhilePrinting,
hideWhilePaused: category.hideWhilePaused,
hideWhileStandby: category.hideWhileStandby,
rules: [
this.$rules.required
],
Expand All @@ -210,12 +222,15 @@ export default class MacroSettings extends Mixins(StateMixin) {
this.$store.dispatch('macros/addCategory', category)
}
handleEditCategory (name: string, color: string, visible: boolean) {
handleEditCategory (name: string, color: string, visible: boolean, hideWhilePrinting: boolean, hideWhilePaused: boolean, hideWhileStandby: boolean) {
const category = {
...this.categoryDialogState.category,
name,
color,
visible
visible,
hideWhilePrinting,
hideWhilePaused,
hideWhileStandby
}
this.$store.dispatch('macros/editCategory', category)
}
Expand Down
43 changes: 41 additions & 2 deletions src/components/settings/macros/MacroSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
<v-divider /> -->

<app-setting
:title="$t('app.general.label.visible')"
>
<v-switch
v-model="newMacro.visible"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.disabled_while_printing')"
>
Expand All @@ -86,10 +99,36 @@
<v-divider />

<app-setting
:title="$t('app.general.label.visible')"
:title="$t('app.general.label.hide_while_printing')"
>
<v-switch
v-model="newMacro.visible"
v-model="newMacro.hideWhilePrinting"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.hide_while_paused')"
>
<v-switch
v-model="newMacro.hideWhilePaused"
class="mt-0 pt-0"
color="primary"
hide-details
/>
</app-setting>

<v-divider />

<app-setting
:title="$t('app.general.label.hide_while_standby')"
>
<v-switch
v-model="newMacro.hideWhileStandby"
class="mt-0 pt-0"
color="primary"
hide-details
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ app:
current_user: Current user
default: Default
disabled_while_printing: Disabled while printing
hide_while_printing: Hide while printing
hide_while_paused: Hide when paused
hide_while_standby: Hide in standby
edit_camera: Edit Camera
edit_filter: Edit Filter
edit_preset: Edit Preset
Expand Down
8 changes: 7 additions & 1 deletion src/store/macros/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export const MACRO_DEFAULTS = {
alias: '',
visible: true,
disabledWhilePrinting: false,
hideWhilePrinting: false,
hideWhilePaused: false,
hideWhileStandby: false,
color: '',
categoryId: '0',
order: undefined
Expand Down Expand Up @@ -121,7 +124,7 @@ export const getters: GetterTree<MacrosState, RootState> = {
getCategories: (state, getters) => {
const cateories = state.categories
.map(category => {
const { id, name, color, order, visible } = category
const { id, name, color, order, visible, hideWhilePrinting, hideWhilePaused, hideWhileStandby } = category

const macros = getters.getMacrosByCategory(id) as Macro[]
const count = macros.length
Expand All @@ -133,6 +136,9 @@ export const getters: GetterTree<MacrosState, RootState> = {
id,
name,
visible,
hideWhilePrinting,
hideWhilePaused,
hideWhileStandby,
count,
color,
order
Expand Down
10 changes: 8 additions & 2 deletions src/store/macros/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export const mutations: MutationTree<MacrosState> = {
name: payload.name,
order: payload.order,
color: payload.color,
visible: payload.visible
visible: payload.visible,
hideWhilePrinting: payload.hideWhilePrinting,
hideWhilePaused: payload.hideWhilePaused,
hideWhileStandby: payload.hideWhileStandby
})
state.stored.forEach((macro, i) => {
if (macro.categoryId === payload.id) {
Expand Down Expand Up @@ -98,7 +101,10 @@ export const mutations: MutationTree<MacrosState> = {
id: payload.id,
name: payload.name,
order: payload.order,
visible: payload.visible
visible: payload.visible,
hideWhilePrinting: payload.hideWhilePrinting,
hideWhilePaused: payload.hideWhilePaused,
hideWhileStandby: payload.hideWhileStandby
})
state.stored.forEach((macro, i) => {
if (macro.categoryId === payload.id) {
Expand Down
6 changes: 6 additions & 0 deletions src/store/macros/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export interface Macro {
category?: MacroCategory;
assignTo?: string;
disabledWhilePrinting?: boolean;
hideWhilePrinting?: boolean;
hideWhilePaused?: boolean;
hideWhileStandby?: boolean;
color?: string;
config?: any;
order?: number;
Expand All @@ -25,4 +28,7 @@ export interface MacroCategory {
visible?: number;
order?: number;
color?: string;
hideWhilePrinting?: boolean;
hideWhilePaused?: boolean;
hideWhileStandby?: boolean;
}

0 comments on commit c637256

Please sign in to comment.