Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to hide FPS counter #1488

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/components/settings/Webcams/WebcamForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
:label="$t('Settings.WebcamsTab.Rotate')" />
</v-col>
</v-row>
<v-row v-if="hasFpsCounter">
<v-col class="pt-1 pb-3">
<v-checkbox
v-model="hideFps"
class="mt-1"
hide-details
:label="$t('Settings.WebcamsTab.HideFps')" />
</v-col>
</v-row>
<v-row>
<v-col class="pt-1 pb-3">
<div class="v-label v-label--active theme--dark text-subtitle-1">
Expand Down Expand Up @@ -250,6 +259,27 @@ export default class WebcamForm extends Mixins(BaseMixin, WebcamMixin) {
return classes
}

get hasFpsCounter() {
return ['mjpegstreamer', 'mjpegstreamer-adaptive'].includes(this.webcam.service)
}

get hideFps() {
return this.webcam.extra_data?.hideFps ?? false
}

set hideFps(newVal) {
if (!('extra_data' in this.webcam)) {
this.webcam.extra_data = {
hideFps: newVal,
}

return
}

// @ts-ignore
this.webcam.extra_data.hideFps = newVal
}

mounted() {
this.oldWebcamName = this.webcam.name
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/webcams/Mjpegstreamer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="webcamImage"
:style="webcamStyle"
@load="onload" />
<span v-if="showFps" class="webcamFpsOutput">{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}</span>
<span v-if="showFpsCounter" class="webcamFpsOutput">{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}</span>
</div>
</template>

Expand Down Expand Up @@ -73,6 +73,12 @@ export default class Mjpegstreamer extends Mixins(BaseMixin, WebcamMixin) {
return this.currentFPS < 10 ? '0' + this.currentFPS.toString() : this.currentFPS
}

get showFpsCounter() {
if (!this.showFps) return false

return !(this.camSettings.extra_data?.hideFps ?? false)
}

startStream() {
if (this.streamState) return
this.streamState = true
Expand Down
8 changes: 7 additions & 1 deletion src/components/webcams/MjpegstreamerAdaptive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
height="400"
:style="webcamStyle"
:class="'webcamImage ' + (isLoaded ? '' : 'hiddenWebcam')"></canvas>
<span v-if="isLoaded && showFps" class="webcamFpsOutput">
<span v-if="isLoaded && showFpsCounter" class="webcamFpsOutput">
{{ $t('Panels.WebcamPanel.FPS') }}: {{ fpsOutput }}
</span>
</div>
Expand Down Expand Up @@ -75,6 +75,12 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin) {
return this.currentFPS < 10 ? '0' + this.currentFPS.toString() : this.currentFPS
}

get showFpsCounter() {
if (!this.showFps) return false

return !(this.camSettings.extra_data?.hideFps ?? false)
}

get rotate() {
return [90, 270].includes(this.camSettings.rotation ?? 0)
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@
"EditWebcam": "Webcam bearbeiten",
"FlipWebcam": "Webcam-Bild spiegeln:",
"Hlsstream": "HLS-Stream",
"HideFps": "FPS-Anzeige verstecken",
"Horizontally": "horizontal",
"IconBed": "Bett",
"IconCam": "Kamera",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@
"EditCrowsnestConf": "Edit crowsnest.conf",
"EditWebcam": "Edit Webcam",
"FlipWebcam": "Flip webcam image:",
"HideFps": "Hide FPS counter",
"Horizontally": "horizontally",
"IconBed": "Bed",
"IconCam": "Cam",
Expand Down
4 changes: 3 additions & 1 deletion src/store/gui/webcams/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface GuiWebcamStateWebcam {
flip_vertical: boolean
rotation: number
aspect_ratio?: string
extra_data?: {}
extra_data?: {
hideFps?: boolean
}
source?: 'config' | 'database'
}
Loading