1
0
Fork 0
mirror of synced 2024-06-02 10:44:40 +12:00

Reformatting, 1.3.0

This commit is contained in:
Dummerle 2021-04-22 14:34:06 +02:00
parent 2149af4546
commit 6deabf4a92
23 changed files with 77 additions and 71 deletions

View file

@ -1,5 +1,5 @@
import os
__version__ = "1.2.1"
__version__ = "1.3.0"
style_path = os.path.join(os.path.dirname(__file__), "styles/")
lang_path = os.path.join(os.path.dirname(__file__), "languages/")

View file

@ -3,8 +3,8 @@ import os
from PyQt5.QtWidgets import QDialog, QFormLayout, QVBoxLayout, QSpinBox, QFileDialog, QLabel, QPushButton, QHBoxLayout, \
QCheckBox
from rare.utils.extra_widgets import PathEdit
from custom_legendary.core import LegendaryCore
from rare.utils.extra_widgets import PathEdit
class InstallDialog(QDialog):
@ -107,4 +107,3 @@ class InstallInfoDialog(QDialog):
def cancel(self):
self.accept = False
self.close()

View file

@ -1,13 +1,12 @@
from logging import getLogger
from requests.exceptions import ConnectionError
from PyQt5.QtCore import QThread, pyqtSignal
from PyQt5.QtWidgets import QDialog, QLabel, QProgressBar, QVBoxLayout
from requests.exceptions import ConnectionError
from custom_legendary.core import LegendaryCore
from rare.components.dialogs.login import LoginDialog
from rare.utils.utils import download_images
from custom_legendary.core import LegendaryCore
logger = getLogger("Login")

View file

@ -1,9 +1,9 @@
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QStackedLayout, QWidget, QPushButton
from custom_legendary.core import LegendaryCore
# Login Opportunities: Browser, Import
from rare.components.dialogs.login.browser_login import BrowserLogin
from rare.components.dialogs.login.import_widget import ImportWidget
from custom_legendary.core import LegendaryCore
class LoginDialog(QDialog):

View file

@ -54,7 +54,7 @@ class TabWidget(QTabWidget):
account_button = TabButtonWidget(core, 'mdi.account-circle', 'Account')
account_button.setMenu(QMenu())
account_button.menu().addAction(account_action)
self.tabBar().setTabButton(disabled_tab+1, self.tabBar().RightSide, account_button)
self.tabBar().setTabButton(disabled_tab + 1, self.tabBar().RightSide, account_button)
self.addTab(self.settings, icon("fa.gear", color='white'),
"(!)" if self.settings.about.update_available else "")

View file

@ -6,14 +6,14 @@ from PyQt5.QtCore import QThread, pyqtSignal, Qt, QSettings
from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar, QPushButton, QDialog, \
QListWidget, QHBoxLayout, QGroupBox
from rare.components.dialogs.install_dialog import InstallInfoDialog, InstallDialog
from rare.components.tabs.downloads.dl_queue_widget import DlQueueWidget
from rare.components.tabs.downloads.download_thread import DownloadThread
from rare.utils.models import InstallOptions
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.components.dialogs.install_dialog import InstallInfoDialog, InstallDialog
from rare.components.tabs.downloads.dl_queue_widget import DlQueueWidget
from rare.components.tabs.downloads.download_thread import DownloadThread
from rare.utils.models import InstallOptions
from rare.utils.utils import get_size
logger = getLogger("Download")
@ -239,7 +239,7 @@ class DownloadTab(QWidget):
self.queue_widget.update_queue(self.dl_queue)
elif text[:5] == "error":
QMessageBox.warning(self, "warn", "Download error: "+text[6:])
QMessageBox.warning(self, "warn", "Download error: " + text[6:])
elif text == "stop":
self.reset_infos()
@ -262,7 +262,8 @@ class DownloadTab(QWidget):
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": {get_size(ui_update.total_downloaded)} / {get_size(self.analysis.dl_size)}")
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:
@ -301,4 +302,4 @@ class UpdateWidget(QWidget):
def update_game(self):
self.update_button.setDisabled(True)
self.update.emit(self.game.app_name)
self.update.emit(self.game.app_name)

View file

