1
0
Fork 0
mirror of synced 2024-06-26 10:11:19 +12:00

Use object instead of ctypes.c_uint64 for signals that carry large ints

This commit is contained in:
loathingKernel 2023-03-16 14:04:12 +02:00
parent ae74d3438b
commit c3231d9e17
No known key found for this signature in database
GPG key ID: CE0C72D0B53821FD
4 changed files with 11 additions and 14 deletions

View file

@ -1,6 +1,5 @@
import datetime
import platform
from ctypes import c_uint64
from logging import getLogger
from typing import Union, Optional
@ -202,15 +201,15 @@ class DownloadsTab(QWidget):
RareCore.instance().image_manager().get_pixmap(rgame.app_name, True)
)
@pyqtSlot(UIUpdate, c_uint64)
def __on_download_progress(self, ui_update: UIUpdate, dl_size: c_uint64):
@pyqtSlot(UIUpdate, object)
def __on_download_progress(self, ui_update: UIUpdate, dl_size: int):
self.download_widget.ui.progress_bar.setValue(int(ui_update.progress))
self.download_widget.ui.dl_speed.setText(f"{format_size(ui_update.download_compressed_speed)}/s")
self.download_widget.ui.cache_used.setText(
f"{format_size(ui_update.cache_usage) if ui_update.cache_usage > 1023 else '0KB'}"
)
self.download_widget.ui.downloaded.setText(
f"{format_size(ui_update.total_downloaded)} / {format_size(dl_size.value)}"
f"{format_size(ui_update.total_downloaded)} / {format_size(dl_size)}"
)
self.download_widget.ui.time_left.setText(get_time(ui_update.estimated_time_left))

View file

@ -2,7 +2,6 @@ import os
import platform
import queue
import time
from ctypes import c_uint64
from dataclasses import dataclass
from enum import IntEnum
from logging import getLogger
@ -41,14 +40,14 @@ class DlResultModel:
class DlThread(QThread):
result = pyqtSignal(DlResultModel)
progress = pyqtSignal(UIUpdate, c_uint64)
progress = pyqtSignal(UIUpdate, object)
def __init__(self, item: InstallQueueItemModel, rgame: RareGame, core: LegendaryCore, debug: bool = False):
super(DlThread, self).__init__()
self.dlm_signals: DLManagerSignals = DLManagerSignals()
self.core: LegendaryCore = core
self.item: InstallQueueItemModel = item
self.dl_size = c_uint64(item.download.analysis.dl_size)
self.dl_size = item.download.analysis.dl_size
self.rgame = rgame
self.debug = debug

View file

@ -1,7 +1,6 @@
import os
import platform
import shutil
from ctypes import c_uint64
from logging import getLogger
from typing import Optional
@ -218,8 +217,8 @@ class GameInfo(QWidget, SideTabContents):
worker.signals.error.connect(self.__on_worker_error)
self.rcore.enqueue_worker(self.rgame, worker)
@pyqtSlot(RareGame, int, c_uint64, c_uint64)
def __on_move_progress(self, rgame: RareGame, progress: int, total_size: c_uint64, copied_size: c_uint64):
@pyqtSlot(RareGame, int, object, object)
def __on_move_progress(self, rgame: RareGame, progress: int, total_size: int, copied_size: int):
# lk: the check is NOT REQUIRED because signals are disconnected but protect against it anyway
if rgame is not self.rgame:
return

View file

@ -1,6 +1,5 @@
import os
import shutil
from ctypes import c_uint64
from logging import getLogger
from PyQt5.QtCore import pyqtSignal, QObject
@ -13,10 +12,11 @@ from .worker import QueueWorker, QueueWorkerInfo
logger = getLogger("MoveWorker")
class MoveWorker(QueueWorker):
class Signals(QObject):
# int: percentage, c_uint64: source size, c_uint64: dest size
progress = pyqtSignal(RareGame, int, c_uint64, c_uint64)
# int: percentage, object: source size, object: dest size
progress = pyqtSignal(RareGame, int, object, object)
# str: destination path
result = pyqtSignal(RareGame, str)
# str: error message
@ -38,7 +38,7 @@ class MoveWorker(QueueWorker):
def progress(self, src_size, dst_size):
progress = dst_size * 100 // src_size
self.rgame.signals.progress.update.emit(progress)
self.signals.progress.emit(self.rgame, progress, c_uint64(src_size), c_uint64(dst_size))
self.signals.progress.emit(self.rgame, progress, src_size, dst_size)
def run_real(self):
self.rgame.signals.progress.start.emit()