1
0
Fork 0
mirror of synced 2024-09-28 23:41:29 +12:00

Add selective downloads

This commit is contained in:
Stelios Tsampas 2021-05-21 17:48:15 +03:00
parent 5ccf73d737
commit 1131edda20
6 changed files with 289 additions and 245 deletions

View file

@ -1,19 +1,21 @@
import os import os
from PyQt5.QtCore import QObject, QRunnable, QThreadPool, pyqtSignal, pyqtSlot from PyQt5.QtCore import QObject, QRunnable, QThreadPool, pyqtSignal, pyqtSlot
from PyQt5.QtWidgets import QDialog, QFileDialog from PyQt5.QtWidgets import QDialog, QFileDialog, QCheckBox
from custom_legendary.core import LegendaryCore from custom_legendary.core import LegendaryCore
from custom_legendary.utils.selective_dl import games
from rare.ui.components.dialogs.install_dialog import Ui_InstallDialog from rare.ui.components.dialogs.install_dialog import Ui_InstallDialog
from rare.utils.extra_widgets import PathEdit from rare.utils.extra_widgets import PathEdit
from rare.utils.models import InstallOptions
from rare.utils.utils import get_size from rare.utils.utils import get_size
class InstallDialog(QDialog, Ui_InstallDialog): class InstallDialog(QDialog, Ui_InstallDialog):
infos = False options = False
def __init__(self, app_name, core: LegendaryCore, update=False): def __init__(self, app_name, core: LegendaryCore, update=False, parent=None):
super(InstallDialog, self).__init__() super(InstallDialog, self).__init__(parent=parent)
self.setupUi(self) self.setupUi(self)
self.core = core self.core = core
@ -23,10 +25,9 @@ class InstallDialog(QDialog, Ui_InstallDialog):
self.threadpool = QThreadPool.globalInstance() self.threadpool = QThreadPool.globalInstance()
header_text = self.tr("Update") if update else self.tr("Install") header = self.tr("Update") if update else self.tr("Install")
self.install_dialog_label.setText("<h3>{} \"{}\"</h3>".format(header_text, self.game.app_title)) self.install_dialog_label.setText(f"<h3>{header} \"{self.game.app_title}\"</h3>")
# TODO: Get application name from QApplication instance self.setWindowTitle(f"{self.windowTitle()} - {header} \"{self.game.app_title}\"")
self.setWindowTitle("{} - {} \"{}\"".format("Rare", header_text, self.game.app_title))
if self.core.lgd.config.has_option("Legendary", "install_dir"): if self.core.lgd.config.has_option("Legendary", "install_dir"):
default_path = self.core.lgd.config.get("Legendary", "install_dir") default_path = self.core.lgd.config.get("Legendary", "install_dir")
@ -35,14 +36,14 @@ class InstallDialog(QDialog, Ui_InstallDialog):
if not default_path: if not default_path:
default_path = os.path.expanduser("~/legendary") default_path = os.path.expanduser("~/legendary")
self.install_dir_path = PathEdit(text=default_path, self.install_dir_edit = PathEdit(text=default_path,
file_type=QFileDialog.DirectoryOnly, file_type=QFileDialog.DirectoryOnly,
edit_func=self.on_install_dir_text_changed) edit_func=self.on_install_dir_text_changed)
self.install_dir_layout.addWidget(self.install_dir_path) self.install_dir_layout.addWidget(self.install_dir_edit)
if update: if update:
self.install_dir_label.setVisible(False) self.install_dir_label.setVisible(False)
self.install_dir_path.setVisible(False) self.install_dir_edit.setVisible(False)
if self.core.lgd.config.has_option("Legendary", "max_workers"): if self.core.lgd.config.has_option("Legendary", "max_workers"):
max_workers = self.core.lgd.config.get("Legendary", "max_workers") max_workers = self.core.lgd.config.get("Legendary", "max_workers")
@ -50,41 +51,70 @@ class InstallDialog(QDialog, Ui_InstallDialog):
max_workers = 0 max_workers = 0
self.max_workers_spin.setValue(int(max_workers)) self.max_workers_spin.setValue(int(max_workers))
self.get_install_info(app_name, default_path) self.sdl_list_checks = list()
self.tags = list()
try:
for key, info in games[app_name].items():
cb = QDataCheckBox(info['name'], info['tags'])
cb.stateChanged.connect(self.on_sdl_checkbox_changed)
if key == '__required':
self.tags.extend(info['tags'])
cb.setChecked(True)
cb.setDisabled(True)
self.sdl_list_layout.addWidget(cb)
self.sdl_list_checks.append(cb)
self.sdl_list_frame.resize(self.sdl_list_frame.minimumSize())
except KeyError:
self.sdl_list_frame.setVisible(False)
self.sdl_list_label.setVisible(False)
self.get_install_info(app_name, default_path, self.tags)
self.install_button.clicked.connect(self.on_install_button_clicked) self.install_button.clicked.connect(self.on_install_button_clicked)
self.cancel_button.clicked.connect(self.on_cancel_button_clicked) self.cancel_button.clicked.connect(self.on_cancel_button_clicked)
self.resize(self.minimumSizeHint()) self.resize(self.minimumSize())
self.setFixedSize(self.size()) self.setFixedSize(self.size())
def get_information(self, path=None): def get_install_options(self, path=None):
if path: if path:
self.install_dir_path.setText(path) self.install_dir_edit.setText(path)
self.exec_() self.exec_()
return self.infos return self.options
def get_install_info(self, app_name, default_path): def get_install_info(self, app_name, path, tags):
updating_text = self.tr("Updating...") message = self.tr("Updating...")
self.download_size_info_label.setText(updating_text) self.download_size_info_label.setText(message)
self.download_size_info_label.setStyleSheet("font-style: italic; font-weight: normal") self.download_size_info_label.setStyleSheet("font-style: italic; font-weight: normal")
self.install_size_info_label.setText(updating_text) self.install_size_info_label.setText(message)
self.install_size_info_label.setStyleSheet("font-style: italic; font-weight: normal") self.install_size_info_label.setStyleSheet("font-style: italic; font-weight: normal")
self.install_button.setEnabled(False) self.install_button.setEnabled(False)
info_worker = InstallInfoWorker(app_name, default_path, self.core) self.sdl_list_frame.setEnabled(False)
info_worker = InstallInfoWorker(app_name, path, tags, self.core)
info_worker.setAutoDelete(True) info_worker.setAutoDelete(True)
info_worker.signals.finished.connect(self.on_worker_finished) info_worker.signals.finished.connect(self.on_worker_finished)
self.threadpool.start(info_worker) self.threadpool.start(info_worker)
def on_sdl_checkbox_changed(self):
self.tags = list()
for cb in self.sdl_list_checks:
if data := cb.isChecked():
self.tags.extend(data)
self.get_install_info(self.app_name, self.install_dir_edit.text(), self.tags)
def on_install_dir_text_changed(self, path: str): def on_install_dir_text_changed(self, path: str):
self.get_install_info(self.app_name, path) self.get_install_info(self.app_name, path, self.tags)
def on_install_button_clicked(self): def on_install_button_clicked(self):
self.infos = self.install_dir_path.text() if not self.update_game else None, \ self.options = InstallOptions(
self.max_workers_spin.value(), \ app_name=self.app_name,
self.force_download_check.isChecked(), \ path=self.install_dir_edit.text() if not self.update_game else None,
self.ignore_space_check.isChecked(), \ max_workers=self.max_workers_spin.value(),
self.download_only_check.isChecked() force=self.force_download_check.isChecked(),
ignore_free_space=self.ignore_space_check.isChecked(),
download_only=self.download_only_check.isChecked(),
sdl_list=self.tags
)
self.threadpool.clear() self.threadpool.clear()
self.close() self.close()
@ -94,11 +124,9 @@ class InstallDialog(QDialog, Ui_InstallDialog):
def on_worker_finished(self, info: tuple): def on_worker_finished(self, info: tuple):
download_size, install_size = info download_size, install_size = info
# TODO: Check available size and act accordingly # TODO: Check available size and act accordingly
# TODO: (show message in label | color it | disable install unless ignore) # TODO: (show message in label | color it | disable install unless ignore)
# TODO: Find a way to get the installation size delta and show it # TODO: Find a way to get the installation size delta and show it
if download_size is not None and install_size is not None: if download_size is not None and install_size is not None:
if download_size: if download_size:
self.download_size_info_label.setText("{}".format(get_size(download_size))) self.download_size_info_label.setText("{}".format(get_size(download_size)))
@ -112,6 +140,7 @@ class InstallDialog(QDialog, Ui_InstallDialog):
else: else:
self.download_size_info_label.setText("Error") self.download_size_info_label.setText("Error")
self.install_size_info_label.setText("Error") self.install_size_info_label.setText("Error")
self.sdl_list_frame.setEnabled(True)
class InstallInfoWorkerSignals(QObject): class InstallInfoWorkerSignals(QObject):
@ -120,12 +149,13 @@ class InstallInfoWorkerSignals(QObject):
class InstallInfoWorker(QRunnable): class InstallInfoWorker(QRunnable):
def __init__(self, app_name, path, core: LegendaryCore): def __init__(self, app_name, path, tags, core: LegendaryCore):
super(InstallInfoWorker, self).__init__() super(InstallInfoWorker, self).__init__()
self.signals = InstallInfoWorkerSignals() self.signals = InstallInfoWorkerSignals()
self.core = core self.core = core
self.app_name = app_name self.app_name = app_name
self.path = path self.path = path
self.tags = tags
@pyqtSlot() @pyqtSlot()
def run(self): def run(self):
@ -133,8 +163,23 @@ class InstallInfoWorker(QRunnable):
dlm, analysis, game, igame, repair, repair_file = self.core.prepare_download( dlm, analysis, game, igame, repair, repair_file = self.core.prepare_download(
app_name=self.app_name, app_name=self.app_name,
base_path=self.path, base_path=self.path,
sdl_prompt=lambda app_name, title: self.tags
) )
self.signals.finished.emit((analysis.dl_size, analysis.install_size)) self.signals.finished.emit((analysis.dl_size, analysis.install_size))
except: except:
self.signals.finished.emit((None, None)) self.signals.finished.emit((None, None))
return return
class QDataCheckBox(QCheckBox):
def __init__(self, text, data=None):
super(QDataCheckBox, self).__init__()
self.setText(text)
self.data = data
def isChecked(self):
if super(QDataCheckBox, self).isChecked():
return self.data
else:
return False

