feat: show a deprecation warning for Ubuntu Focal (20.04)

This commit is contained in:
Alexis Métaireau 2024-10-28 15:38:33 +01:00
parent 8172195f95
commit 06cbf5afcc
No known key found for this signature in database
GPG key ID: C65C7A89A8FFC56E
2 changed files with 36 additions and 1 deletions

View file

@ -1,5 +1,6 @@
import logging import logging
import os import os
from pathlib import Path
import platform import platform
import tempfile import tempfile
import typing import typing
@ -60,6 +61,11 @@ about updates.</p>
HAMBURGER_MENU_SIZE = 30 HAMBURGER_MENU_SIZE = 30
WARNING_MESSAGE = """<p><b>Warning:</b> You are not receiving security updates because systems with Python 3.8 are no longer supported.
Please upgrade to a more recent version of your operating system to use an updated version of Dangerzone. While Dangerzone aims to protect
you from malicious documents, using an unsupported version may expose you to known security vulnerabilities.</p>"""
def load_svg_image(filename: str, width: int, height: int) -> QtGui.QPixmap: def load_svg_image(filename: str, width: int, height: int) -> QtGui.QPixmap:
"""Load an SVG image from a filename. """Load an SVG image from a filename.
@ -579,6 +585,17 @@ class ContentWidget(QtWidgets.QWidget):
self.dangerzone = dangerzone self.dangerzone = dangerzone
self.conversion_started = False self.conversion_started = False
self.warning_label = None
if platform.system() == "Linux":
# Add the warning message only for ubuntu focal
os_release_path = Path("/etc/os-release")
if os_release_path.exists():
os_release = os_release_path.read_text()
if 'Ubuntu 20.04' in os_release or 'focal' in os_release:
self.warning_label = QtWidgets.QLabel(WARNING_MESSAGE)
self.warning_label.setWordWrap(True)
self.warning_label.setProperty("style", "warning")
# Doc selection widget # Doc selection widget
self.doc_selection_widget = DocSelectionWidget(self.dangerzone) self.doc_selection_widget = DocSelectionWidget(self.dangerzone)
self.doc_selection_widget.documents_selected.connect(self.documents_selected) self.doc_selection_widget.documents_selected.connect(self.documents_selected)
@ -604,6 +621,8 @@ class ContentWidget(QtWidgets.QWidget):
# Layout # Layout
layout = QtWidgets.QVBoxLayout() layout = QtWidgets.QVBoxLayout()
if self.warning_label:
layout.addWidget(self.warning_label) # Add warning at the top
layout.addWidget(self.settings_widget, stretch=1) layout.addWidget(self.settings_widget, stretch=1)
layout.addWidget(self.documents_list, stretch=1) layout.addWidget(self.documents_list, stretch=1)
layout.addWidget(self.doc_selection_wrapper, stretch=1) layout.addWidget(self.doc_selection_wrapper, stretch=1)

View file

@ -56,3 +56,19 @@ QTextEdit[style="traceback"] {
color: #000000; color: #000000;
padding: 10px; padding: 10px;
} }
QLabel[style="warning"] {
background-color: #FFF3CD;
color: #856404;
border: 1px solid #FFEEBA;
border-radius: 4px;
padding: 10px;
margin: 10px;
}
MainWindow[OSColorMode="dark"] QLabel[style="warning"] {
background-color: #332D00;
color: #FFD970;
border-color: #665A00;
}