From f91312c8241994063df88d6d1a30a4340af02f48 Mon Sep 17 00:00:00 2001 From: Robert Kossessa Date: Wed, 13 Mar 2024 21:29:36 +0100 Subject: [PATCH] ADD: Ring color configuration --- .../config/knob/KnobLightConfig.vue | 59 ++++++++++++++----- src/renderer/src/deviceStore.ts | 33 +++++++++-- 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/src/renderer/src/components/config/knob/KnobLightConfig.vue b/src/renderer/src/components/config/knob/KnobLightConfig.vue index e210253..f0964d5 100644 --- a/src/renderer/src/components/config/knob/KnobLightConfig.vue +++ b/src/renderer/src/components/config/knob/KnobLightConfig.vue @@ -1,27 +1,58 @@ diff --git a/src/renderer/src/deviceStore.ts b/src/renderer/src/deviceStore.ts index 98b492f..09dae5f 100644 --- a/src/renderer/src/deviceStore.ts +++ b/src/renderer/src/deviceStore.ts @@ -68,10 +68,8 @@ export const useDeviceStore = defineStore('device', { }), getters: { connected: (state) => state.currentDeviceId !== null, - currentProfile: (state) => - state.currentProfileName - ? state.profiles.find((profile) => profile.name === state.currentProfileName) - : null, + currentProfile: (state): Profile | null => + state.profiles.find((profile) => profile.name === state.currentProfileName) || null, profileTags: (state) => [...new Set(state.profiles.map((profile) => profile.profileTag))], profilesByTag: (state) => state.profiles.reduce((acc, profile) => { @@ -204,6 +202,33 @@ export const useDeviceStore = defineStore('device', { JSON.stringify({ profile: this.currentProfileName, updates: { [propertyName]: color } }) ) } + }, + setPrimaryColor(color: number, updateDevice: boolean = true) { + this.currentProfile!.primary = color + if (updateDevice) { + sendDebounced( + this.currentDeviceId!, + JSON.stringify({ profile: this.currentProfileName, updates: { primary: color } }) + ) + } + }, + setSecondaryColor(color: number, updateDevice: boolean = true) { + this.currentProfile!.secondary = color + if (updateDevice) { + sendDebounced( + this.currentDeviceId!, + JSON.stringify({ profile: this.currentProfileName, updates: { secondary: color } }) + ) + } + }, + setPointerColor(color: number, updateDevice: boolean = true) { + this.currentProfile!.pointer = color + if (updateDevice) { + sendDebounced( + this.currentDeviceId!, + JSON.stringify({ profile: this.currentProfileName, updates: { pointer: color } }) + ) + } } } })