From 50a37be433639a25117b20ada4658b422ff598ac Mon Sep 17 00:00:00 2001
From: loathingKernel <142770+loathingKernel@users.noreply.github.com>
Date: Sat, 13 Aug 2022 18:53:00 +0300
Subject: [PATCH] DownloadsTab: Remove dead code
---
CONTRIBUTING.md | 10 ++++++++++
rare/app.py | 3 +--
rare/components/tabs/__init__.py | 6 +++---
rare/components/tabs/account/__init__.py | 19 +++++++++----------
rare/components/tabs/downloads/__init__.py | 19 +++----------------
.../tabs/downloads/download_thread.py | 1 +
rare/utils/misc.py | 4 ++--
7 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index da4f8b49..7b8c56b7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -23,3 +23,13 @@ To contribute fork the repository and clone **your** repo: `git clone https://gi
and upload it to GitHub with `git commit -m "message"` and `git push`. Some IDEs like PyCharm can do this automatically.
If you uploaded your changes, create a pull request
+
+# Code Style Guidelines
+
+## Signals and threads
+
+## Function naming
+
+## UI Classes
+
+### Widget and Layout naming
\ No newline at end of file
diff --git a/rare/app.py b/rare/app.py
index b5405b37..46be17fd 100644
--- a/rare/app.py
+++ b/rare/app.py
@@ -167,8 +167,7 @@ class App(RareApp):
logger.info(f"{igame.title} needs verification")
self.mainwindow = MainWindow()
- self.launch_dialog.close()
- self.tray_icon = TrayIcon(self)
+ self.tray_icon: TrayIcon = TrayIcon(self)
self.tray_icon.exit_action.triggered.connect(self.exit_app)
self.tray_icon.start_rare.triggered.connect(self.show_mainwindow)
self.tray_icon.activated.connect(
diff --git a/rare/components/tabs/__init__.py b/rare/components/tabs/__init__.py
index 50db0ba0..a8e62e82 100644
--- a/rare/components/tabs/__init__.py
+++ b/rare/components/tabs/__init__.py
@@ -2,7 +2,7 @@ from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QMenu, QTabWidget, QWidget, QWidgetAction, QShortcut
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton, ArgumentsSingleton
-from rare.components.tabs.account import MiniWidget
+from rare.components.tabs.account import AccountWidget
from rare.components.tabs.downloads import DownloadsTab
from rare.components.tabs.games import GamesTab
from rare.components.tabs.settings import SettingsTab
@@ -54,9 +54,9 @@ class TabWidget(QTabWidget):
self.addTab(self.account, "")
self.setTabEnabled(disabled_tab + 1, False)
- self.mini_widget = MiniWidget()
+ self.account_widget = AccountWidget()
account_action = QWidgetAction(self)
- account_action.setDefaultWidget(self.mini_widget)
+ account_action.setDefaultWidget(self.account_widget)
account_button = TabButtonWidget("mdi.account-circle", "Account", fallback_icon="fa.user")
account_button.setMenu(QMenu())
account_button.menu().addAction(account_action)
diff --git a/rare/components/tabs/account/__init__.py b/rare/components/tabs/account/__init__.py
index 19039eec..2f522b67 100644
--- a/rare/components/tabs/account/__init__.py
+++ b/rare/components/tabs/account/__init__.py
@@ -6,31 +6,30 @@ from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
from rare.utils.misc import icon
-class MiniWidget(QWidget):
+class AccountWidget(QWidget):
def __init__(self):
- super(MiniWidget, self).__init__()
- self.layout = QVBoxLayout()
+ super(AccountWidget, self).__init__()
self.core = LegendaryCoreSingleton()
self.signals = GlobalSignalsSingleton()
- self.layout.addWidget(QLabel("Account"))
+
username = self.core.lgd.userdata.get("display_name")
if not username:
username = "Offline"
- self.layout.addWidget(QLabel(self.tr("Logged in as {}").format(username)))
-
self.open_browser = QPushButton(icon("fa.external-link"), self.tr("Account settings"))
self.open_browser.clicked.connect(
lambda: webbrowser.open(
"https://www.epicgames.com/account/personal?productName=epicgames"
)
)
- self.layout.addWidget(self.open_browser)
-
self.logout_button = QPushButton(self.tr("Logout"))
self.logout_button.clicked.connect(self.logout)
- self.layout.addWidget(self.logout_button)
- self.setLayout(self.layout)
+
+ layout = QVBoxLayout(self)
+ layout.addWidget(QLabel(self.tr("Account")))
+ layout.addWidget(QLabel(self.tr("Logged in as {}").format(username)))
+ layout.addWidget(self.open_browser)
+ layout.addWidget(self.logout_button)
def logout(self):
reply = QMessageBox.question(
diff --git a/rare/components/tabs/downloads/__init__.py b/rare/components/tabs/downloads/__init__.py
index 45661376..26739a26 100644
--- a/rare/components/tabs/downloads/__init__.py
+++ b/rare/components/tabs/downloads/__init__.py
@@ -1,6 +1,6 @@
import datetime
from logging import getLogger
-from typing import List, Dict
+from typing import List, Dict, Union
from PyQt5.QtCore import QThread, pyqtSignal, QSettings, pyqtSlot
from PyQt5.QtWidgets import (
@@ -230,7 +230,7 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
100 * ui_update.total_downloaded // self.analysis.dl_size
)
- def get_time(self, seconds: int) -> str:
+ def get_time(self, seconds: Union[int, float]) -> str:
return str(datetime.timedelta(seconds=seconds))
def on_install_dialog_closed(self, download_item: InstallQueueItemModel):
@@ -257,19 +257,6 @@ class DownloadsTab(QWidget, Ui_DownloadsTab):
install_dialog.result_ready.connect(self.on_install_dialog_closed)
install_dialog.execute()
- def start_download(self, download_item: InstallQueueItemModel):
- downloads = (
- len(self.downloadTab.dl_queue)
- + len(self.downloadTab.update_widgets.keys())
- + 1
- )
- self.setTabText(
- 1, "Downloads" + ((" (" + str(downloads) + ")") if downloads != 0 else "")
- )
- self.setCurrentIndex(1)
- self.downloadTab.install_game(download_item)
- self.games_tab.start_download(download_item.options.app_name)
-
@property
def is_download_active(self):
return self.active_game is not None
@@ -298,7 +285,7 @@ class UpdateWidget(QWidget):
QLabel(
self.tr("Version: ")
+ self.igame.version
- + " \u2B9E "
+ + " >> "
+ self.game.app_version(self.igame.platform)
+ ""
)
diff --git a/rare/components/tabs/downloads/download_thread.py b/rare/components/tabs/downloads/download_thread.py
index 576d5740..5f672558 100644
--- a/rare/components/tabs/downloads/download_thread.py
+++ b/rare/components/tabs/downloads/download_thread.py
@@ -104,6 +104,7 @@ class DownloadThread(QThread):
dlcs = self.core.get_dlc_for_game(self.item.download.igame.app_name)
if dlcs and not self.item.options.skip_dlcs:
+ ret.dlcs = []
for dlc in dlcs:
ret.dlcs.append(
{
diff --git a/rare/utils/misc.py b/rare/utils/misc.py
index 6b56d5b9..4dbe590e 100644
--- a/rare/utils/misc.py
+++ b/rare/utils/misc.py
@@ -4,7 +4,7 @@ import shlex
import subprocess
import sys
from logging import getLogger
-from typing import List
+from typing import List, Union
import qtawesome
import requests
@@ -157,7 +157,7 @@ def get_latest_version():
return "0.0.0"
-def get_size(b: int) -> str:
+def get_size(b: Union[int, float]) -> str:
for i in ["", "K", "M", "G", "T", "P", "E"]:
if b < 1024:
return f"{b:.2f}{i}B"