Make crop iptions and stretch options panels editable by default without breaking the popup. Add them to UI and keyboard section of settings

This commit is contained in:
Tamius Han 2024-12-27 13:18:31 +01:00
parent 6d8d8493a6
commit fe336122e0
4 changed files with 54 additions and 16 deletions

View File

@ -164,7 +164,7 @@ export default {
tabs: [ tabs: [
// {id: 'videoSettings', label: 'Video settings', icon: 'crop'}, // {id: 'videoSettings', label: 'Video settings', icon: 'crop'},
{id: 'extensionSettings', label: 'Site and Extension options', icon: 'cogs' }, {id: 'extensionSettings', label: 'Site and Extension options', icon: 'cogs' },
{id: 'playerUiSettings', label: 'In-player interface', icon: 'movie-cog-outline' }, {id: 'playerUiSettings', label: 'UI and keyboard', icon: 'movie-cog-outline' },
{id: 'playerDetection', label: 'Player detection', icon: 'television-play'}, {id: 'playerDetection', label: 'Player detection', icon: 'television-play'},
{id: 'autodetectionSettings', label: 'Autodetection options', icon: 'auto-fix'}, {id: 'autodetectionSettings', label: 'Autodetection options', icon: 'auto-fix'},
// {id: 'advancedOptions', label: 'Advanced options', icon: 'cogs' }, // {id: 'advancedOptions', label: 'Advanced options', icon: 'cogs' },

View File

@ -1,9 +1,6 @@
<template> <template>
<!-- <div class="flex flex-row">
<mdicon name="crop" :size="32" />
<h1>Crop video:</h1>
</div> -->
<div class="sub-panel-content flex flex-row flex-wrap"> <div class="sub-panel-content flex flex-row flex-wrap">
<ShortcutButton <ShortcutButton
v-for="(command, index) of settings?.active.commands.crop" v-for="(command, index) of settings?.active.commands.crop"
class="flex b3 button" class="flex b3 button"
@ -19,7 +16,7 @@
<ShortcutButton <ShortcutButton
v-if="editMode" v-if="editMode"
class="button b3" class="button b3"
:class="{active: editMode ? editModeOptions?.crop?.selectedIndex === null : isActiveCrop(command)}" :class="{active: editMode ? editModeOptions?.crop?.selectedIndex === null : isActiveCrop(command)}"
label="Add new" label="Add new"
@click="editAction( @click="editAction(
{action: 'set-ar', label: 'New aspect ratio', arguments: {type: AspectRatioType.Fixed}}, {action: 'set-ar', label: 'New aspect ratio', arguments: {type: AspectRatioType.Fixed}},
@ -114,7 +111,7 @@
</div> </div>
</div> </div>
<div class="edit-action-area"> <div v-if="siteSettings" class="edit-action-area">
<div class="field"> <div class="field">
<div class="label">Default for this site</div> <div class="label">Default for this site</div>
<div class="select"> <div class="select">
@ -176,11 +173,19 @@ export default {
}, },
computed: { computed: {
siteDefaultCrop() { siteDefaultCrop() {
if (!this.siteSettings) {
return null;
}
return JSON.stringify( return JSON.stringify(
this.siteSettings.data.defaults.crop this.siteSettings.data.defaults.crop
); );
}, },
}, },
created() {
if (this.isEditing) {
this.enableEditMode();
}
},
watch: { watch: {
isEditing(newValue, oldValue) { isEditing(newValue, oldValue) {
if (newValue) { if (newValue) {
@ -195,6 +200,9 @@ export default {
* Sets default crop, for either site or global * Sets default crop, for either site or global
*/ */
setDefaultCrop($event, scope) { setDefaultCrop($event, scope) {
if (!this.siteSettings) {
return;
}
const commandArguments = JSON.parse($event.target.value); const commandArguments = JSON.parse($event.target.value);
this.siteSettings.set('defaults.crop', commandArguments); this.siteSettings.set('defaults.crop', commandArguments);
@ -205,7 +213,7 @@ export default {
* Determines whether a given crop command is the currently active one * Determines whether a given crop command is the currently active one
*/ */
isActiveCrop(cropCommand) { isActiveCrop(cropCommand) {
if (! this.resizerConfig.crop) { if (! this.resizerConfig.crop || !this.siteSettings) {
return false; return false;
} }

View File

@ -127,7 +127,7 @@
</div> </div>
</div> </div>
<div class="edit-action-area"> <div v-if="siteSettings" class="edit-action-area">
<div class="field"> <div class="field">
<div class="label">Default for this site:</div> <div class="label">Default for this site:</div>
<div class="select"> <div class="select">
@ -191,11 +191,19 @@ export default {
}, },
computed: { computed: {
siteDefaultStretch() { siteDefaultStretch() {
if (!this.siteSettings) {
return null;
}
return JSON.stringify( return JSON.stringify(
this.siteSettings.data.defaults.stretch this.siteSettings.data.defaults.stretch
); );
}, },
}, },
created() {
if (this.isEditing) {
this.enableEditMode();
}
},
watch: { watch: {
isEditing(newValue, oldValue) { isEditing(newValue, oldValue) {
if (newValue) { if (newValue) {
@ -210,6 +218,9 @@ export default {
* Sets default stretching mode, for either site or global * Sets default stretching mode, for either site or global
*/ */
setDefaultStretchingMode($event, globalOrSite) { setDefaultStretchingMode($event, globalOrSite) {
if (!this.siteSettings) {
return;
}
const commandArguments = JSON.parse($event.target.value); const commandArguments = JSON.parse($event.target.value);
this.siteSettings.set('defaults.stretch', commandArguments); this.siteSettings.set('defaults.stretch', commandArguments);
}, },
@ -218,7 +229,7 @@ export default {
* Determines whether a given stretch command is the currently active one * Determines whether a given stretch command is the currently active one
*/ */
isActiveStretch(stretchCommand) { isActiveStretch(stretchCommand) {
if (! this.resizerConfig.stretch) { if (! this.resizerConfig.stretch || !this.siteSettings) {
return false; return false;
} }

View File

@ -66,13 +66,15 @@
</div> </div>
</div> </div>
<h2>Menu options and keyboard shortcuts</h2> <h2 class="mt2r">Menu options and keyboard shortcuts</h2>
<div class="flex flex-row"> <div>
Click 'add new' to add a new option. Click a button to edit or remove the keyboard shortcut.
</div>
<div class="keyboard-settings">
<!-- CROP OPTIONS --> <!-- CROP OPTIONS -->
<div> <div>
<div class="flex flex-row"> <div class="flex flex-row">
<mdicon name="crop" :size="32" /> <h3 class="mth3">CROP OPTIONS</h3>
<h3>Crop video:</h3>
</div> </div>
<CropOptionsPanel <CropOptionsPanel
@ -86,8 +88,7 @@
<!-- STRETCH OPTIONS --> <!-- STRETCH OPTIONS -->
<div> <div>
<div class="flex flex-row"> <div class="flex flex-row">
<mdicon name="stretch-to-page-outline" :size="32" /> <h3 class="mth3">STRETCH OPTIONS</h3>
<h3>Stretch video:</h3>
</div> </div>
<StretchOptionsPanel <StretchOptionsPanel
@ -206,4 +207,22 @@ export default {
} }
} }
.keyboard-settings {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 1rem;
> * {
width: calc(50% - 0.5rem);
}
}
.mt2r {
margin-top: 2rem;
margin-bottom: 0.5rem;
}
.mth3 {
margin-top: 1.5rem;
}
</style> </style>