1
0
Fork 0
mirror of synced 2024-06-17 01:54:46 +12:00

Show size in gb or mb

This commit is contained in:
Dummerle 2021-04-11 21:02:56 +02:00
parent a34be7614b
commit dc2f622013
4 changed files with 13 additions and 5 deletions

View file

@ -71,8 +71,6 @@ class App(QApplication):
self.setStyleSheet(open(style_path + "RareStyle.qss").read())
self.setWindowIcon(QIcon(style_path + "Logo.png"))
# tray icon
# launch app
self.launch_dialog = LaunchDialog(self.core)
self.launch_dialog.start_app.connect(self.start_app)

View file

@ -14,6 +14,7 @@ from custom_legendary.core import LegendaryCore
from custom_legendary.models.downloading import UIUpdate
from custom_legendary.models.game import Game, InstalledGame
from custom_legendary.utils.selective_dl import games
from rare.utils.utils import get_size
logger = getLogger("Download")
@ -145,6 +146,7 @@ class DownloadTab(QWidget):
self.thread.statistics.connect(self.statistics)
self.thread.start()
self.kill_button.setDisabled(False)
self.analysis = analysis
self.installing_game.setText(self.tr("Installing Game: ") + self.active_game.app_title)
def sdl_prompt(self, app_name: str = '', title: str = '') -> list:
@ -242,12 +244,13 @@ class DownloadTab(QWidget):
self.time_left.setText("")
self.cache_used.setText("")
self.downloaded.setText("")
self.analysis = None
def statistics(self, ui_update: UIUpdate):
self.prog_bar.setValue(ui_update.progress)
self.dl_speed.setText(self.tr("Download speed") + f": {ui_update.download_speed / 1024 / 1024:.02f}MB/s")
self.cache_used.setText(self.tr("Cache used") + f": {ui_update.cache_usage / 1024 / 1024:.02f}MB")
self.downloaded.setText(self.tr("Downloaded") + f": {ui_update.total_downloaded / 1024 / 1024:.02f}MB")
self.downloaded.setText(self.tr("Downloaded") + f": {get_size(ui_update.total_downloaded)} / {get_size(self.analysis.dl_size)}")
self.time_left.setText(self.tr("Time left: ") + self.get_time(ui_update.estimated_time_left))
def get_time(self, seconds: int) -> str:

View file

@ -11,7 +11,7 @@ from rare.components.tabs.games.game_info.game_settings import GameSettings
from rare.utils import legendary_utils
from rare.utils.legendary_utils import VerifyThread
from rare.utils.extra_widgets import SideTabBar
from rare.utils.utils import IMAGE_DIR
from rare.utils.utils import IMAGE_DIR, get_size
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame, Game
@ -168,7 +168,7 @@ class GameInfo(QScrollArea):
self.version.setText("Version: " + self.game.app_version)
self.dev.setText(self.tr("Developer: ") + self.game.metadata["developer"])
self.install_size.setText(
self.tr("Install size: ") + str(round(self.igame.install_size / (1024 ** 3), 2)) + " GB")
self.tr("Install size: ") + get_size(self.igame.install_size))
self.install_path.setText(self.tr("Install path: ") + self.igame.install_path)
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(app_name):

View file

@ -124,3 +124,10 @@ def get_latest_version():
resp = requests.get("https://api.github.com/repos/Dummerle/Rare/releases/latest")
tag = json.loads(resp.content.decode("utf-8"))["tag_name"]
return tag
def get_size(b: int) -> str:
for i in ['', 'K', 'M', 'G', 'T', 'P', 'E']:
if b < 1024:
return f"{b:.2f}{i}B"
b /= 1024