@ -63,7 +63,8 @@ class DownloadThread(QThread):
# clean up all the queues, otherwise this process won't terminate properly
for name, q in zip(('Download jobs', 'Writer jobs', 'Download results', 'Writer results'),
(self.dlm.dl_worker_queue, self.dlm.writer_queue, self.dlm.dl_result_q, self.dlm.writer_result_q)):
(self.dlm.dl_worker_queue, self.dlm.writer_queue, self.dlm.dl_result_q,
self.dlm.writer_result_q)):
logger.debug(f'Cleaning up queue "{name}"')
try:
while True:
@ -111,7 +112,7 @@ class DownloadThread(QThread):
except Exception as e:
logger.error(f"Installation failed after {time.time() - start_time:.02f} seconds: {e}")
self.status.emit("error "+str(e))
self.status.emit("error " + str(e))
return
else:
@ -172,4 +173,3 @@ class DownloadThread(QThread):
def kill(self):
self._kill = True

View file

@ -6,16 +6,15 @@ from PyQt5.QtWidgets import QWidget, QPushButton, QVBoxLayout, QLabel, QHBoxLayo
QProgressBar, QStackedWidget, QGroupBox, QScrollArea
from qtawesome import icon
from rare.components.tabs.games.game_info.dlcs import DlcTab
from rare.utils import legendary_utils
from rare.components.dialogs.uninstall_dialog import UninstallDialog
from rare.components.tabs.games.game_info.game_settings import GameSettings
from rare.utils.legendary_utils import VerifyThread
from rare.utils.extra_widgets import SideTabBar
from rare.utils.utils import IMAGE_DIR, get_size, create_desktop_link
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame, Game
from rare.components.dialogs.uninstall_dialog import UninstallDialog
from rare.components.tabs.games.game_info.dlcs import DlcTab
from rare.components.tabs.games.game_info.game_settings import GameSettings
from rare.utils import legendary_utils
from rare.utils.extra_widgets import SideTabBar
from rare.utils.legendary_utils import VerifyThread
from rare.utils.utils import IMAGE_DIR, get_size
class InfoTabs(QTabWidget):

View file

@ -2,7 +2,7 @@ import os
from PyQt5.QtCore import pyqtSignal, QSettings
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout, QScrollArea, QWidget, QLabel, QPushButton, QMessageBox
from PyQt5.QtWidgets import QGroupBox, QHBoxLayout, QVBoxLayout, QScrollArea, QLabel, QPushButton, QMessageBox
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import Game
@ -71,7 +71,8 @@ class DlcTab(QScrollArea):
def install(self, app_name):
if not self.core.is_installed(self.game.app_name):
QMessageBox.warning(self, "Error", self.tr("Base Game is not installed. Please install {} first").format(self.game.app_title))
QMessageBox.warning(self, "Error", self.tr("Base Game is not installed. Please install {} first").format(
self.game.app_title))
return
infos = InstallDialog(self.game.app_name, self.core, True).get_information()
if infos != 0:

View file

@ -45,7 +45,8 @@ class GameSettings(QScrollArea):
self.launch_params_widget = SettingsWidget(self.tr("Launch parameters"), self.launch_params,
self.launch_params_accept_button)
self.layout.addWidget(self.launch_params_widget)
self.launch_params_accept_button.clicked.connect(lambda: self.save_line_edit("start_params", self.launch_params.text()))
self.launch_params_accept_button.clicked.connect(
lambda: self.save_line_edit("start_params", self.launch_params.text()))
self.cloud_sync = QCheckBox("Sync with cloud")
self.cloud_sync_widget = SettingsWidget(self.tr("Auto sync with cloud"), self.cloud_sync)

View file

@ -101,8 +101,6 @@ class GameList(QStackedWidget):
list_widget.finish_signal.connect(self.finished)
list_widget.update_list.connect(lambda: self.update_list(self.settings.value("icon_view", True, bool)))
if icon_widget.update_available:
self.updates.append(igame)
@ -251,8 +249,8 @@ class GameList(QStackedWidget):
uninstalled_games.append(game.app_name)
# get new uninstalled/ installed games that changed
new_installed_games = list(set(installed)-set([i.app_name for i in self.installed]))
new_uninstalled_games = list(set(uninstalled_games)-set([i.app_name for i in self.uninstalled_games]))
new_installed_games = list(set(installed) - set([i.app_name for i in self.installed]))
new_uninstalled_games = list(set(uninstalled_games) - set([i.app_name for i in self.uninstalled_games]))
if not new_uninstalled_games and not new_installed_games:
return

