Skip to content

Commit

Permalink
Implement #23 (scroll area event filter)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangalio committed May 1, 2020
1 parent 4c1691c commit e0a6211
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
IGNORE_REPLAYS = False # Development purposes
if socket.gethostname() != "kangalioo-pc": IGNORE_REPLAYS = False

# QScrollArea wrapper with scroll wheel scrolling disabled.
# I did this to prevent simultaneous scrolling and panning
# when hovering a plot while scrolling
class ScrollArea(QScrollArea):
def wheelEvent(self, event):
pass

SETTINGS_FIELDS = {
"etterna-xml": "etterna_xml",
"replays-dir": "replays_dir",
Expand Down Expand Up @@ -192,14 +185,23 @@ def __init__(self):
root = QWidget()
layout = QVBoxLayout(root)
self.layout = layout

# Put the widgets in
self.setup_widgets(layout)

# QScrollArea wrapper with scroll wheel scrolling disabled on plots. I did this to prevent
# simultaneous scrolling and panning when hovering a plot while scrolling
class ScrollArea(QScrollArea):
def eventFilter(self, obj, event) -> bool:
if event.type() == QEvent.Wheel and self.ui_object.plotter.frame.underMouse():
return True
return False
scroll = ScrollArea(window)
scroll.ui_object = self
scroll.setWidget(root)
scroll.setWidgetResizable(True)
window.setCentralWidget(scroll)

# Put the widgets in
self.setup_widgets(layout)

# Start
w, h = 1600, 2500
if app.app.prefs.enable_all_plots: h = 3800 # More plots -> more room
Expand Down

0 comments on commit e0a6211

Please sign in to comment.