]> Softwares of Agnibho - medscript.git/commitdiff
Added display without rendering
authorAgnibho Mondal <mondal@agnibho.com>
Wed, 8 Nov 2023 14:53:14 +0000 (20:23 +0530)
committerAgnibho Mondal <mondal@agnibho.com>
Wed, 8 Nov 2023 14:53:14 +0000 (20:23 +0530)
renderbox.py
resource/icon_view.svg [new file with mode: 0644]
window.py

index 23ce9ba73edcc53113c82118336912fd4d694a5f..b5c87f8dd0d104e8bfb3796b56166d20257cda27 100644 (file)
@@ -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/>.
 
-from PyQt6.QtWidgets import QWidget, QMainWindow, QToolBar, QFileDialog, QComboBox, QPushButton, QSizePolicy
+from PyQt6.QtWidgets import QWidget, QMainWindow, QDialog, QToolBar, QFileDialog, QComboBox, QPushButton, QLabel, QVBoxLayout, QTextBrowser, QSizePolicy
 from PyQt6.QtWebEngineWidgets import QWebEngineView
 from PyQt6.QtGui import QIcon, QPageLayout, QPageSize
 from PyQt6.QtCore import QUrl, QMarginsF
@@ -74,3 +74,33 @@ class RenderBox(QMainWindow):
             QMessageBox.warning(self,"Display failed", "Failed to display file.")
             self.hide()
             logging.warning(e)
+
+
+class UnrenderBox(QDialog):
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+
+        self.setWindowTitle("MedScript")
+        self.setMinimumSize(600, 400)
+        self.setSizeGripEnabled(True)
+
+        layout=QVBoxLayout(self)
+        heading=QLabel("<strong>Prescription</strong>")
+        self.display=QTextBrowser()
+        layout.addWidget(heading)
+        layout.addWidget(self.display)
+
+        self.setWindowIcon(QIcon(os.path.join("resource", "icon_medscript.ico")))
+
+    def show(self, prescription):
+        text=""
+        for attr, value in prescription.prescriber.__dict__.items():
+            if(attr not in ["properties"] and len(value)>0):
+                text=text+"<strong>"+value.upper()+"</strong><br>"
+        text=text+"<hr>"
+        for attr, value in prescription.__dict__.items():
+            if(attr not in ["prescriber", "custom", "properties", "file"] and len(str(value))>0):
+                text=text+"<strong>"+attr.upper()+"</strong><br>"
+                text=text+str(value)+"<br>"
+        self.display.setText(text)
diff --git a/resource/icon_view.svg b/resource/icon_view.svg
new file mode 100644 (file)
index 0000000..6b1b2d1
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   id="svg2"
+   viewBox="0 0 188 188"
+   version="1.1"
+   sodipodi:docname="icon_view.svg"
+   inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
+   width="188"
+   height="188"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <defs
+     id="defs1" />
+  <sodipodi:namedview
+     id="namedview1"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:showpageshadow="2"
+     inkscape:pageopacity="0.0"
+     inkscape:pagecheckerboard="0"
+     inkscape:deskcolor="#d1d1d1"
+     inkscape:zoom="3.4692426"
+     inkscape:cx="50.875657"
+     inkscape:cy="118.46966"
+     inkscape:window-width="1920"
+     inkscape:window-height="1080"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg2" />
+  <g
+     id="g3797"
+     transform="matrix(0.40733211,0,0,0.65646603,-10.842647,-431.2148)">
+    <path
+       id="path2987"
+       d="m 33.085,279.89 c 0,0 57.693,-135.96 224.35,-135.96 163.35,-1e-5 224.35,135.96 224.35,135.96 0,0 -109.55,85.296 -224.35,85.296 -112.95,0 -224.35,-85.296 -224.35,-85.296 z"
+       transform="translate(0,540.36)"
+       style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:6.98745;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       id="path2987-4"
+       d="m 47.863,820.53 c 0,0 60.047,-107.58 209.58,-107.58 146.56,-1e-5 209.58,107.58 209.58,107.58 0,0 -106.57,75.712 -209.58,75.712 -101.34,0 -209.58,-75.712 -209.58,-75.712 z"
+       fill="#ffffff" />
+    <path
+       id="path3793"
+       d="m 302.75,165.84 c 0,40.528 -35.95,73.382 -80.297,73.382 -44.347,0 -80.297,-32.854 -80.297,-73.382 0,-40.528 35.95,-73.382 80.297,-73.382 44.347,0 80.297,32.854 80.297,73.382 z"
+       fill-rule="evenodd"
+       transform="matrix(1.2803,0,0,1.4009,-27.362,568.16)"
+       style="fill:#000000;fill-opacity:0.5" />
+    <path
+       id="path3795"
+       d="m 182.11,133.18 c 0,11.882 -9.6326,21.515 -21.515,21.515 -11.8824,0 -21.515,-9.6326 -21.515,-21.515 0,-11.8824 9.6326,-21.515 21.515,-21.515 11.8824,0 21.515,9.6326 21.515,21.515 z"
+       fill-rule="evenodd"
+       transform="matrix(1.0714,0,0,1.0714,26.949,616.14)"
+       fill="#ffffff" />
+  </g>
+  <metadata
+     id="metadata1">
+    <rdf:RDF>
+      <cc:Work>
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <cc:license
+           rdf:resource="http://creativecommons.org/publicdomain/zero/1.0/" />
+        <dc:publisher>
+          <cc:Agent
+             rdf:about="http://openclipart.org/">
+            <dc:title>Openclipart</dc:title>
+          </cc:Agent>
+        </dc:publisher>
+        <dc:title>Eye</dc:title>
+        <dc:date>2013-11-11T01:25:34</dc:date>
+        <dc:description>black-and-white stylized image of a human eye</dc:description>
+        <dc:source>https://openclipart.org/detail/188640/eye-by-sumitomohiko-188640</dc:source>
+        <dc:creator>
+          <cc:Agent>
+            <dc:title>SumiTomohiko</dc:title>
+          </cc:Agent>
+        </dc:creator>
+        <dc:subject>
+          <rdf:Bag>
+            <rdf:li>eye</rdf:li>
+          </rdf:Bag>
+        </dc:subject>
+      </cc:Work>
+      <cc:License
+         rdf:about="http://creativecommons.org/publicdomain/zero/1.0/">
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Reproduction" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#Distribution" />
+        <cc:permits
+           rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
+      </cc:License>
+    </rdf:RDF>
+  </metadata>
+</svg>
index 30cdf44786b56e0b6ddd854574192ecc01c269ae..f721eabe3d017df876a7965d1ede1603149029e7 100644 (file)
--- a/window.py
+++ b/window.py
@@ -19,7 +19,7 @@ from config import config, info, real_dir
 from prescription import Prescription, Prescriber
 from renderer import Renderer
 from filehandler import FileHandler
