diff options
author | Blaine | 2020-05-06 16:51:02 +0530 |
---|---|---|
committer | Blaine | 2020-05-06 16:51:02 +0530 |
commit | 97b304ea746d3ad380fa1ac31409cadc4dbb139b (patch) | |
tree | 18c1bc1b275a4b9373bc7db002470a9a8fbadd21 /src | |
parent | 708835a4859a0c5d81a34b26442962e727a0035b (diff) | |
download | Chemical-PFD-97b304ea746d3ad380fa1ac31409cadc4dbb139b.tar.gz Chemical-PFD-97b304ea746d3ad380fa1ac31409cadc4dbb139b.tar.bz2 Chemical-PFD-97b304ea746d3ad380fa1ac31409cadc4dbb139b.zip |
scroll wheel init
Diffstat (limited to 'src')
-rw-r--r-- | src/main/python/main.py | 2 | ||||
-rw-r--r-- | src/main/python/utils/canvas.py | 4 | ||||
-rw-r--r-- | src/main/python/utils/graphics.py | 16 | ||||
-rw-r--r-- | src/main/python/utils/tabs.py | 10 |
4 files changed, 25 insertions, 7 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py index 81e54e1..fc4c145 100644 --- a/src/main/python/main.py +++ b/src/main/python/main.py @@ -158,7 +158,7 @@ class appWindow(QMainWindow): elif event.key() == Qt.Key_O: self.openProject() - elif event.key() == Qt.Key_Q: + elif event.key() == Qt.Key_W: self.close() elif event.key() == Qt.Key_P: diff --git a/src/main/python/utils/canvas.py b/src/main/python/utils/canvas.py index e2e6ab8..640d4cc 100644 --- a/src/main/python/utils/canvas.py +++ b/src/main/python/utils/canvas.py @@ -30,7 +30,7 @@ class canvas(QWidget): self.painter = QGraphicsScene() self.painter.setBackgroundBrush(QBrush(Qt.white)) #set white background - self.view = QGraphicsView(self.painter) #create a viewport for the canvas board + self.view = graphics.customView(self.painter, self) #create a viewport for the canvas board self.layout = QHBoxLayout(self) #create the layout of the canvas, the canvas could just subclass QGView instead self.layout.addWidget(self.view, alignment=Qt.AlignCenter) @@ -69,7 +69,7 @@ class canvas(QWidget): #if view is visible use half of available width factor = 2 if self.parentFileWindow.sideViewTab is not None else 1 #use minimum width required to fit the view - width = min((prect.width() - 20)//factor, width) + width = min((prect.width() - 40)//factor, width) height = min(prect.height() - 80, height) #set view dims self.view.setFixedWidth(width) diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py index fc80254..9e1f690 100644 --- a/src/main/python/utils/graphics.py +++ b/src/main/python/utils/graphics.py @@ -1 +1,15 @@ -pass
\ No newline at end of file +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QGraphicsView +class customView(QGraphicsView): + + def __init__(self, scene, parent=None): + super(customView, self).__init__(scene, parent) + self.zoom = 1 + + def wheelEvent(self, QWheelEvent): + if Qt.ControlModifier: + self.zoom += QWheelEvent.angleDelta().y()/2880 + self.scale(self.zoom, self.zoom) + QWheelEvent.accept() + else: + return super().wheelEvent(self, QWheelEvent)
\ No newline at end of file diff --git a/src/main/python/utils/tabs.py b/src/main/python/utils/tabs.py index d42a8c9..eab056a 100644 --- a/src/main/python/utils/tabs.py +++ b/src/main/python/utils/tabs.py @@ -30,11 +30,15 @@ class customTabWidget(QTabWidget): self.plusButton = QPushButton('+', self) #create the new tab button #style the new tab button self.plusButton.setFlat(True) - self.plusButton.setStyleSheet("""QPushButton{ + self.plusButton.setStyleSheet(""" + QPushButton{ background: rgba(230, 230, 227, 0%); + padding: 1px; + border: 0px solid #E6E6E3; + } - QPushButton:Hover{ - background: rgba(230, 230, 227, 40%); + QPushButton:hover{ + background: rgba(230, 230, 227, 60%); }""") #and parent it to the widget to add it at 0, 0 |