main caleson win made with .ui in the class for widgets

This commit is contained in:
Houston4444 2024-05-07 00:20:57 +02:00
parent a82bbcc919
commit d793098c5a
4 changed files with 501 additions and 503 deletions

View File

@ -768,7 +768,7 @@
<x>0</x>
<y>0</y>
<width>586</width>
<height>288</height>
<height>368</height>
</rect>
</property>
<attribute name="label">
@ -1381,7 +1381,7 @@
<item>
<widget class="QGroupBox" name="groupBox_catia">
<property name="title">
<string>Catia</string>
<string>Patchance</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -1402,7 +1402,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/screens/catia.png</pixmap>
<pixmap>:/screens/catia.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1412,7 +1412,7 @@
<item>
<widget class="QLabel" name="label_tools_catia">
<property name="text">
<string>JACK Patchbay with A2J Bridge support and JACK Transport</string>
<string>JACK Patchbay with A2J Bridge, Alsa MIDI and JACK Transport</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1426,30 +1426,30 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_render">
<widget class="QGroupBox" name="groupBox_catia_2">
<property name="title">
<string>Render</string>
<string>RaySession</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<layout class="QVBoxLayout" name="verticalLayout_26">
<item>
<widget class="ClickableLabel" name="pic_render">
<widget class="ClickableLabel" name="pic_catia_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>128</height>
<height>117</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>128</height>
<height>117</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/screens/caleson-render.png</pixmap>
<pixmap>:/screens/catia.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1457,9 +1457,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_tools_render">
<widget class="QLabel" name="label_tools_catia_2">
<property name="text">
<string>Render a JACK project</string>
<string>Session Manager with NSM support</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1490,23 +1490,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_tools_tools">
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Tools</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_tools_tools">
<property name="lineWidth">
@ -1570,77 +1553,13 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_meter">
<widget class="QGroupBox" name="groupBox_render">
<property name="title">
<string>Meter In / Out</string>
<string>QJackRecord</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="ClickableLabel" name="pic_meter_in">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/screens/caleson-jackmeter-in.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="ClickableLabel" name="pic_meter_out">
<property name="minimumSize">
<size>
<width>0</width>
<height>117</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>117</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/screens/caleson-jackmeter-out.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_tools_meter">
<property name="text">
<string>Digital peak meter, auto-connected to all system inputs or outputs</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_xycontroller">
<property name="title">
<string>XY-Controller</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="ClickableLabel" name="pic_xycontroller">
<widget class="ClickableLabel" name="pic_render">
<property name="minimumSize">
<size>
<width>0</width>
@ -1657,7 +1576,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="../resources.qrc">:/screens/caleson-xycontroller.png</pixmap>
<pixmap>:/screens/caleson-render.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1665,9 +1584,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_tools_xycontroller">
<widget class="QLabel" name="label_tools_render">
<property name="text">
<string>Virtual XY Controller with MIDI Keyboard</string>
<string>Render a JACK project</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1976,7 +1895,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<width>91</width>
<height>89</height>
</rect>
</property>
@ -2010,7 +1929,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<width>91</width>
<height>89</height>
</rect>
</property>
@ -2044,7 +1963,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<width>91</width>
<height>89</height>
</rect>
</property>
@ -2078,7 +1997,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<width>91</width>
<height>89</height>
</rect>
</property>
@ -2134,8 +2053,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>99</width>
<height>99</height>
<width>327</width>
<height>201</height>
</rect>
</property>
<attribute name="label">

File diff suppressed because it is too large Load Diff

View File

