mirror of
https://github.com/Xevion/sharex-quickzoom.git
synced 2025-12-08 04:08:27 -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.
|
In case you wish to use this repo, these are the utilties you will require.
|
||||||
|
|
||||||
**
|
**PyQt5** - GUI and most accessibility functionality
|
||||||
|
|
||||||
**os** - Path managemennt
|
**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.mainwindow import Ui_MainWindow
|
||||||
from ui.aboutform import Ui_AboutForm
|
from ui.aboutform import Ui_AboutForm
|
||||||
import sys
|
import sys
|
||||||
|
from PIL import Image, ImageQt
|
||||||
|
|
||||||
|
# Simple About Window class
|
||||||
class AboutWindow(QtWidgets.QMainWindow):
|
class AboutWindow(QtWidgets.QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AboutWindow, self).__init__()
|
super(AboutWindow, self).__init__()
|
||||||
self.ui = Ui_AboutForm()
|
self.ui = Ui_AboutForm()
|
||||||
self.ui.setupUi(self)
|
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):
|
class Window(QtWidgets.QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Window, self).__init__()
|
super(Window, self).__init__()
|
||||||
@@ -17,25 +36,48 @@ class Window(QtWidgets.QMainWindow):
|
|||||||
self.ui.setupUi(self)
|
self.ui.setupUi(self)
|
||||||
self.initUI()
|
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):
|
def initUI(self):
|
||||||
self.ui.graphicsView.viewport().installEventFilter(self)
|
self.ui.graphicsView.viewport().installEventFilter(self)
|
||||||
# About tab
|
# About tab
|
||||||
self.ui.actionAbout.triggered.connect(lambda : self.aboutui.show())
|
self.ui.actionAbout.triggered.connect(lambda : self.aboutui.show())
|
||||||
self.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):
|
def eventFilter(self, source, e):
|
||||||
if e.type() == QtCore.QEvent.MouseMove:
|
if e.type() == QtCore.QEvent.MouseMove:
|
||||||
if e.buttons() == QtCore.Qt.NoButton:
|
if e.buttons() == QtCore.Qt.NoButton:
|
||||||
pass
|
self.redraw(e)
|
||||||
elif e.buttons() == QtCore.Qt.LeftButton:
|
elif e.buttons() == QtCore.Qt.LeftButton:
|
||||||
pass
|
pass
|
||||||
elif e.buttons() == QtCore.Qt.RightButton:
|
elif e.buttons() == QtCore.Qt.RightButton:
|
||||||
pass
|
pass
|
||||||
elif e.type() == QtCore.QEvent.MouseButtonPress:
|
elif e.type() == QtCore.QEvent.MouseButtonPress:
|
||||||
if e.button() == QtCore.Qt.LeftButton:
|
if e.button() == QtCore.Qt.LeftButton:
|
||||||
print(f'Left Click at ({e.x()}, {e.y()})')
|
pass
|
||||||
elif e.button() == QtCore.Qt.RightButton:
|
elif e.button() == QtCore.Qt.RightButton:
|
||||||
print(f'Right Click at ({e.x()}, {e.y()})')
|
pass
|
||||||
return super(Window, self).eventFilter(source, e)
|
return super(Window, self).eventFilter(source, e)
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
@@ -11,38 +11,42 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||||||
class Ui_MainWindow(object):
|
class Ui_MainWindow(object):
|
||||||
def setupUi(self, MainWindow):
|
def setupUi(self, MainWindow):
|
||||||
MainWindow.setObjectName("MainWindow")
|
MainWindow.setObjectName("MainWindow")
|
||||||
MainWindow.resize(539, 540)
|
MainWindow.resize(608, 540)
|
||||||
icon = QtGui.QIcon()
|
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.setWindowIcon(icon)
|
||||||
MainWindow.setAutoFillBackground(False)
|
MainWindow.setAutoFillBackground(False)
|
||||||
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
||||||
self.centralwidget.setObjectName("centralwidget")
|
self.centralwidget.setObjectName("centralwidget")
|
||||||
self.graphicsView = QtWidgets.QGraphicsView(self.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.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
|
||||||
self.graphicsView.setMouseTracking(True)
|
self.graphicsView.setMouseTracking(True)
|
||||||
self.graphicsView.setObjectName("graphicsView")
|
self.graphicsView.setObjectName("graphicsView")
|
||||||
self.checkBox = QtWidgets.QCheckBox(self.centralwidget)
|
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.setObjectName("checkBox")
|
||||||
self.checkBox_2 = QtWidgets.QCheckBox(self.centralwidget)
|
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.checkBox_2.setObjectName("checkBox_2")
|
||||||
self.submitButton = QtWidgets.QPushButton(self.centralwidget)
|
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.submitButton.setObjectName("submitButton")
|
||||||
self.spinTypeComboxBox = QtWidgets.QComboBox(self.centralwidget)
|
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.setObjectName("spinTypeComboxBox")
|
||||||
self.spinTypeComboxBox.addItem("")
|
self.spinTypeComboxBox.addItem("")
|
||||||
self.spinTypeComboxBox.addItem("")
|
self.spinTypeComboxBox.addItem("")
|
||||||
self.thresholdSpinbox = QtWidgets.QDoubleSpinBox(self.centralwidget)
|
self.horizontalSlider = QtWidgets.QSlider(self.centralwidget)
|
||||||
self.thresholdSpinbox.setGeometry(QtCore.QRect(20, 460, 111, 22))
|
self.horizontalSlider.setGeometry(QtCore.QRect(20, 450, 181, 22))
|
||||||
self.thresholdSpinbox.setObjectName("thresholdSpinbox")
|
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)
|
MainWindow.setCentralWidget(self.centralwidget)
|
||||||
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
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.menubar.setObjectName("menubar")
|
||||||
self.menuShareX_Quick_ZOom = QtWidgets.QMenu(self.menubar)
|
self.menuShareX_Quick_ZOom = QtWidgets.QMenu(self.menubar)
|
||||||
self.menuShareX_Quick_ZOom.setObjectName("menuShareX_Quick_ZOom")
|
self.menuShareX_Quick_ZOom.setObjectName("menuShareX_Quick_ZOom")
|
||||||
@@ -67,6 +71,7 @@ class Ui_MainWindow(object):
|
|||||||
self.submitButton.setText(_translate("MainWindow", "Save and Exit"))
|
self.submitButton.setText(_translate("MainWindow", "Save and Exit"))
|
||||||
self.spinTypeComboxBox.setItemText(0, _translate("MainWindow", "Centered Radial / Zoom Blur"))
|
self.spinTypeComboxBox.setItemText(0, _translate("MainWindow", "Centered Radial / Zoom Blur"))
|
||||||
self.spinTypeComboxBox.setItemText(1, _translate("MainWindow", "Radial Spin 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.menuShareX_Quick_ZOom.setTitle(_translate("MainWindow", "ShareX Quick Zoom"))
|
||||||
self.actionAbout.setText(_translate("MainWindow", "About"))
|
self.actionAbout.setText(_translate("MainWindow", "About"))
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>539</width>
|
<width>608</width>
|
||||||
<height>540</height>
|
<height>540</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -26,10 +26,16 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>500</width>
|
<width>571</width>
|
||||||
<height>400</height>
|
<height>400</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="cursor" stdset="0">
|
<property name="cursor" stdset="0">
|
||||||
<cursorShape>CrossCursor</cursorShape>
|
<cursorShape>CrossCursor</cursorShape>
|
||||||
</property>
|
</property>
|
||||||
@@ -43,8 +49,8 @@
|
|||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="checkBox">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>140</x>
|
<x>220</x>
|
||||||
<y>440</y>
|
<y>420</y>
|
||||||
<width>141</width>
|
<width>141</width>
|
||||||
<height>17</height>
|
<height>17</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -56,8 +62,8 @@
|
|||||||
<widget class="QCheckBox" name="checkBox_2">
|
<widget class="QCheckBox" name="checkBox_2">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>140</x>
|
<x>220</x>
|
||||||
<y>460</y>
|
<y>440</y>
|
||||||
<width>131</width>
|
<width>131</width>
|
||||||
<height>17</height>
|
<height>17</height>
|
||||||
</rect>
|
</rect>
|
||||||
@@ -69,7 +75,7 @@
|
|||||||
<widget class="QPushButton" name="submitButton">
|
<widget class="QPushButton" name="submitButton">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>280</x>
|
<x>350</x>
|
||||||
<y>420</y>
|
<y>420</y>
|
||||||
<width>241</width>
|
<width>241</width>
|
||||||
<height>61</height>
|
<height>61</height>
|
||||||
@@ -83,8 +89,8 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>430</y>
|
<y>420</y>
|
||||||
<width>111</width>
|
<width>191</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@@ -99,15 +105,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDoubleSpinBox" name="thresholdSpinbox">
|
<widget class="QSlider" name="horizontalSlider">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
<y>460</y>
|
<y>450</y>
|
||||||
<width>111</width>
|
<width>181</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
@@ -115,7 +137,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>539</width>
|
<width>608</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user