Skip to content

Commit

Permalink
DownloadsTab: Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel committed Aug 17, 2022
1 parent c40fef0 commit 50a37be
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions rare/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ def start_app(self):
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(
Expand Down
6 changes: 3 additions & 3 deletions rare/components/tabs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
Expand Down Expand Up @@ -54,9 +54,9 @@ def __init__(self, parent):
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)
Expand Down
19 changes: 9 additions & 10 deletions rare/components/tabs/account/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,30 @@
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(
Expand Down
19 changes: 3 additions & 16 deletions rare/components/tabs/downloads/__init__.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -230,7 +230,7 @@ def progress_update(self, ui_update: UIUpdate):
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):
Expand All @@ -257,19 +257,6 @@ def get_install_options(self, options: InstallOptionsModel):
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
Expand Down Expand Up @@ -298,7 +285,7 @@ def __init__(self, core: LegendaryCore, app_name: str, parent):
QLabel(
self.tr("Version: <b>")
+ self.igame.version
+ "</b> \u2B9E <b>"
+ "</b> >> <b>"
+ self.game.app_version(self.igame.platform)
+ "</b>"
)
Expand Down
1 change: 1 addition & 0 deletions rare/components/tabs/downloads/download_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def run(self):

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(
{
Expand Down
4 changes: 2 additions & 2 deletions rare/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess
import sys
from logging import getLogger
from typing import List
from typing import List, Union

import qtawesome
import requests
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 50a37be

Please sign in to comment.