diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-02 16:06:31 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-02 16:06:31 +0100 |
commit | e2d0e84992c539d0aa249483cad3ceca96bb03d9 (patch) | |
tree | 02d58f019fce13a9bfa7a652d5facf673b65660d | |
parent | 430466b0e3a4dd762d8c4a44403437691d9d6118 (diff) |
Improved Qt GUI layout, added set A and set B buttons
-rw-r--r-- | MainWindow.py | 99 | ||||
-rw-r--r-- | mainwindow.ui | 176 | ||||
-rw-r--r-- | solo_tool_qt.py | 16 |
3 files changed, 173 insertions, 118 deletions
diff --git a/MainWindow.py b/MainWindow.py index 0dde7f0..137bd33 100644 --- a/MainWindow.py +++ b/MainWindow.py @@ -14,68 +14,83 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") - MainWindow.resize(602, 424) + MainWindow.resize(971, 767) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") - self.centralWidgetLayout = QtWidgets.QHBoxLayout(self.centralwidget) - self.centralWidgetLayout.setObjectName("centralWidgetLayout") + self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.listsLayout = QtWidgets.QHBoxLayout() + self.listsLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) + self.listsLayout.setSpacing(6) + self.listsLayout.setObjectName("listsLayout") self.songListView = QtWidgets.QListView(self.centralwidget) - self.songListView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.songListView.setObjectName("songListView") - self.centralWidgetLayout.addWidget(self.songListView) - self.verticalLayout = QtWidgets.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") + self.listsLayout.addWidget(self.songListView) + self.abListView = QtWidgets.QListView(self.centralwidget) + self.abListView.setObjectName("abListView") + self.listsLayout.addWidget(self.abListView) + self.verticalLayout.addLayout(self.listsLayout) + self.slidersLayout = QtWidgets.QVBoxLayout() + self.slidersLayout.setObjectName("slidersLayout") self.songSlider = QtWidgets.QSlider(self.centralwidget) self.songSlider.setMinimumSize(QtCore.QSize(0, 0)) self.songSlider.setOrientation(QtCore.Qt.Horizontal) self.songSlider.setObjectName("songSlider") - self.verticalLayout.addWidget(self.songSlider) + self.slidersLayout.addWidget(self.songSlider) self.aSlider = QtWidgets.QSlider(self.centralwidget) self.aSlider.setOrientation(QtCore.Qt.Horizontal) self.aSlider.setObjectName("aSlider") - self.verticalLayout.addWidget(self.aSlider) + self.slidersLayout.addWidget(self.aSlider) self.bSlider = QtWidgets.QSlider(self.centralwidget) self.bSlider.setOrientation(QtCore.Qt.Horizontal) self.bSlider.setObjectName("bSlider") - self.verticalLayout.addWidget(self.bSlider) - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setObjectName("horizontalLayout") - self.abListView = QtWidgets.QListView(self.centralwidget) - self.abListView.setObjectName("abListView") - self.horizontalLayout.addWidget(self.abListView) - self.formLayout = QtWidgets.QFormLayout() - self.formLayout.setObjectName("formLayout") - self.playButton = QtWidgets.QPushButton(self.centralwidget) - self.playButton.setObjectName("playButton") - self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.playButton) + self.slidersLayout.addWidget(self.bSlider) + self.verticalLayout.addLayout(self.slidersLayout) + self.buttonsLayout = QtWidgets.QGridLayout() + self.buttonsLayout.setObjectName("buttonsLayout") self.pauseButton = QtWidgets.QPushButton(self.centralwidget) self.pauseButton.setObjectName("pauseButton") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.pauseButton) - self.saveAbButton = QtWidgets.QPushButton(self.centralwidget) - self.saveAbButton.setObjectName("saveAbButton") - self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.saveAbButton) + self.buttonsLayout.addWidget(self.pauseButton, 0, 1, 1, 1) + self.initMidiButton = QtWidgets.QPushButton(self.centralwidget) + self.initMidiButton.setObjectName("initMidiButton") + self.buttonsLayout.addWidget(self.initMidiButton, 0, 4, 1, 1) + self.rateSlider = QtWidgets.QSlider(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.rateSlider.sizePolicy().hasHeightForWidth()) + self.rateSlider.setSizePolicy(sizePolicy) + self.rateSlider.setOrientation(QtCore.Qt.Horizontal) + self.rateSlider.setObjectName("rateSlider") + self.buttonsLayout.addWidget(self.rateSlider, 2, 0, 1, 1) + self.playButton = QtWidgets.QPushButton(self.centralwidget) + self.playButton.setObjectName("playButton") + self.buttonsLayout.addWidget(self.playButton, 0, 0, 1, 1) self.saveSessionButton = QtWidgets.QPushButton(self.centralwidget) self.saveSessionButton.setObjectName("saveSessionButton") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.saveSessionButton) + self.buttonsLayout.addWidget(self.saveSessionButton, 0, 2, 1, 1) + self.storeAbButton = QtWidgets.QPushButton(self.centralwidget) + self.storeAbButton.setObjectName("storeAbButton") + self.buttonsLayout.addWidget(self.storeAbButton, 2, 3, 1, 1) self.loadSessionButton = QtWidgets.QPushButton(self.centralwidget) self.loadSessionButton.setObjectName("loadSessionButton") - self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.loadSessionButton) + self.buttonsLayout.addWidget(self.loadSessionButton, 0, 3, 1, 1) self.abRepeatCheckBox = QtWidgets.QCheckBox(self.centralwidget) self.abRepeatCheckBox.setObjectName("abRepeatCheckBox") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.abRepeatCheckBox) - self.initMidiButton = QtWidgets.QPushButton(self.centralwidget) - self.initMidiButton.setObjectName("initMidiButton") - self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.initMidiButton) + self.buttonsLayout.addWidget(self.abRepeatCheckBox, 2, 1, 1, 1) self.addSongButton = QtWidgets.QPushButton(self.centralwidget) self.addSongButton.setObjectName("addSongButton") - self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.addSongButton) - self.rateSlider = QtWidgets.QSlider(self.centralwidget) - self.rateSlider.setOrientation(QtCore.Qt.Horizontal) - self.rateSlider.setObjectName("rateSlider") - self.formLayout.setWidget(12, QtWidgets.QFormLayout.FieldRole, self.rateSlider) - self.horizontalLayout.addLayout(self.formLayout) - self.verticalLayout.addLayout(self.horizontalLayout) - self.centralWidgetLayout.addLayout(self.verticalLayout) + self.buttonsLayout.addWidget(self.addSongButton, 2, 4, 1, 1) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.setAButton = QtWidgets.QPushButton(self.centralwidget) + self.setAButton.setObjectName("setAButton") + self.horizontalLayout.addWidget(self.setAButton) + self.setBButton = QtWidgets.QPushButton(self.centralwidget) + self.setBButton.setObjectName("setBButton") + self.horizontalLayout.addWidget(self.setBButton) + self.buttonsLayout.addLayout(self.horizontalLayout, 2, 2, 1, 1) + self.verticalLayout.addLayout(self.buttonsLayout) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) @@ -84,11 +99,13 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) - self.playButton.setText(_translate("MainWindow", "Play")) self.pauseButton.setText(_translate("MainWindow", "Pause")) - self.saveAbButton.setText(_translate("MainWindow", "Save AB")) + self.initMidiButton.setText(_translate("MainWindow", "Connect MIDI")) + self.playButton.setText(_translate("MainWindow", "Play")) self.saveSessionButton.setText(_translate("MainWindow", "Save session")) + self.storeAbButton.setText(_translate("MainWindow", "Store AB")) self.loadSessionButton.setText(_translate("MainWindow", "Load session")) self.abRepeatCheckBox.setText(_translate("MainWindow", "AB repeat")) - self.initMidiButton.setText(_translate("MainWindow", "Connect MIDI")) self.addSongButton.setText(_translate("MainWindow", "Add song")) + self.setAButton.setText(_translate("MainWindow", "Set A")) + self.setBButton.setText(_translate("MainWindow", "Set B")) diff --git a/mainwindow.ui b/mainwindow.ui index 236460f..ac4d97b 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,24 +6,33 @@ <rect> <x>0</x> <y>0</y> - <width>602</width> - <height>424</height> + <width>971</width> + <height>767</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QHBoxLayout" name="centralWidgetLayout"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QListView" name="songListView"> - <property name="contextMenuPolicy"> - <enum>Qt::CustomContextMenu</enum> + <layout class="QHBoxLayout" name="listsLayout"> + <property name="spacing"> + <number>6</number> </property> - </widget> + <property name="sizeConstraint"> + <enum>QLayout::SetDefaultConstraint</enum> + </property> + <item> + <widget class="QListView" name="songListView"/> + </item> + <item> + <widget class="QListView" name="abListView"/> + </item> + </layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout"> + <layout class="QVBoxLayout" name="slidersLayout"> <item> <widget class="QSlider" name="songSlider"> <property name="minimumSize"> @@ -51,77 +60,94 @@ </property> </widget> </item> - <item> + </layout> + </item> + <item> + <layout class="QGridLayout" name="buttonsLayout"> + <item row="0" column="1"> + <widget class="QPushButton" name="pauseButton"> + <property name="text"> + <string>Pause</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QPushButton" name="initMidiButton"> + <property name="text"> + <string>Connect MIDI</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QSlider" name="rateSlider"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QPushButton" name="playButton"> + <property name="text"> + <string>Play</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QPushButton" name="saveSessionButton"> + <property name="text"> + <string>Save session</string> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QPushButton" name="storeAbButton"> + <property name="text"> + <string>Store AB</string> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QPushButton" name="loadSessionButton"> + <property name="text"> + <string>Load session</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="abRepeatCheckBox"> + <property name="text"> + <string>AB repeat</string> + </property> + </widget> + </item> + <item row="2" column="4"> + <widget class="QPushButton" name="addSongButton"> + <property name="text"> + <string>Add song</string> + </property> + </widget> + </item> + <item row="2" column="2"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QListView" name="abListView"/> + <widget class="QPushButton" name="setAButton"> + <property name="text"> + <string>Set A</string> + </property> + </widget> </item> <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="1"> - <widget class="QPushButton" name="playButton"> - <property name="text"> - <string>Play</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="pauseButton"> - <property name="text"> - <string>Pause</string> - </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QPushButton" name="saveAbButton"> - <property name="text"> - <string>Save AB</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="saveSessionButton"> - <property name="text"> - <string>Save session</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QPushButton" name="loadSessionButton"> - <property name="text"> - <string>Load session</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QCheckBox" name="abRepeatCheckBox"> - <property name="text"> - <string>AB repeat</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QPushButton" name="initMidiButton"> - <property name="text"> - <string>Connect MIDI</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QPushButton" name="addSongButton"> - <property name="text"> - <string>Add song</string> - </property> - </widget> - </item> - <item row="12" column="1"> - <widget class="QSlider" name="rateSlider"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - </layout> + <widget class="QPushButton" name="setBButton"> + <property name="text"> + <string>Set B</string> + </property> + </widget> </item> </layout> </item> diff --git a/solo_tool_qt.py b/solo_tool_qt.py index 7bb3821..44f2ee4 100644 --- a/solo_tool_qt.py +++ b/solo_tool_qt.py @@ -73,7 +73,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.playButton.pressed.connect(self.soloTool.play) self.pauseButton.pressed.connect(self.soloTool.pause) - self.saveAbButton.pressed.connect(self.saveAbLimits) + self.storeAbButton.pressed.connect(self.storeAbLimits) + self.setAButton.pressed.connect(self.setA) + self.setBButton.pressed.connect(self.setB) self.saveSessionButton.pressed.connect(self.saveSession) self.loadSessionButton.pressed.connect(self.loadSession) self.addSongButton.pressed.connect(self.addSong) @@ -94,12 +96,22 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.soloTool.addSong(path) self.playlistModel.layoutChanged.emit() - def saveAbLimits(self): + def storeAbLimits(self): a = self.aSlider.value() / float(POSITION_FACTOR) b = self.bSlider.value() / float(POSITION_FACTOR) self.soloTool.storeAbLimits(a, b) self.abListModel.layoutChanged.emit() + def setA(self): + position = self.songSlider.value() + self.aSlider.setValue(position) + self.abSliderReleased() + + def setB(self): + position = self.songSlider.value() + self.bSlider.setValue(position) + self.abSliderReleased() + def toggleAbRepeat(self): enable = self.abRepeatCheckBox.isChecked() self.soloTool.setAbLimitEnable(enable) |