Skip to content
Snippets Groups Projects
Commit 4f486209 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

imprv: Preview: Add setting to disable file preview

Fixes #10991
parent feaf6f49
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,9 @@ class _ACCOUNT_DEFAULT:
'dev_force_bookmark_2',
'dev_use_message_label',
'developer_modus',
'enable_emoji_shortcodes',
'enable_negative_priority',
'enable_file_preview',
'escape_key_closes',
'gc_notify_on_all_messages_private_default',
'gc_notify_on_all_messages_public_default',
......@@ -107,7 +109,6 @@ class _ACCOUNT_DEFAULT:
'use_stun_server',
'use_urgency_hint',
'video_see_self',
'enable_emoji_shortcodes',
]
IntSettings = Literal[
......@@ -203,7 +204,9 @@ class _ACCOUNT_DEFAULT:
'developer_modus': False,
'dictionary_url': 'WIKTIONARY',
'emoticons_theme': 'noto-emoticons',
'enable_emoji_shortcodes': True,
'enable_negative_priority': False,
'enable_file_preview': True,
'escape_key_closes': False,
'file_transfers_port': 28011,
'ft_add_hosts_to_send': '',
......@@ -295,7 +298,6 @@ class _ACCOUNT_DEFAULT:
'video_see_self': True,
'video_size': '',
'workspace_order': [],
'enable_emoji_shortcodes': True,
}
BoolAccountSettings = Literal[
......
......@@ -123,9 +123,11 @@ def __init__(self,
from_us = kind == 'outgoing'
is_previewable = False
if additional_data is not None:
preview_enabled = app.settings.get('enable_file_preview')
if additional_data is not None and preview_enabled:
is_previewable = app.preview_manager.is_previewable(
text, additional_data)
if is_previewable:
context = None
if self._is_groupchat:
......
......@@ -445,11 +445,17 @@ def __init__(self, *args: Any) -> None:
}
settings = [
Setting(SettingKind.SWITCH,
_('File Preview'),
SettingType.CONFIG,
'enable_file_preview',
desc=_('Show previews for files')),
Setting(SettingKind.SPIN,
_('Preview Size'),
SettingType.CONFIG,
'preview_size',
desc=_('Size of preview image'),
bind='enable_file_preview',
props={'range_': (100, 1000)}),
Setting(SettingKind.POPOVER,
......@@ -457,6 +463,7 @@ def __init__(self, *args: Any) -> None:
SettingType.CONFIG,
'preview_max_file_size',
desc=_('Maximum file size for preview generation'),
bind='enable_file_preview',
props={'entries': sizes}),
Setting(SettingKind.SWITCH,
......@@ -464,27 +471,31 @@ def __init__(self, *args: Any) -> None:
SettingType.CONFIG,
'preview_anonymous_muc',
desc=_('Generate preview automatically in public '
'group chats (may disclose your data)')),
'group chats (may disclose your data)'),
bind='enable_file_preview'),
Setting(SettingKind.SWITCH,
_('Preview all Image URLs'),
SettingType.CONFIG,
'preview_allow_all_images',
desc=_('Generate preview for any URLs containing images '
'(may be unsafe)')),
'(may be unsafe)'),
bind='enable_file_preview'),
Setting(SettingKind.POPOVER,
_('Left Click Action'),
SettingType.CONFIG,
'preview_leftclick_action',
desc=_('Action when left-clicking a preview'),
bind='enable_file_preview',
props={'entries': actions}),
Setting(SettingKind.SWITCH,
_('HTTPS Verification'),
SettingType.CONFIG,
'preview_verify_https',
desc=_('Whether to check for a valid certificate')),
desc=_('Whether to check for a valid certificate'),
bind='enable_file_preview'),
]
PreferenceBox.__init__(self, settings)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment