]> Softwares of Agnibho - medscript.git/commitdiff
Enabled check update on startup
authorAgnibho Mondal <mondal@agnibho.com>
Wed, 25 Oct 2023 18:29:01 +0000 (23:59 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Wed, 25 Oct 2023 18:29:01 +0000 (23:59 +0530)
config.py
setting.py
window.py

index 2c3ff49a4db328bb0a861f242b7aa8c1298cf716..4b43fd81ca836b843e98b7ac3722bddca7d96568 100644 (file)
--- 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": "",
index 243df9a882d0993493841ca5574227caaed64782..a4a68fa916f1dd4c7a40f8678f7633539952557d 100644 (file)
@@ -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)
index 830427c1d854c4a0fa4fead88503f2f75f724585..b4c3c2967c65105a79ace2219a5e020d91430c42 100644 (file)
--- 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 <https://www.gnu.org/licenses/>.
 
-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()