Skip to content

Commit

Permalink
modularized all cards in ColorSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
pljakobs committed Dec 15, 2024
1 parent 2091905 commit 979ed3f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/components/ColorModelCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
label="Color Model"
style="width: 200px"
dropdown-icon="img:icons/arrow_drop_down.svg"
@update:model-value="emitColorModel"
>
<template #dropdown-icon>
<img
Expand Down Expand Up @@ -45,7 +46,8 @@ export default {
MyCard,
ColorSlider,
},
setup() {
emits: ["update:colorModel"],
setup(props, { emit }) {
const configData = configDataStore();
const colorModel = ref("");
Expand Down Expand Up @@ -108,17 +110,18 @@ export default {
configData.updateData(model, value);
};
const updateColorModel = (newColorModel) => {
const emitColorModel = (newColorModel) => {
const modelIndex = colorOptions.value.indexOf(newColorModel);
configData.updateData("color.color_mode", modelIndex);
configData.updateData("color.outputmode", modelIndex);
colorModel.value = newColorModel; // Ensure the ref is updated
emit("update:colorModel", modelIndex);
};
watch(colorModel, (newColorModel, oldColorModel) => {
console.log(
`Selected color model changed from ${oldColorModel} to ${newColorModel}`,
);
updateColorModel(newColorModel);
emitColorModel(newColorModel);
});
// Initialize values from configDataStore when the component is mounted
Expand All @@ -143,7 +146,7 @@ export default {
colorSliders,
getColorSliderValue,
updateColorSlider,
updateColorModel,
emitColorModel,
};
},
};
Expand Down
1 change: 1 addition & 0 deletions src/components/WhiteBalanceCard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<MyCard icon="img:icons/exposure_outlined.svg" title="White balance">
<q-card-section>
select color temperature
<ColorSlider
v-for="colorTemperature in colorTemperatures"
:key="colorTemperature.label"
Expand Down
22 changes: 19 additions & 3 deletions src/pages/ColorSettings.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<TransitionModeCard />
<ColorModelCard />
<WhiteBalanceCard v-if="colorMode.value === 3" />
<ColorModelCard @update:color-model="handleColorModelUpdate" />
<WhiteBalanceCard v-if="colorMode === 3" />
</template>

<script>
Expand All @@ -22,26 +22,42 @@ export default {
const colorMode = ref(configData.data.color.color_mode || 0);
const handleColorModelUpdate = (newColorModel) => {
console.log(
"handleColorModelUpdate triggered: colorModel changed to ",
newColorModel,
);
colorMode.value = newColorModel;
};
watch(
() => configData.data.color.color_mode,
(newMode) => {
console.log("Watcher triggered: colorMode changed to ", newMode);
colorMode.value = newMode;
console.log(
"%cChanged colorMode: " + colorMode.value,
"color: red; font-weight: bold;",
);
},
{ deep: true },
);
onMounted(() => {
// Initialize color mode
colorMode.value = configData.data.color.color_mode || 0;
console.log("Mounted ColorSettings with colorMode:", colorMode.value);
console.log(
"%cMounted ColorSettings with colorMode: " + colorMode.value,
"color: green; font-weight: bold;",
);
});
return {
colorMode,
TransitionModeCard,
ColorModelCard,
WhiteBalanceCard,
handleColorModelUpdate,
};
},
};
Expand Down
9 changes: 9 additions & 0 deletions src/stores/configDataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const configDataStore = defineStore({
id: "configDataStore",
state: () => ({
status: storeStatus.LOADING,
data: {
color: {
color_mode: 0,
// other properties...
},
// other properties...
},
}),
actions: {
async fetchData() {
Expand Down Expand Up @@ -37,6 +44,8 @@ export const configDataStore = defineStore({
currentObject = currentObject[fieldParts[i]];
}

currentObject[fieldParts[fieldParts.length - 1]] = value;

const minimalUpdate = {};
let tempObject = minimalUpdate;
currentObject = this.data;
Expand Down

0 comments on commit 979ed3f

Please sign in to comment.