v0.4 - cockybastard
This commit is contained in:
+37
-27
@@ -2,7 +2,7 @@
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QFrame, QHBoxLayout, QVBoxLayout, QLabel, QPushButton,
|
||||
QComboBox, QScrollArea, QWidget
|
||||
QComboBox, QScrollArea, QWidget, QListWidget
|
||||
)
|
||||
from PySide6.QtCore import Qt, QTimer, Signal, QSize, QPoint
|
||||
from PySide6.QtGui import QFont
|
||||
@@ -134,7 +134,6 @@ class TopBarWidget(QFrame):
|
||||
|
||||
def _toggle_settings_popup(self):
|
||||
self._popup = SettingsPopup(self._midi_engine, self)
|
||||
self._popup.ratio_changed.connect(self.ratio_changed.emit)
|
||||
self._popup.save_session.connect(self.save_session.emit)
|
||||
self._popup.load_session.connect(self.load_session.emit)
|
||||
pos = self.settings_btn.mapToGlobal(QPoint(0, self.settings_btn.height() + 4))
|
||||
@@ -244,14 +243,12 @@ POPUP_STYLE = """
|
||||
|
||||
|
||||
class SettingsPopup(QFrame):
|
||||
ratio_changed = Signal(int, int)
|
||||
save_session = Signal()
|
||||
load_session = Signal()
|
||||
|
||||
def __init__(self, midi_engine, parent=None):
|
||||
super().__init__(parent)
|
||||
self._midi_engine = midi_engine
|
||||
self._ratio_index = 1
|
||||
|
||||
self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
|
||||
self.setObjectName("settingsPopup")
|
||||
@@ -265,21 +262,9 @@ class SettingsPopup(QFrame):
|
||||
root.setContentsMargins(12, 10, 12, 10)
|
||||
root.setSpacing(6)
|
||||
|
||||
# Row 1: Aspect ratio + Save/Load
|
||||
# Row 1: Save/Load
|
||||
row1 = QHBoxLayout()
|
||||
row1.setSpacing(6)
|
||||
self._ratio_btns = []
|
||||
for i, (label, w, h) in enumerate(RATIOS):
|
||||
btn = QPushButton(label)
|
||||
btn.setObjectName("ratioBtn")
|
||||
btn.setFixedHeight(24)
|
||||
btn.setCheckable(True)
|
||||
btn.setChecked(i == self._ratio_index)
|
||||
btn.clicked.connect(partial(self._set_ratio, i))
|
||||
row1.addWidget(btn)
|
||||
self._ratio_btns.append(btn)
|
||||
|
||||
row1.addSpacing(8)
|
||||
save_btn = QPushButton("SAVE")
|
||||
save_btn.setObjectName("popupBtn")
|
||||
save_btn.setFixedHeight(24)
|
||||
@@ -326,7 +311,7 @@ class SettingsPopup(QFrame):
|
||||
|
||||
scroll = QScrollArea()
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setFixedHeight(170)
|
||||
scroll.setFixedHeight(200)
|
||||
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
scroll.setStyleSheet(POPUP_STYLE)
|
||||
|
||||
@@ -347,6 +332,14 @@ class SettingsPopup(QFrame):
|
||||
("Cart 2", "cart_trigger", 1),
|
||||
("Cart 3", "cart_trigger", 2),
|
||||
("Cart 4", "cart_trigger", 3),
|
||||
("Ch 1 Volume", "mixer_volume", 0),
|
||||
("Ch 2 Volume", "mixer_volume", 1),
|
||||
("Ch 3 Volume", "mixer_volume", 2),
|
||||
("Ch 4 Volume", "mixer_volume", 3),
|
||||
("Ch 5 Volume", "mixer_volume", 4),
|
||||
("Ch 6 Volume", "mixer_volume", 5),
|
||||
("Ch 7 Volume", "mixer_volume", 6),
|
||||
("Ch 8 Volume", "mixer_volume", 7),
|
||||
("Ch 1 Solo", "mixer_solo", 0),
|
||||
("Ch 1 PFL", "mixer_pfl", 0),
|
||||
("Ch 2 Solo", "mixer_solo", 1),
|
||||
@@ -392,7 +385,7 @@ class SettingsPopup(QFrame):
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
QPushButton:hover { background-color: #5a2a2a; }
|
||||
QPushButton:hover { background-color: #5a2a2a; }
|
||||
""")
|
||||
clear_btn.setFixedSize(20, 20)
|
||||
clear_btn.clicked.connect(partial(self._clear_mapping, action, target_id))
|
||||
@@ -403,19 +396,36 @@ class SettingsPopup(QFrame):
|
||||
scroll.setWidget(content)
|
||||
root.addWidget(scroll)
|
||||
|
||||
monitor_label = QLabel("MIDI MONITOR")
|
||||
monitor_label.setStyleSheet("color: #556670; background: transparent; border: none; font-size: 7pt; font-weight: bold;")
|
||||
root.addWidget(monitor_label)
|
||||
|
||||
self._midi_monitor = QListWidget()
|
||||
self._midi_monitor.setFixedHeight(80)
|
||||
self._midi_monitor.setStyleSheet("""
|
||||
QListWidget {
|
||||
background-color: #0d0e12;
|
||||
border: 1px solid #22242a;
|
||||
border-radius: 3px;
|
||||
color: #8890a0;
|
||||
font-size: 7pt;
|
||||
font-family: monospace;
|
||||
}
|
||||
""")
|
||||
|
||||
self._refresh_ports()
|
||||
|
||||
if self._midi_engine:
|
||||
self._midi_engine.mapping_learned.connect(self._on_mapping_learned)
|
||||
self._midi_engine.raw_midi_event.connect(self._on_raw_midi)
|
||||
|
||||
# ── Ratio ──────────────────────────────────────────────────────
|
||||
|
||||
def _set_ratio(self, index):
|
||||
self._ratio_index = index
|
||||
for i, btn in enumerate(self._ratio_btns):
|
||||
btn.setChecked(i == index)
|
||||
_, w, h = RATIOS[index]
|
||||
self.ratio_changed.emit(w, h)
|
||||
def _on_raw_midi(self, type_name, channel, control, value):
|
||||
self._midi_monitor.addItem(
|
||||
f"{type_name:>10} ch{channel} ctl={control:>3} val={value:>3}"
|
||||
)
|
||||
while self._midi_monitor.count() > 200:
|
||||
self._midi_monitor.takeItem(0)
|
||||
self._midi_monitor.scrollToBottom()
|
||||
|
||||
# ── MIDI port ──────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user