import { systemPreferences } from '@electron/remote'; import { Component, ReactElement } from 'react'; import { observer } from 'mobx-react'; import prettyBytes from 'pretty-bytes'; import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'; import { mdiGithub, mdiOpenInNew, mdiPowerPlug } from '@mdi/js'; import Form from '../../../lib/Form'; import Button from '../../ui/button'; import Toggle from '../../ui/toggle'; import Select from '../../ui/Select'; import Input from '../../ui/input/index'; import ColorPickerInput from '../../ui/colorPickerInput'; import Infobox from '../../ui/Infobox'; import { H1, H2, H3, H5 } from '../../ui/headline'; import { ferdiumVersion, userDataPath, userDataRecipesPath, } from '../../../environment-remote'; import { updateVersionParse } from '../../../helpers/update-helpers'; import { DEFAULT_ACCENT_COLOR, DEFAULT_APP_SETTINGS, FERDIUM_TRANSLATION, GITHUB_FRANZ_URL, GITHUB_FERDIUM_URL, SPLIT_COLUMNS_MAX, SPLIT_COLUMNS_MIN, } from '../../../config'; import { isMac, isWindows, lockFerdiumShortcutKey } from '../../../environment'; import { openExternalUrl, openPath } from '../../../helpers/url-helpers'; import globalMessages from '../../../i18n/globalMessages'; import Icon from '../../ui/icon'; import Slider from '../../ui/Slider'; const debug = require('../../../preload-safe-debug')( 'Ferdium:EditSettingsForm', ); const messages = defineMessages({ headlineGeneral: { id: 'settings.app.headlineGeneral', defaultMessage: 'General', }, headlineServices: { id: 'settings.app.headlineServices', defaultMessage: 'Services', }, sentryInfo: { id: 'settings.app.sentryInfo', defaultMessage: 'Sending telemetry data allows us to find errors in Ferdium - we will not send any personal information like your message data!', }, hibernateInfo: { id: 'settings.app.hibernateInfo', defaultMessage: 'By default, Ferdium will keep all your services open and loaded in the background so they are ready when you want to use them. Service Hibernation will unload your services after a specified amount. This is useful to save RAM or keeping services from slowing down your computer.', }, inactivityLockInfo: { id: 'settings.app.inactivityLockInfo', defaultMessage: 'Minutes of inactivity, after which Ferdium should automatically lock. Use 0 to disable', }, todoServerInfo: { id: 'settings.app.todoServerInfo', defaultMessage: 'This server will be used for the "Ferdium Todo" feature.', }, lockedPassword: { id: 'settings.app.lockedPassword', defaultMessage: 'Password', }, lockedPasswordInfo: { id: 'settings.app.lockedPasswordInfo', defaultMessage: "Please make sure to set a password you'll remember.\nIf you loose this password, you will have to reinstall Ferdium.", }, lockInfo: { id: 'settings.app.lockInfo', defaultMessage: 'Password Lock allows you to keep your messages protected.\nUsing Password Lock, you will be prompted to enter your password everytime you start Ferdium or lock Ferdium yourself using the lock symbol in the bottom left corner or the shortcut {lockShortcut}.', }, scheduledDNDTimeInfo: { id: 'settings.app.scheduledDNDTimeInfo', defaultMessage: 'Times in 24-Hour-Format. End time can be before start time (e.g. start 17:00, end 09:00) to enable Do-not-Disturb overnight.', }, scheduledDNDInfo: { id: 'settings.app.scheduledDNDInfo', defaultMessage: 'Scheduled Do-not-Disturb allows you to define a period of time in which you do not want to get Notifications from Ferdium.', }, headlineLanguage: { id: 'settings.app.headlineLanguage', defaultMessage: 'Language', }, headlineUpdates: { id: 'settings.app.headlineUpdates', defaultMessage: 'Updates', }, headlineAppearance: { id: 'settings.app.headlineAppearance', defaultMessage: 'Appearance', }, sectionMain: { id: 'settings.app.sectionMain', defaultMessage: 'Main', }, sectionHibernation: { id: 'settings.app.sectionHibernation', defaultMessage: 'Hibernation', }, sectionGeneralUi: { id: 'settings.app.sectionGeneralUi', defaultMessage: 'General UI', }, sectionSidebarSettings: { id: 'settings.app.sectionSidebarSettings', defaultMessage: 'Sidebar Settings', }, sectionPrivacy: { id: 'settings.app.sectionPrivacy', defaultMessage: 'Privacy Settings', }, sectionLanguage: { id: 'settings.app.sectionLanguage', defaultMessage: 'Language Settings', }, sectionAdvanced: { id: 'settings.app.sectionAdvanced', defaultMessage: 'Advanced Settings', }, sectionUpdates: { id: 'settings.app.sectionUpdates', defaultMessage: 'App Updates Settings', }, sectionServiceIconsSettings: { id: 'settings.app.sectionServiceIconsSettings', defaultMessage: 'Service Icons Settings', }, sectionAccentColorSettings: { id: 'settings.app.sectionAccentColorSettings', defaultMessage: 'Accent Color Settings', }, accentColorInfo: { id: 'settings.app.accentColorInfo', defaultMessage: 'Write your color choice in a CSS-compatible format. (Default: {defaultAccentColor} or clear the input field)', }, overallTheme: { id: 'settings.app.overallTheme', defaultMessage: 'Overall Theme', }, progressbarTheme: { id: 'settings.app.progressbarTheme', defaultMessage: 'Progressbar Theme', }, universalDarkModeInfo: { id: 'settings.app.universalDarkModeInfo', defaultMessage: 'Universal Dark Mode tries to dynamically generate dark mode styles for services that are otherwise not currently supported.', }, headlinePrivacy: { id: 'settings.app.headlinePrivacy', defaultMessage: 'Privacy', }, headlineAdvanced: { id: 'settings.app.headlineAdvanced', defaultMessage: 'Advanced', }, translationHelp: { id: 'settings.app.translationHelp', defaultMessage: 'Help us to translate Ferdium into your language.', }, spellCheckerLanguageInfo: { id: 'settings.app.spellCheckerLanguageInfo', defaultMessage: "Ferdium uses your Mac's build-in spellchecker to check for typos. If you want to change the languages the spellchecker checks for, you can do so in your Mac's System Preferences.", }, subheadlineCache: { id: 'settings.app.subheadlineCache', defaultMessage: 'Cache', }, cacheInfo: { id: 'settings.app.cacheInfo', defaultMessage: 'Ferdium cache is currently using {size} of disk space.', }, cacheNotCleared: { id: 'settings.app.cacheNotCleared', defaultMessage: "Couldn't clear all cache", }, buttonClearAllCache: { id: 'settings.app.buttonClearAllCache', defaultMessage: 'Clear cache', }, subheadlineFerdiumProfile: { id: 'settings.app.subheadlineFerdiumProfile', defaultMessage: 'Ferdium Profile', }, buttonOpenFerdiumProfileFolder: { id: 'settings.app.buttonOpenFerdiumProfileFolder', defaultMessage: 'Open Profile folder', }, buttonOpenFerdiumServiceRecipesFolder: { id: 'settings.app.buttonOpenFerdiumServiceRecipesFolder', defaultMessage: 'Open Service Recipes folder', }, buttonOpenImportExport: { id: 'settings.app.buttonOpenImportExport', defaultMessage: 'Import / Export', }, serverHelp: { id: 'settings.app.serverHelp', defaultMessage: 'Connected to server at {serverURL}', }, buttonSearchForUpdate: { id: 'settings.app.buttonSearchForUpdate', defaultMessage: 'Check for updates', }, buttonInstallUpdate: { id: 'settings.app.buttonInstallUpdate', defaultMessage: 'Restart & install update', }, buttonShowChangelog: { id: 'settings.app.buttonShowChangelog', defaultMessage: 'Show changelog', }, updateStatusSearching: { id: 'settings.app.updateStatusSearching', defaultMessage: 'Searching for updates...', }, updateStatusAvailable: { id: 'settings.app.updateStatusAvailable', defaultMessage: 'Update available, downloading...', }, updateStatusUpToDate: { id: 'settings.app.updateStatusUpToDate', defaultMessage: 'You are using the latest version of Ferdium', }, currentVersion: { id: 'settings.app.currentVersion', defaultMessage: 'Current version:', }, appRestartRequired: { id: 'settings.app.restartRequired', defaultMessage: 'Changes require restart', }, servicesUpdated: { id: 'infobar.servicesUpdated', defaultMessage: 'Your services have been updated.', }, buttonReloadServices: { id: 'infobar.buttonReloadServices', defaultMessage: 'Reload services', }, numberOfColumns: { id: 'settings.app.form.splitColumns', defaultMessage: 'Number of columns', }, }); const Hr = (): ReactElement => (