Fix game_info
This commit is contained in:
parent
e0916a0fa6
commit
e002023600
1 changed files with 28 additions and 112 deletions
|
@ -3,8 +3,7 @@ import os
|
|||
|
||||
from PyQt5.QtCore import Qt, pyqtSignal
|
||||
from PyQt5.QtGui import QPixmap, QKeyEvent
|
||||
from PyQt5.QtWidgets import QWidget, QPushButton, QVBoxLayout, QLabel, QHBoxLayout, QTabWidget, QMessageBox, \
|
||||
QProgressBar, QStackedWidget, QGroupBox, QScrollArea
|
||||
from PyQt5.QtWidgets import QWidget, QTabWidget, QMessageBox
|
||||
from qtawesome import icon
|
||||
|
||||
from custom_legendary.core import LegendaryCore
|
||||
|
@ -12,6 +11,7 @@ from custom_legendary.models.game import InstalledGame, Game
|
|||
from rare.components.dialogs.uninstall_dialog import UninstallDialog
|
||||
from rare.components.tabs.games.game_info.dlcs import DlcTab
|
||||
from rare.components.tabs.games.game_info.game_settings import GameSettings
|
||||
from rare.ui.components.tabs.games.game_info.game_info import Ui_GameInfo
|
||||
from rare.utils import legendary_utils
|
||||
from rare.utils.extra_widgets import SideTabBar
|
||||
from rare.utils.legendary_utils import VerifyThread
|
||||
|
@ -56,7 +56,7 @@ class InfoTabs(QTabWidget):
|
|||
self.parent().layout.setCurrentIndex(0)
|
||||
|
||||
|
||||
class GameInfo(QScrollArea):
|
||||
class GameInfo(QWidget, Ui_GameInfo):
|
||||
igame: InstalledGame
|
||||
game: Game
|
||||
update_list = pyqtSignal()
|
||||
|
@ -67,7 +67,7 @@ class GameInfo(QScrollArea):
|
|||
|
||||
def __init__(self, core: LegendaryCore, parent):
|
||||
super(GameInfo, self).__init__(parent=parent)
|
||||
|
||||
self.setupUi(self)
|
||||
self.ratings = {"platinum": self.tr("Platimum"),
|
||||
"gold": self.tr("Gold"),
|
||||
"silver": self.tr("Silver"),
|
||||
|
@ -77,58 +77,13 @@ class GameInfo(QScrollArea):
|
|||
|
||||
self.widget = QWidget()
|
||||
self.core = core
|
||||
self.layout = QVBoxLayout()
|
||||
self.setWidgetResizable(True)
|
||||
if os.name == "nt":
|
||||
self.lbl_grade.setVisible(False)
|
||||
self.grade.setVisible(False)
|
||||
|
||||
top_layout = QHBoxLayout()
|
||||
|
||||
# No Game at start. Game is set when clicked info
|
||||
self.image = QLabel()
|
||||
top_layout.addWidget(self.image)
|
||||
|
||||
right_layout = QVBoxLayout()
|
||||
self.game_title = QLabel("Error")
|
||||
self.game_title.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
right_layout.addWidget(self.game_title)
|
||||
|
||||
self.dev = QLabel("Error")
|
||||
self.dev.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
right_layout.addWidget(self.dev)
|
||||
|
||||
self.app_name = QLabel("Error")
|
||||
self.app_name.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
right_layout.addWidget(self.app_name)
|
||||
|
||||
if os.name != "nt":
|
||||
self.grade = QLabel("Error")
|
||||
right_layout.addWidget(self.grade)
|
||||
self.grade.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
|
||||
self.version = QLabel("Error")
|
||||
self.version.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
right_layout.addWidget(self.version)
|
||||
|
||||
self.install_size = QLabel("Error")
|
||||
right_layout.addWidget(self.install_size)
|
||||
|
||||
self.install_path = QLabel("Error")
|
||||
self.install_path.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
||||
self.install_path.setWordWrap(True)
|
||||
right_layout.addWidget(self.install_path)
|
||||
|
||||
top_layout.addLayout(right_layout)
|
||||
top_layout.addStretch()
|
||||
self.game_actions = GameActions()
|
||||
|
||||
self.game_actions.uninstall_button.clicked.connect(self.uninstall)
|
||||
self.game_actions.verify_button.clicked.connect(self.verify)
|
||||
self.game_actions.repair_button.clicked.connect(self.repair)
|
||||
|
||||
self.layout.addLayout(top_layout)
|
||||
self.layout.addWidget(self.game_actions)
|
||||
self.layout.addStretch()
|
||||
self.widget.setLayout(self.layout)
|
||||
self.setWidget(self.widget)
|
||||
self.uninstall_button.clicked.connect(self.uninstall)
|
||||
self.verify_button.clicked.connect(self.verify)
|
||||
self.repair_button.clicked.connect(self.repair)
|
||||
|
||||
def uninstall(self):
|
||||
infos = UninstallDialog(self.game).get_information()
|
||||
|
@ -147,18 +102,18 @@ class GameInfo(QScrollArea):
|
|||
self.verify_game.emit(self.game.app_name)
|
||||
|
||||
def verify(self):
|
||||
self.game_actions.verify_widget.setCurrentIndex(1)
|
||||
self.verify_widget.setCurrentIndex(1)
|
||||
verify_thread = VerifyThread(self.core, self.game.app_name)
|
||||
verify_thread.status.connect(self.verify_satistics)
|
||||
verify_thread.summary.connect(self.finish_verify)
|
||||
verify_thread.start()
|
||||
self.game_actions.verify_progress_bar.setValue(0)
|
||||
self.verify_progress.setValue(0)
|
||||
self.verify_threads[self.game.app_name] = verify_thread
|
||||
|
||||
def verify_satistics(self, progress):
|
||||
# checked, max, app_name
|
||||
if progress[2] == self.game.app_name:
|
||||
self.game_actions.verify_progress_bar.setValue(progress[0] * 100 / progress[1])
|
||||
self.verify_progress.setValue(progress[0] * 100 / progress[1])
|
||||
|
||||
def finish_verify(self, failed):
|
||||
failed, missing, app_name = failed
|
||||
|
@ -171,7 +126,7 @@ class GameInfo(QScrollArea):
|
|||
failed, missing), QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
|
||||
if ans == QMessageBox.Yes:
|
||||
self.verify_game.emit(self.game.app_name)
|
||||
self.game_actions.verify_widget.setCurrentIndex(0)
|
||||
self.verify_widget.setCurrentIndex(0)
|
||||
self.verify_threads.pop(app_name)
|
||||
|
||||
def update_game(self, app_name):
|
||||
|
@ -193,62 +148,23 @@ class GameInfo(QScrollArea):
|
|||
w = 200
|
||||
pixmap = pixmap.scaled(w, int(w * 4 / 3))
|
||||
self.image.setPixmap(pixmap)
|
||||
self.app_name.setText("App name: " + self.game.app_name)
|
||||
self.version.setText("Version: " + self.game.app_version)
|
||||
self.dev.setText(self.tr("Developer: ") + self.game.metadata["developer"])
|
||||
self.install_size.setText(
|
||||
self.tr("Install size: ") + get_size(self.igame.install_size))
|
||||
self.install_path.setText(self.tr("Install path: ") + self.igame.install_path)
|
||||
|
||||
self.app_name.setText(self.game.app_name)
|
||||
self.version.setText(self.game.app_version)
|
||||
self.dev.setText(self.game.metadata["developer"])
|
||||
self.install_size.setText(get_size(self.igame.install_size))
|
||||
self.install_path.setText(self.igame.install_path)
|
||||
|
||||
if os.name != "nt":
|
||||
if grade := self.ratings.get(self.grade_table[app_name].get("grade")):
|
||||
self.grade.setText(self.tr("ProtonDB rating: ") + grade)
|
||||
else:
|
||||
self.grade.setText(self.tr("ProtonDB rating: Error"))
|
||||
try:
|
||||
grade = self.ratings.get(self.grade_table[app_name].get("grade"))
|
||||
except KeyError:
|
||||
grade = (self.tr("Error"))
|
||||
self.grade.setText(grade)
|
||||
|
||||
if len(self.verify_threads.keys()) == 0 or not self.verify_threads.get(app_name):
|
||||
self.game_actions.verify_widget.setCurrentIndex(0)
|
||||
self.verify_widget.setCurrentIndex(0)
|
||||
elif self.verify_threads.get(app_name):
|
||||
self.game_actions.verify_widget.setCurrentIndex(1)
|
||||
self.game_actions.verify_progress_bar.setValue(
|
||||
self.verify_widget.setCurrentIndex(1)
|
||||
self.verify_progress.setValue(
|
||||
self.verify_threads[app_name].num / self.verify_threads[app_name].total * 100)
|
||||
|
||||
|
||||
class GameActions(QGroupBox):
|
||||
def __init__(self):
|
||||
super(GameActions, self).__init__()
|
||||
self.setTitle(f"{self.tr('Game actions')}")
|
||||
self.setStyleSheet("QGroupBox{font-size: 20px}")
|
||||
self.layout = QVBoxLayout()
|
||||
|
||||
uninstall_layout = QHBoxLayout()
|
||||
self.uninstall_game = QLabel(self.tr("Uninstall game"))
|
||||
uninstall_layout.addWidget(self.uninstall_game)
|
||||
self.uninstall_button = QPushButton(self.tr("Uninstall"))
|
||||
self.uninstall_button.setFixedWidth(250)
|
||||
uninstall_layout.addWidget(self.uninstall_button)
|
||||
self.layout.addLayout(uninstall_layout)
|
||||
|
||||
verify_layout = QHBoxLayout()
|
||||
self.verify_game = QLabel(self.tr("Verify Game"))
|
||||
verify_layout.addWidget(self.verify_game)
|
||||
self.verify_widget = QStackedWidget()
|
||||
self.verify_widget.setMaximumHeight(20)
|
||||
self.verify_widget.setFixedWidth(250)
|
||||
self.verify_button = QPushButton(self.tr("Verify"))
|
||||
self.verify_widget.addWidget(self.verify_button)
|
||||
self.verify_progress_bar = QProgressBar()
|
||||
self.verify_progress_bar.setMaximum(100)
|
||||
self.verify_widget.addWidget(self.verify_progress_bar)
|
||||
verify_layout.addWidget(self.verify_widget)
|
||||
self.layout.addLayout(verify_layout)
|
||||
|
||||
repair_layout = QHBoxLayout()
|
||||
repair_info = QLabel(self.tr("Repair Game"))
|
||||
repair_layout.addWidget(repair_info)
|
||||
self.repair_button = QPushButton(self.tr("Repair"))
|
||||
self.repair_button.setFixedWidth(250)
|
||||
repair_layout.addWidget(self.repair_button)
|
||||
self.layout.addLayout(repair_layout)
|
||||
|
||||
self.setLayout(self.layout)
|
||||
|
|
Loading…
Reference in a new issue