Base for Game info
This commit is contained in:
parent
549a4f335c
commit
f0ff1524e5
|
@ -5,7 +5,7 @@ from legendary.core import LegendaryCore
|
||||||
from Rare import style_path
|
from Rare import style_path
|
||||||
from Rare.Components.Tabs.Account.AccountWidget import MiniWidget
|
from Rare.Components.Tabs.Account.AccountWidget import MiniWidget
|
||||||
from Rare.Components.Tabs.Downloads.DownloadTab import DownloadTab
|
from Rare.Components.Tabs.Downloads.DownloadTab import DownloadTab
|
||||||
from Rare.Components.Tabs.Games.GamesTab import Games
|
from Rare.Components.Tabs.Games.GamesTab import GameTab
|
||||||
from Rare.Components.Tabs.Settings.SettingsTab import SettingsTab
|
from Rare.Components.Tabs.Settings.SettingsTab import SettingsTab
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ class TabWidget(QTabWidget):
|
||||||
super(TabWidget, self).__init__()
|
super(TabWidget, self).__init__()
|
||||||
self.setTabBar(TabBar(2))
|
self.setTabBar(TabBar(2))
|
||||||
self.settings = SettingsTab(core)
|
self.settings = SettingsTab(core)
|
||||||
self.game_list = Games(core)
|
self.game_list = GameTab(core)
|
||||||
self.addTab(self.game_list, self.tr("Games"))
|
self.addTab(self.game_list, self.tr("Games"))
|
||||||
self.downloadTab = DownloadTab(core)
|
self.downloadTab = DownloadTab(core)
|
||||||
self.addTab(self.downloadTab, "Downloads")
|
self.addTab(self.downloadTab, "Downloads")
|
||||||
self.downloadTab.finished.connect(self.game_list.game_list.update_list)
|
self.downloadTab.finished.connect(self.game_list.default_widget.game_list.update_list)
|
||||||
self.game_list.game_list.install_game.connect(lambda x: self.downloadTab.install_game(x))
|
self.game_list.default_widget.game_list.install_game.connect(lambda x: self.downloadTab.install_game(x))
|
||||||
# Space Tab
|
# Space Tab
|
||||||
self.addTab(QWidget(), "")
|
self.addTab(QWidget(), "")
|
||||||
self.setTabEnabled(2, False)
|
self.setTabEnabled(2, False)
|
||||||
|
|
31
Rare/Components/Tabs/Games/GameInfo.py
Normal file
31
Rare/Components/Tabs/Games/GameInfo.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
from PyQt5.QtWidgets import QWidget, QPushButton, QVBoxLayout, QLabel
|
||||||
|
from legendary.core import LegendaryCore
|
||||||
|
from legendary.models.game import InstalledGame, Game
|
||||||
|
|
||||||
|
|
||||||
|
class GameInfo(QWidget):
|
||||||
|
igame: InstalledGame
|
||||||
|
game: Game
|
||||||
|
|
||||||
|
def __init__(self, core: LegendaryCore):
|
||||||
|
super(GameInfo, self).__init__()
|
||||||
|
self.core = core
|
||||||
|
self.app_name = ""
|
||||||
|
self.layout = QVBoxLayout()
|
||||||
|
self.back_button = QPushButton("Back")
|
||||||
|
self.layout.addWidget(self.back_button)
|
||||||
|
|
||||||
|
# TODO More Information: Image text settings needs_verification platform
|
||||||
|
|
||||||
|
self.game_title = QLabel("Error")
|
||||||
|
self.layout.addWidget(self.game_title)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def update_game(self, app_name):
|
||||||
|
self.game = self.core.get_game(app_name)
|
||||||
|
self.igame = self.core.get_installed_game(app_name)
|
||||||
|
|
||||||
|
self.game_title.setText(self.game.app_title)
|
|
@ -9,6 +9,7 @@ from Rare.utils.QtExtensions import FlowLayout
|
||||||
|
|
||||||
class GameList(QScrollArea):
|
class GameList(QScrollArea):
|
||||||
install_game = pyqtSignal(dict)
|
install_game = pyqtSignal(dict)
|
||||||
|
show_game_info = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, core: LegendaryCore):
|
def __init__(self, core: LegendaryCore):
|
||||||
super(GameList, self).__init__()
|
super(GameList, self).__init__()
|
||||||
|
@ -21,10 +22,9 @@ class GameList(QScrollArea):
|
||||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
self.widget = QWidget()
|
self.widget = QWidget()
|
||||||
self.widgets=[]
|
self.widgets = []
|
||||||
self.layout = FlowLayout()
|
self.layout = FlowLayout()
|
||||||
# Installed Games
|
# Installed Games
|
||||||
for game in sorted(self.core.get_installed_list(), key=lambda x: x.title):
|
for game in sorted(self.core.get_installed_list(), key=lambda x: x.title):
|
||||||
|
@ -32,6 +32,7 @@ class GameList(QScrollArea):
|
||||||
widget = GameWidgetInstalled(self.core, game)
|
widget = GameWidgetInstalled(self.core, game)
|
||||||
self.layout.addWidget(widget)
|
self.layout.addWidget(widget)
|
||||||
widget.update_list.connect(self.update_list)
|
widget.update_list.connect(self.update_list)
|
||||||
|
widget.show_info.connect(lambda app_name: self.show_game_info.emit(app_name))
|
||||||
|
|
||||||
uninstalled_games = []
|
uninstalled_games = []
|
||||||
installed = [i.app_name for i in self.core.get_installed_list()]
|
installed = [i.app_name for i in self.core.get_installed_list()]
|
||||||
|
|
|
@ -16,6 +16,7 @@ logger = getLogger("GameWidgetInstalled")
|
||||||
|
|
||||||
class GameWidgetInstalled(QWidget):
|
class GameWidgetInstalled(QWidget):
|
||||||
update_list = pyqtSignal()
|
update_list = pyqtSignal()
|
||||||
|
show_info = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, core: LegendaryCore, game: InstalledGame):
|
def __init__(self, core: LegendaryCore, game: InstalledGame):
|
||||||
super(GameWidgetInstalled, self).__init__()
|
super(GameWidgetInstalled, self).__init__()
|
||||||
|
@ -108,6 +109,8 @@ class GameWidgetInstalled(QWidget):
|
||||||
logger.info("Uninstalling " + self.game.title)
|
logger.info("Uninstalling " + self.game.title)
|
||||||
self.core.uninstall_game(self.game)
|
self.core.uninstall_game(self.game)
|
||||||
self.update_list.emit()
|
self.update_list.emit()
|
||||||
|
elif action == "info":
|
||||||
|
self.show_info.emit(self.game.app_name)
|
||||||
|
|
||||||
|
|
||||||
class Menu(QMenu):
|
class Menu(QMenu):
|
||||||
|
|
|
@ -1,8 +1,27 @@
|
||||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QCheckBox, QLineEdit, QLabel, QPushButton, QStyle
|
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QCheckBox, QLineEdit, QLabel, QPushButton, QStyle, \
|
||||||
|
QStackedLayout
|
||||||
|
|
||||||
|
from Rare.Components.Tabs.Games.GameInfo import GameInfo
|
||||||
from Rare.Components.Tabs.Games.GameList import GameList
|
from Rare.Components.Tabs.Games.GameList import GameList
|
||||||
|
|
||||||
|
|
||||||
|
class GameTab(QWidget):
|
||||||
|
def __init__(self, core):
|
||||||
|
super(GameTab, self).__init__()
|
||||||
|
self.layout = QStackedLayout()
|
||||||
|
self.default_widget = Games(core)
|
||||||
|
self.default_widget.game_list.show_game_info.connect(self.show_info)
|
||||||
|
self.layout.addWidget(self.default_widget)
|
||||||
|
self.game_info = GameInfo(core)
|
||||||
|
self.game_info.back_button.clicked.connect(lambda: self.layout.setCurrentIndex(0))
|
||||||
|
self.layout.addWidget(self.game_info)
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
def show_info(self, app_name):
|
||||||
|
self.game_info.update_game(app_name)
|
||||||
|
self.layout.setCurrentIndex(1)
|
||||||
|
|
||||||
|
|
||||||
class Games(QWidget):
|
class Games(QWidget):
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
super(Games, self).__init__()
|
super(Games, self).__init__()
|
||||||
|
|
|
@ -4,7 +4,6 @@ import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QTranslator, QSettings
|
from PyQt5.QtCore import QTranslator, QSettings
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
from legendary.core import LegendaryCore
|
from legendary.core import LegendaryCore
|
||||||
|
|
||||||
from Rare import style_path, lang_path
|
from Rare import style_path, lang_path
|
||||||
|
@ -25,7 +24,7 @@ def main():
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
# Translator
|
# Translator
|
||||||
translator = QTranslator()
|
translator = QTranslator()
|
||||||
lang = settings.value("language",get_lang() , type=str)
|
lang = settings.value("language", get_lang(), type=str)
|
||||||
|
|
||||||
if os.path.exists(lang_path + lang + ".qm"):
|
if os.path.exists(lang_path + lang + ".qm"):
|
||||||
translator.load(lang_path + lang + ".qm")
|
translator.load(lang_path + lang + ".qm")
|
||||||
|
@ -35,7 +34,6 @@ def main():
|
||||||
# Style
|
# Style
|
||||||
app.setStyleSheet(open(style_path + "RareStyle.qss").read())
|
app.setStyleSheet(open(style_path + "RareStyle.qss").read())
|
||||||
|
|
||||||
|
|
||||||
launch_dialog = LaunchDialog(core)
|
launch_dialog = LaunchDialog(core)
|
||||||
launch_dialog.exec_()
|
launch_dialog.exec_()
|
||||||
mainwindow = MainWindow(core)
|
mainwindow = MainWindow(core)
|
||||||
|
|
Loading…
Reference in a new issue