mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Add dummy conversion to GUI
This commit is contained in:
parent
da0cb6b3c5
commit
a339eff648
3 changed files with 32 additions and 9 deletions
|
@ -50,6 +50,9 @@ class Application(QtWidgets.QApplication):
|
|||
|
||||
|
||||
@click.command()
|
||||
@click.option(
|
||||
"--unsafe-dummy-conversion", "dummy_conversion", flag_value=True, hidden=True
|
||||
)
|
||||
@click.argument(
|
||||
"filenames",
|
||||
required=False,
|
||||
|
@ -59,7 +62,7 @@ class Application(QtWidgets.QApplication):
|
|||
)
|
||||
@click.version_option(version=get_version(), message="%(version)s")
|
||||
@errors.handle_document_errors
|
||||
def gui_main(filenames: Optional[List[str]]) -> bool:
|
||||
def gui_main(dummy_conversion: bool, filenames: Optional[List[str]]) -> bool:
|
||||
setup_logging()
|
||||
|
||||
if platform.system() == "Darwin":
|
||||
|
@ -77,7 +80,12 @@ def gui_main(filenames: Optional[List[str]]) -> bool:
|
|||
app = Application()
|
||||
|
||||
# Common objects
|
||||
dangerzone = DangerzoneGui(app)
|
||||
if getattr(sys, "dangerzone_dev", False) and dummy_conversion:
|
||||
dummy = Dummy()
|
||||
dangerzone = DangerzoneGui(app, isolation_provider=dummy)
|
||||
else:
|
||||
container = Container()
|
||||
dangerzone = DangerzoneGui(app, isolation_provider=container)
|
||||
|
||||
# Allow Ctrl-C to smoothly quit the program instead of throwing an exception
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
|
|
@ -13,7 +13,7 @@ from PySide2 import QtCore, QtGui, QtWidgets
|
|||
if platform.system() == "Linux":
|
||||
from xdg.DesktopEntry import DesktopEntry
|
||||
|
||||
from ..isolation_provider.container import Container
|
||||
from ..isolation_provider.base import IsolationProvider
|
||||
from ..logic import DangerzoneCore
|
||||
from ..settings import Settings
|
||||
from ..util import get_resource_path
|
||||
|
@ -26,8 +26,10 @@ class DangerzoneGui(DangerzoneCore):
|
|||
Singleton of shared state / functionality for the GUI and core app logic
|
||||
"""
|
||||
|
||||
def __init__(self, app: QtWidgets.QApplication) -> None:
|
||||
super().__init__(isolation_provider=Container())
|
||||
def __init__(
|
||||
self, app: QtWidgets.QApplication, isolation_provider: IsolationProvider
|
||||
) -> None:
|
||||
super().__init__(isolation_provider)
|
||||
|
||||
# Qt app
|
||||
self.app = app
|
||||
|
|
|
@ -57,9 +57,15 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
header_layout.addWidget(header_version_label)
|
||||
header_layout.addStretch()
|
||||
|
||||
# Waiting widget, replaces content widget while container runtime isn't available
|
||||
self.waiting_widget = WaitingWidget(self.dangerzone)
|
||||
self.waiting_widget.finished.connect(self.waiting_finished)
|
||||
if isinstance(self.dangerzone.isolation_provider, Container):
|
||||
# Waiting widget replaces content widget while container runtime isn't available
|
||||
self.waiting_widget: WaitingWidget = WaitingWidgetContainer(self.dangerzone)
|
||||
self.waiting_widget.finished.connect(self.waiting_finished)
|
||||
|
||||
elif isinstance(self.dangerzone.isolation_provider, Dummy):
|
||||
# Don't wait with dummy converter
|
||||
self.waiting_widget = WaitingWidget()
|
||||
self.dangerzone.is_waiting_finished = True
|
||||
|
||||
# Content widget, contains all the window content except waiting widget
|
||||
self.content_widget = ContentWidget(self.dangerzone)
|
||||
|
@ -122,6 +128,13 @@ class InstallContainerThread(QtCore.QThread):
|
|||
|
||||
|
||||
class WaitingWidget(QtWidgets.QWidget):
|
||||
finished = QtCore.Signal()
|
||||
|
||||
def __init__(self) -> None:
|
||||
super(WaitingWidget, self).__init__()
|
||||
|
||||
|
||||
class WaitingWidgetContainer(WaitingWidget):
|
||||
# These are the possible states that the WaitingWidget can show.
|
||||
#
|
||||
# Windows and macOS states:
|
||||
|
@ -134,7 +147,7 @@ class WaitingWidget(QtWidgets.QWidget):
|
|||
finished = QtCore.Signal()
|
||||
|
||||
def __init__(self, dangerzone: DangerzoneGui) -> None:
|
||||
super(WaitingWidget, self).__init__()
|
||||
super(WaitingWidgetContainer, self).__init__()
|
||||
self.dangerzone = dangerzone
|
||||
|
||||
self.label = QtWidgets.QLabel()
|
||||
|
|
Loading…
Reference in a new issue