Skip to content

Commit

Permalink
feat: add option to disable favicon progress circle (mainsail-crew#1825)
Browse files Browse the repository at this point in the history
Co-authored-by: rackrick <[email protected]>
  • Loading branch information
meteyou and rackrick authored Apr 5, 2024
1 parent 13d5ed1 commit 7583168
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ export default class App extends Mixins(BaseMixin, ThemeMixin) {
}
}
get progressAsFavicon() {
return this.$store.state.gui.uiSettings.progressAsFavicon
}
@Watch('language')
async languageChanged(newVal: string): Promise<void> {
await setAndLoadLocale(newVal)
Expand Down Expand Up @@ -235,7 +239,7 @@ export default class App extends Mixins(BaseMixin, ThemeMixin) {
const favicon32: HTMLLinkElement | null = document.querySelector("link[rel*='icon'][sizes='32x32']")
if (favicon16 && favicon32) {
if (this.printerIsPrinting) {
if (this.progressAsFavicon && this.printerIsPrinting) {
let faviconSize = 64
let canvas = document.createElement('canvas')
Expand Down Expand Up @@ -304,6 +308,11 @@ export default class App extends Mixins(BaseMixin, ThemeMixin) {
this.drawFavicon(this.print_percent)
}
@Watch('progressAsFavicon')
progressAsFaviconChanged(): void {
this.drawFavicon(this.print_percent)
}
@Watch('logoColor')
logoColorChanged(): void {
this.drawFavicon(this.print_percent)
Expand Down
15 changes: 15 additions & 0 deletions src/components/settings/SettingsUiSettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@
<v-switch v-model="displayCancelPrint" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.ProgressAsFavicon')"
:sub-title="$t('Settings.UiSettingsTab.ProgressAsFaviconDescription')"
:dynamic-slot-width="true">
<v-switch v-model="progressAsFavicon" hide-details class="mt-0" />
</settings-row>
<v-divider class="my-2" />
<settings-row
:title="$t('Settings.UiSettingsTab.LockSliders')"
:sub-title="$t('Settings.UiSettingsTab.LockSlidersDescription')"
Expand Down Expand Up @@ -340,6 +347,14 @@ export default class SettingsUiSettingsTab extends Mixins(BaseMixin) {
this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.displayCancelPrint', value: newVal })
}
get progressAsFavicon() {
return this.$store.state.gui.uiSettings.progressAsFavicon
}
set progressAsFavicon(newVal) {
this.$store.dispatch('gui/saveSetting', { name: 'uiSettings.progressAsFavicon', value: newVal })
}
get confirmOnEmergencyStop() {
return this.$store.state.gui.uiSettings.confirmOnEmergencyStop
}
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,8 @@
"PowerDeviceName": "Printer power device",
"PowerDeviceNameDescription": "Select which Moonraker power device should be used to power on the printer.",
"Primary": "Primary",
"ProgressAsFavicon": "Show progress as favicon",
"ProgressAsFaviconDescription": "Change the Mainsail logo favicon to a progress circle.",
"ScrewsTiltAdjustDialog": "Screws Tilt Adjust Dialog",
"ScrewsTiltAdjustDialogDescription": "Display helper dialog for SCREWS_TILT_CALCULATE.",
"TempchartHeight": "Height Temperature Chart",
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const getDefaultState = (): GuiState => {
navigationStyle: 'iconsAndText',
defaultNavigationStateSetting: 'alwaysOpen',
powerDeviceName: null,
progressAsFavicon: true,
hideSaveConfigForBedMash: false,
disableFanAnimation: false,
boolManualProbeDialog: true,
Expand Down
1 change: 1 addition & 0 deletions src/store/gui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export interface GuiState {
navigationStyle: 'iconsAndText' | 'iconsOnly'
defaultNavigationStateSetting: 'alwaysOpen' | 'alwaysClosed' | 'lastState'
powerDeviceName: string | null
progressAsFavicon: boolean
hideSaveConfigForBedMash: boolean
disableFanAnimation: boolean
boolManualProbeDialog: boolean
Expand Down

0 comments on commit 7583168

Please sign in to comment.