1
0
Fork 0
mirror of synced 2024-04-24 15:52:25 +12:00

DownloadsTab: Remove dead code

This commit is contained in:
loathingKernel 2022-08-13 18:53:00 +03:00
parent c40fef0595
commit 50a37be433
7 changed files with 29 additions and 33 deletions

View file

@ -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

View file

@ -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(

View file

@ -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)

View file

@ -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 <b>{}</b>").format(username)))
layout.addWidget(self.open_browser)
layout.addWidget(self.logout_button)
def logout(self):
reply = QMessageBox.question(

View file

@ -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: <b>")
+ self.igame.version
+ "</b> \u2B9E <b>"
+ "</b> >> <b>"
+ self.game.app_version(self.igame.platform)
+ "</b>"
)

View file

@ -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(
{

View file

@ -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"