aboutsummaryrefslogtreecommitdiffstats
path: root/solo_tool_qt.py
diff options
context:
space:
mode:
Diffstat (limited to 'solo_tool_qt.py')
-rw-r--r--solo_tool_qt.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/solo_tool_qt.py b/solo_tool_qt.py
index 25a15fb..b3eac81 100644
--- a/solo_tool_qt.py
+++ b/solo_tool_qt.py
@@ -42,6 +42,7 @@ class ABListModel(QAbstractListModel):
class MainWindow(QMainWindow, Ui_MainWindow):
songChangeSignal = pyqtSignal(int)
+ abLimitsChangeSignal = pyqtSignal(int)
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
@@ -64,6 +65,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.abListModel = ABListModel(self.soloTool)
self.abListView.setModel(self.abListModel)
self.abListView.selectionModel().selectionChanged.connect(self.abListSelectionChanged)
+ self.abLimitsChangePending = None
+ self.abLimitsChangeSignal.connect(self.currentAbLimitsChanged)
+ self.soloTool.registerCurrentAbLimitsCallback(self.abLimitsChangeSignal.emit)
self.songSlider.setMaximum(POSITION_FACTOR)
self.songSlider.sliderPressed.connect(self.songSliderPressed)
@@ -167,8 +171,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
index = i.indexes()[0].row()
self.soloTool.setSong(index)
- self.abListModel.layoutChanged.emit()
self.clearListViewSelection(self.abListView)
+ self.abListModel.layoutChanged.emit()
def currentSongChanged(self, songIndex):
if self.songChangePending == CHANGE_GUI:
@@ -176,15 +180,35 @@ class MainWindow(QMainWindow, Ui_MainWindow):
else:
assert self.songChangePending is None
self.songChangePending = CHANGE_INTERNAL
- print(f"Forcing selection to {songIndex}")
i = self.playlistModel.createIndex(songIndex, 0)
self.songListView.selectionModel().select(i, QItemSelectionModel.ClearAndSelect)
def abListSelectionChanged(self, i):
- if i is not None and not i.isEmpty():
- index = i.indexes()[0].row()
- ab = self.soloTool.getStoredAbLimits()[index]
- self.soloTool.loadAbLimits(index)
+ if self.abLimitsChangePending == CHANGE_INTERNAL:
+ print("Ack internal change")
+ self.abLimitsChangePending = None
+ else:
+ assert self.abLimitsChangePending is None
+ if i is not None and not i.isEmpty():
+ print("Processing GUI change")
+ self.abLimitsChangePending = CHANGE_GUI
+ index = i.indexes()[0].row()
+ ab = self.soloTool.getStoredAbLimits()[index]
+ self.soloTool.loadAbLimits(index)
+ self.aSlider.setValue(int(ab[0] * POSITION_FACTOR))
+ self.bSlider.setValue(int(ab[1] * POSITION_FACTOR))
+
+ def currentAbLimitsChanged(self, abIndex):
+ if self.abLimitsChangePending == CHANGE_GUI:
+ print("Ack GUI change")
+ self.abLimitsChangePending = None
+ else:
+ assert self.abLimitsChangePending is None
+ print("Processing internal change")
+ self.abLimitsChangePending = CHANGE_INTERNAL
+ i = self.abListModel.createIndex(abIndex, 0)
+ self.abListView.selectionModel().select(i, QItemSelectionModel.ClearAndSelect)
+ ab = self.soloTool.getStoredAbLimits()[abIndex]
self.aSlider.setValue(int(ab[0] * POSITION_FACTOR))
self.bSlider.setValue(int(ab[1] * POSITION_FACTOR))