View file

@ -1,3 +1,4 @@
import logging
import os
from logging import getLogger
@ -66,7 +67,7 @@ class BaseInstalledWidget(QGroupBox):
path = os.path.expanduser("~/.local/share/applications/")
else:
return
if not (os.path.exists(os.path.expanduser(f"{path}{self.igame.title}.desktop")) \
if not (os.path.exists(os.path.expanduser(f"{path}{self.igame.title}.desktop"))
or os.path.exists(os.path.expanduser(f"{path}{self.igame.title}.lnk"))):
create_desktop_link(self.igame.app_name, self.core, type_of_link)
if type_of_link == "desktop":
@ -93,7 +94,8 @@ class BaseInstalledWidget(QGroupBox):
logger.info("Launching " + self.igame.title)
if offline or self.offline:
if not self.igame.can_run_offline:
QMessageBox.warning(self, "Offline", self.tr("Game cannot run offline. Please start game in Online mode"))
QMessageBox.warning(self, "Offline",
self.tr("Game cannot run offline. Please start game in Online mode"))
return
try:
@ -127,7 +129,7 @@ class BaseInstalledWidget(QGroupBox):
def stderr(self):
stderr = bytes(self.proc.readAllStandardError()).decode("utf-8")
self.game_logger.error(stderr)
QMessageBox.warning(self, "Warning", stderr)
QMessageBox.warning(self, "Warning", stderr + "\nSee ~/.cache/rare/logs/")
def finished(self, exit_code):
logger.info("Game exited with exit code: " + str(exit_code))

View file

@ -1,7 +1,7 @@
from logging import getLogger
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QGroupBox
from PyQt5.QtWidgets import QGroupBox
from rare.components.dialogs.install_dialog import InstallDialog
from rare.utils.models import InstallOptions
@ -25,4 +25,6 @@ class BaseUninstalledWidget(QGroupBox):
infos = InstallDialog(self.game.app_name, self.core).get_information()
if infos != 0:
path, max_workers, force, ignore_free_space = infos
self.install_game.emit(InstallOptions(app_name=self.game.app_name, max_workers=max_workers, path=path, force=force, ignore_free_space=ignore_free_space))
self.install_game.emit(
InstallOptions(app_name=self.game.app_name, max_workers=max_workers, path=path, force=force,
ignore_free_space=ignore_free_space))

View file

@ -1,16 +1,14 @@
import os
from logging import getLogger
from PyQt5.QtCore import QEvent, pyqtSignal, QSettings, QSize, Qt
from PyQt5.QtCore import QEvent, pyqtSignal, QSize, Qt
from PyQt5.QtGui import QMouseEvent
from PyQt5.QtWidgets import *
from qtawesome import icon
from rare.components.tabs.games.game_widgets.base_installed_widget import BaseInstalledWidget
from rare.utils import legendary_utils
from rare.utils.extra_widgets import ClickableLabel
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame
from rare.components.tabs.games.game_widgets.base_installed_widget import BaseInstalledWidget
from rare.utils.extra_widgets import ClickableLabel
logger = getLogger("GameWidgetInstalled")
@ -112,4 +110,4 @@ class GameWidgetInstalled(BaseInstalledWidget):
desktop_link = menu.addAction("Add Desktop link")
action = menu.exec_(self.mapToGlobal(event.pos()))
if action == desktop_link:
print("LOL")"""
print("LOL")"""

View file

@ -2,12 +2,12 @@ import os
from logging import getLogger
from PyQt5.QtCore import QProcess, pyqtSignal, Qt
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QPushButton, QStyle, QVBoxLayout, QAction
from PyQt5.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout
from qtawesome import icon
from rare.components.tabs.games.game_widgets.base_installed_widget import BaseInstalledWidget
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import InstalledGame
from rare.components.tabs.games.game_widgets.base_installed_widget import BaseInstalledWidget
logger = getLogger("GameWidget")
@ -23,8 +23,6 @@ class InstalledListWidget(BaseInstalledWidget):
self.size = game.install_size
self.launch_params = game.launch_parameters
self.layout = QHBoxLayout()
##Layout on the right
@ -59,7 +57,7 @@ class InstalledListWidget(BaseInstalledWidget):
self.childLayout.addWidget(self.app_name_label)
self.childLayout.addWidget(self.developer_label)
#if os.name != "nt":
# if os.name != "nt":
# self.childLayout.addWidget(self.wine_rating)
self.childLayout.addWidget(self.version_label)
self.childLayout.addWidget(self.size_label)

View file

@ -3,11 +3,11 @@ from logging import getLogger
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QVBoxLayout, QLabel
from rare.components.tabs.games.game_widgets.base_uninstalled_widget import BaseUninstalledWidget
from rare.utils.models import InstallOptions
from rare.utils.extra_widgets import ClickableLabel
from custom_legendary.core import LegendaryCore
from custom_legendary.models.game import Game
from rare.components.tabs.games.game_widgets.base_uninstalled_widget import BaseUninstalledWidget
from rare.utils.extra_widgets import ClickableLabel
from rare.utils.models import InstallOptions
logger = getLogger("Uninstalled")

View file

@ -2,8 +2,8 @@ from logging import getLogger
from PyQt5.QtWidgets import QLabel, QHBoxLayout, QVBoxLayout, QPushButton
from rare.components.tabs.games.game_widgets.base_uninstalled_widget import BaseUninstalledWidget
from custom_legendary.core import LegendaryCore
from rare.components.tabs.games.game_widgets.base_uninstalled_widget import BaseUninstalledWidget
logger = getLogger("Game")

View file

@ -8,9 +8,9 @@ from PyQt5.QtWidgets import QWidget, QLabel, QHBoxLayout, QPushButton, QVBoxLayo
QGroupBox
from qtawesome import icon
from custom_legendary.core import LegendaryCore
from rare.utils import legendary_utils
from rare.utils.extra_widgets import PathEdit
from custom_legendary.core import LegendaryCore
logger = getLogger("Import")
@ -43,7 +43,8 @@ class ImportWidget(QWidget):
self.import_game_info = QLabel(self.tr("Select path to game"))
self.gb_layout.addWidget(self.import_game_info)
self.override_app_name_label = QLabel(self.tr("Override app name (Only if imported game from legendary or the app could not find the app name)"))
self.override_app_name_label = QLabel(
self.tr("Override app name (Only if imported game from legendary or the app could not find the app name)"))
self.override_app_name_label.setWordWrap(True)
self.app_name_input = QLineEdit()
self.app_name_input.setFixedHeight(32)
@ -86,9 +87,9 @@ class ImportWidget(QWidget):
def app_name_changed(self, text):
if text in self.game_list:
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16,16))
self.indicator_label.setPixmap(icon("ei.ok-sign", color="green").pixmap(16, 16))
else:
self.indicator_label.setPixmap(icon("ei.remove-sign", color="red").pixmap(16,16))
self.indicator_label.setPixmap(icon("ei.remove-sign", color="red").pixmap(16, 16))
def path_changed(self, path):
if os.path.exists(path):
@ -120,7 +121,8 @@ class ImportWidget(QWidget):
return
if legendary_utils.import_game(self.core, app_name=app_name, path=path):
self.info_label.setText(self.tr("Successfully imported {}. Reload library").format(self.core.get_installed_game(app_name).title))
self.info_label.setText(self.tr("Successfully imported {}. Reload library").format(
self.core.get_installed_game(app_name).title))
self.app_name_input.setText("")
self.update_list.emit()
@ -165,7 +167,8 @@ class ImportWidget(QWidget):
for wine_prefix in possible_wineprefixes:
imported += self.auto_import_games(os.path.join(wine_prefix, "drive_c/Program Files/Epic Games/"))
if imported > 0:
QMessageBox.information(self, "Imported Games", self.tr("Successfully imported {} Games. Reloading Library").format(imported))
QMessageBox.information(self, "Imported Games",
self.tr("Successfully imported {} Games. Reloading Library").format(imported))
self.update_list.emit()
else:
QMessageBox.information(self, "Imported Games", self.tr("No Games were found"))

