Skip to content

Commit

Permalink
FIXUP: Change the error message and use setPlainText
Browse files Browse the repository at this point in the history
  • Loading branch information
almet committed Sep 2, 2024
1 parent 532fd74 commit 8a16be7
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions dangerzone/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
# FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details.
if typing.TYPE_CHECKING:
from PySide2 import QtCore, QtGui, QtSvg, QtWidgets
from PySide2.QtWidgets import QAction, QTextEdit
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QAction, QTextEdit
else:
try:
from PySide6 import QtCore, QtGui, QtSvg, QtWidgets
from PySide6.QtCore import Qt
from PySide6.QtGui import QAction
from PySide6.QtWidgets import QTextEdit
from PySide6.QtCore import Qt
except ImportError:
from PySide2 import QtCore, QtGui, QtSvg, QtWidgets
from PySide2.QtWidgets import QAction, QTextEdit
from PySide2.QtCore import Qt


from .. import errors
from ..document import SAFE_EXTENSION, Document
from ..isolation_provider.container import Container, NoContainerTechException
Expand Down Expand Up @@ -442,15 +441,17 @@ def __init__(self, dangerzone: DangerzoneGui) -> None:
# Error
self.error_text = QTextEdit()
self.error_text.setReadOnly(True)
self.error_text.setStyleSheet("""
self.error_text.setStyleSheet(
"""
QTextEdit {
font-family: Consolas, Monospace;
font-size: 12px;
background-color: #fff;
color: #000;
padding: 10px;
}
""")
"""
)
self.error_text.setVisible(False)
# Enable copying
self.error_text.setTextInteractionFlags(Qt.TextSelectableByMouse)
Expand Down Expand Up @@ -522,16 +523,13 @@ def state_change(self, state: str, error: str) -> None:
self.buttons.show()
elif state == "not_running":
if platform.system() == "Linux":
# "not_running" here means that the `podman image ls` command failed.
message = (
"<strong>Dangerzone requires Podman</strong><br><br>"
"Podman is installed but isn't running.<br>"
"It could mean that it is not configured properly."
"Podman is installed but cannot run properly. See errors below"
)
if error:
message += "<br><br>The following error was caught when trying to run <code>podman image list</code>"

code_snippet = f"<pre>{error.decode()}</pre>"
self.error_text.setHtml(code_snippet)
self.error_text.setPlainText(error.decode())
self.error_text.setVisible(True)

self.label.setText(message)
Expand Down

0 comments on commit 8a16be7

Please sign in to comment.