From e04b36498b70df9eceb7f803dd32f313cefadc1c Mon Sep 17 00:00:00 2001 From: Dummerle Date: Sat, 27 Feb 2021 15:54:26 +0100 Subject: [PATCH] DXVK Bugs and refractoring --- README.md | 7 ++ Rare/Components/Tabs/Games/GameInfo.py | 29 -------- .../Tabs/Games/GameInfo/GameInfo.py | 71 +++++++++++++++++++ .../Tabs/Games/GameInfo/__init__.py | 0 Rare/Components/Tabs/Games/GamesTab.py | 8 +-- Rare/Components/Tabs/Settings/DXVK/Dxvk.py | 7 +- Rare/Components/Tabs/Settings/SettingsTab.py | 34 +-------- Rare/Styles/RareStyle.qss | 9 +++ Rare/utils/QtExtensions.py | 34 ++++++++- 9 files changed, 131 insertions(+), 68 deletions(-) delete mode 100644 Rare/Components/Tabs/Games/GameInfo.py create mode 100644 Rare/Components/Tabs/Games/GameInfo/GameInfo.py create mode 100644 Rare/Components/Tabs/Games/GameInfo/__init__.py diff --git a/README.md b/README.md index f2824874..aa9a5bcb 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,10 @@ GUI for legendary. An Epic Games Launcher open source alternative ## This is a new version with better Styles. It has not many features, but i work on it. It will take some time, because I want to reimplement some features on a smoother way. + +### TODOS + - Sync Saves +- Game Settings +- Style Sheets +- Updates +- etc \ No newline at end of file diff --git a/Rare/Components/Tabs/Games/GameInfo.py b/Rare/Components/Tabs/Games/GameInfo.py deleted file mode 100644 index af762844..00000000 --- a/Rare/Components/Tabs/Games/GameInfo.py +++ /dev/null @@ -1,29 +0,0 @@ -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) diff --git a/Rare/Components/Tabs/Games/GameInfo/GameInfo.py b/Rare/Components/Tabs/Games/GameInfo/GameInfo.py new file mode 100644 index 00000000..16e41c68 --- /dev/null +++ b/Rare/Components/Tabs/Games/GameInfo/GameInfo.py @@ -0,0 +1,71 @@ +import os + +from PyQt5.QtGui import QPixmap +from PyQt5.QtWidgets import QWidget, QPushButton, QVBoxLayout, QLabel, QHBoxLayout, QTabWidget +from legendary.core import LegendaryCore +from legendary.models.game import InstalledGame, Game + +from Rare.utils.QtExtensions import SideTabBar +from Rare.utils.utils import IMAGE_DIR + + +class InfoTabs(QTabWidget): + def __init__(self, core): + super(InfoTabs, self).__init__() + + self.setTabBar(SideTabBar()) + self.setTabPosition(QTabWidget.West) + + self.info = GameInfo(core) + self.addTab(self.info, "Game Info") + self.addTab(QLabel("Coming soon"), "Cloud Saves") + self.addTab(QLabel("Coming soon"), "Settings") + + +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 + top_layout = QHBoxLayout() + + self.image = QLabel() + top_layout.addWidget(self.image) + + right_layout = QVBoxLayout() + self.game_title = QLabel("Error") + right_layout.addWidget(self.game_title) + + top_layout.addLayout(right_layout) + + self.layout.addLayout(top_layout) + self.layout.addStretch() + 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(f"

{self.game.app_title}