View file

@ -2,12 +2,12 @@ from logging import getLogger
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIntValidator
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QFileDialog, QPushButton, QLineEdit, QGroupBox, QMessageBox, \
from PyQt5.QtWidgets import QVBoxLayout, QFileDialog, QPushButton, QLineEdit, QGroupBox, QMessageBox, \
QScrollArea
from custom_legendary.core import LegendaryCore
from rare.components.tabs.settings.settings_widget import SettingsWidget
from rare.utils.extra_widgets import PathEdit
from custom_legendary.core import LegendaryCore
from rare.utils.utils import get_size
logger = getLogger("LegendarySettings")
@ -42,7 +42,7 @@ class LegendarySettings(QScrollArea):
self.max_worker_select)
self.layout.addWidget(self.max_worker_widget)
#cleanup
# cleanup
self.clean_layout = QVBoxLayout()
self.cleanup_widget = QGroupBox(self.tr("Cleanup"))
self.clean_button = QPushButton(self.tr("Remove everything"))
@ -97,7 +97,8 @@ class LegendarySettings(QScrollArea):
after = self.core.lgd.get_dir_size()
logger.info(f'Cleanup complete! Removed {(before - after) / 1024 / 1024:.02f} MiB.')
if (before-after) > 0:
QMessageBox.information(self, "Cleanup", self.tr("Cleanup complete! Successfully removed {}").format(get_size(before-after)))
if (before - after) > 0:
QMessageBox.information(self, "Cleanup", self.tr("Cleanup complete! Successfully removed {}").format(
get_size(before - after)))
else:
QMessageBox.information(self, "Cleanup", "Nothing to clean")

