mirror of
https://github.com/Xevion/sharex-quickzoom.git
synced 2025-12-05 23:16:14 -06:00
latest changes for GraphicsScene fix
This commit is contained in:
@@ -12,7 +12,7 @@ The effect may reach into being just zoom for radially, depending on how far I c
|
||||
|
||||
In case you wish to use this repo, these are the utilties you will require.
|
||||
|
||||
**
|
||||
**PyQt5** - GUI and most accessibility functionality
|
||||
|
||||
**os** - Path managemennt
|
||||
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
from PyQt5 import QtWidgets, QtCore
|
||||
from PyQt5 import QtWidgets, QtCore, QtGui
|
||||
from ui.mainwindow import Ui_MainWindow
|
||||
from ui.aboutform import Ui_AboutForm
|
||||
import sys
|
||||
from PIL import Image, ImageQt
|
||||
|
||||
# Simple About Window class
|
||||
class AboutWindow(QtWidgets.QMainWindow):
|
||||
def __init__(self):
|
||||
super(AboutWindow, self).__init__()
|
||||
self.ui = Ui_AboutForm()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
# Custom GraphicsScene
|
||||
class GraphicsScene(QtWidgets.QGraphicsScene):
|
||||
def __init__(self, parent=None):
|
||||
QtWidgets.QGraphicsScene.__init__(self, parent)
|
||||
# Mysterious suff stuff that fixes it
|
||||
self.setSceneRect(-100, -100, 200, 200)
|
||||
# Dimensions
|
||||
self.x, self.y = 30, 30
|
||||
|
||||
def mouseMoveEvent(self, event):
|
||||
self.clear()
|
||||
x = event.scenePos().x()
|
||||
y = event.scenePos().y()
|
||||
self.addRect(x-(self.x // 2), y - (self.y // 2), self.x, self.y, QtCore.Qt.black)
|
||||
# self.addRect(QtCore.QRectF(QtCore.QPointF(x, y), QtCore.QSizeF(10, 10)), QtCore.Qt.black)
|
||||
# self.addEllipse(x-2, y-2, 4, 4, QtCore.Qt.black, QtGui.QBrush(QtCore.Qt.black))
|
||||
|
||||
class Window(QtWidgets.QMainWindow):
|
||||
def __init__(self):
|
||||
super(Window, self).__init__()
|
||||
@@ -16,26 +35,49 @@ class Window(QtWidgets.QMainWindow):
|
||||
self.aboutui = AboutWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.initUI()
|
||||
|
||||
self.ui.scene = GraphicsScene()
|
||||
self.ui.graphicsView.setScene(self.ui.scene)
|
||||
print(dir(self.ui.scene))
|
||||
|
||||
# self.ui.graphicsView = QtWidgets.QGraphicsView(self.ui.scene)
|
||||
# self.ui.graphicsView.setGeometry(QtCore.QRect(20, 10, 571, 400))
|
||||
# self.ui.graphicsView.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
|
||||
# self.ui.graphicsView.setMouseTracking(True)
|
||||
# self.ui.graphicsView.setObjectName("graphicsView")
|
||||
|
||||
|
||||
def initUI(self):
|
||||
self.ui.graphicsView.viewport().installEventFilter(self)
|
||||
# About tab
|
||||
self.ui.actionAbout.triggered.connect(lambda : self.aboutui.show())
|
||||
self.show()
|
||||
self.pen = QtCore.Qt.black
|
||||
self.img = ImageQt.ImageQt(Image.open('ui/images/sharex.png'))
|
||||
|
||||
def redraw(self, event):
|
||||
return
|
||||
self.ui.scene.clear()
|
||||
# Draw Rect
|
||||
import random
|
||||
r = QtCore.QRectF(QtCore.QPointF(event.x(), event.y()), QtCore.QSizeF(10, 10))
|
||||
self.ui.scene.addRect(r, self.pen)
|
||||
pixMap = QtGui.QPixmap.fromImage(self.img)
|
||||
self.ui.scene.addPixmap(pixMap)
|
||||
|
||||
def eventFilter(self, source, e):
|
||||
if e.type() == QtCore.QEvent.MouseMove:
|
||||
if e.buttons() == QtCore.Qt.NoButton:
|
||||
pass
|
||||
self.redraw(e)
|
||||
elif e.buttons() == QtCore.Qt.LeftButton:
|
||||
pass
|
||||
elif e.buttons() == QtCore.Qt.RightButton:
|
||||
pass
|
||||
elif e.type() == QtCore.QEvent.MouseButtonPress:
|
||||
if e.button() == QtCore.Qt.LeftButton:
|
||||
print(f'Left Click at ({e.x()}, {e.y()})')
|
||||
pass
|
||||
elif e.button() == QtCore.Qt.RightButton:
|
||||
print(f'Right Click at ({e.x()}, {e.y()})')
|
||||
pass
|
||||
return super(Window, self).eventFilter(source, e)
|
||||
|
||||
def run():
|
||||
|
||||
@@ -11,38 +11,42 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(539, 540)
|
||||
MainWindow.resize(608, 540)
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(":/logo/images/sharex.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
|
||||
icon.addPixmap(QtGui.QPixmap(":/logo/images/sharex.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
MainWindow.setWindowIcon(icon)
|
||||
MainWindow.setAutoFillBackground(False)
|
||||
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName("centralwidget")
|
||||
self.graphicsView = QtWidgets.QGraphicsView(self.centralwidget)
|
||||
self.graphicsView.setGeometry(QtCore.QRect(20, 10, 500, 400))
|
||||
self.graphicsView.setGeometry(QtCore.QRect(20, 10, 571, 400))
|
||||
self.graphicsView.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
|
||||
self.graphicsView.setMouseTracking(True)
|
||||
self.graphicsView.setObjectName("graphicsView")
|
||||
self.checkBox = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.checkBox.setGeometry(QtCore.QRect(140, 440, 141, 17))
|
||||
self.checkBox.setGeometry(QtCore.QRect(220, 420, 141, 17))
|
||||
self.checkBox.setObjectName("checkBox")
|
||||
self.checkBox_2 = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.checkBox_2.setGeometry(QtCore.QRect(140, 460, 131, 17))
|
||||
self.checkBox_2.setGeometry(QtCore.QRect(220, 440, 131, 17))
|
||||
self.checkBox_2.setObjectName("checkBox_2")
|
||||
self.submitButton = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.submitButton.setGeometry(QtCore.QRect(280, 420, 241, 61))
|
||||
self.submitButton.setGeometry(QtCore.QRect(350, 420, 241, 61))
|
||||
self.submitButton.setObjectName("submitButton")
|
||||
self.spinTypeComboxBox = QtWidgets.QComboBox(self.centralwidget)
|
||||
self.spinTypeComboxBox.setGeometry(QtCore.QRect(20, 430, 111, 22))
|
||||
self.spinTypeComboxBox.setGeometry(QtCore.QRect(20, 420, 191, 22))
|
||||
self.spinTypeComboxBox.setObjectName("spinTypeComboxBox")
|
||||
self.spinTypeComboxBox.addItem("")
|
||||
self.spinTypeComboxBox.addItem("")
|
||||
self.thresholdSpinbox = QtWidgets.QDoubleSpinBox(self.centralwidget)
|
||||
self.thresholdSpinbox.setGeometry(QtCore.QRect(20, 460, 111, 22))
|
||||
self.thresholdSpinbox.setObjectName("thresholdSpinbox")
|
||||
self.horizontalSlider = QtWidgets.QSlider(self.centralwidget)
|
||||
self.horizontalSlider.setGeometry(QtCore.QRect(20, 450, 181, 22))
|
||||
self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.horizontalSlider.setObjectName("horizontalSlider")
|
||||
self.label = QtWidgets.QLabel(self.centralwidget)
|
||||
self.label.setGeometry(QtCore.QRect(80, 470, 71, 16))
|
||||
self.label.setObjectName("label")
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 539, 21))
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 608, 21))
|
||||
self.menubar.setObjectName("menubar")
|
||||
self.menuShareX_Quick_ZOom = QtWidgets.QMenu(self.menubar)
|
||||
self.menuShareX_Quick_ZOom.setObjectName("menuShareX_Quick_ZOom")
|
||||
@@ -67,7 +71,8 @@ class Ui_MainWindow(object):
|
||||
self.submitButton.setText(_translate("MainWindow", "Save and Exit"))
|
||||
self.spinTypeComboxBox.setItemText(0, _translate("MainWindow", "Centered Radial / Zoom Blur"))
|
||||
self.spinTypeComboxBox.setItemText(1, _translate("MainWindow", "Radial Spin Blur"))
|
||||
self.label.setText(_translate("MainWindow", "Threshold"))
|
||||
self.menuShareX_Quick_ZOom.setTitle(_translate("MainWindow", "ShareX Quick Zoom"))
|
||||
self.actionAbout.setText(_translate("MainWindow", "About"))
|
||||
|
||||
from . import resourcefile_rc
|
||||
from . import resourcefile_rc
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>539</width>
|
||||
<width>608</width>
|
||||
<height>540</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -26,10 +26,16 @@
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>500</width>
|
||||
<width>571</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>CrossCursor</cursorShape>
|
||||
</property>
|
||||
@@ -43,8 +49,8 @@
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>440</y>
|
||||
<x>220</x>
|
||||
<y>420</y>
|
||||
<width>141</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
@@ -56,8 +62,8 @@
|
||||
<widget class="QCheckBox" name="checkBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>460</y>
|
||||
<x>220</x>
|
||||
<y>440</y>
|
||||
<width>131</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
@@ -69,7 +75,7 @@
|
||||
<widget class="QPushButton" name="submitButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<x>350</x>
|
||||
<y>420</y>
|
||||
<width>241</width>
|
||||
<height>61</height>
|
||||
@@ -83,8 +89,8 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>430</y>
|
||||
<width>111</width>
|
||||
<y>420</y>
|
||||
<width>191</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -99,15 +105,31 @@
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="thresholdSpinbox">
|
||||
<widget class="QSlider" name="horizontalSlider">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>460</y>
|
||||
<width>111</width>
|
||||
<y>450</y>
|
||||
<width>181</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>470</y>
|
||||
<width>71</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Threshold</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
@@ -115,7 +137,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>539</width>
|
||||
<width>608</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user