Commit 20131bd6 authored by Andy Regensky's avatar Andy Regensky
Browse files

Add SlidableLineEdit for integer line edits for slidable value...

Add SlidableLineEdit for integer line edits for slidable value increase/decrease via mouse drag interactions
parent af6a38d5
......@@ -32,6 +32,7 @@ from PySide2.QtGui import QIntValidator, QDoubleValidator
from PySide2.QtWidgets import (QWidget, QLabel, QLineEdit, QGridLayout, QSpacerItem, QSlider,
QCheckBox, QComboBox, QFileDialog)
from PySide2.QtCore import Slot, Qt
from fishui.widgets import SlidableLineEdit
from fishui.MainViewModel import MainViewModel
from fishui.model import motion_models, viewports
......@@ -62,11 +63,11 @@ class PropertiesWidget(QWidget):
self.resolutionLabel = QLabel(self)
self.resolutionLabel.setText("Sensor resolution")
self.resolutionWidthEdit = QLineEdit(self)
self.resolutionWidthEdit = SlidableLineEdit(self)
self.resolutionWidthEdit.setValidator(intValidator)
self.resolutionWidthEdit.editingFinished.connect(self.resolutionWidthEditingFinished)
self.resolutionHeightEdit = QLineEdit(self)
self.resolutionHeightEdit = SlidableLineEdit(self)
self.resolutionHeightEdit.setValidator(intValidator)
self.resolutionHeightEdit.editingFinished.connect(self.resolutionHeightEditingFinished)
......@@ -98,22 +99,22 @@ class PropertiesWidget(QWidget):
self.originLabel = QLabel(self)
self.originLabel.setText("Origin")
self.originXEdit = QLineEdit(self)
self.originXEdit = SlidableLineEdit(self)
self.originXEdit.setValidator(intValidator)
self.originXEdit.editingFinished.connect(self.originXEditingFinished)
self.originYEdit = QLineEdit(self)
self.originYEdit = SlidableLineEdit(self)
self.originYEdit.setValidator(intValidator)
self.originYEdit.editingFinished.connect(self.originYEditingFinished)
self.blocksizeLabel = QLabel(self)
self.blocksizeLabel.setText("Blocksize")
self.blocksizeWidthEdit = QLineEdit(self)
self.blocksizeWidthEdit = SlidableLineEdit(self)
self.blocksizeWidthEdit.setValidator(intValidator)
self.blocksizeWidthEdit.editingFinished.connect(self.blocksizeWidthEditingFinished)
self.blocksizeHeightEdit = QLineEdit(self)
self.blocksizeHeightEdit = SlidableLineEdit(self)
self.blocksizeHeightEdit.setValidator(intValidator)
self.blocksizeHeightEdit.editingFinished.connect(self.blocksizeHeightEditingFinished)
......@@ -134,33 +135,33 @@ class PropertiesWidget(QWidget):
self.motionVector0Label = QLabel(self)
self.motionVector0Label.setText("Motion Vector")
self.motionVectorX0Edit = QLineEdit(self)
self.motionVectorX0Edit = SlidableLineEdit(self)
self.motionVectorX0Edit.setValidator(negIntValidator)
self.motionVectorX0Edit.editingFinished.connect(self.motionVectorX0EditingFinished)
self.motionVectorY0Edit = QLineEdit(self)
self.motionVectorY0Edit = SlidableLineEdit(self)
self.motionVectorY0Edit.setValidator(negIntValidator)
self.motionVectorY0Edit.editingFinished.connect(self.motionVectorY0EditingFinished)
self.motionVector1Label = QLabel(self)
self.motionVector1Label.setText("CP1 Motion Vector")
self.motionVectorX1Edit = QLineEdit(self)
self.motionVectorX1Edit = SlidableLineEdit(self)
self.motionVectorX1Edit.setValidator(negIntValidator)
self.motionVectorX1Edit.editingFinished.connect(self.motionVectorX1EditingFinished)
self.motionVectorY1Edit = QLineEdit(self)
self.motionVectorY1Edit = SlidableLineEdit(self)
self.motionVectorY1Edit.setValidator(negIntValidator)
self.motionVectorY1Edit.editingFinished.connect(self.motionVectorY1EditingFinished)
self.motionVector2Label = QLabel(self)
self.motionVector2Label.setText("CP2 Motion Vector")
self.motionVectorX2Edit = QLineEdit(self)
self.motionVectorX2Edit = SlidableLineEdit(self)
self.motionVectorX2Edit.setValidator(negIntValidator)
self.motionVectorX2Edit.editingFinished.connect(self.motionVectorX2EditingFinished)
self.motionVectorY2Edit = QLineEdit(self)
self.motionVectorY2Edit = SlidableLineEdit(self)
self.motionVectorY2Edit.setValidator(negIntValidator)
self.motionVectorY2Edit.editingFinished.connect(self.motionVectorY2EditingFinished)
......
# Copyright (c) 2020-2021 Chair of Multimedia Communications and Signal Processing (LMS),
# Friedrich-Alexander-University Erlangen-Nürnberg (FAU).
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QLineEdit
class SlidableLineEdit(QLineEdit):
def __init__(self, parent):
super().__init__(parent)
self.lastCursor = None
self.initialValue = None
self.initialMouseX = None
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.lastCursor = self.cursor()
self.setCursor(Qt.SizeHorCursor)
self.initialValue = 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()
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton:
self.setCursor(self.lastCursor)
self.initialValue = None
self.initialMouseX = None
......@@ -29,6 +29,7 @@
from .AspectRatioWidget import AspectRatioWidget
from .SlidableLineEdit import SlidableLineEdit
from .BlockComparisonWindow import BlockComparisonWindow
from .FisheyeBackgroundWidget import FisheyeBackgroundWidget
from .FisheyeBlockWidget import FisheyeBlockWidget
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment