mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Save and open document, as needed
This commit is contained in:
parent
bdcd61b964
commit
cbc4a1e7ea
4 changed files with 10 additions and 7 deletions
|
@ -23,10 +23,10 @@ def main(filename):
|
||||||
app.setQuitOnLastWindowClosed(False)
|
app.setQuitOnLastWindowClosed(False)
|
||||||
|
|
||||||
# Common object
|
# Common object
|
||||||
common = Common()
|
common = Common(app)
|
||||||
|
|
||||||
# Main window
|
# Main window
|
||||||
main_window = MainWindow(app, common)
|
main_window = MainWindow(common)
|
||||||
|
|
||||||
if filename != "":
|
if filename != "":
|
||||||
# Validate filename
|
# Validate filename
|
||||||
|
|
|
@ -14,7 +14,10 @@ class Common(object):
|
||||||
The Common class is a singleton of shared functionality throughout the app
|
The Common class is a singleton of shared functionality throughout the app
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, app):
|
||||||
|
# Qt app
|
||||||
|
self.app = app
|
||||||
|
|
||||||
# Temporary directory to store pixel data
|
# Temporary directory to store pixel data
|
||||||
self.pixel_dir = tempfile.TemporaryDirectory()
|
self.pixel_dir = tempfile.TemporaryDirectory()
|
||||||
self.safe_dir = tempfile.TemporaryDirectory()
|
self.safe_dir = tempfile.TemporaryDirectory()
|
||||||
|
|
|
@ -8,9 +8,8 @@ from .tasks_widget import TasksWidget
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QtWidgets.QMainWindow):
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
def __init__(self, app, common):
|
def __init__(self, common):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.app = app
|
|
||||||
self.common = common
|
self.common = common
|
||||||
|
|
||||||
self.setWindowTitle("dangerzone")
|
self.setWindowTitle("dangerzone")
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import shutil
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
@ -91,7 +92,7 @@ class TasksWidget(QtWidgets.QWidget):
|
||||||
or args[i] == "%u"
|
or args[i] == "%u"
|
||||||
or args[i] == "%U"
|
or args[i] == "%U"
|
||||||
):
|
):
|
||||||
args[i] = self.save_filename
|
args[i] = self.common.save_filename
|
||||||
|
|
||||||
# Open as a background process
|
# Open as a background process
|
||||||
subprocess.Popen(args)
|
subprocess.Popen(args)
|
||||||
|
@ -101,7 +102,7 @@ class TasksWidget(QtWidgets.QWidget):
|
||||||
self.common.safe_dir.cleanup()
|
self.common.safe_dir.cleanup()
|
||||||
|
|
||||||
# Quit
|
# Quit
|
||||||
self.app.quit()
|
self.common.app.quit()
|
||||||
|
|
||||||
def scroll_to_bottom(self, minimum, maximum):
|
def scroll_to_bottom(self, minimum, maximum):
|
||||||
self.details_scrollarea.verticalScrollBar().setValue(maximum)
|
self.details_scrollarea.verticalScrollBar().setValue(maximum)
|
||||||
|
|
Loading…
Reference in a new issue