Fix methods that need int as argument and not float.

This commit is contained in:
Sandro Knauß 2024-03-06 18:49:59 +01:00
parent 5bd00429f7
commit 74c857de56
3 changed files with 11 additions and 9 deletions

View File

@ -624,9 +624,11 @@ class ToggleCheckbox(QtWidgets.QCheckBox):
x = (
rect.width() - rect.x() - self.w + 20
) # 20 is the padding between text and toggle
x = int(x)
y = (
self.height() / 2 - self.h / 2 + 16
) # 16 is the padding top for the checkbox
y = int(y)
self.toggleRect = QtCore.QRect(x, y, self.w, self.h)
painter.setBrush(QtGui.QColor(self.bg_color))
painter.drawRoundedRect(x, y, self.w, self.h, self.h / 2, self.h / 2)

View File

@ -121,7 +121,7 @@ class ShareHistoryItem(HistoryItem):
self.progress_bar.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.progress_bar.setAlignment(QtCore.Qt.AlignHCenter)
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(total_bytes / 1024)
self.progress_bar.setMaximum(total_bytes // 1024)
self.progress_bar.setValue(0)
self.progress_bar.setStyleSheet(
self.common.gui.css["downloads_uploads_progress_bar"]
@ -140,7 +140,7 @@ class ShareHistoryItem(HistoryItem):
def update(self, downloaded_bytes):
self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes / 1024)
self.progress_bar.setValue(downloaded_bytes // 1024)
if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024):
pb_fmt = strings._("gui_all_modes_progress_complete").format(
self.common.format_seconds(time.time() - self.started)
@ -392,8 +392,8 @@ class ReceiveHistoryItem(HistoryItem):
total_uploaded_bytes += data["progress"][filename]["uploaded_bytes"]
# Update the progress bar
self.progress_bar.setMaximum(self.content_length / 1024)
self.progress_bar.setValue(total_uploaded_bytes / 1024)
self.progress_bar.setMaximum(self.content_length // 1024)
self.progress_bar.setValue(total_uploaded_bytes // 1024)
elapsed = datetime.now() - self.started
if elapsed.seconds < 10:
@ -526,7 +526,7 @@ class IndividualFileHistoryItem(HistoryItem):
else:
self.total_bytes = data["filesize"]
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(data["filesize"] / 1024)
self.progress_bar.setMaximum(data["filesize"] // 1024)
self.progress_bar.total_bytes = data["filesize"]
# Start at 0
@ -535,7 +535,7 @@ class IndividualFileHistoryItem(HistoryItem):
def update(self, downloaded_bytes):
self.downloaded_bytes = downloaded_bytes
self.progress_bar.setValue(downloaded_bytes / 1024)
self.progress_bar.setValue(downloaded_bytes // 1024)
if (downloaded_bytes / 1024) == (self.progress_bar.total_bytes / 1024):
self.status_code_label.setText("200")
self.status_code_label.setStyleSheet(

View File

@ -69,11 +69,11 @@ class NewTabButton(QtWidgets.QPushButton):
self.title_label.setStyleSheet(self.common.gui.css["new_tab_title_text"])
if self.title_label.sizeHint().width() >= 250:
self.title_label.setGeometry(
(self.width() - 250) / 2, self.height() - 120, 250, 60
(self.width() - 250) // 2, self.height() - 120, 250, 60
)
else:
self.title_label.setGeometry(
(self.width() - 250) / 2, self.height() - 100, 250, 30
(self.width() - 250) // 2, self.height() - 100, 250, 30
)
self.title_label.show()
@ -82,7 +82,7 @@ class NewTabButton(QtWidgets.QPushButton):
self.text_label.setAlignment(QtCore.Qt.AlignCenter)
self.text_label.setStyleSheet(self.common.gui.css["new_tab_button_text"])
self.text_label.setGeometry(
(self.width() - 200) / 2, self.height() - 50, 200, 30
(self.width() - 200) // 2, self.height() - 50, 200, 30
)
self.text_label.show()