From 452bba954c30d5a642f03c02411529f511bda786 Mon Sep 17 00:00:00 2001
From: Louis Sautier <sautier.louis@gmail.com>
Date: Fri, 27 Aug 2021 00:43:48 +0200
Subject: [PATCH] Fix TypeErrors with Python 3.10

Without these changes, running Picard with Python 3.10 results in errors
such as:
  File "./picard/ui/coverartbox.py", line 74, in __init__
    self.shadow = self.shadow.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
TypeError: arguments did not match any overloaded call:
  scaled(self, int, int, aspectRatioMode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio, transformMode: Qt.TransformationMode = Qt.FastTransformation): argument 1 has unexpected type 'float'
  scaled(self, QSize, aspectRatioMode: Qt.AspectRatioMode = Qt.IgnoreAspectRatio, transformMode: Qt.TransformationMode = Qt.FastTransformation): argument 1 has unexpected type 'float'
---
 picard/ui/coverartbox.py | 2 +-
 picard/ui/itemviews.py   | 6 +++---
 picard/util/__init__.py  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/picard/ui/coverartbox.py b/picard/ui/coverartbox.py
index c3eb4ddb74..f3a174664b 100644
--- a/picard/ui/coverartbox.py
+++ b/picard/ui/coverartbox.py
@@ -135,7 +135,7 @@ def dropEvent(self, event):
             event.acceptProposedAction()
 
     def scaled(self, *dimensions):
-        return (self.pixel_ratio * dimension for dimension in dimensions)
+        return (round(self.pixel_ratio * dimension) for dimension in dimensions)
 
     def show(self):
         self.set_data(self.data, True)
diff --git a/picard/ui/itemviews.py b/picard/ui/itemviews.py
index cffab6d70d..d1101b340f 100644
--- a/picard/ui/itemviews.py
+++ b/picard/ui/itemviews.py
@@ -141,9 +141,9 @@ def get_match_color(similarity, basecolor):
     c1 = (basecolor.red(), basecolor.green(), basecolor.blue())
     c2 = (223, 125, 125)
     return QtGui.QColor(
-        c2[0] + (c1[0] - c2[0]) * similarity,
-        c2[1] + (c1[1] - c2[1]) * similarity,
-        c2[2] + (c1[2] - c2[2]) * similarity)
+        int(c2[0] + (c1[0] - c2[0]) * similarity),
+        int(c2[1] + (c1[1] - c2[1]) * similarity),
+        int(c2[2] + (c1[2] - c2[2]) * similarity))
 
 
 class MainPanel(QtWidgets.QSplitter):
diff --git a/picard/util/__init__.py b/picard/util/__init__.py
index 3a4765f7cd..26f7576f56 100644
--- a/picard/util/__init__.py
+++ b/picard/util/__init__.py
@@ -400,7 +400,7 @@ def throttled_func(*args, **kwargs):
             else:
                 decorator.args = args
                 decorator.kwargs = kwargs
-                QtCore.QTimer.singleShot(r, later)
+                QtCore.QTimer.singleShot(int(r), later)
                 decorator.is_ticking = True
             mutex.unlock()
 
