1
0
Fork 0
mirror of synced 2024-06-26 18:20:50 +12:00

Move a bunch of class attributes to instance attributes

This commit is contained in:
loathingKernel 2022-09-07 15:35:51 +03:00
parent 9ca879e0fc
commit 5029921b09
6 changed files with 18 additions and 22 deletions

View file

@ -71,6 +71,7 @@ class App(RareApp):
# set Application name for settings # set Application name for settings
self.mainwindow: Optional[MainWindow] = None self.mainwindow: Optional[MainWindow] = None
self.launch_dialog: Optional[LaunchDialog] = None self.launch_dialog: Optional[LaunchDialog] = None
self.timer = QTimer()
# launch app # launch app
self.launch_dialog = LaunchDialog(parent=None) self.launch_dialog = LaunchDialog(parent=None)
@ -84,7 +85,6 @@ class App(RareApp):
dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1]) dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1])
dt_now = datetime.utcnow() dt_now = datetime.utcnow()
td = abs(dt_exp - dt_now) td = abs(dt_exp - dt_now)
self.timer = QTimer()
self.timer.timeout.connect(self.re_login) self.timer.timeout.connect(self.re_login)
self.timer.start(int(td.total_seconds() - 60) * 1000) self.timer.start(int(td.total_seconds() - 60) * 1000)

View file

@ -309,6 +309,9 @@ class InstallDialog(QDialog):
self.show() self.show()
def error_box(self, label: str = "", message: str = ""): def error_box(self, label: str = "", message: str = ""):
if message.startswith("403 Client Error: Forbidden for url:"):
message = self.tr("403 Client Error: Wait a few seconds and try <b>Verify</b> again")
self.options_changed = True
self.ui.warn_label.setVisible(bool(label)) self.ui.warn_label.setVisible(bool(label))
self.ui.warn_label.setText(label) self.ui.warn_label.setText(label)
self.ui.warn_message.setVisible(bool(message)) self.ui.warn_message.setVisible(bool(message))

View file

@ -11,7 +11,7 @@ from rare.shared import LegendaryCoreSingleton, ArgumentsSingleton, ApiResultsSi
from rare.ui.components.dialogs.launch_dialog import Ui_LaunchDialog from rare.ui.components.dialogs.launch_dialog import Ui_LaunchDialog
from rare.utils.misc import CloudWorker from rare.utils.misc import CloudWorker
logger = getLogger("LoginDialog") logger = getLogger("LaunchDialog")
class LaunchWorker(QRunnable): class LaunchWorker(QRunnable):

View file

@ -12,7 +12,7 @@ from rare.widgets.sliding_stack import SlidingStackedWidget
from .browser_login import BrowserLogin from .browser_login import BrowserLogin
from .import_login import ImportLogin from .import_login import ImportLogin
logger = getLogger("Login") logger = getLogger("LoginDialog")
@dataclass @dataclass

View file

@ -1,16 +1,16 @@
from logging import getLogger from logging import getLogger
from typing import Tuple, Dict, Union, List from typing import Tuple, Dict, Union, List, Set
from PyQt5.QtCore import QSettings, Qt, pyqtSlot from PyQt5.QtCore import QSettings, Qt, pyqtSlot
from PyQt5.QtWidgets import QStackedWidget, QVBoxLayout, QWidget, QScrollArea, QFrame from PyQt5.QtWidgets import QStackedWidget, QVBoxLayout, QWidget, QScrollArea, QFrame
from legendary.models.game import InstalledGame, Game from legendary.models.game import InstalledGame, Game
from rare.shared import ImageManagerSingleton
from rare.shared import ( from rare.shared import (
LegendaryCoreSingleton, LegendaryCoreSingleton,
GlobalSignalsSingleton, GlobalSignalsSingleton,
ArgumentsSingleton, ArgumentsSingleton,
ApiResultsSingleton, ApiResultsSingleton,
ImageManagerSingleton,
) )
from rare.widgets.library_layout import LibraryLayout from rare.widgets.library_layout import LibraryLayout
from rare.widgets.sliding_stack import SlidingStackedWidget from rare.widgets.sliding_stack import SlidingStackedWidget
@ -32,10 +32,6 @@ logger = getLogger("GamesTab")
class GamesTab(QStackedWidget): class GamesTab(QStackedWidget):
updates = set()
active_filter = 0
def __init__(self, parent=None): def __init__(self, parent=None):
super(GamesTab, self).__init__(parent=parent) super(GamesTab, self).__init__(parent=parent)
self.core = LegendaryCoreSingleton() self.core = LegendaryCoreSingleton()
@ -47,6 +43,8 @@ class GamesTab(QStackedWidget):
self.widgets: Dict[str, Tuple[ self.widgets: Dict[str, Tuple[
Union[InstalledIconWidget, UninstalledIconWidget], Union[InstalledListWidget, UninstalledListWidget]]] = {} Union[InstalledIconWidget, UninstalledIconWidget], Union[InstalledListWidget, UninstalledListWidget]]] = {}
self.updates: Set = set()
self.active_filter: int = 0
self.uninstalled_games: List[Game] = [] self.uninstalled_games: List[Game] = []
self.game_list: List[Game] = self.api_results.game_list self.game_list: List[Game] = self.api_results.game_list

View file

@ -38,17 +38,13 @@ logger = getLogger("ImageManager")
class ImageSize: class ImageSize:
class Preset: class Preset:
__img_factor = 67
__size: QSize
__divisor: float = 1.0
__pixel_ratio: float = 1.0
# lk: for prettier images set this to true
__smooth_transform: bool = False
def __init__(self, divisor: float, pixel_ratio: float): def __init__(self, divisor: float, pixel_ratio: float):
self.__pixel_ratio = pixel_ratio self.__img_factor = 67
self.__divisor = divisor self.__divisor = divisor
self.__pixel_ratio = pixel_ratio
self.__size = QSize(self.__img_factor * 3, self.__img_factor * 4) * pixel_ratio / divisor self.__size = QSize(self.__img_factor * 3, self.__img_factor * 4) * pixel_ratio / divisor
# lk: for prettier images set this to true
self.__smooth_transform: bool = False
if divisor > 2: if divisor > 2:
self.__smooth_transform = False self.__smooth_transform = False
@ -107,12 +103,11 @@ class ImageManager(QObject):
logger.debug(f" Emitting singal for game {self.game.app_name} - {self.game.app_title}") logger.debug(f" Emitting singal for game {self.game.app_name} - {self.game.app_title}")
self.signals.completed.emit(self.game.app_name) self.signals.completed.emit(self.game.app_name)
# lk: the ordering in __img_types matters for the order of fallbacks
__img_types: List = ["DieselGameBoxTall", "Thumbnail", "DieselGameBoxLogo"]
__dl_retries = 1
__worker_app_names: List[str] = list()
def __init__(self, signals: GlobalSignals, core: LegendaryCore): def __init__(self, signals: GlobalSignals, core: LegendaryCore):
# lk: the ordering in __img_types matters for the order of fallbacks
self.__img_types: Tuple = ("DieselGameBoxTall", "Thumbnail", "DieselGameBoxLogo")
self.__dl_retries = 1
self.__worker_app_names: List[str] = []
super(QObject, self).__init__() super(QObject, self).__init__()
self.signals = signals self.signals = signals
self.core = core self.core = core