media_player_client/src/components/SpecialVideoGridSettingDial...

220 lines
5.6 KiB
Vue
Raw Normal View History

<template>
<q-dialog
persistent
v-model="show_dialog"
@before-hide="resetData"
@keydown="
(evt) => {
if (!loading && evt.keyCode == 27) {
show_dialog = false;
}
}
"
>
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 35vw">
<q-form @submit="onSubmit">
<q-card-section class="q-ma-none q-pa-sm">
<div class="row">
<div class="col-auto text-h6">
{{ $t("grid setting") }}
</div>
<q-space />
<div>
<q-btn
:loading="loading"
flat
round
icon="close"
:disable="loading"
color="red"
v-close-popup
>
<q-tooltip>
{{ $t("close") }}
</q-tooltip>
</q-btn>
</div>
</div>
</q-card-section>
<q-separator />
<q-card-section style="max-height: 50vh; width: 35vw" class="scroll">
<q-list>
<q-item>
<q-item-section>
<q-select
:label="$t('layout')"
:options="select_options"
v-model="layout"
>
</q-select>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-select
:label="$t('rotation')"
:options="rotation_options"
v-model="rotation"
>
</q-select>
</q-item-section>
</q-item>
</q-list>
</q-card-section>
<q-separator />
<q-card-actions align="right">
<q-btn
:loading="loading"
flat
:label="$t('Cancel')"
no-caps
color="primary"
v-close-popup
/>
<q-btn
ref="accept"
flat
:label="$t('Accept')"
no-caps
:loading="loading"
type="submit"
color="primary"
/>
</q-card-actions>
</q-form>
</q-card>
</q-dialog>
</template>
<style scoped></style>
<script lang="ts">
import { defineComponent, ref, watch, computed } from "vue";
import { useStore } from "src/store";
import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n";
import GlobalData from "src/common/GlobalData";
export default defineComponent({
name: "ComponentSpecialVideoGridSettingDialog",
setup() {
let $store = useStore();
let $q = useQuasar();
let $t = useI18n();
let show_dialog = ref(false);
let loading = ref(false);
let layout = ref("1X3");
2022-09-28 15:00:17 +08:00
const row_values: number[] = [];
const col_values: number[] = [];
const select_options: string[] = [];
// 生成布局选项
{
const target_row_col_values = [3, 4, 5, 6];
for (let i = 0; i < target_row_col_values.length; ++i) {
row_values.push(1);
col_values.push(target_row_col_values[i]);
select_options.push(row_values[i] + "X" + col_values[i]);
}
for (let i = 0; i < target_row_col_values.length; ++i) {
row_values.push(target_row_col_values[i]);
col_values.push(1);
select_options.push(
row_values[target_row_col_values.length + i] +
"X" +
col_values[target_row_col_values.length + i]
);
}
}
const rotation_options = ref(["0", "90", "180", "270"]);
const rotation = ref("0");
rotation.value =
GlobalData.getInstance()?.applicationConfig
?.special_video_layout_rotation ?? "0";
return {
show_dialog,
loading,
layout,
select_options,
rotation_options,
rotation,
showDialog() {
show_dialog.value = true;
let col = parseInt(
(GlobalData.getInstance().applicationConfig?.wall_col ?? 1).toString()
);
if (isNaN(col)) {
col = 1;
}
let row = parseInt(
(GlobalData.getInstance().applicationConfig?.wall_row ?? 4).toString()
);
if (isNaN(row)) {
row = 4;
}
layout.value = row + "X" + col;
const v = select_options.find(
(element) => element && element == layout.value
);
if (!v) {
layout.value = "1X4";
}
rotation.value =
GlobalData.getInstance()?.applicationConfig
?.special_video_layout_rotation ?? "0";
},
resetData() {
loading.value = false;
},
async onSubmit() {
loading.value = true;
try {
const index = select_options.findIndex((e) => e && e == layout.value);
if (index != -1) {
// console.log(row_values[index] + "X" + col_values[index]);
GlobalData.getInstance()
.getCurrentClient()
?.setWallRowCol(row_values[index], col_values[index]);
switch (rotation.value) {
case "0":
case "90":
case "180":
2022-09-28 15:00:17 +08:00
case "270":
GlobalData.getInstance()
.getCurrentClient()
?.setSpecialVideoLayoutRotation(rotation.value ?? "0");
break;
default:
GlobalData.getInstance()
.getCurrentClient()
?.setSpecialVideoLayoutRotation("0");
break;
}
}
show_dialog.value = false;
} catch {}
loading.value = false;
},
};
},
});
</script>