@ -34,8 +34,10 @@ from shared_i18n import setup_i18n
# Fix log text output (get rid of terminal colors stuff)
def fixLogText(text):
return text.replace("", "").replace("", "").replace("", "").replace("", "").replace("", "")
def fixLogText(text: str) -> str:
return text.replace(
"", "").replace("", "").replace(
"", "").replace("", "").replace("", "")
# Syntax Highlighter for JACK
@ -45,17 +47,26 @@ class SyntaxHighlighter_JACK(QSyntaxHighlighter):
self.fPalette = parent.palette()
def highlightBlock(self, text):
def highlightBlock(self, text: str):
if ": ERROR: " in text:
self.setFormat(text.find(" ERROR: "), len(text), Qt.red)
elif ": WARNING: " in text:
self.setFormat(text.find(" WARNING: "), len(text), Qt.darkRed)
elif ": ------------------" in text:
self.setFormat(text.find(" ------------------"), len(text), self.fPalette.color(QPalette.Active, QPalette.Mid))
self.setFormat(
text.find(" ------------------"),
len(text),
self.fPalette.color(QPalette.Active, QPalette.Mid))
elif ": Connecting " in text:
self.setFormat(text.find(" Connecting "), len(text), self.fPalette.color(QPalette.Active, QPalette.Link))
self.setFormat(
text.find(" Connecting "),
len(text),
self.fPalette.color(QPalette.Active, QPalette.Link))
elif ": Disconnecting " in text:
self.setFormat(text.find(" Disconnecting "), len(text), self.fPalette.color(QPalette.Active, QPalette.LinkVisited))
self.setFormat(
text.find(" Disconnecting "),
len(text),
self.fPalette.color(QPalette.Active, QPalette.LinkVisited))
# Syntax Highlighter for A2J
@ -71,11 +82,20 @@ class SyntaxHighlighter_A2J(QSyntaxHighlighter):
elif ": WARNING: " in text:
self.setFormat(text.find(" WARNING: "), len(text), Qt.darkRed)
elif ": ----------------------------" in text:
self.setFormat(text.find("----------------------------"), len(text), self.fPalette.color(QPalette.Active, QPalette.Mid))
self.setFormat
(text.find("----------------------------"),
len(text),
self.fPalette.color(QPalette.Active, QPalette.Mid))
elif ": port created: " in text:
self.setFormat(text.find(" port created: "), len(text), self.fPalette.color(QPalette.Active, QPalette.Link))
self.setFormat(
text.find(" port created: "),
len(text),
self.fPalette.color(QPalette.Active, QPalette.Link))
elif ": port deleted: " in text:
self.setFormat(text.find(" port deleted: "), len(text), self.fPalette.color(QPalette.Active, QPalette.LinkVisited))
self.setFormat(
text.find(" port deleted: "),
len(text),
self.fPalette.color(QPalette.Active, QPalette.LinkVisited))
# Syntax Highlighter for LASH
@ -91,7 +111,10 @@ class SyntaxHighlighter_LASH(QSyntaxHighlighter):
elif ": WARNING: " in text:
self.setFormat(text.find(" WARNING: "), len(text), Qt.darkRed)
elif ": ------------------" in text:
self.setFormat(text.find(" ------------------"), len(text), self.fPalette.color(QPalette.Active, QPalette.Mid))
self.setFormat(
text.find(" ------------------"),
len(text),
self.fPalette.color(QPalette.Active, QPalette.Mid))
# Lock-less file read thread
@ -124,7 +147,8 @@ class LogsReadThread(QThread):
self.fLogStreamJACK.setCodec("UTF-8")
if self.fLogFileJACK.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamJACK.seek(self.fLogFileJACK.size() - self.MAX_INITIAL_SIZE)
self.fLogStreamJACK.seek(
self.fLogFileJACK.size() - self.MAX_INITIAL_SIZE)
if self.LOG_FILE_A2J is not None:
self.fLogFileA2J = QFile(self.LOG_FILE_A2J)
@ -133,7 +157,8 @@ class LogsReadThread(QThread):
self.fLogStreamA2J.setCodec("UTF-8")
if self.fLogFileA2J.size() > self.MAX_INITIAL_SIZE:
self.fLogStreamA2J.seek(self.fLogFileA2J.size() - self.MAX_INITIAL_SIZE)
self.fLogStreamA2J.seek(
self.fLogFileA2J.size() - self.MAX_INITIAL_SIZE)
def closeNow(self):
self.fCloseNow = True
@ -165,7 +190,8 @@ class LogsReadThread(QThread):
else:
if self.LOG_FILE_JACK:
textJACK = fixLogText(self.fLogStreamJACK.readAll()).strip()
textJACK = fixLogText(
self.fLogStreamJACK.readAll()).strip()
else:
textJACK = ""
@ -287,9 +313,11 @@ class LogsW(QDialog):
if self.fFirstRun:
self.ui.pte_jack.horizontalScrollBar().setValue(0)
self.ui.pte_jack.verticalScrollBar().setValue(self.ui.pte_jack.verticalScrollBar().maximum())
self.ui.pte_jack.verticalScrollBar().setValue(
self.ui.pte_jack.verticalScrollBar().maximum())
self.ui.pte_a2j.horizontalScrollBar().setValue(0)
self.ui.pte_a2j.verticalScrollBar().setValue(self.ui.pte_a2j.verticalScrollBar().maximum())
self.ui.pte_a2j.verticalScrollBar().setValue(
self.ui.pte_a2j.verticalScrollBar().maximum())
self.fFirstRun = False
@pyqtSlot()

