summaryrefslogtreecommitdiff
path: root/src/main/python
diff options
context:
space:
mode:
authorBlaine2020-05-05 13:45:48 +0530
committerBlaine2020-05-05 13:45:48 +0530
commit7fa23828f14322e7c34fc32b7e9c6ac5d688200e (patch)
tree137dee0adc66f908bb6532f20c3ea0c7cfcde7b2 /src/main/python
parentc169f11c3f7d887cc956d291e224046e1b75fbe4 (diff)
downloadChemical-PFD-7fa23828f14322e7c34fc32b7e9c6ac5d688200e.tar.gz
Chemical-PFD-7fa23828f14322e7c34fc32b7e9c6ac5d688200e.tar.bz2
Chemical-PFD-7fa23828f14322e7c34fc32b7e9c6ac5d688200e.zip
some keyboard shortcuts
Diffstat (limited to 'src/main/python')
-rw-r--r--src/main/python/main.py42
-rw-r--r--src/main/python/utils/canvas.py5
-rw-r--r--src/main/python/utils/fileWindow.py3
3 files changed, 48 insertions, 2 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py
index 3addc68..56e29e3 100644
--- a/src/main/python/main.py
+++ b/src/main/python/main.py
@@ -145,6 +145,48 @@ class appWindow(QMainWindow):
def count(self):
return len(self.mdi.subWindowList())
+ #Key input handler
+ def keyPressEvent(self, event):
+ #overload key press event for custom keyboard shortcuts
+ if event.modifiers() and Qt.ControlModifier:
+ if event.key() == Qt.key_N:
+ self.newProject()
+
+ elif event.key() == Qt.Key_S:
+ self.saveProject()
+
+ elif event.key() == Qt.Key_O:
+ self.openProject()
+
+ elif event.key() == Qt.Key_Q:
+ self.closeEvent()
+
+ elif event.key() == Qt.Key_P:
+ if Qt.AltModifier:
+ self.saveImage()
+ else:
+ self.generateReport()
+
+ elif event.key() == Qt.key_A:
+ #todo implement selectAll
+ for item in self.mdi.activeSubWindow().tabber.currentWidget().items:
+ item.setSelected(True)
+
+ #todo copy, paste, undo redo
+
+ else:
+ return event.reject()
+
+ elif event.key() == Qt.Key_Delete or event.key() == Qt.Key_Backspace:
+ for item in self.mdi.activeSubWindow().tabber.currentWidget().painter.selectedItems():
+ item.setEnabled(False)
+ #donot delete, to manage undo redo
+
+ else:
+ return event.reject()
+
+ return event.accept()
+
if __name__ == '__main__':
app = ApplicationContext() # 1. Instantiate ApplicationContext
test = appWindow()
diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py
index bf035f1..e2e6ab8 100644
--- a/src/main/python/utils/canvas.py
+++ b/src/main/python/utils/canvas.py
@@ -95,6 +95,11 @@ class canvas(QWidget):
def dimensions(self):
#returns the dimension of the current scene
return self.painter.sceneRect().width(), self.painter.sceneRect().height()
+ @property
+ def items(self):
+ # generator to filter out certain items
+ for i in self.painter.items():
+ yield i
@property
def canvasSize(self):
diff --git a/src/main/python/utils/fileWindow.py b/src/main/python/utils/fileWindow.py
index fdf1c11..26daf46 100644
--- a/src/main/python/utils/fileWindow.py
+++ b/src/main/python/utils/fileWindow.py
@@ -100,8 +100,7 @@ class fileWindow(QMdiSubWindow):
self.setFixedSize(width, height)
self.tabber.resize(width, height)
self.tabber.currentWidget().adjustView()
-
-
+
def contextMenu(self, point):
#function to display the right click menu at point of right click
menu = QMenu("Context Menu", self)