Save and open document, as needed

This commit is contained in:
Micah Lee 2020-01-07 16:14:43 -08:00
parent bdcd61b964
commit cbc4a1e7ea
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
4 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -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()

View file

@ -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")

View file

@ -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)