|
|
e44045 |
From 480e0e74f43565d7ece72141666961ae8cc2ed75 Mon Sep 17 00:00:00 2001
|
|
|
e44045 |
From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= <andrius@stikonas.eu>
|
|
|
e44045 |
Date: Mon, 20 Nov 2017 19:56:53 +0000
|
|
|
e44045 |
Subject: [PATCH 090/106] qpaeq: port to PyQt5
|
|
|
e44045 |
|
|
|
e44045 |
---
|
|
|
e44045 |
src/utils/qpaeq | 68 ++++++++++++++++++++++++++++-----------------------------
|
|
|
e44045 |
1 file changed, 34 insertions(+), 34 deletions(-)
|
|
|
e44045 |
|
|
|
e44045 |
diff --git a/src/utils/qpaeq b/src/utils/qpaeq
|
|
|
e44045 |
index f657659d..651d3a4e 100755
|
|
|
e44045 |
--- a/src/utils/qpaeq
|
|
|
e44045 |
+++ b/src/utils/qpaeq
|
|
|
e44045 |
@@ -18,13 +18,13 @@
|
|
|
e44045 |
|
|
|
e44045 |
import os,math,sys
|
|
|
e44045 |
try:
|
|
|
e44045 |
- import PyQt4,sip
|
|
|
e44045 |
- from PyQt4 import QtGui,QtCore
|
|
|
e44045 |
+ import PyQt5,sip
|
|
|
e44045 |
+ from PyQt5 import QtWidgets,QtCore
|
|
|
e44045 |
import dbus.mainloop.qt
|
|
|
e44045 |
import dbus
|
|
|
e44045 |
except ImportError as e:
|
|
|
e44045 |
sys.stderr.write('There was an error importing needed libraries\n'
|
|
|
e44045 |
- 'Make sure you have qt4 and dbus-python installed\n'
|
|
|
e44045 |
+ 'Make sure you have qt5 and dbus-python installed\n'
|
|
|
e44045 |
'The error that occured was:\n'
|
|
|
e44045 |
'\t%s\n' % (str(e)))
|
|
|
e44045 |
sys.exit(-1)
|
|
|
e44045 |
@@ -62,7 +62,7 @@ def connect():
|
|
|
e44045 |
prop_iface='org.freedesktop.DBus.Properties'
|
|
|
e44045 |
eq_iface='org.PulseAudio.Ext.Equalizing1.Equalizer'
|
|
|
e44045 |
device_iface='org.PulseAudio.Core1.Device'
|
|
|
e44045 |
-class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
+class QPaeq(QtWidgets.QWidget):
|
|
|
e44045 |
manager_path='/org/pulseaudio/equalizing1'
|
|
|
e44045 |
manager_iface='org.PulseAudio.Ext.Equalizing1.Manager'
|
|
|
e44045 |
core_iface='org.PulseAudio.Core1'
|
|
|
e44045 |
@@ -70,7 +70,7 @@ class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
module_name='module-equalizer-sink'
|
|
|
e44045 |
|
|
|
e44045 |
def __init__(self):
|
|
|
e44045 |
- QtGui.QWidget.__init__(self)
|
|
|
e44045 |
+ QtWidgets.QWidget.__init__(self)
|
|
|
e44045 |
self.setWindowTitle('qpaeq')
|
|
|
e44045 |
self.slider_widget=None
|
|
|
e44045 |
self.sink_name=None
|
|
|
e44045 |
@@ -84,50 +84,50 @@ class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
self.setMinimumSize(self.sizeHint())
|
|
|
e44045 |
|
|
|
e44045 |
def create_layout(self):
|
|
|
e44045 |
- self.main_layout=QtGui.QVBoxLayout()
|
|
|
e44045 |
+ self.main_layout=QtWidgets.QVBoxLayout()
|
|
|
e44045 |
self.setLayout(self.main_layout)
|
|
|
e44045 |
- toprow_layout=QtGui.QHBoxLayout()
|
|
|
e44045 |
- sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
|
|
|
e44045 |
+ toprow_layout=QtWidgets.QHBoxLayout()
|
|
|
e44045 |
+ sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
|
|
|
e44045 |
sizePolicy.setHorizontalStretch(0)
|
|
|
e44045 |
sizePolicy.setVerticalStretch(0)
|
|
|
e44045 |
#sizePolicy.setHeightForWidth(self.profile_box.sizePolicy().hasHeightForWidth())
|
|
|
e44045 |
|
|
|
e44045 |
- toprow_layout.addWidget(QtGui.QLabel('Sink'))
|
|
|
e44045 |
- self.sink_box = QtGui.QComboBox()
|
|
|
e44045 |
+ toprow_layout.addWidget(QtWidgets.QLabel('Sink'))
|
|
|
e44045 |
+ self.sink_box = QtWidgets.QComboBox()
|
|
|
e44045 |
self.sink_box.setSizePolicy(sizePolicy)
|
|
|
e44045 |
self.sink_box.setDuplicatesEnabled(False)
|
|
|
e44045 |
- self.sink_box.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
|
|
|
e44045 |
- #self.sink_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
|
|
e44045 |
+ self.sink_box.setInsertPolicy(QtWidgets.QComboBox.InsertAlphabetically)
|
|
|
e44045 |
+ #self.sink_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
|
|
|
e44045 |
toprow_layout.addWidget(self.sink_box)
|
|
|
e44045 |
|
|
|
e44045 |
- toprow_layout.addWidget(QtGui.QLabel('Channel'))
|
|
|
e44045 |
- self.channel_box = QtGui.QComboBox()
|
|
|
e44045 |
+ toprow_layout.addWidget(QtWidgets.QLabel('Channel'))
|
|
|
e44045 |
+ self.channel_box = QtWidgets.QComboBox()
|
|
|
e44045 |
self.channel_box.setSizePolicy(sizePolicy)
|
|
|
e44045 |
toprow_layout.addWidget(self.channel_box)
|
|
|
e44045 |
|
|
|
e44045 |
- toprow_layout.addWidget(QtGui.QLabel('Preset'))
|
|
|
e44045 |
- self.profile_box = QtGui.QComboBox()
|
|
|
e44045 |
+ toprow_layout.addWidget(QtWidgets.QLabel('Preset'))
|
|
|
e44045 |
+ self.profile_box = QtWidgets.QComboBox()
|
|
|
e44045 |
self.profile_box.setSizePolicy(sizePolicy)
|
|
|
e44045 |
- self.profile_box.setInsertPolicy(QtGui.QComboBox.InsertAlphabetically)
|
|
|
e44045 |
- #self.profile_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
|
|
e44045 |
+ self.profile_box.setInsertPolicy(QtWidgets.QComboBox.InsertAlphabetically)
|
|
|
e44045 |
+ #self.profile_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
|
|
|
e44045 |
toprow_layout.addWidget(self.profile_box)
|
|
|
e44045 |
|
|
|
e44045 |
- large_icon_size=self.style().pixelMetric(QtGui.QStyle.PM_LargeIconSize)
|
|
|
e44045 |
+ large_icon_size=self.style().pixelMetric(QtWidgets.QStyle.PM_LargeIconSize)
|
|
|
e44045 |
large_icon_size=QtCore.QSize(large_icon_size,large_icon_size)
|
|
|
e44045 |
- save_profile=QtGui.QToolButton()
|
|
|
e44045 |
- save_profile.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DriveFDIcon))
|
|
|
e44045 |
+ save_profile=QtWidgets.QToolButton()
|
|
|
e44045 |
+ save_profile.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_DriveFDIcon))
|
|
|
e44045 |
save_profile.setIconSize(large_icon_size)
|
|
|
e44045 |
save_profile.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
|
|
|
e44045 |
save_profile.clicked.connect(self.save_profile)
|
|
|
e44045 |
- remove_profile=QtGui.QToolButton()
|
|
|
e44045 |
- remove_profile.setIcon(self.style().standardIcon(QtGui.QStyle.SP_TrashIcon))
|
|
|
e44045 |
+ remove_profile=QtWidgets.QToolButton()
|
|
|
e44045 |
+ remove_profile.setIcon(self.style().standardIcon(QtWidgets.QStyle.SP_TrashIcon))
|
|
|
e44045 |
remove_profile.setIconSize(large_icon_size)
|
|
|
e44045 |
remove_profile.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
|
|
|
e44045 |
remove_profile.clicked.connect(self.remove_profile)
|
|
|
e44045 |
toprow_layout.addWidget(save_profile)
|
|
|
e44045 |
toprow_layout.addWidget(remove_profile)
|
|
|
e44045 |
|
|
|
e44045 |
- reset_button = QtGui.QPushButton('Reset')
|
|
|
e44045 |
+ reset_button = QtWidgets.QPushButton('Reset')
|
|
|
e44045 |
reset_button.clicked.connect(self.reset)
|
|
|
e44045 |
toprow_layout.addStretch()
|
|
|
e44045 |
toprow_layout.addWidget(reset_button)
|
|
|
e44045 |
@@ -192,11 +192,11 @@ class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
def save_profile(self):
|
|
|
e44045 |
#popup dialog box for name
|
|
|
e44045 |
current=self.profile_box.currentIndex()
|
|
|
e44045 |
- profile,ok=QtGui.QInputDialog.getItem(self,'Preset Name','Preset',self.profiles,current)
|
|
|
e44045 |
+ profile,ok=QtWidgets.QInputDialog.getItem(self,'Preset Name','Preset',self.profiles,current)
|
|
|
e44045 |
if not ok or profile=='':
|
|
|
e44045 |
return
|
|
|
e44045 |
if profile in self.profiles:
|
|
|
e44045 |
- mbox=QtGui.QMessageBox(self)
|
|
|
e44045 |
+ mbox=QtWidgets.QMessageBox(self)
|
|
|
e44045 |
mbox.setText('%s preset already exists'%(profile,))
|
|
|
e44045 |
mbox.setInformativeText('Do you want to save over it?')
|
|
|
e44045 |
mbox.setStandardButtons(mbox.Save|mbox.Discard|mbox.Cancel)
|
|
|
e44045 |
@@ -217,7 +217,7 @@ class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
profile=self.profile_box.itemText(x)
|
|
|
e44045 |
self.filter_state.load_profile(profile)
|
|
|
e44045 |
def select_channel(self,x):
|
|
|
e44045 |
- self.filter_state.channel = self.channel_box.itemData(x).toPyObject()
|
|
|
e44045 |
+ self.filter_state.channel = self.channel_box.itemData(x)
|
|
|
e44045 |
self._set_profile_name()
|
|
|
e44045 |
self.filter_state.readback()
|
|
|
e44045 |
|
|
|
e44045 |
@@ -295,13 +295,13 @@ class QPaeq(QtGui.QWidget):
|
|
|
e44045 |
self.profile_box.blockSignals(False)
|
|
|
e44045 |
|
|
|
e44045 |
|
|
|
e44045 |
-class SliderArray(QtGui.QWidget):
|
|
|
e44045 |
+class SliderArray(QtWidgets.QWidget):
|
|
|
e44045 |
def __init__(self,filter_state,parent=None):
|
|
|
e44045 |
super(SliderArray,self).__init__(parent)
|
|
|
e44045 |
#self.setStyleSheet('padding: 0px; border-width: 0px; margin: 0px;')
|
|
|
e44045 |
#self.setStyleSheet('font-family: monospace;'+outline%('blue'))
|
|
|
e44045 |
self.filter_state=filter_state
|
|
|
e44045 |
- self.setLayout(QtGui.QHBoxLayout())
|
|
|
e44045 |
+ self.setLayout(QtWidgets.QHBoxLayout())
|
|
|
e44045 |
self.sub_array=None
|
|
|
e44045 |
self.set_sub_array(SliderArraySub(self.filter_state))
|
|
|
e44045 |
self.inhibit_resize=0
|
|
|
e44045 |
@@ -359,11 +359,11 @@ class SliderArray(QtGui.QWidget):
|
|
|
e44045 |
self.set_sub_array(SliderArraySub(self.filter_state))
|
|
|
e44045 |
self.inhibit_resize-=1
|
|
|
e44045 |
|
|
|
e44045 |
-class SliderArraySub(QtGui.QWidget):
|
|
|
e44045 |
+class SliderArraySub(QtWidgets.QWidget):
|
|
|
e44045 |
def __init__(self,filter_state,parent=None):
|
|
|
e44045 |
super(SliderArraySub,self).__init__(parent)
|
|
|
e44045 |
self.filter_state=filter_state
|
|
|
e44045 |
- self.setLayout(QtGui.QGridLayout())
|
|
|
e44045 |
+ self.setLayout(QtWidgets.QGridLayout())
|
|
|
e44045 |
self.slider=[None]*len(self.filter_state.frequencies)
|
|
|
e44045 |
self.label=[None]*len(self.slider)
|
|
|
e44045 |
#self.setStyleSheet('padding: 0px; border-width: 0px; margin: 0px;')
|
|
|
e44045 |
@@ -375,7 +375,7 @@ class SliderArraySub(QtGui.QWidget):
|
|
|
e44045 |
self.layout().addWidget(label,1,c,qt.AlignHCenter)
|
|
|
e44045 |
self.layout().setColumnMinimumWidth(c,max(label.sizeHint().width(),slider.sizeHint().width()))
|
|
|
e44045 |
def create_slider(slider_label):
|
|
|
e44045 |
- slider=QtGui.QSlider(QtCore.Qt.Vertical,self)
|
|
|
e44045 |
+ slider=QtWidgets.QSlider(QtCore.Qt.Vertical,self)
|
|
|
e44045 |
label=SliderLabel(slider_label,filter_state,self)
|
|
|
e44045 |
slider.setRange(-1000,2000)
|
|
|
e44045 |
slider.setSingleStep(1)
|
|
|
e44045 |
@@ -461,7 +461,7 @@ class SliderArraySub(QtGui.QWidget):
|
|
|
e44045 |
return int((x-1.0)*1000)
|
|
|
e44045 |
outline='border-width: 1px; border-style: solid; border-color: %s;'
|
|
|
e44045 |
|
|
|
e44045 |
-class SliderLabel(QtGui.QLabel):
|
|
|
e44045 |
+class SliderLabel(QtWidgets.QLabel):
|
|
|
e44045 |
clicked=QtCore.pyqtSignal()
|
|
|
e44045 |
def __init__(self,label_text,filter_state,parent=None):
|
|
|
e44045 |
super(SliderLabel,self).__init__(parent)
|
|
|
e44045 |
@@ -566,7 +566,7 @@ def subdivide(xs, t_points):
|
|
|
e44045 |
|
|
|
e44045 |
def main():
|
|
|
e44045 |
dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
|
|
|
e44045 |
- app=QtGui.QApplication(sys.argv)
|
|
|
e44045 |
+ app=QtWidgets.QApplication(sys.argv)
|
|
|
e44045 |
qpaeq_main=QPaeq()
|
|
|
e44045 |
qpaeq_main.show()
|
|
|
e44045 |
sys.exit(app.exec_())
|
|
|
e44045 |
--
|
|
|
e44045 |
2.14.3
|
|
|
e44045 |
|