aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/mainwindow.py63
-rw-r--r--src/gui/preview_win.py1
2 files changed, 39 insertions, 25 deletions
diff --git a/src/gui/mainwindow.py b/src/gui/mainwindow.py
index 3b204b7..d7fde5c 100644
--- a/src/gui/mainwindow.py
+++ b/src/gui/mainwindow.py
@@ -11,6 +11,7 @@ from queue import Queue
import sys
import os
import signal
+import atexit
import filecmp
import time
import logging
@@ -49,6 +50,13 @@ class MainWindow(QtWidgets.QMainWindow):
self.window = window
self.core = Core()
Core.mode = 'GUI'
+ # widgets of component settings
+ self.pages = []
+ self.lastAutosave = time.time()
+ # list of previous five autosave times, used to reduce update spam
+ self.autosaveTimes = []
+ self.autosaveCooldown = 0.2
+ self.encoding = False
# Find settings created by Core object
self.dataDir = Core.dataDir
@@ -56,19 +64,16 @@ class MainWindow(QtWidgets.QMainWindow):
self.autosavePath = os.path.join(self.dataDir, 'autosave.avp')
self.settings = Core.settings
+ # Register clean-up functions
+ signal.signal(signal.SIGINT, self.terminate)
+ atexit.register(self.cleanUp)
+
# Create stack of undoable user actions
self.undoStack = QtWidgets.QUndoStack(self)
undoLimit = self.settings.value("pref_undoLimit")
self.undoStack.setUndoLimit(undoLimit)
- # widgets of component settings
- self.pages = []
- self.lastAutosave = time.time()
- # list of previous five autosave times, used to reduce update spam
- self.autosaveTimes = []
- self.autosaveCooldown = 0.2
- self.encoding = False
-
+ # Create Preset Manager
self.presetManager = PresetManager(
uic.loadUi(
os.path.join(Core.wd, 'gui', 'presetmanager.ui')), self)
@@ -97,7 +102,6 @@ class MainWindow(QtWidgets.QMainWindow):
self.timer.start(timeout)
# Begin decorating the window and connecting events
- self.window.installEventFilter(self)
componentList = self.window.listWidget_componentList
style = window.pushButton_undo.style()
@@ -391,24 +395,41 @@ class MainWindow(QtWidgets.QMainWindow):
activated=lambda: self.moveComponent('bottom')
)
- # Debug Hotkeys
QtWidgets.QShortcut(
- "Ctrl+Alt+Shift+R", self.window, self.drawPreview
+ "Ctrl+Shift+F", self.window, self.showFfmpegCommand
)
QtWidgets.QShortcut(
- "Ctrl+Alt+Shift+F", self.window, self.showFfmpegCommand
+ "Ctrl+Shift+U", self.window, self.showUndoStack
)
- QtWidgets.QShortcut(
- "Ctrl+Alt+Shift+U", self.window, self.showUndoStack
+
+ if log.isEnabledFor(logging.DEBUG):
+ QtWidgets.QShortcut(
+ "Ctrl+Alt+Shift+R", self.window, self.drawPreview
+ )
+ QtWidgets.QShortcut(
+ "Ctrl+Alt+Shift+A", self.window, lambda: log.debug(repr(self))
+ )
+
+ def __repr__(self):
+ return (
+ '\n%s\n'
+ '#####\n'
+ 'Preview thread is %s\n' % (
+ repr(self.core),
+ 'live' if self.previewThread.isRunning() else 'dead',
+ )
)
- @QtCore.pyqtSlot()
def cleanUp(self, *args):
log.info('Ending the preview thread')
self.timer.stop()
self.previewThread.quit()
self.previewThread.wait()
+ def terminate(self, *args):
+ self.cleanUp()
+ sys.exit(0)
+
@disableWhenOpeningProject
def updateWindowTitle(self):
appName = 'Audio Visualizer'
@@ -542,7 +563,7 @@ class MainWindow(QtWidgets.QMainWindow):
return True
except FileNotFoundError:
log.error(
- 'Project file couldn\'t be located:', self.currentProject)
+ 'Project file couldn\'t be located: %s', self.currentProject)
return identical
return False
@@ -639,6 +660,7 @@ class MainWindow(QtWidgets.QMainWindow):
detail=detail,
icon='Critical',
)
+ log.info('%s', repr(self))
def changeEncodingStatus(self, status):
self.encoding = status
@@ -1017,12 +1039,3 @@ class MainWindow(QtWidgets.QMainWindow):
self.menu.move(parentPosition + QPos)
self.menu.show()
-
- def eventFilter(self, object, event):
- if event.type() == QtCore.QEvent.WindowActivate \
- or event.type() == QtCore.QEvent.FocusIn:
- Core.windowHasFocus = True
- elif event.type() == QtCore.QEvent.WindowDeactivate \
- or event.type() == QtCore.QEvent.FocusOut:
- Core.windowHasFocus = False
- return False
diff --git a/src/gui/preview_win.py b/src/gui/preview_win.py
index c6b9a32..49a22eb 100644
--- a/src/gui/preview_win.py
+++ b/src/gui/preview_win.py
@@ -60,3 +60,4 @@ class PreviewWindow(QtWidgets.QLabel):
icon='Critical',
parent=self
)
+ log.info('%', repr(self.parent))