View file

@ -97,12 +97,9 @@ class TabWidget(QTabWidget):
def install_game(self, app_name, disable_path=False): def install_game(self, app_name, disable_path=False):
infos = InstallDialog(app_name, self.core, disable_path).get_information() options = InstallDialog(app_name, self.core, disable_path, parent=self).get_install_options()
if infos: if options:
path, max_workers, force, ignore_free_space, dl_only = infos self.setCurrentIndex(1)
options = InstallOptions(app_name=app_name, max_workers=max_workers, path=path, force=force,
ignore_free_space=ignore_free_space, download_only=dl_only)
self.start_download(options) self.start_download(options)
def start_download(self, options): def start_download(self, options):

View file

@ -29,6 +29,7 @@ class DownloadTab(QWidget):
self.core = core self.core = core
self.layout = QVBoxLayout() self.layout = QVBoxLayout()
self.active_game: Game = None self.active_game: Game = None
self.analysis = None
self.info_layout = QGridLayout() self.info_layout = QGridLayout()
@ -85,7 +86,7 @@ class DownloadTab(QWidget):
widget = UpdateWidget(self.core, igame, self) widget = UpdateWidget(self.core, igame, self)
self.update_layout.addWidget(widget) self.update_layout.addWidget(widget)
self.update_widgets[igame.app_name] = widget self.update_widgets[igame.app_name] = widget
widget.update.connect(self.update_game) widget.update_signal.connect(self.update_game)
if QSettings().value("auto_update", False, bool): if QSettings().value("auto_update", False, bool):
self.update_game(igame.app_name, True) self.update_game(igame.app_name, True)
widget.update_button.setDisabled(True) widget.update_button.setDisabled(True)
@ -125,7 +126,8 @@ class DownloadTab(QWidget):
# disable_delta=, # disable_delta=,
# override_delta_manifest=, # override_delta_manifest=,
# reset_sdl=, # reset_sdl=,
sdl_prompt=self.sdl_prompt) sdl_prompt=lambda app_name, title: options.sdl_list
)
except Exception as e: except Exception as e:
QMessageBox.warning(self, self.tr("Error preparing download"), QMessageBox.warning(self, self.tr("Error preparing download"),
str(e)) str(e))
@ -153,44 +155,6 @@ class DownloadTab(QWidget):
self.analysis = analysis self.analysis = analysis
self.installing_game.setText(self.tr("Installing Game: ") + self.active_game.app_title) self.installing_game.setText(self.tr("Installing Game: ") + self.active_game.app_title)
def sdl_prompt(self, app_name: str = '', title: str = '') -> list:
sdl = QDialog()
sdl.setWindowTitle('Select Additional Downloads')
layout = QVBoxLayout(sdl)
sdl.setLayout(layout)
pack_list = QListWidget()
layout.addWidget(pack_list)
done = QPushButton(text='Done')
done.clicked.connect(sdl.accept)
layout.addWidget(done)
tags = ['']
if '__required' in games[app_name]:
tags.extend(games[app_name]['__required']['tags'])
# add available additional downloads to list
pack_list.addItems([tag + ': ' + info['name'] for tag, info in games[app_name].items() if tag != '__required'])
# enable checkboxes
for i in range(len(pack_list)):
item = pack_list.item(i)
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(Qt.Unchecked)
sdl.exec_()
# read checkboxes states
for i in range(len(pack_list)):
item = pack_list.item(i)
if item.checkState() == Qt.Checked:
tag = item.text().split(':')[0]
tags.extend(games[app_name][tag]['tags'])
return tags
def status(self, text): def status(self, text):
if text == "dl_finished": if text == "dl_finished":
pass pass
@ -270,14 +234,12 @@ class DownloadTab(QWidget):
def update_game(self, app_name: str, auto=False): def update_game(self, app_name: str, auto=False):
logger.info("Update " + app_name) logger.info("Update " + app_name)
if not auto: if not auto:
infos = InstallDialog(app_name, self.core, True).get_information() options = InstallDialog(app_name, self.core, True).get_install_options()
else: else:
self.install_game(InstallOptions(app_name=app_name), True) self.install_game(InstallOptions(app_name=app_name), True)
return return
if infos: if options:
path, max_workers, force, ignore_free_space, dl_only = infos self.install_game(options, True)
self.install_game(InstallOptions(app_name=app_name, max_workers=max_workers, path=path,
force=force, ignore_free_space=ignore_free_space, download_only=dl_only), True)
else: else:
self.update_widgets[app_name].update_button.setDisabled(False) self.update_widgets[app_name].update_button.setDisabled(False)
self.update_widgets[app_name].update_with_settings.setDisabled(False) self.update_widgets[app_name].update_with_settings.setDisabled(False)

