Download settings update, More download options
This commit is contained in:
parent
836ec1f895
commit
54adc0cbea
|
@ -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("<h3>Install {}</h3>").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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -84,7 +84,12 @@ QLineEdit {
|
|||
|
||||
QCheckBox {
|
||||
color: #F0F0F0;
|
||||
background-color: none;
|
||||
}
|
||||
QCheckBox::indicator{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#list_widget {
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue