From 7c6946e4738a4c4afd2ba49acbf865b6ee4d4f4b Mon Sep 17 00:00:00 2001
From: Bill Clark <saikou@vt.edu>
Date: Fri, 3 Apr 2015 14:20:15 -0400
Subject: qtgui: range control -> jump to nearest step with left click

---
 gr-qtgui/python/qtgui/range.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'gr-qtgui/python/qtgui/range.py')

diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py
index 9f369d687e..61eee03513 100755
--- a/gr-qtgui/python/qtgui/range.py
+++ b/gr-qtgui/python/qtgui/range.py
@@ -107,6 +107,19 @@ class RangeWidget(QtGui.QWidget):
             self.setTickPosition(2)
             self.valueChanged.connect(slot)
 
+        def mousePressEvent(self, event):
+            #opt_style = QtGui.QStyleOption.init(None)
+            #self.initStyleOption(opt_style)
+            #sr = (self.style()).subControlRect(QtGui.QStyle.CC_Slider,opt_style,QtGui.QStyle.SC_SliderHandle,parent)
+            if((event.button() == QtCore.Qt.LeftButton)):# and (sr.contains(event.pos()) == False)):
+                newVal = self.minimum() + ((self.maximum()-self.minimum()) * event.x()) / self.width()
+                #if self.invertedAppearance():
+                #    self.setValue(self.maximum() - newVal)
+                #else:
+                self.setValue(newVal)
+                event.accept()
+            QtGui.QSlider.mousePressEvent(self, event)
+
     class Counter(QtGui.QDoubleSpinBox):
         """ Creates the range using a counter """
         def __init__(self, parent, ranges, slot):
-- 
cgit v1.2.3