View File

@ -31,6 +31,7 @@ load-module module-rescue-streams
### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink
"""
PULSE_CONFIG_DIR = os.path.join(os.getenv('HOME'), '.pulse')
if os.getenv('PULSE_CONFIG_DIR'):
PULSE_CONFIG_DIR = os.getenv('PULSE_CONFIG_DIR')
@ -45,7 +46,8 @@ class Bridge:
existing = False
number_in_file = ''
def __init__(self, bridge_type, name, channels, connected):
def __init__(self, bridge_type: str, name: str,
channels: str, connected: str):
if bridge_type.lower() == 'sink':
self.type = 'sink'
@ -57,11 +59,12 @@ class Bridge:
if connected.lower() in ('false', 'no'):
self.connected = 'no'
def is_same_as(self, other)->bool:
return bool(self.type == other.type
and self.name == other.name
and self.channels == other.channels
and self.connected == other.connected)
def is_same_as(self, other: 'Bridge') -> bool:
return bool(
self.type == other.type
and self.name == other.name
and self.channels == other.channels
and self.connected == other.connected)
def set_module_id(self, module_id: str):
self.module_id = module_id
@ -75,25 +78,25 @@ class Bridge:
elif key == 'connect':
self.connected = value
def get_load_module_string(self)->str:
string = "load-module module-jack-%s" % self.type
def get_load_module_string(self) -> str:
string = f"load-module module-jack-{self.type}"
if self.channels:
string += " channels=%s" % self.channels
string += f" channels={self.channels}"
if self.connected:
string += " connected=%s" % self.connected
string += f" connected={self.connected}"
if self.name:
string += " client_name=\"%s\"" % self.name.replace('"', '\\"')
return string
def get_save_string(self)->str:
str_base = "pulseaudio_%s%s" % (self.type, self.number_in_file)
save_list = []
def get_save_string(self) -> str:
str_base = f"pulseaudio_{self.type}{self.number_in_file}"
save_list = list[str]()
if self.name:
save_list.append("%s_name:%s" % (str_base, self.name))
save_list.append(f"{str_base}_name:{self.name}")
if self.channels:
save_list.append("%s_channels:%s" % (str_base, self.channels))
save_list.append(f"{str_base}_channels:{self.channels}")
if self.connected:
save_list.append("%s_connect:%s" % (str_base, self.connected))
save_list.append(f"{str_base}_connect:{self.connected}")
return '\n'.join(save_list)
@ -198,10 +201,10 @@ def get_wanted_bridges_from_str(input_parameters: str)->list:
return bridges
def pactl_contents_to_bridge_list(pactl_contents: str)->list:
def pactl_contents_to_bridge_list(pactl_contents: str) -> list[Bridge]:
"""Converts the contents of `pactl list modules short`
to a list of Bridge class elements"""
modules = []
to a list of Bridge class elements"""
modules = list[Bridge]()
# parse the pactl list
for line in pactl_contents.split('\n'):
@ -237,8 +240,9 @@ to a list of Bridge class elements"""
return modules
def get_existing_modules()->list:
"""reads loaded pulseaudio modules and returns them in a list of Bridges"""
def get_existing_modules() -> list[Bridge]:
"""reads loaded pulseaudio modules
and returns them in a list of Bridges"""
# will raise FileNotFoundError if pactl is missing
# or subprocess.CalledProcessError if pulseaudio is not running
@ -247,10 +251,10 @@ def get_existing_modules()->list:
return pactl_contents_to_bridge_list(pactl_contents)
def get_save_string(existing_modules: list)->str:
save_string = ''
def get_save_string(existing_modules: list[Bridge]) -> str:
n_sink = 1
n_source = 1
for bridge in existing_modules:
if bridge.type == 'sink':
if n_sink > 1:
@ -263,7 +267,8 @@ def get_save_string(existing_modules: list)->str:
return '\n'.join([b.get_save_string() for b in existing_modules])
def unload_and_load_modules(wanted_modules, existing_modules):
def unload_and_load_modules(
wanted_modules: list[Bridge], existing_modules: list[Bridge]):
"""Unload unwanted PulseAudio JACK modules
and load wanted modules, skipping theses one already bridged"""