View file

@ -14,106 +14,119 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_InstallDialog(object): class Ui_InstallDialog(object):
def setupUi(self, InstallDialog): def setupUi(self, InstallDialog):
InstallDialog.setObjectName("InstallDialog") InstallDialog.setObjectName("InstallDialog")
InstallDialog.setWindowTitle("Rare")
self.install_dialog_layout = QtWidgets.QGridLayout(InstallDialog) self.install_dialog_layout = QtWidgets.QGridLayout(InstallDialog)
self.install_dialog_layout.setObjectName("install_dialog_layout") self.install_dialog_layout.setObjectName("install_dialog_layout")
self.ignore_space_label = QtWidgets.QLabel(InstallDialog)
self.ignore_space_label.setObjectName("ignore_space_label")
self.install_dialog_layout.addWidget(self.ignore_space_label, 4, 0, 1, 1, QtCore.Qt.AlignRight)
self.install_dialog_label = QtWidgets.QLabel(InstallDialog)
self.install_dialog_label.setObjectName("install_dialog_label")
self.install_dialog_layout.addWidget(self.install_dialog_label, 0, 0, 1, 3)
self.download_size_label = QtWidgets.QLabel(InstallDialog)
self.download_size_label.setObjectName("download_size_label")
self.install_dialog_layout.addWidget(self.download_size_label, 6, 0, 1, 1, QtCore.Qt.AlignRight)
self.install_size_info_label = QtWidgets.QLabel(InstallDialog)
self.install_size_info_label.setText("")
self.install_size_info_label.setObjectName("install_size_info_label")
self.install_dialog_layout.addWidget(self.install_size_info_label, 7, 1, 1, 2)
self.install_dir_label = QtWidgets.QLabel(InstallDialog)
self.install_dir_label.setObjectName("install_dir_label")
self.install_dialog_layout.addWidget(self.install_dir_label, 1, 0, 1, 1, QtCore.Qt.AlignRight)
spacerItem = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.install_dialog_layout.addItem(spacerItem, 3, 2, 1, 1)
self.ignore_space_info_label = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont()
font.setItalic(True)
self.ignore_space_info_label.setFont(font)
self.ignore_space_info_label.setObjectName("ignore_space_info_label")
self.install_dialog_layout.addWidget(self.ignore_space_info_label, 4, 2, 1, 1)
self.force_download_check = QtWidgets.QCheckBox(InstallDialog)
self.force_download_check.setObjectName("force_download_check")
self.install_dialog_layout.addWidget(self.force_download_check, 3, 1, 1, 1)
self.force_download_label = QtWidgets.QLabel(InstallDialog) self.force_download_label = QtWidgets.QLabel(InstallDialog)
self.force_download_label.setObjectName("force_download_label") self.force_download_label.setObjectName("force_download_label")
self.install_dialog_layout.addWidget(self.force_download_label, 3, 0, 1, 1, QtCore.Qt.AlignRight) self.install_dialog_layout.addWidget(self.force_download_label, 3, 0, 1, 1, QtCore.Qt.AlignRight)
self.button_layout = QtWidgets.QHBoxLayout() self.button_layout = QtWidgets.QHBoxLayout()
self.button_layout.setObjectName("button_layout") self.button_layout.setObjectName("button_layout")
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.button_layout.addItem(spacerItem1) self.button_layout.addItem(spacerItem)
self.cancel_button = QtWidgets.QPushButton(InstallDialog) self.cancel_button = QtWidgets.QPushButton(InstallDialog)
self.cancel_button.setObjectName("cancel_button") self.cancel_button.setObjectName("cancel_button")
self.button_layout.addWidget(self.cancel_button) self.button_layout.addWidget(self.cancel_button)
self.install_button = QtWidgets.QPushButton(InstallDialog) self.install_button = QtWidgets.QPushButton(InstallDialog)
self.install_button.setObjectName("install_button") self.install_button.setObjectName("install_button")
self.button_layout.addWidget(self.install_button) self.button_layout.addWidget(self.install_button)
self.install_dialog_layout.addLayout(self.button_layout, 8, 0, 1, 3) self.install_dialog_layout.addLayout(self.button_layout, 9, 0, 1, 3)
self.max_workers_spin = QtWidgets.QSpinBox(InstallDialog) self.ignore_space_info_label = QtWidgets.QLabel(InstallDialog)
self.max_workers_spin.setObjectName("max_workers_spin") font = QtGui.QFont()
self.install_dialog_layout.addWidget(self.max_workers_spin, 2, 1, 1, 1) font.setItalic(True)
self.ignore_space_info_label.setFont(font)
self.ignore_space_info_label.setObjectName("ignore_space_info_label")
self.install_dialog_layout.addWidget(self.ignore_space_info_label, 4, 2, 1, 1)
self.install_dir_label = QtWidgets.QLabel(InstallDialog)
self.install_dir_label.setObjectName("install_dir_label")
self.install_dialog_layout.addWidget(self.install_dir_label, 1, 0, 1, 1, QtCore.Qt.AlignRight)
self.ignore_space_check = QtWidgets.QCheckBox(InstallDialog) self.ignore_space_check = QtWidgets.QCheckBox(InstallDialog)
self.ignore_space_check.setObjectName("ignore_space_check") self.ignore_space_check.setObjectName("ignore_space_check")
self.install_dialog_layout.addWidget(self.ignore_space_check, 4, 1, 1, 1) self.install_dialog_layout.addWidget(self.ignore_space_check, 4, 1, 1, 1)
self.install_size_label = QtWidgets.QLabel(InstallDialog)
self.install_size_label.setObjectName("install_size_label")
self.install_dialog_layout.addWidget(self.install_size_label, 7, 0, 1, 1, QtCore.Qt.AlignRight)
self.max_workers_info_label = QtWidgets.QLabel(InstallDialog) self.max_workers_info_label = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont() font = QtGui.QFont()
font.setItalic(True) font.setItalic(True)
self.max_workers_info_label.setFont(font) self.max_workers_info_label.setFont(font)
self.max_workers_info_label.setObjectName("max_workers_info_label") self.max_workers_info_label.setObjectName("max_workers_info_label")
self.install_dialog_layout.addWidget(self.max_workers_info_label, 2, 2, 1, 1) self.install_dialog_layout.addWidget(self.max_workers_info_label, 2, 2, 1, 1)
self.install_dir_layout = QtWidgets.QHBoxLayout() self.max_workers_spin = QtWidgets.QSpinBox(InstallDialog)
self.install_dir_layout.setObjectName("install_dir_layout") self.max_workers_spin.setObjectName("max_workers_spin")
self.install_dialog_layout.addLayout(self.install_dir_layout, 1, 1, 1, 2) self.install_dialog_layout.addWidget(self.max_workers_spin, 2, 1, 1, 1)
self.download_size_info_label = QtWidgets.QLabel(InstallDialog)
self.download_size_info_label.setText("")
self.download_size_info_label.setObjectName("download_size_info_label")
self.install_dialog_layout.addWidget(self.download_size_info_label, 6, 1, 1, 2)
self.max_workers_label = QtWidgets.QLabel(InstallDialog)
self.max_workers_label.setObjectName("max_workers_label")
self.install_dialog_layout.addWidget(self.max_workers_label, 2, 0, 1, 1, QtCore.Qt.AlignRight)
self.download_only_label = QtWidgets.QLabel(InstallDialog)
self.download_only_label.setObjectName("download_only_label")
self.install_dialog_layout.addWidget(self.download_only_label, 5, 0, 1, 1, QtCore.Qt.AlignRight)
self.download_only_check = QtWidgets.QCheckBox(InstallDialog)
self.download_only_check.setText("")
self.download_only_check.setObjectName("download_only_check")
self.install_dialog_layout.addWidget(self.download_only_check, 5, 1, 1, 1)
self.download_only_info_label = QtWidgets.QLabel(InstallDialog) self.download_only_info_label = QtWidgets.QLabel(InstallDialog)
font = QtGui.QFont() font = QtGui.QFont()
font.setItalic(True) font.setItalic(True)
self.download_only_info_label.setFont(font) self.download_only_info_label.setFont(font)
self.download_only_info_label.setObjectName("download_only_info_label") self.download_only_info_label.setObjectName("download_only_info_label")
self.install_dialog_layout.addWidget(self.download_only_info_label, 5, 2, 1, 1) self.install_dialog_layout.addWidget(self.download_only_info_label, 5, 2, 1, 1)
self.install_size_label = QtWidgets.QLabel(InstallDialog)
self.install_size_label.setObjectName("install_size_label")
self.install_dialog_layout.addWidget(self.install_size_label, 8, 0, 1, 1, QtCore.Qt.AlignRight)
self.install_dir_layout = QtWidgets.QHBoxLayout()
self.install_dir_layout.setObjectName("install_dir_layout")
self.install_dialog_layout.addLayout(self.install_dir_layout, 1, 1, 1, 2)
spacerItem1 = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.install_dialog_layout.addItem(spacerItem1, 3, 2, 1, 1)
self.ignore_space_label = QtWidgets.QLabel(InstallDialog)
self.ignore_space_label.setObjectName("ignore_space_label")
self.install_dialog_layout.addWidget(self.ignore_space_label, 4, 0, 1, 1, QtCore.Qt.AlignRight)
self.download_only_label = QtWidgets.QLabel(InstallDialog)
self.download_only_label.setObjectName("download_only_label")
self.install_dialog_layout.addWidget(self.download_only_label, 5, 0, 1, 1, QtCore.Qt.AlignRight)
self.max_workers_label = QtWidgets.QLabel(InstallDialog)
self.max_workers_label.setObjectName("max_workers_label")
self.install_dialog_layout.addWidget(self.max_workers_label, 2, 0, 1, 1, QtCore.Qt.AlignRight)
self.install_size_info_label = QtWidgets.QLabel(InstallDialog)
self.install_size_info_label.setText("")
self.install_size_info_label.setObjectName("install_size_info_label")
self.install_dialog_layout.addWidget(self.install_size_info_label, 8, 1, 1, 2)
self.download_size_label = QtWidgets.QLabel(InstallDialog)
self.download_size_label.setObjectName("download_size_label")
self.install_dialog_layout.addWidget(self.download_size_label, 7, 0, 1, 1, QtCore.Qt.AlignRight)
self.download_size_info_label = QtWidgets.QLabel(InstallDialog)
self.download_size_info_label.setText("")
self.download_size_info_label.setObjectName("download_size_info_label")
self.install_dialog_layout.addWidget(self.download_size_info_label, 7, 1, 1, 2)
self.force_download_check = QtWidgets.QCheckBox(InstallDialog)
self.force_download_check.setObjectName("force_download_check")
self.install_dialog_layout.addWidget(self.force_download_check, 3, 1, 1, 1)
self.install_dialog_label = QtWidgets.QLabel(InstallDialog)
self.install_dialog_label.setObjectName("install_dialog_label")
self.install_dialog_layout.addWidget(self.install_dialog_label, 0, 0, 1, 3)
self.download_only_check = QtWidgets.QCheckBox(InstallDialog)
self.download_only_check.setText("")
self.download_only_check.setObjectName("download_only_check")
self.install_dialog_layout.addWidget(self.download_only_check, 5, 1, 1, 1)
self.sdl_list_frame = QtWidgets.QFrame(InstallDialog)
self.sdl_list_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.sdl_list_frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.sdl_list_frame.setObjectName("sdl_list_frame")
self.sdl_list_layout = QtWidgets.QVBoxLayout(self.sdl_list_frame)
self.sdl_list_layout.setSpacing(0)
self.sdl_list_layout.setObjectName("sdl_list_layout")
self.install_dialog_layout.addWidget(self.sdl_list_frame, 6, 1, 1, 2, QtCore.Qt.AlignTop)
self.sdl_list_label = QtWidgets.QLabel(InstallDialog)
self.sdl_list_label.setObjectName("sdl_list_label")
self.install_dialog_layout.addWidget(self.sdl_list_label, 6, 0, 1, 1, QtCore.Qt.AlignRight)
self.retranslateUi(InstallDialog) self.retranslateUi(InstallDialog)
QtCore.QMetaObject.connectSlotsByName(InstallDialog) QtCore.QMetaObject.connectSlotsByName(InstallDialog)
def retranslateUi(self, InstallDialog): def retranslateUi(self, InstallDialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
self.ignore_space_label.setText(_translate("InstallDialog", "Ignore free space"))
self.install_dialog_label.setText(_translate("InstallDialog", "error"))
self.download_size_label.setText(_translate("InstallDialog", "Download size"))
self.install_dir_label.setText(_translate("InstallDialog", "Install directory"))
self.ignore_space_info_label.setText(_translate("InstallDialog", "Use with caution!"))
self.force_download_label.setText(_translate("InstallDialog", "Force download")) self.force_download_label.setText(_translate("InstallDialog", "Force download"))
self.cancel_button.setText(_translate("InstallDialog", "Cancel")) self.cancel_button.setText(_translate("InstallDialog", "Cancel"))
self.install_button.setText(_translate("InstallDialog", "Install")) self.install_button.setText(_translate("InstallDialog", "Install"))
self.install_size_label.setText(_translate("InstallDialog", "Total install size")) self.ignore_space_info_label.setText(_translate("InstallDialog", "Use with caution!"))
self.install_dir_label.setText(_translate("InstallDialog", "Install directory"))
self.max_workers_info_label.setText(_translate("InstallDialog", "Less is slower. (0: Default)")) self.max_workers_info_label.setText(_translate("InstallDialog", "Less is slower. (0: Default)"))
self.max_workers_label.setText(_translate("InstallDialog", "Max workers"))
self.download_only_label.setText(_translate("InstallDialog", "Download only"))
self.download_only_info_label.setText(_translate("InstallDialog", "Do not try to install.")) self.download_only_info_label.setText(_translate("InstallDialog", "Do not try to install."))
self.install_size_label.setText(_translate("InstallDialog", "Total install size"))
self.ignore_space_label.setText(_translate("InstallDialog", "Ignore free space"))
self.download_only_label.setText(_translate("InstallDialog", "Download only"))
self.max_workers_label.setText(_translate("InstallDialog", "Max workers"))
self.download_size_label.setText(_translate("InstallDialog", "Download size"))
self.install_dialog_label.setText(_translate("InstallDialog", "error"))
self.sdl_list_label.setText(_translate("InstallDialog", "Optional packs"))
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -2,70 +2,10 @@
<ui version="4.0"> <ui version="4.0">
<class>InstallDialog</class> <class>InstallDialog</class>
<widget class="QDialog" name="InstallDialog"> <widget class="QDialog" name="InstallDialog">
<property name="windowTitle">
<string notr="true">Rare</string>
</property>
<layout class="QGridLayout" name="install_dialog_layout"> <layout class="QGridLayout" name="install_dialog_layout">
<item row="4" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="ignore_space_label">
<property name="text">
<string>Ignore free space</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="install_dialog_label">
<property name="text">
<string>error</string>
</property>
</widget>
</item>
<item row="6" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="download_size_label">
<property name="text">
<string>Download size</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="QLabel" name="install_size_info_label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="install_dir_label">
<property name="text">
<string>Install directory</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="install_dialog_hspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="2">
<widget class="QLabel" name="ignore_space_info_label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Use with caution!</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="force_download_check"/>
</item>
<item row="3" column="0" alignment="Qt::AlignRight"> <item row="3" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="force_download_label"> <widget class="QLabel" name="force_download_label">
<property name="text"> <property name="text">
@ -73,7 +13,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" colspan="3"> <item row="9" column="0" colspan="3">
<layout class="QHBoxLayout" name="button_layout"> <layout class="QHBoxLayout" name="button_layout">
<item> <item>
<spacer name="button_hspacer"> <spacer name="button_hspacer">
@ -104,19 +44,28 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="1"> <item row="4" column="2">
<widget class="QSpinBox" name="max_workers_spin"/> <widget class="QLabel" name="ignore_space_info_label">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Use with caution!</string>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="install_dir_label">
<property name="text">
<string>Install directory</string>
</property>
</widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QCheckBox" name="ignore_space_check"/> <widget class="QCheckBox" name="ignore_space_check"/>
</item> </item>
<item row="7" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="install_size_label">
<property name="text">
<string>Total install size</string>
</property>
</widget>
</item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QLabel" name="max_workers_info_label"> <widget class="QLabel" name="max_workers_info_label">
<property name="font"> <property name="font">
@ -129,36 +78,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2"> <item row="2" column="1">
<layout class="QHBoxLayout" name="install_dir_layout"/> <widget class="QSpinBox" name="max_workers_spin"/>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="download_size_info_label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="max_workers_label">
<property name="text">
<string>Max workers</string>
</property>
</widget>
</item>
<item row="5" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="download_only_label">
<property name="text">
<string>Download only</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="download_only_check">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item> </item>
<item row="5" column="2"> <item row="5" column="2">
<widget class="QLabel" name="download_only_info_label"> <widget class="QLabel" name="download_only_info_label">
@ -172,6 +93,110 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="install_size_label">
<property name="text">
<string>Total install size</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<layout class="QHBoxLayout" name="install_dir_layout"/>
</item>
<item row="3" column="2">
<spacer name="install_dialog_hspacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="ignore_space_label">
<property name="text">
<string>Ignore free space</string>
</property>
</widget>
</item>
<item row="5" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="download_only_label">
<property name="text">
<string>Download only</string>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="max_workers_label">
<property name="text">
<string>Max workers</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2">
<widget class="QLabel" name="install_size_info_label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="download_size_label">
<property name="text">
<string>Download size</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="QLabel" name="download_size_info_label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="force_download_check"/>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="install_dialog_label">
<property name="text">
<string>error</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="download_only_check">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2" alignment="Qt::AlignTop">
<widget class="QFrame" name="sdl_list_frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="sdl_list_layout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="6" column="0" alignment="Qt::AlignRight">
<widget class="QLabel" name="sdl_list_label">
<property name="text">
<string>Optional packs</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View file

@ -5,6 +5,7 @@ class InstallOptions:
def __init__(self, app_name: str, path: str = os.path.expanduser("~/legendary"), def __init__(self, app_name: str, path: str = os.path.expanduser("~/legendary"),
max_workers: int = os.cpu_count() * 2, repair: bool = False, max_workers: int = os.cpu_count() * 2, repair: bool = False,
download_only: bool = False, ignore_free_space: bool = False, force: bool = False, download_only: bool = False, ignore_free_space: bool = False, force: bool = False,
sdl_list: list = list()
): ):
self.app_name = app_name self.app_name = app_name
self.path = path self.path = path
@ -13,3 +14,4 @@ class InstallOptions:
self.download_only = download_only self.download_only = download_only
self.ignore_free_space = ignore_free_space self.ignore_free_space = ignore_free_space
self.force = force self.force = force
self.sdl_list = sdl_list