2023-12-26 11:05:11 +13:00
|
|
|
from PyQt5.QtCore import pyqtSignal
|
2024-01-21 04:11:41 +13:00
|
|
|
from PyQt5.QtWidgets import QVBoxLayout, QGroupBox
|
2023-12-20 07:53:21 +13:00
|
|
|
|
|
|
|
from rare.models.game import RareGame
|
|
|
|
from rare.models.install import SelectiveDownloadsModel
|
2024-02-22 00:21:44 +13:00
|
|
|
from rare.utils.misc import qta_icon
|
2024-01-22 12:26:27 +13:00
|
|
|
from rare.widgets.dialogs import ButtonDialog, game_title
|
2024-01-10 03:32:53 +13:00
|
|
|
from rare.widgets.selective_widget import SelectiveWidget
|
2023-12-20 07:53:21 +13:00
|
|
|
|
|
|
|
|
2023-12-26 11:05:11 +13:00
|
|
|
class SelectiveDialog(ButtonDialog):
|
2023-12-20 07:53:21 +13:00
|
|
|
result_ready = pyqtSignal(RareGame, SelectiveDownloadsModel)
|
|
|
|
|
|
|
|
def __init__(self, rgame: RareGame, parent=None):
|
2023-12-26 11:05:11 +13:00
|
|
|
super(SelectiveDialog, self).__init__(parent=parent)
|
2023-12-20 07:53:21 +13:00
|
|
|
header = self.tr("Optional downloads for")
|
2024-01-22 12:26:27 +13:00
|
|
|
self.setWindowTitle(game_title(header, rgame.app_title))
|
|
|
|
self.setSubtitle(game_title(header, rgame.app_title))
|
2023-12-20 07:53:21 +13:00
|
|
|
|
|
|
|
self.rgame = rgame
|
2024-01-10 03:32:53 +13:00
|
|
|
self.selective_widget = SelectiveWidget(rgame, rgame.igame.platform, self)
|
2023-12-20 07:53:21 +13:00
|
|
|
|
2024-01-10 03:32:53 +13:00
|
|
|
container = QGroupBox(self.tr("Optional downloads"), self)
|
|
|
|
container_layout = QVBoxLayout(container)
|
|
|
|
container_layout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
container_layout.addWidget(self.selective_widget)
|
2023-12-20 07:53:21 +13:00
|
|
|
|
2024-01-21 03:57:28 +13:00
|
|
|
layout = QVBoxLayout()
|
|
|
|
layout.addWidget(container)
|
|
|
|
|
|
|
|
self.setCentralLayout(layout)
|
2023-12-20 07:53:21 +13:00
|
|
|
|
2023-12-26 11:05:11 +13:00
|
|
|
self.accept_button.setText(self.tr("Verify"))
|
2024-02-22 00:21:44 +13:00
|
|
|
self.accept_button.setIcon(qta_icon("fa.check"))
|
2023-12-20 07:53:21 +13:00
|
|
|
|
|
|
|
self.options: SelectiveDownloadsModel = SelectiveDownloadsModel(rgame.app_name)
|
|
|
|
|
2023-12-26 11:05:11 +13:00
|
|
|
def done_handler(self):
|
2023-12-20 07:53:21 +13:00
|
|
|
self.result_ready.emit(self.rgame, self.options)
|
|
|
|
|
2023-12-26 11:05:11 +13:00
|
|
|
def accept_handler(self):
|
2023-12-20 07:53:21 +13:00
|
|
|
self.options.accepted = True
|
2024-01-10 03:32:53 +13:00
|
|
|
self.options.install_tag = self.selective_widget.install_tags()
|
2023-12-20 07:53:21 +13:00
|
|
|
|
2023-12-26 11:05:11 +13:00
|
|
|
def reject_handler(self):
|
2023-12-20 07:53:21 +13:00
|
|
|
self.options.accepted = False
|
|
|
|
self.options.install_tag = None
|