From affa17bf7b82ed1aac9dfd5cceb0791c0e1701f3 Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Wed, 25 Oct 2023 23:59:01 +0530 Subject: [PATCH] Enabled check update on startup --- config.py | 1 + setting.py | 8 ++++++-- window.py | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 2c3ff49..4b43fd8 100644 --- a/config.py +++ b/config.py @@ -36,6 +36,7 @@ default = { "preset_newline": "True", "preset_delimiter": ",", "markdown": "False", + "check_update": "False", "smime": "False", "root_bundle": "", "private_key": "", diff --git a/setting.py b/setting.py index 243df9a..a4a68fa 100644 --- a/setting.py +++ b/setting.py @@ -42,6 +42,7 @@ class EditConfiguration(QMainWindow): self.input_newline.setChecked(bool(self.config["preset_newline"])) self.input_delimiter.setCurrentText(self.config["preset_delimiter"]) self.input_markdown.setChecked(bool(self.config["markdown"])) + self.input_update.setChecked(bool(self.config["check_update"])) self.input_smime.setChecked(bool(self.config["smime"])) self.input_key.setText(self.config["private_key"]) self.input_certificate.setText(self.config["certificate"]) @@ -58,6 +59,7 @@ class EditConfiguration(QMainWindow): self.config["preset_newline"]=self.input_newline.isChecked() self.config["preset_delimiter"]=self.input_delimiter.currentText() self.config["markdown"]=self.input_markdown.isChecked() + self.config["check_update"]=self.input_update.isChecked() self.config["smime"]=self.input_smime.isChecked() self.config["private_key"]=self.input_key.text() self.config["certificate"]=self.input_certificate.text() @@ -68,14 +70,14 @@ class EditConfiguration(QMainWindow): self.hide() except Exception as e: QMessageBox.critical(self,"Failed to save", "Failed to save the data to the file.") - raise(e) + print(e) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) try: with open(config_file) as f: - self.config=json.loads(f.read()) + self.config=json.loads(f.read()) | config except Exception as e: print(e) self.config=config @@ -106,6 +108,8 @@ class EditConfiguration(QMainWindow): layout.addRow("Preset Delimiter", self.input_delimiter) self.input_markdown=QCheckBox("Enable markdown formatting", self) layout.addRow("Markdown", self.input_markdown) + self.input_update=QCheckBox("Check update on startup", self) + layout.addRow("Check Update", self.input_update) self.input_smime=QCheckBox("Enable digital signature (experimental)", self) layout.addRow("S/MIME", self.input_smime) self.input_key=QLineEdit(self) diff --git a/window.py b/window.py index 830427c..b4c3c29 100644 --- a/window.py +++ b/window.py @@ -5,7 +5,7 @@ # MedScript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with MedScript. If not, see . -import os, sys, datetime, dateutil.parser, shutil, json +import os, sys, datetime, dateutil.parser, shutil, json, threading from PyQt6.QtCore import Qt, QDateTime, QSize, pyqtSignal from PyQt6.QtWidgets import QWidget, QMainWindow, QMessageBox, QLabel, QPushButton, QLineEdit, QTextEdit, QDateTimeEdit, QListWidget, QComboBox, QCheckBox, QVBoxLayout, QHBoxLayout, QFormLayout, QToolBar, QTabWidget, QStatusBar, QFileDialog, QInputDialog, QCompleter, QSizePolicy from PyQt6.QtGui import QAction, QIcon @@ -776,5 +776,8 @@ class MainWindow(QMainWindow): if(len(self.prescription.prescriber.name.strip())<1): self.cmd_prescriber() + if(config["check_update"]): + threading.Thread(target=self.cmd_update, args=[True]).start() + self.setWindowIcon(QIcon(os.path.join(config["resource"], "icon_medscript.ico"))) self.showMaximized() -- 2.39.5