From b33b211b7ba6030f02e3537d5ef0217e76652083 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 3 Jan 2024 13:28:23 +0100 Subject: [PATCH] cleanup --- bin/evaluate.py | 13 ++++++++----- src/gui_qt/lib/backup.py | 3 +-- src/gui_qt/lib/update.py | 4 ++-- src/gui_qt/main/mainwindow.py | 11 +++++++---- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/bin/evaluate.py b/bin/evaluate.py index 7ba36a6..0478b37 100755 --- a/bin/evaluate.py +++ b/bin/evaluate.py @@ -17,31 +17,35 @@ from nmreval.lib.logger import handle_exception sys.excepthook = handle_exception from gui_qt import App -from gui_qt.Qt import QtCore, QtWidgets, QtGui +from gui_qt.Qt import QtCore -app = App(['Team Rocket FTW!']) +app = App(['NMReval']) from gui_qt.main.mainwindow import NMRMainWindow from gui_qt.lib.backup import BackupManager -from gui_qt.lib.update import UpdateDialog def do_autosave(): + # autosave and update timestamp in db success = mplQt.autosave() if success: backuping.update_last_save() - +# autosave stuff: keep track of instance and their backup files backuping = BackupManager() +# look for autosaves in DB without running programs files = backuping.search_unsaved() +# tell everyone what autosave files belongs to this process pid = os.getpid() bck_name = backuping.create_entry(pid) mplQt = NMRMainWindow(bck_file=bck_name) +# one manual autosave to create the file do_autosave() +# load all selected autosaves to program for f in files: mplQt.management.load_files(f) f.unlink() @@ -54,5 +58,4 @@ app.aboutToQuit.connect(backuping.close) mplQt.show() - sys.exit(app.exec()) diff --git a/src/gui_qt/lib/backup.py b/src/gui_qt/lib/backup.py index 3030f70..29ed6f3 100644 --- a/src/gui_qt/lib/backup.py +++ b/src/gui_qt/lib/backup.py @@ -6,7 +6,7 @@ from pathlib import Path from nmreval.configs import config_paths from ..Qt import QtCore, QtWidgets -DB_FILE = '/autohome/dominik/nmreval/nmreval.db' +DB_FILE = '/tmp/nmreval.db' class BackupManager(QtCore.QObject): @@ -119,7 +119,6 @@ class BackupManager(QtCore.QObject): Path(DB_FILE).unlink() def close(self): - print('close db') self.remove_file() self.delete_db_if_empty() diff --git a/src/gui_qt/lib/update.py b/src/gui_qt/lib/update.py index bb5347a..4534693 100644 --- a/src/gui_qt/lib/update.py +++ b/src/gui_qt/lib/update.py @@ -74,7 +74,7 @@ class UpdateDialog(QtWidgets.QDialog): label_text += '

Could not determine if this version is newer, please update manually (if necessary).

' dialog_bttns = QtWidgets.QDialogButtonBox.Close elif is_updateble: - label_text += '

Newer version available. Press Ok to download new version, Cancel to ignore.

' + label_text += '

Different version available. Press Ok to download this version, Cancel to ignore.

' dialog_bttns = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel else: label_text += '

Version may be already up-to-date.

' @@ -136,7 +136,7 @@ class QRestartWindow(QtWidgets.QMessageBox): self.setIcon(QtWidgets.QMessageBox.Warning) else: self.setText('Download completed!') - self.setInformativeText("Press Restart to use new version now") + self.setInformativeText("Press Restart to use new AppImage") self.setDetailedText(f'Location of AppImage: {file_loc}') self.setIcon(QtWidgets.QMessageBox.Information) diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index acc4a5b..39fdbea 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -82,6 +82,9 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): ) self.__backup_path = pathlib.Path(bck_file) + if os.getenv('APPIMAGE'): + # ignore AppImages if not running from AppImage + self.look_for_update() def _init_gui(self): self.setupUi(self) @@ -1017,9 +1020,10 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): @staticmethod @QtCore.pyqtSlot(name='on_actionDocumentation_triggered') def open_doc(): - docpath = '/autohome/dominik/auswerteprogramm3/doc/_build/html/index.html' - import webbrowser - webbrowser.open(docpath) + pass + # docpath = '/autohome/dominik/auswerteprogramm3/doc/_build/html/index.html' + # import webbrowser + # webbrowser.open(docpath) def dropEvent(self, evt): if evt.mimeData().hasUrls(): @@ -1106,7 +1110,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): QLog(parent=self).show() def autosave(self) -> bool: - # TODO better separate thread may it takes some time to save self.status.setText('Autosave...') success = NMRWriter(self.management.graphs, self.management.data).export(self.__backup_path.with_suffix('.nmr.0'))