From 9efb5716cdbc1d0cfdcc14adc53c0a178cef951d Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 4 Jan 2022 18:31:29 +0100 Subject: Added AB limits feedback to Qt interface, very buggy --- known-issues.md | 2 ++ solo_tool_qt.py | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/known-issues.md b/known-issues.md index 86e83c7..a9f5bbe 100644 --- a/known-issues.md +++ b/known-issues.md @@ -8,6 +8,8 @@ * automatically play next song when current song ends * playback doesn't stop when jumping to next/previous song * should this be the default anyway? +* Switching between songs and AB limits does not work properly + * AB controller only keeps track of limit index, not current song => when song changes, index is invalid but not properly reset # Closed Issues 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)) -- cgit v1.2.3