def setupScrollers(self): sp = QScrollerProperties() sp.setScrollMetric(QScrollerProperties.DragVelocitySmoothingFactor, 0.6) sp.setScrollMetric(QScrollerProperties.MinimumVelocity, 0.0) sp.setScrollMetric(QScrollerProperties.MaximumVelocity, 0.5) sp.setScrollMetric(QScrollerProperties.AcceleratingFlickMaximumTime, 0.4) sp.setScrollMetric(QScrollerProperties.AcceleratingFlickSpeedupFactor, 1.2) sp.setScrollMetric(QScrollerProperties.SnapPositionRatio, 0.2) sp.setScrollMetric(QScrollerProperties.MaximumClickThroughVelocity, 0) sp.setScrollMetric(QScrollerProperties.DragStartDistance, 0.001) sp.setScrollMetric(QScrollerProperties.MousePressEventDelay, 0.5) hourListScroller = QScroller.scroller(self.hourListWidget) hourListScroller.grabGesture(self.hourListWidget, QScroller.LeftMouseButtonGesture) hourListScroller.setScrollerProperties(sp) minuteListScroller = QScroller.scroller(self.minuteListWidget) minuteListScroller.grabGesture(self.minuteListWidget, QScroller.LeftMouseButtonGesture) minuteListScroller.setScrollerProperties(sp) amPmListScroller = QScroller.scroller(self.amPmListWidget) amPmListScroller.grabGesture(self.amPmListWidget, QScroller.LeftMouseButtonGesture) amPmListScroller.setScrollerProperties(sp)
def setup_gestures(view): if has_gestures: v = view.viewport() view.scroller = QScroller.grabGesture(v, QScroller.TouchGesture) v.grabGesture(Qt.TapGesture) v.grabGesture(Qt.TapAndHoldGesture) view.last_tap_at = 0
def __init__(self, view): QObject.__init__(self, view) if touch_supported: view.viewport().setAttribute(Qt.WA_AcceptTouchEvents) self.state = State() self.state.tapped.connect(self.handle_tap, type=Qt.QueuedConnection) # has to be queued otherwise QApplication.keyboardModifiers() does not work self.state.flicking.connect(self.handle_flicking) connect_lambda(self.state.tap_hold_started, self, lambda self, tp: self.handle_tap_hold('start', tp)) connect_lambda(self.state.tap_hold_updated, self, lambda self, tp: self.handle_tap_hold('update', tp)) connect_lambda(self.state.tap_hold_finished, self, lambda self, tp: self.handle_tap_hold('end', tp)) self.evmap = {QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end'} self.last_tap_at = 0 if touch_supported: self.scroller = QScroller.scroller(view.viewport())
def __init__(self, view): QObject.__init__(self, view) if touch_supported: view.viewport().setAttribute(Qt.WidgetAttribute.WA_AcceptTouchEvents) self.state = State() self.state.tapped.connect(self.handle_tap, type=Qt.ConnectionType.QueuedConnection) # has to be queued otherwise QApplication.keyboardModifiers() does not work self.state.flicking.connect(self.handle_flicking) connect_lambda(self.state.tap_hold_started, self, lambda self, tp: self.handle_tap_hold('start', tp)) connect_lambda(self.state.tap_hold_updated, self, lambda self, tp: self.handle_tap_hold('update', tp)) connect_lambda(self.state.tap_hold_finished, self, lambda self, tp: self.handle_tap_hold('end', tp)) self.evmap = {QEvent.Type.TouchBegin: 'start', QEvent.Type.TouchUpdate: 'update', QEvent.Type.TouchEnd: 'end'} self.last_tap_at = 0 if touch_supported: self.scroller = QScroller.scroller(view.viewport())
def __init__(self, view): QObject.__init__(self, view) if touch_supported: view.viewport().setAttribute(Qt.WA_AcceptTouchEvents) self.state = State() self.state.tapped.connect(self.handle_tap) self.state.flicking.connect(self.handle_flicking) self.state.tap_hold_started.connect( partial(self.handle_tap_hold, 'start')) self.state.tap_hold_updated.connect( partial(self.handle_tap_hold, 'update')) self.state.tap_hold_finished.connect( partial(self.handle_tap_hold, 'end')) self.evmap = { QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end' } self.last_tap_at = 0 if touch_supported: self.scroller = QScroller.scroller(view.viewport())
def setup_gestures(view): v = view.viewport() view.scroller = QScroller.grabGesture(v, QScroller.TouchGesture) v.grabGesture(Qt.TapGesture) v.grabGesture(Qt.TapAndHoldGesture) view.last_tap_at = 0