") + + if os.path.exists(f"{IMAGE_DIR}/{self.game.app_name}/FinalArt.png"): + pixmap = QPixmap(f"{IMAGE_DIR}/{self.game.app_name}/FinalArt.png") + elif os.path.exists(f"{IMAGE_DIR}/{self.game.app_name}/DieselGameBoxTall.png"): + pixmap = QPixmap(f"{IMAGE_DIR}/{self.game.app_name}/DieselGameBoxTall.png") + elif os.path.exists(f"{IMAGE_DIR}/{self.game.app_name}/DieselGameBoxLogo.png"): + pixmap = QPixmap(f"{IMAGE_DIR}/{self.game.app_name}/DieselGameBoxLogo.png") + else: + # logger.warning(f"No Image found: {self.game.title}") + pixmap = None + if pixmap: + w = 200 + pixmap = pixmap.scaled(w, int(w * 4 / 3)) + self.image.setPixmap(pixmap) diff --git a/Rare/Components/Tabs/Games/GameInfo/__init__.py b/Rare/Components/Tabs/Games/GameInfo/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Rare/Components/Tabs/Games/GamesTab.py b/Rare/Components/Tabs/Games/GamesTab.py index 2678905b..10e27fc5 100644 --- a/Rare/Components/Tabs/Games/GamesTab.py +++ b/Rare/Components/Tabs/Games/GamesTab.py @@ -1,7 +1,7 @@ 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.GameInfo.GameInfo import InfoTabs from Rare.Components.Tabs.Games.GameList import GameList @@ -12,13 +12,13 @@ class GameTab(QWidget): 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.game_info = InfoTabs(core) + self.game_info.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.game_info.info.update_game(app_name) self.layout.setCurrentIndex(1) diff --git a/Rare/Components/Tabs/Settings/DXVK/Dxvk.py b/Rare/Components/Tabs/Settings/DXVK/Dxvk.py index 973020dc..4233d6d1 100644 --- a/Rare/Components/Tabs/Settings/DXVK/Dxvk.py +++ b/Rare/Components/Tabs/Settings/DXVK/Dxvk.py @@ -1,7 +1,11 @@ +from logging import getLogger + from PyQt5.QtCore import pyqtSignal from PyQt5.QtWidgets import QWidget, QCheckBox, QVBoxLayout, QWidgetAction, QMenu, QToolButton, QHBoxLayout, QLabel from legendary.core import LegendaryCore +logger = getLogger("DXVK Settings") + class DxvkWidget(QWidget): dxvk_settings = {"fps": (False, "Fps"), @@ -89,14 +93,13 @@ class DxvkMoreSettingsWidget(QWidget): self.setLayout(self.layout) def change(self, signal: tuple): - print(self.settings) tag, checked = signal y = list(self.settings[tag]) y[0] = checked self.settings[tag] = tuple(y) # print(self.settings) sett = [] - print(self.settings) + logger.debug(self.settings) for i in self.settings: check, _ = self.settings[i] if check: diff --git a/Rare/Components/Tabs/Settings/SettingsTab.py b/Rare/Components/Tabs/Settings/SettingsTab.py index 6d306483..3c6829bd 100644 --- a/Rare/Components/Tabs/Settings/SettingsTab.py +++ b/Rare/Components/Tabs/Settings/SettingsTab.py @@ -7,13 +7,14 @@ from Rare.Components.Tabs.Settings.About import About from Rare.Components.Tabs.Settings.Legendary import LegendarySettings from Rare.Components.Tabs.Settings.Linux import LinuxSettings from Rare.Components.Tabs.Settings.Rare import RareSettings +from Rare.utils.QtExtensions import SideTabBar class SettingsTab(QTabWidget): def __init__(self, core): super(SettingsTab, self).__init__() self.core = core - self.setTabBar(TabBar()) + self.setTabBar(SideTabBar()) self.setTabPosition(QTabWidget.West) self.addTab(RareSettings(), "Rare") self.addTab(LegendarySettings(core), "Legendary") @@ -21,34 +22,3 @@ class SettingsTab(QTabWidget): self.addTab(LinuxSettings(core), "Linux") self.addTab(About(), "About") - -class TabBar(QTabBar): - def __init__(self): - super(TabBar, self).__init__() - self.setObjectName("settings_bar") - - def tabSizeHint(self, index): - # width = QTabBar.tabSizeHint(self, index).width() - return QSize(200, 30) - - def paintEvent(self, event): - painter = QStylePainter(self) - opt = QStyleOptionTab() - - for i in range(self.count()): - self.initStyleOption(opt, i) - painter.drawControl(QStyle.CE_TabBarTabShape, opt) - painter.save() - - s = opt.rect.size() - s.transpose() - r = QRect(QPoint(), s) - r.moveCenter(opt.rect.center()) - opt.rect = r - - c = self.tabRect(i).center() - painter.translate(c) - painter.rotate(90) - painter.translate(-c) - painter.drawControl(QStyle.CE_TabBarTabLabel, opt); - painter.restore() diff --git a/Rare/Styles/RareStyle.qss b/Rare/Styles/RareStyle.qss index 45a233db..535da564 100644 --- a/Rare/Styles/RareStyle.qss +++ b/Rare/Styles/RareStyle.qss @@ -83,3 +83,12 @@ QTabBar::tab:hover#settings_bar { QTabBar::tab::selected#settings_bar { background-color: darkslategrey; } +/* +QScrollBar:vertical{ + border: 1px solid white; +} +QScrollBar::handle:vertical{ + background-color: gray; + border-radius: 4px; +} +*/ diff --git a/Rare/utils/QtExtensions.py b/Rare/utils/QtExtensions.py index 683c3176..6398c92d 100644 --- a/Rare/utils/QtExtensions.py +++ b/Rare/utils/QtExtensions.py @@ -2,7 +2,7 @@ import os from PyQt5.QtCore import Qt, QRect, QSize, QPoint, pyqtSignal from PyQt5.QtWidgets import QLayout, QStyle, QSizePolicy, QLabel, QFileDialog, QHBoxLayout, QWidget, QLineEdit, \ - QPushButton + QPushButton, QStyleOptionTab, QStylePainter, QTabBar class FlowLayout(QLayout): @@ -145,3 +145,35 @@ class PathEdit(QWidget): if dlg.exec_(): names = dlg.selectedFiles() self.text_edit.setText(names[0]) + + +class SideTabBar(QTabBar): + def __init__(self): + super(SideTabBar, self).__init__() + self.setObjectName("settings_bar") + + def tabSizeHint(self, index): + # width = QTabBar.tabSizeHint(self, index).width() + return QSize(200, 30) + + def paintEvent(self, event): + painter = QStylePainter(self) + opt = QStyleOptionTab() + + for i in range(self.count()): + self.initStyleOption(opt, i) + painter.drawControl(QStyle.CE_TabBarTabShape, opt) + painter.save() + + s = opt.rect.size() + s.transpose() + r = QRect(QPoint(), s) + r.moveCenter(opt.rect.center()) + opt.rect = r + + c = self.tabRect(i).center() + painter.translate(c) + painter.rotate(90) + painter.translate(-c) + painter.drawControl(QStyle.CE_TabBarTabLabel, opt); + painter.restore()