Skip to content

Commit

Permalink
fix #933 improve y-scale in SendRecvDialog (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl authored Feb 27, 2022
1 parent a165ef7 commit bc49c6d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/urh/controller/dialogs/SendRecvDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def __init__(self, project_manager: ProjectManager, is_tx: bool, continuous_send

self.ui.splitter.setSizes([int(0.4 * self.width()), int(0.6 * self.width())])

self.current_y_slider_value = 1

@property
def is_rx(self) -> bool:
return not self.is_tx
Expand Down Expand Up @@ -212,11 +214,6 @@ def __parse_error_messages(self, messages):
self._restart_device_thread()

def update_view(self):
try:
self.ui.sliderYscale.setValue(int(self.graphics_view.transform().m22()))
except AttributeError:
return

txt = self.ui.txtEditErrors.toPlainText()
new_messages = self.device.read_messages()

Expand Down Expand Up @@ -285,8 +282,13 @@ def closeEvent(self, event: QCloseEvent):

@pyqtSlot(int)
def on_slider_y_scale_value_changed(self, new_value: int):
# Scale Up = Top Half, Scale Down = Lower Half
transform = self.graphics_view.transform()
self.graphics_view.setTransform(QTransform(transform.m11(), transform.m12(), transform.m13(),
transform.m21(), new_value, transform.m23(),
transform.m31(), transform.m32(), transform.m33()))
if new_value == 1:
self.graphics_view.auto_fit_view()
elif new_value > self.current_y_slider_value:
scale = new_value + 1 - self.current_y_slider_value
self.graphics_view.scale(1, scale)
else:
scale = 1 / (self.current_y_slider_value + 1 - new_value)
self.graphics_view.scale(1, scale)
self.graphics_view.centerOn(0, 0)
self.current_y_slider_value = new_value

0 comments on commit bc49c6d

Please sign in to comment.