-from renderbox import RenderBox
+from renderbox import RenderBox, UnrenderBox
 from setting import EditConfiguration, EditPrescriber, SelectPrescriber
 from editpreset import EditPreset
 from viewbox import ViewBox
@@ -124,6 +124,10 @@ class MainWindow(QMainWindow):
         if(self.confirm_close()):
             sys.exit()
 
+    def cmd_unrender(self):
+        self.unrenderbox.show(self.prescription)
+        self.unrenderbox.exec()
+
     def cmd_render(self):
         self.refresh()
         if(self.save_state==md5(self.prescription.get_json().encode()).hexdigest()):
@@ -523,6 +527,7 @@ class MainWindow(QMainWindow):
         icon_save=QIcon(os.path.join(config["resource"], "icon_save.svg"))
         icon_render=QIcon(os.path.join(config["resource"], "icon_render.svg"))
         icon_refresh=QIcon(os.path.join(config["resource"], "icon_refresh.svg"))
+        icon_view=QIcon(os.path.join(config["resource"], "icon_view.svg"))
 
         self.preset_note=Preset("note")
         self.preset_report=Preset("report")
@@ -561,6 +566,11 @@ class MainWindow(QMainWindow):
         action_render2=QAction(icon_render, "Render", self)
         action_render.triggered.connect(self.cmd_render)
         action_render2.triggered.connect(self.cmd_render)
+        action_unrender=QAction("Plain Display", self)
+        action_unrender.setShortcut("Ctrl+D")
+        action_unrender2=QAction(icon_view, "View", self)
+        action_unrender.triggered.connect(self.cmd_unrender)
+        action_unrender2.triggered.connect(self.cmd_unrender)
         action_sign=QAction("Sign Prescription", self)
         action_sign.triggered.connect(self.cmd_sign)
         action_unsign=QAction("Delete Signature", self)
@@ -597,6 +607,7 @@ class MainWindow(QMainWindow):
         menu_file.addAction(action_save_as)
         menu_file.addAction(action_quit)
         menu_prepare=menubar.addMenu("Prepare")
+        menu_prepare.addAction(action_unrender)
         menu_prepare.addAction(action_render)
         menu_prepare.addAction(action_refresh)
         if(config["smime"]):
@@ -637,6 +648,7 @@ class MainWindow(QMainWindow):
         toolbar.addAction(action_open2)
         toolbar.addAction(action_save2)
         toolbar.addAction(action_refresh2)
+        toolbar.addAction(action_unrender2)
         toolbar.addAction(action_render2)
         toolbar.addSeparator()
         label_template=QLabel("Template:")
@@ -904,6 +916,7 @@ class MainWindow(QMainWindow):
         self.setStatusBar(self.statusbar)
 
         self.renderbox=RenderBox()
+        self.unrenderbox=UnrenderBox()
         self.signal_view.connect(self.renderbox.update)
         self.edit_configuration=EditConfiguration()
         self.edit_prescriber=EditPrescriber()