Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/app/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export type AppConfig = {
* Default: 1.
*/
zoomFactor: number
/**
* User-provided CSS injected into desktop app windows.
* Default: empty string.
*/
customCss: string

// ----------------
// Privacy settings
Expand Down Expand Up @@ -143,6 +148,7 @@ const defaultAppConfig: AppConfig = {
systemTitleBar: false,
monochromeTrayIcon: isMac,
zoomFactor: 1,
customCss: '',
playSoundChat: 'respect-dnd',
playSoundCall: 'respect-dnd',
enableCallbox: 'respect-dnd',
Expand Down
20 changes: 19 additions & 1 deletion src/shared/setupWebPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isRTL, register } from '@nextcloud/l10n'
import { appData } from '../app/AppData.js'
import { refetchAppData } from '../app/appData.service.js'
import { TITLE_BAR_HEIGHT } from '../constants.js'
import { initAppConfig } from './appConfig.service.ts'
import { getAppConfigValue, initAppConfig } from './appConfig.service.ts'
import { BUILD_CONFIG } from './build.config.ts'
import { initGlobals } from './globals/globals.js'
import { setupInitialState } from './initialState.service.js'
Expand Down Expand Up @@ -242,6 +242,23 @@ function applyHeaderHeight() {
document.body.style.setProperty('--header-height', `${TITLE_BAR_HEIGHT}px`)
document.documentElement.style.setProperty('--header-height', `${TITLE_BAR_HEIGHT}px`)
}
/**
* Apply custom user CSS from the desktop settings.
*/
function applyCustomCss(css = getAppConfigValue('customCss')) {
let style = document.getElementById('talk-desktop-custom-css')
if (!style) {
style = document.createElement('style')
style.id = 'talk-desktop-custom-css'
document.head.appendChild(style)
}
style.textContent = typeof css === 'string' ? css : ''
window.TALK_DESKTOP.onAppConfigChange((_event, { key, value }) => {
if (key === 'customCss') {
style.textContent = typeof value === 'string' ? value : ''
}
})
}

/**
* Handle download links
Expand All @@ -267,6 +284,7 @@ export async function setupWebPage() {
initGlobals()
applyUserData()
applyHeaderHeight()
applyCustomCss()
applyAxiosInterceptors()
applyDownloadLinkHandler()

Expand Down
8 changes: 8 additions & 0 deletions src/talk/renderer/Settings/DesktopSettingsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const theme = useAppConfigValue('theme')
const systemTitleBar = useAppConfigValue('systemTitleBar')
const monochromeTrayIcon = useAppConfigValue('monochromeTrayIcon')
const zoomFactor = useAppConfigValue('zoomFactor')
const customCss = useAppConfigValue('customCss')

const playSoundChat = useAppConfigValue('playSoundChat')
const playSoundCall = useAppConfigValue('playSoundCall')
Expand Down Expand Up @@ -80,6 +81,13 @@ const secondarySpeakerDevice = useAppConfigValue('secondarySpeakerDevice')

<UiFormGroupZoom v-model="zoomFactor" />

<NcFormGroup :label="t('talk_desktop', 'Custom CSS')">
<textarea
v-model="customCss"
:aria-label="t('talk_desktop', 'Custom CSS')"
spellcheck="false" />
</NcFormGroup>

<NcFormGroup :label="t('talk_desktop', 'Notifications & Sounds')">
<NcFormBox>
<UiFormBoxSelectNative v-model="playSoundChat" :label="t('talk_desktop', 'Play chat notification sound')" :options="notificationLevelOptions" />
Expand Down