Remove window management logic

Since everything now happens in a single window, there is no need
to have a way to keep track other windows. They simply won't exist.

But on windows and Linux it will still be possible to start
multiple windows by starting various Dangerzone processes. On MacOS
this doesn't seem to be as easy from the launcher, but it should
not be critical as multiple documents can be converted at the same
time in the one window.
This commit is contained in:
deeplow 2022-09-30 14:19:02 +01:00
parent 6f8eb96b35
commit df8e2f1b8b
No known key found for this signature in database
GPG key ID: 577982871529A52A
2 changed files with 7 additions and 24 deletions

View file

@ -20,7 +20,6 @@ from .main_window import MainWindow
class Application(QtWidgets.QApplication):
document_selected = QtCore.Signal(str)
new_window = QtCore.Signal()
application_activated = QtCore.Signal()
def __init__(self) -> None:
@ -80,32 +79,20 @@ def gui_main(filenames: Optional[List[str]]) -> bool:
# Allow Ctrl-C to smoothly quit the program instead of throwing an exception
signal.signal(signal.SIGINT, signal.SIG_DFL)
closed_windows: Dict[str, MainWindow] = {}
windows: Dict[str, MainWindow] = {}
def delete_window(window_id: str) -> None:
closed_windows[window_id] = windows[window_id]
del windows[window_id]
# Open a document in a window
def new_window(filenames: Optional[List[str]] = []) -> None:
window_id = uuid.uuid4().hex
window = MainWindow(dangerzone, window_id)
def new_window(filenames: Optional[List[str]] = []) -> MainWindow:
window = MainWindow(dangerzone)
if filenames:
window.content_widget.doc_selection_widget.document_selected.emit(filenames)
window.delete_window.connect(delete_window)
windows[window_id] = window
return window
new_window(filenames)
window = new_window(filenames)
# Open a new window, if all windows are closed
# MacOS: Open a new window, if all windows are closed
def application_activated() -> None:
if len(windows) == 0:
new_window()
window.show()
# If we get a file open event, open it
app.document_selected.connect(new_window)
app.new_window.connect(new_window)
# If the application is activated and all windows are closed, open a new one
app.application_activated.connect(application_activated)

View file

@ -20,12 +20,9 @@ log = logging.getLogger(__name__)
class MainWindow(QtWidgets.QMainWindow):
delete_window = QtCore.Signal(str)
def __init__(self, dangerzone: DangerzoneGui, window_id: str) -> None:
def __init__(self, dangerzone: DangerzoneGui) -> None:
super(MainWindow, self).__init__()
self.dangerzone = dangerzone
self.window_id = window_id
self.setWindowTitle("Dangerzone")
self.setWindowIcon(self.dangerzone.get_window_icon())
@ -82,7 +79,6 @@ class MainWindow(QtWidgets.QMainWindow):
def closeEvent(self, e: QtGui.QCloseEvent) -> None:
e.accept()
self.delete_window.emit(self.window_id)
if platform.system() != "Darwin":
# in MacOS applications only quit when the user