View file

@ -1,11 +1,11 @@
from logging import getLogger
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel, QPushButton, QFileDialog, QLineEdit, QGroupBox
from PyQt5.QtWidgets import QVBoxLayout, QPushButton, QFileDialog, QLineEdit, QGroupBox
from custom_legendary.core import LegendaryCore
from rare.components.tabs.settings.dxvk import DxvkWidget
from rare.components.tabs.settings.settings_widget import SettingsWidget
from rare.utils.extra_widgets import PathEdit
from custom_legendary.core import LegendaryCore
logger = getLogger("LinuxSettings")

View file

@ -28,10 +28,13 @@ class RareSettings(QScrollArea):
self.setWidgetResizable(True)
# (option_name, group_text, checkbox_text, default
self.checkboxes = [("sys_tray", self.tr("Hide to System Tray Icon"), self.tr("Exit to System Tray Icon"), True),
("auto_update", self.tr("Automatically update Games on startup"), self.tr("Auto updates"), False),
("confirm_start", self.tr("Confirm launch of game"), self.tr("Confirm launch of game"), False),
("auto_update", self.tr("Automatically update Games on startup"), self.tr("Auto updates"),
False),
("confirm_start", self.tr("Confirm launch of game"), self.tr("Confirm launch of game"),
False),
("auto_sync_cloud", self.tr("Auto sync with cloud"), self.tr("Sync with cloud"), True),
("notification", self.tr("Show Notifications after Downloads"), self.tr("Show notification"), True),
("notification", self.tr("Show Notifications after Downloads"), self.tr("Show notification"),
True),
("save_size", self.tr("Save size of window after restart"), self.tr("Save size"), False)
]

View file

@ -38,4 +38,4 @@ class RPCSettings(QGroupBox):
def changed(self, i):
self.settings.setValue("rpc_enable", i)
self.update_settings.emit()
self.update_settings.emit()

View file

@ -1,12 +1,13 @@
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QSystemTrayIcon, QMenu, QAction
from rare import style_path
class TrayIcon(QSystemTrayIcon):
def __init__(self, parent):
super(TrayIcon, self).__init__(parent)
self.setIcon(QIcon(style_path+"Logo.png"))
self.setIcon(QIcon(style_path + "Logo.png"))
self.setVisible(True)
self.setToolTip("Rare")