Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LMS
FishUI
Commits
498e4c42
Commit
498e4c42
authored
Dec 02, 2021
by
Andy Regensky
Browse files
Extend SlidableLineEdit configuration with support for float/double value inputs
parent
5f577079
Changes
2
Hide whitespace changes
Inline
Side-by-side
fishui/widgets/PropertiesWidget.py
View file @
498e4c42
...
...
@@ -56,36 +56,36 @@ class PropertiesWidget(QWidget):
self
.
sensorSizeLabel
=
QLabel
(
self
)
self
.
sensorSizeLabel
.
setText
(
"Sensor height in mm"
)
self
.
sensorSizeHeightEdit
=
Q
LineEdit
(
self
)
self
.
sensorSizeHeightEdit
=
Slidable
LineEdit
(
self
,
0.01
)
self
.
sensorSizeHeightEdit
.
setValidator
(
doubleValidator
)
self
.
sensorSizeHeightEdit
.
editingFinished
.
connect
(
self
.
sensorSizeHeightEditingFinished
)
self
.
resolutionLabel
=
QLabel
(
self
)
self
.
resolutionLabel
.
setText
(
"Sensor resolution"
)
self
.
resolutionWidthEdit
=
SlidableLineEdit
(
self
)
self
.
resolutionWidthEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
resolutionWidthEdit
.
setValidator
(
intValidator
)
self
.
resolutionWidthEdit
.
editingFinished
.
connect
(
self
.
resolutionWidthEditingFinished
)
self
.
resolutionHeightEdit
=
SlidableLineEdit
(
self
)
self
.
resolutionHeightEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
resolutionHeightEdit
.
setValidator
(
intValidator
)
self
.
resolutionHeightEdit
.
editingFinished
.
connect
(
self
.
resolutionHeightEditingFinished
)
self
.
opticalCenterLabel
=
QLabel
(
self
)
self
.
opticalCenterLabel
.
setText
(
"Optical center"
)
self
.
opticalCenterXEdit
=
Q
LineEdit
(
self
)
self
.
opticalCenterXEdit
=
Slidable
LineEdit
(
self
,
0.1
)
self
.
opticalCenterXEdit
.
setValidator
(
doubleValidator
)
self
.
opticalCenterXEdit
.
editingFinished
.
connect
(
self
.
opticalCenterXEditingFinished
)
self
.
opticalCenterYEdit
=
Q
LineEdit
(
self
)
self
.
opticalCenterYEdit
=
Slidable
LineEdit
(
self
,
0.1
)
self
.
opticalCenterYEdit
.
setValidator
(
doubleValidator
)
self
.
opticalCenterYEdit
.
editingFinished
.
connect
(
self
.
opticalCenterYEditingFinished
)
self
.
focalLengthLabel
=
QLabel
(
self
)
self
.
focalLengthLabel
.
setText
(
"Focal length in mm"
)
self
.
focalLengthEdit
=
Q
LineEdit
(
self
)
self
.
focalLengthEdit
=
Slidable
LineEdit
(
self
,
0.01
)
self
.
focalLengthEdit
.
setValidator
(
doubleValidator
)
self
.
focalLengthEdit
.
editingFinished
.
connect
(
self
.
focalLengthEditingFinished
)
...
...
@@ -99,22 +99,22 @@ class PropertiesWidget(QWidget):
self
.
originLabel
=
QLabel
(
self
)
self
.
originLabel
.
setText
(
"Origin"
)
self
.
originXEdit
=
SlidableLineEdit
(
self
)
self
.
originXEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
originXEdit
.
setValidator
(
intValidator
)
self
.
originXEdit
.
editingFinished
.
connect
(
self
.
originXEditingFinished
)
self
.
originYEdit
=
SlidableLineEdit
(
self
)
self
.
originYEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
originYEdit
.
setValidator
(
intValidator
)
self
.
originYEdit
.
editingFinished
.
connect
(
self
.
originYEditingFinished
)
self
.
blocksizeLabel
=
QLabel
(
self
)
self
.
blocksizeLabel
.
setText
(
"Blocksize"
)
self
.
blocksizeWidthEdit
=
SlidableLineEdit
(
self
)
self
.
blocksizeWidthEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
blocksizeWidthEdit
.
setValidator
(
intValidator
)
self
.
blocksizeWidthEdit
.
editingFinished
.
connect
(
self
.
blocksizeWidthEditingFinished
)
self
.
blocksizeHeightEdit
=
SlidableLineEdit
(
self
)
self
.
blocksizeHeightEdit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
blocksizeHeightEdit
.
setValidator
(
intValidator
)
self
.
blocksizeHeightEdit
.
editingFinished
.
connect
(
self
.
blocksizeHeightEditingFinished
)
...
...
@@ -135,33 +135,33 @@ class PropertiesWidget(QWidget):
self
.
motionVector0Label
=
QLabel
(
self
)
self
.
motionVector0Label
.
setText
(
"Motion Vector"
)
self
.
motionVectorX0Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorX0Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorX0Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorX0Edit
.
editingFinished
.
connect
(
self
.
motionVectorX0EditingFinished
)
self
.
motionVectorY0Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorY0Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorY0Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorY0Edit
.
editingFinished
.
connect
(
self
.
motionVectorY0EditingFinished
)
self
.
motionVector1Label
=
QLabel
(
self
)
self
.
motionVector1Label
.
setText
(
"CP1 Motion Vector"
)
self
.
motionVectorX1Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorX1Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorX1Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorX1Edit
.
editingFinished
.
connect
(
self
.
motionVectorX1EditingFinished
)
self
.
motionVectorY1Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorY1Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorY1Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorY1Edit
.
editingFinished
.
connect
(
self
.
motionVectorY1EditingFinished
)
self
.
motionVector2Label
=
QLabel
(
self
)
self
.
motionVector2Label
.
setText
(
"CP2 Motion Vector"
)
self
.
motionVectorX2Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorX2Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorX2Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorX2Edit
.
editingFinished
.
connect
(
self
.
motionVectorX2EditingFinished
)
self
.
motionVectorY2Edit
=
SlidableLineEdit
(
self
)
self
.
motionVectorY2Edit
=
SlidableLineEdit
(
self
,
0.1
)
self
.
motionVectorY2Edit
.
setValidator
(
negIntValidator
)
self
.
motionVectorY2Edit
.
editingFinished
.
connect
(
self
.
motionVectorY2EditingFinished
)
...
...
fishui/widgets/SlidableLineEdit.py
View file @
498e4c42
...
...
@@ -30,12 +30,14 @@
from
PySide2.QtCore
import
Qt
from
PySide2.QtWidgets
import
QLineEdit
from
PySide2.QtGui
import
QValidator
,
QDoubleValidator
class
SlidableLineEdit
(
QLineEdit
):
def
__init__
(
self
,
parent
):
def
__init__
(
self
,
parent
,
step
):
super
().
__init__
(
parent
)
self
.
step
=
step
self
.
lastCursor
=
None
self
.
initialValue
=
None
self
.
initialMouseX
=
None
...
...
@@ -44,14 +46,19 @@ class SlidableLineEdit(QLineEdit):
if
event
.
button
()
==
Qt
.
LeftButton
:
self
.
lastCursor
=
self
.
cursor
()
self
.
setCursor
(
Qt
.
SizeHorCursor
)
self
.
initialValue
=
int
(
self
.
text
())
self
.
initialValue
=
float
(
self
.
text
())
if
isinstance
(
self
.
validator
(),
QDoubleValidator
)
else
int
(
self
.
text
())
self
.
initialMouseX
=
event
.
pos
().
x
()
def
mouseMoveEvent
(
self
,
event
):
if
self
.
initialMouseX
is
not
None
:
deltaX
=
int
((
event
.
pos
().
x
()
-
self
.
initialMouseX
)
*
0.25
)
self
.
setText
(
str
(
self
.
initialValue
+
deltaX
))
self
.
editingFinished
.
emit
()
if
isinstance
(
self
.
validator
(),
QDoubleValidator
):
deltaX
=
float
((
event
.
pos
().
x
()
-
self
.
initialMouseX
)
*
self
.
step
)
else
:
deltaX
=
int
((
event
.
pos
().
x
()
-
self
.
initialMouseX
)
*
self
.
step
)
slidedText
=
str
(
self
.
initialValue
+
deltaX
)
if
self
.
validator
().
validate
(
slidedText
,
0
)[
0
]
==
QValidator
.
Acceptable
:
self
.
setText
(
str
(
self
.
initialValue
+
deltaX
))
self
.
editingFinished
.
emit
()
def
mouseReleaseEvent
(
self
,
event
):
if
event
.
button
()
==
Qt
.
LeftButton
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment