From b462a07f43907edc87a5a6a845dbf718dff9400a Mon Sep 17 00:00:00 2001 From: Francesco Ceruti Date: Sat, 18 Dec 2021 12:59:59 +0100 Subject: [PATCH] Fix 'float' to 'int' conversion, formatting (#226). --- lisp/core/model.py | 2 +- lisp/core/util.py | 2 +- lisp/layouts/list_layout/listwidgets.py | 2 +- lisp/modules/action_cues/volume_control.py | 2 +- lisp/modules/gst_backend/settings/audio_pan.py | 2 +- lisp/modules/gst_backend/settings/db_meter.py | 4 ++-- lisp/modules/gst_backend/settings/speed.py | 2 +- lisp/modules/gst_backend/settings/volume.py | 2 +- lisp/ui/widgets/qclickslider.py | 2 +- lisp/ui/widgets/qdbmeter.py | 8 ++++---- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lisp/core/model.py b/lisp/core/model.py index 5ef04ab19..a4b647588 100644 --- a/lisp/core/model.py +++ b/lisp/core/model.py @@ -18,7 +18,7 @@ # along with Linux Show Player. If not, see . from abc import abstractmethod -from collections import Sized, Iterable, Container +from collections.abc import Sized, Iterable, Container from lisp.core.signal import Signal diff --git a/lisp/core/util.py b/lisp/core/util.py index 87003c35a..80d492894 100644 --- a/lisp/core/util.py +++ b/lisp/core/util.py @@ -19,7 +19,7 @@ import re import socket -from collections import Mapping +from collections.abc import Mapping from enum import Enum from os import listdir from os.path import isdir, exists, join diff --git a/lisp/layouts/list_layout/listwidgets.py b/lisp/layouts/list_layout/listwidgets.py index cad22d6c4..dc1ec1619 100644 --- a/lisp/layouts/list_layout/listwidgets.py +++ b/lisp/layouts/list_layout/listwidgets.py @@ -115,7 +115,7 @@ def _update_duration(self, duration): self.setTextVisible(True) self.setFormat(strtime(duration, accurate=self.accurate_time)) # Avoid settings min and max to 0, or the the bar go in busy state - self.setRange(0 if duration > 0 else -1, duration) + self.setRange(0 if duration > 0 else -1, int(duration)) else: self.setTextVisible(False) diff --git a/lisp/modules/action_cues/volume_control.py b/lisp/modules/action_cues/volume_control.py index 982df064c..9f682c4cb 100644 --- a/lisp/modules/action_cues/volume_control.py +++ b/lisp/modules/action_cues/volume_control.py @@ -213,7 +213,7 @@ def get_settings(self): if not (checkable and not self.volumeGroup.isCheckable()): conf['volume'] = self.volumeEdit.value() / 100 if not (checkable and not self.fadeGroup.isCheckable()): - conf['duration'] = self.fadeEdit.duration() * 1000 + conf['duration'] = int(self.fadeEdit.duration() * 1000) conf['fade_type'] = self.fadeEdit.fadeType() return conf diff --git a/lisp/modules/gst_backend/settings/audio_pan.py b/lisp/modules/gst_backend/settings/audio_pan.py index 269afa2f2..80647ab60 100644 --- a/lisp/modules/gst_backend/settings/audio_pan.py +++ b/lisp/modules/gst_backend/settings/audio_pan.py @@ -71,7 +71,7 @@ def get_settings(self): return {} def load_settings(self, settings): - self.panSlider.setValue(settings.get('pan', 0.5) * 10) + self.panSlider.setValue(int(settings.get('pan', 0.5) * 10)) def pan_changed(self, value): if value < 0: diff --git a/lisp/modules/gst_backend/settings/db_meter.py b/lisp/modules/gst_backend/settings/db_meter.py index 8906aa28b..c39f844be 100644 --- a/lisp/modules/gst_backend/settings/db_meter.py +++ b/lisp/modules/gst_backend/settings/db_meter.py @@ -86,8 +86,8 @@ def retranslateUi(self): translate('DbMeterSettings', 'Peak falloff (dB/sec)')) def load_settings(self, settings): - self.intervalSpin.setValue(settings.get('interval', 50) / Gst.MSECOND) - self.ttlSpin.setValue(settings.get('peak_ttl', 500) / Gst.MSECOND) + self.intervalSpin.setValue(settings.get('interval', 50) // Gst.MSECOND) + self.ttlSpin.setValue(settings.get('peak_ttl', 500) // Gst.MSECOND) self.falloffSpin.setValue(settings.get('peak_falloff', 20)) def get_settings(self): diff --git a/lisp/modules/gst_backend/settings/speed.py b/lisp/modules/gst_backend/settings/speed.py index 7dba38f52..e9581e4fb 100644 --- a/lisp/modules/gst_backend/settings/speed.py +++ b/lisp/modules/gst_backend/settings/speed.py @@ -75,7 +75,7 @@ def get_settings(self): return {} def load_settings(self, settings): - self.speedSlider.setValue(settings.get('speed', 1) * 100) + self.speedSlider.setValue(int(settings.get('speed', 1) * 100)) def speedChanged(self, value): self.speedLabel.setText(str(value / 100.0)) diff --git a/lisp/modules/gst_backend/settings/volume.py b/lisp/modules/gst_backend/settings/volume.py index 1a6b106c4..6b69d6fdb 100644 --- a/lisp/modules/gst_backend/settings/volume.py +++ b/lisp/modules/gst_backend/settings/volume.py @@ -106,7 +106,7 @@ def get_settings(self): return settings def load_settings(self, settings): - self.volume.setValue(linear_to_db(settings.get('volume', 1)) * 10) + self.volume.setValue(int(linear_to_db(settings.get('volume', 1)) * 10)) self.muteButton.setMute(settings.get('mute', False)) self.normal = settings.get('normal_volume', 1) self.normalLabel.setText( diff --git a/lisp/ui/widgets/qclickslider.py b/lisp/ui/widgets/qclickslider.py index 1cf560bef..8a5905834 100644 --- a/lisp/ui/widgets/qclickslider.py +++ b/lisp/ui/widgets/qclickslider.py @@ -41,7 +41,7 @@ def mousePressEvent(self, e): value += e.x() * (zmax / self.width()) if self.value() != value: - self.setValue(value) + self.setValue(round(value)) self.sliderJumped.emit(self.value()) e.accept() else: diff --git a/lisp/ui/widgets/qdbmeter.py b/lisp/ui/widgets/qdbmeter.py index ae814d652..c583469a1 100644 --- a/lisp/ui/widgets/qdbmeter.py +++ b/lisp/ui/widgets/qdbmeter.py @@ -104,7 +104,7 @@ def paintEvent(self, e): for n, (peak, rms, dPeak) in enumerate(zip(peaks, rmss, dPeaks)): # Maximum "peak-rect" size - maxRect = QtCore.QRect(xpos, self.height() - 2, xdim - 2, + maxRect = QtCore.QRectF(xpos, self.height() - 2, xdim - 2, 2 - self.height()) # Set QLinearGradient start and final-stop position @@ -112,17 +112,17 @@ def paintEvent(self, e): self.grad.setFinalStop(maxRect.bottomRight()) # Draw peak (audio peak in dB) - rect = QtCore.QRect(xpos, self.height() - 2, xdim - 2, -peak) + rect = QtCore.QRectF(xpos, self.height() - 2, xdim - 2, -peak) qp.setOpacity(0.6) qp.fillRect(rect, self.grad) qp.setOpacity(1.0) # Draw rms (in db) - rect = QtCore.QRect(xpos, self.height() - 2, xdim - 2, -rms) + rect = QtCore.QRectF(xpos, self.height() - 2, xdim - 2, -rms) qp.fillRect(rect, self.grad) # Draw decay peak - decRect = QtCore.QRect(xpos, (self.height() - 3) - dPeak, + decRect = QtCore.QRectF(xpos, (self.height() - 3) - dPeak, xdim - 2, 2) qp.fillRect(decRect, self.grad)