211 lines
6.9 KiB
Python
211 lines
6.9 KiB
Python
import sys
|
|
from PySide6.QtWidgets import (QApplication, QWidget, QPushButton, QGridLayout,
|
|
QVBoxLayout, QHBoxLayout, QCheckBox, QComboBox,
|
|
QLabel, QSlider, QFrame, QGroupBox)
|
|
from PySide6.QtCore import Qt
|
|
from widgets.audio_filter_widget import AudioFilterWidget
|
|
|
|
class ChannelButton(QWidget):
|
|
def __init__(self, channel_num):
|
|
super().__init__()
|
|
|
|
self.channel_num = channel_num # 保存通道号
|
|
|
|
# Create GroupBox for the channel
|
|
self.group = QGroupBox(f"CH{channel_num}")
|
|
layout = QVBoxLayout()
|
|
layout.setSpacing(2)
|
|
|
|
# Channel button
|
|
self.channel_btn = QPushButton(f"Channel {channel_num}")
|
|
self.channel_btn.setFixedHeight(25)
|
|
|
|
# Store audio filter window reference
|
|
self.filter_window = None
|
|
|
|
# Controls container with two rows
|
|
controls_layout = QGridLayout()
|
|
controls_layout.setSpacing(2)
|
|
|
|
# SOLO row
|
|
self.solo_cb = QCheckBox("S")
|
|
self.solo_btn = QPushButton("SOLO")
|
|
self.solo_btn.setFixedHeight(20)
|
|
controls_layout.addWidget(self.solo_cb, 0, 0)
|
|
controls_layout.addWidget(self.solo_btn, 0, 1)
|
|
|
|
# MUTE row
|
|
self.mute_cb = QCheckBox("M")
|
|
self.mute_btn = QPushButton("MUTE")
|
|
self.mute_btn.setFixedHeight(20)
|
|
controls_layout.addWidget(self.mute_cb, 1, 0)
|
|
controls_layout.addWidget(self.mute_btn, 1, 1)
|
|
|
|
# Add widgets to main layout
|
|
layout.addWidget(self.channel_btn)
|
|
layout.addLayout(controls_layout)
|
|
|
|
# Set GroupBox layout
|
|
self.group.setLayout(layout)
|
|
|
|
# Main layout
|
|
main_layout = QVBoxLayout()
|
|
main_layout.addWidget(self.group)
|
|
main_layout.setContentsMargins(2, 2, 2, 2)
|
|
self.setLayout(main_layout)
|
|
|
|
# Set fixed size for the channel widget
|
|
self.setFixedSize(110, 100)
|
|
|
|
# Style
|
|
self.channel_btn.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: #404040;
|
|
color: white;
|
|
border: 1px solid #505050;
|
|
}
|
|
QPushButton:hover {
|
|
background-color: #505050;
|
|
}
|
|
""")
|
|
|
|
button_style = """
|
|
QPushButton {
|
|
background-color: #303030;
|
|
color: white;
|
|
border: 1px solid #404040;
|
|
padding: 2px;
|
|
}
|
|
QPushButton:hover {
|
|
background-color: #404040;
|
|
}
|
|
"""
|
|
|
|
self.solo_btn.setStyleSheet(button_style)
|
|
self.mute_btn.setStyleSheet(button_style)
|
|
|
|
self.group.setStyleSheet("""
|
|
QGroupBox {
|
|
border: 1px solid #505050;
|
|
margin-top: 0.5em;
|
|
padding: 2px;
|
|
}
|
|
QCheckBox {
|
|
spacing: 2px;
|
|
}
|
|
""")
|
|
|
|
# Connect button click event
|
|
self.channel_btn.clicked.connect(self.show_filter_window)
|
|
|
|
def show_filter_window(self):
|
|
# 如果窗口已存在且可见,则关闭它
|
|
if self.filter_window and self.filter_window.isVisible():
|
|
self.filter_window.raise_()
|
|
self.filter_window.activateWindow()
|
|
else:
|
|
# 如果窗口不存在或已关闭,创建新窗口
|
|
self.filter_window = AudioFilterWidget(channel_id=self.channel_num)
|
|
self.filter_window.setWindowTitle(f"Channel {self.group.title()} Filter Settings")
|
|
|
|
# 监听窗口关闭事件,在窗口关闭时重置 filter_window
|
|
self.filter_window.destroyed.connect(self._on_filter_window_closed)
|
|
self.filter_window.show()
|
|
|
|
def _on_filter_window_closed(self):
|
|
"""当滤波器窗口关闭时调用"""
|
|
self.filter_window = None
|
|
|
|
class AVAS_WIDGET(QWidget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("AVAS")
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
main_layout = QVBoxLayout()
|
|
|
|
# Top section - Channel buttons
|
|
channels_layout = QGridLayout()
|
|
for i in range(24):
|
|
row = i // 8
|
|
col = i % 8
|
|
channel = ChannelButton(i + 1)
|
|
channels_layout.addWidget(channel, row, col)
|
|
|
|
# Middle section
|
|
middle_layout = QHBoxLayout()
|
|
|
|
# Left side - Parameter matrix
|
|
param_matrix = self.create_parameter_matrix()
|
|
|
|
# Right side - Filter controls
|
|
filter_controls = self.create_filter_controls()
|
|
|
|
middle_layout.addWidget(param_matrix, stretch=2)
|
|
middle_layout.addWidget(filter_controls, stretch=1)
|
|
|
|
# Bottom section
|
|
bottom_layout = QHBoxLayout()
|
|
clean_btn = QPushButton("Clean")
|
|
send_btn = QPushButton("Send")
|
|
enable_cb = QCheckBox("Enable")
|
|
|
|
bottom_layout.addStretch()
|
|
bottom_layout.addWidget(clean_btn)
|
|
bottom_layout.addWidget(send_btn)
|
|
bottom_layout.addWidget(enable_cb)
|
|
|
|
# Add all sections to main layout
|
|
main_layout.addLayout(channels_layout)
|
|
main_layout.addLayout(middle_layout)
|
|
main_layout.addLayout(bottom_layout)
|
|
|
|
self.setLayout(main_layout)
|
|
|
|
def create_parameter_matrix(self):
|
|
frame = QFrame()
|
|
frame.setFrameStyle(QFrame.Box)
|
|
layout = QGridLayout()
|
|
|
|
# Add headers and parameter rows
|
|
for i in range(24): # 24 channels
|
|
layout.addWidget(QLabel(f"Ch{i+1}"), i+1, 0)
|
|
# Add parameter controls for each channel
|
|
for j in range(5): # Example: 5 parameters per channel
|
|
layout.addWidget(QSlider(Qt.Horizontal), i+1, j+1)
|
|
|
|
frame.setLayout(layout)
|
|
return frame
|
|
|
|
def create_filter_controls(self):
|
|
frame = QFrame()
|
|
frame.setFrameStyle(QFrame.Box)
|
|
layout = QVBoxLayout()
|
|
|
|
# Filter selection
|
|
filter_select = QComboBox()
|
|
filter_select.addItems(["Filter 1", "Filter 2", "Filter 3"])
|
|
|
|
# Filter type radio buttons
|
|
filter_types = QVBoxLayout()
|
|
types = ["Pink-Pin", "Bass Setting", "Stereo Surround", "None"]
|
|
for type_name in types:
|
|
filter_types.addWidget(QCheckBox(type_name))
|
|
|
|
# Sliders
|
|
sliders_layout = QVBoxLayout()
|
|
slider_labels = ["Input Level", "Freq", "Gain"]
|
|
for label in slider_labels:
|
|
sliders_layout.addWidget(QLabel(label))
|
|
sliders_layout.addWidget(QSlider(Qt.Horizontal))
|
|
|
|
layout.addWidget(QLabel("Filter Select"))
|
|
layout.addWidget(filter_select)
|
|
layout.addLayout(filter_types)
|
|
layout.addLayout(sliders_layout)
|
|
|
|
frame.setLayout(layout)
|
|
return frame
|
|
|