From 836ec1f89506a4f55b6d69e76f98053c5ee541c2 Mon Sep 17 00:00:00 2001 From: Dummerle Date: Mon, 5 Apr 2021 10:57:11 +0200 Subject: [PATCH 1/2] Some small fixes --- README.md | 4 +++- Rare/Components/Tabs/CloudSaves/SyncWidget.py | 1 - .../Games/GameWidgets/UninstalledIconWidget.py | 6 +++--- Rare/Main.py | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 47403626..7b227675 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ Using the exe file could cause errors - For Arch Linux is an AUR package available: [rare-git](https://aur.archlinux.org/packages/rare-git) or [rare](https://aur.archlinux.org/packages/rare) -- Other distributions have to install it with pip or clone the repo and install it manually: *python3 setup.py install* +- For Debian-based Distros is a .deb package at the releases +- Other distributions have to install it with pip or clone the repo and install it manually: *python3 setup.py install (--user)* ## Features @@ -51,6 +52,7 @@ Using the exe file could cause errors - Offline mode - More Translations (Need help) - More Information about Games +More planned features are in projects ## Contributing There are more options to contribute. diff --git a/Rare/Components/Tabs/CloudSaves/SyncWidget.py b/Rare/Components/Tabs/CloudSaves/SyncWidget.py index f3b48457..e19ce92b 100644 --- a/Rare/Components/Tabs/CloudSaves/SyncWidget.py +++ b/Rare/Components/Tabs/CloudSaves/SyncWidget.py @@ -147,7 +147,6 @@ class SyncWidget(QWidget): def change_path(self): path = PathInputDialog("Select directory", "Select savepath. Warning: Do not change if you are not sure", self.igame.save_path).get_path() - print(path) if path != "": self.igame.save_path = path self.core.lgd.set_installed_game(self.igame.app_name, self.igame) diff --git a/Rare/Components/Tabs/Games/GameWidgets/UninstalledIconWidget.py b/Rare/Components/Tabs/Games/GameWidgets/UninstalledIconWidget.py index 68ac870a..a5eec79b 100644 --- a/Rare/Components/Tabs/Games/GameWidgets/UninstalledIconWidget.py +++ b/Rare/Components/Tabs/Games/GameWidgets/UninstalledIconWidget.py @@ -36,11 +36,11 @@ class IconWidgetUninstalled(BaseUninstalledWidget): self.setLayout(self.layout) self.setFixedWidth(self.sizeHint().width()) - def mousePressEvent(self, a0) -> None: + def mousePressEvent(self, e) -> None: self.install() - def enterEvent(self, QEvent): + def enterEvent(self, e): self.info_label.setText(self.tr("Install Game")) - def leaveEvent(self, QEvent): + def leaveEvent(self, e): self.info_label.setText("") diff --git a/Rare/Main.py b/Rare/Main.py index b10f4669..bb3b1566 100644 --- a/Rare/Main.py +++ b/Rare/Main.py @@ -1,3 +1,4 @@ +import configparser import logging import os import sys @@ -23,11 +24,22 @@ class App(QApplication): def __init__(self): super(App, self).__init__(sys.argv) # init Legendary - self.core = LegendaryCore() + try: + self.core = LegendaryCore() + except configparser.MissingSectionHeaderError as e: + logger.warning(f"Config is corrupt: {e}") + if config_path := os.environ.get('XDG_CONFIG_HOME'): + path = os.path.join(config_path, 'legendary') + else: + path = os.path.expanduser('~/.config/legendary') + with open(os.path.join(path, "config.ini"), "w") as config_file: + config_file.write("[Legendary]") + self.core = LegendaryCore() if not "Legendary" in self.core.lgd.config.sections(): self.core.lgd.config.add_section("Legendary") self.core.lgd.save_config() + # set Application name for settings self.setApplicationName("Rare") self.setOrganizationName("Rare") settings = QSettings() @@ -46,12 +58,14 @@ class App(QApplication): self.setStyleSheet(open(style_path + "RareStyle.qss").read()) self.setWindowIcon(QIcon(style_path + "Logo.png")) + # launch app self.launch_dialog = LaunchDialog(self.core) self.launch_dialog.start_app.connect(self.start_app) self.launch_dialog.show() def start_app(self): self.mainwindow = MainWindow(self.core) + # close launch dialog after app widgets were created self.launch_dialog.close() From 54adc0cbead0da42703e4d76094a5552b002872e Mon Sep 17 00:00:00 2001 From: Dummerle Date: Mon, 5 Apr 2021 11:53:33 +0200 Subject: [PATCH 2/2] Download settings update, More download options --- Rare/Components/Dialogs/InstallDialog.py | 28 +++++++++++++++---- Rare/Components/Tabs/Downloads/DownloadTab.py | 14 ++++++---- .../GameWidgets/BaseUninstalledWidget.py | 6 ++-- Rare/Styles/RareStyle.qss | 5 ++++ Rare/utils/Models.py | 3 +- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Rare/Components/Dialogs/InstallDialog.py b/Rare/Components/Dialogs/InstallDialog.py index 87400d93..e0705dcb 100644 --- a/Rare/Components/Dialogs/InstallDialog.py +++ b/Rare/Components/Dialogs/InstallDialog.py @@ -1,26 +1,41 @@ import os -from PyQt5.QtWidgets import QDialog, QFormLayout, QVBoxLayout, QSpinBox, QFileDialog, QLabel, QPushButton, QHBoxLayout +from PyQt5.QtWidgets import QDialog, QFormLayout, QVBoxLayout, QSpinBox, QFileDialog, QLabel, QPushButton, QHBoxLayout, \ + QCheckBox from Rare.utils.QtExtensions import PathEdit +from custom_legendary.core import LegendaryCore class InstallDialog(QDialog): infos = 0 - def __init__(self): + def __init__(self, app_name, core: LegendaryCore, update=False): super(InstallDialog, self).__init__() self.layout = QVBoxLayout() - + self.core = core + self.game = self.core.get_game(app_name) self.form = QFormLayout() + self.update_game = update + self.layout.addWidget(QLabel(self.tr("

Install {}

").format(self.game.app_title))) default_path = os.path.expanduser("~/legendary") + # TODO read from config - self.install_path_field = PathEdit(text=default_path, type_of_file=QFileDialog.DirectoryOnly) - self.form.addRow(QLabel("Install directory"), self.install_path_field) + if not update: + self.install_path_field = PathEdit(text=default_path, type_of_file=QFileDialog.DirectoryOnly) + self.form.addRow(QLabel("Install directory"), self.install_path_field) self.max_workes = QSpinBox() self.form.addRow(QLabel(self.tr("Max workers (0: Default)")), self.max_workes) + self.force = QCheckBox() + self.force.setChecked(False) + self.form.addRow(QLabel(self.tr("Force download")), self.force) + + self.ignore_free_space = QCheckBox() + self.ignore_free_space.setChecked(False) + self.form.addRow(QLabel(self.tr("Ignore free space (Warning!)")), self.ignore_free_space) + self.layout.addLayout(self.form) self.ok_btn = QPushButton("Next") @@ -42,7 +57,7 @@ class InstallDialog(QDialog): return self.infos def ok(self): - self.infos = self.install_path_field.text(), self.max_workes.value() + self.infos = self.install_path_field.text() if not self.update_game else None, self.max_workes.value(), self.force.isChecked(), self.ignore_free_space.isChecked() self.close() @@ -80,3 +95,4 @@ class InstallInfoDialog(QDialog): def cancel(self): self.accept = False self.close() + diff --git a/Rare/Components/Tabs/Downloads/DownloadTab.py b/Rare/Components/Tabs/Downloads/DownloadTab.py index 46180e2d..944732e7 100644 --- a/Rare/Components/Tabs/Downloads/DownloadTab.py +++ b/Rare/Components/Tabs/Downloads/DownloadTab.py @@ -10,7 +10,7 @@ from PyQt5.QtCore import QThread, pyqtSignal, Qt from PyQt5.QtWidgets import QWidget, QMessageBox, QVBoxLayout, QLabel, QGridLayout, QProgressBar, QPushButton, QDialog, \ QListWidget, QHBoxLayout -from Rare.Components.Dialogs.InstallDialog import InstallInfoDialog +from Rare.Components.Dialogs.InstallDialog import InstallInfoDialog, InstallDialog from Rare.utils.Models import InstallOptions, KillDownloadException from custom_legendary.core import LegendaryCore from custom_legendary.downloader.manager import DLManager @@ -193,7 +193,7 @@ class DownloadTab(QWidget): dlm, analysis, game, igame, repair, repair_file = self.core.prepare_download( app_name=options.app_name, base_path=options.path, - force=False, # TODO allow overwrite + force=options.force, no_install=options.download_only, status_q=status_queue, # max_shm=, @@ -211,7 +211,7 @@ class DownloadTab(QWidget): # dl_timeout=, repair=options.repair, # repair_use_latest=, - # ignore_space_req=, + ignore_space_req=options.ignore_free_space, # disable_delta=, # override_delta_manifest=, # reset_sdl=, @@ -229,6 +229,7 @@ class DownloadTab(QWidget): return self.active_game = game + self.installing_game_widget.setText(self.tr("Installing game: ")+self.active_game.app_title) self.thread = DownloadThread(dlm, self.core, status_queue, igame, options.repair, repair_file) self.thread.status.connect(self.status) self.thread.statistics.connect(self.statistics) @@ -329,7 +330,11 @@ class DownloadTab(QWidget): def update_game(self, app_name: str): print("Update ", app_name) - self.install_game(InstallOptions(app_name)) + infos = InstallDialog(app_name, self.core, True).get_information() + if infos != 0: + path, max_workers, force, ignore_free_space = infos + self.install_game(InstallOptions(app_name=app_name, max_workers=max_workers, path=path, + force=force, ignore_free_space=ignore_free_space)) def repair(self): pass @@ -343,7 +348,6 @@ class UpdateWidget(QWidget): print(game) self.core = core self.game = game - print(self.game) self.layout = QVBoxLayout() self.title = QLabel(self.game.title) diff --git a/Rare/Components/Tabs/Games/GameWidgets/BaseUninstalledWidget.py b/Rare/Components/Tabs/Games/GameWidgets/BaseUninstalledWidget.py index d57b4097..80b48177 100644 --- a/Rare/Components/Tabs/Games/GameWidgets/BaseUninstalledWidget.py +++ b/Rare/Components/Tabs/Games/GameWidgets/BaseUninstalledWidget.py @@ -21,7 +21,7 @@ class BaseUninstalledWidget(QGroupBox): self.setContentsMargins(0, 0, 0, 0) def install(self): - infos = InstallDialog().get_information() + infos = InstallDialog(self.game.app_name, self.core).get_information() if infos != 0: - path, max_workers = infos - self.install_game.emit(InstallOptions(app_name=self.game.app_name, max_workers=max_workers, path=path)) + 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)) diff --git a/Rare/Styles/RareStyle.qss b/Rare/Styles/RareStyle.qss index 6f1d2150..d6670020 100644 --- a/Rare/Styles/RareStyle.qss +++ b/Rare/Styles/RareStyle.qss @@ -84,7 +84,12 @@ QLineEdit { QCheckBox { color: #F0F0F0; + background-color: none; } +QCheckBox::indicator{ + +} + #list_widget { diff --git a/Rare/utils/Models.py b/Rare/utils/Models.py index e4a9a730..5b1a8f76 100644 --- a/Rare/utils/Models.py +++ b/Rare/utils/Models.py @@ -4,13 +4,14 @@ import os class InstallOptions: def __init__(self, app_name: str, path: str = os.path.expanduser("~/legendary"), max_workers: int = os.cpu_count() * 2, repair: bool = False, - download_only: bool = False, ignore_free_space: bool = False): + download_only: bool = False, ignore_free_space: bool = False, force: bool = False): self.app_name = app_name self.path = path self.max_workers = max_workers self.repair = repair self.download_only = download_only self.ignore_free_space = ignore_free_space + self.force = force class KillDownloadException(Exception):