diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a713f279..1a3ab52c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -40,6 +40,9 @@ jobs: run: | pip3 install -r requirements.txt pip3 install -r requirements-presence.txt + - name: Install Development Dependencies + run: | + pip3 install qstylizer - name: Analysis with pylint run: | python3 -m pylint -E rare --jobs=3 --disable=E0611,E1123,E1120 --ignore=ui,singleton.py --extension-pkg-whitelist=PyQt5 --generated-members=PyQt5.* diff --git a/rare/components/tabs/games/game_widgets/icon_widget.py b/rare/components/tabs/games/game_widgets/icon_widget.py index 0cbf6ac1..9ec78ba4 100644 --- a/rare/components/tabs/games/game_widgets/icon_widget.py +++ b/rare/components/tabs/games/game_widgets/icon_widget.py @@ -10,7 +10,7 @@ from PyQt5.QtWidgets import ( QPushButton, ) -from rare.utils.misc import icon +from rare.utils.misc import icon, widget_object_name from rare.widgets.elide_label import ElideLabel @@ -58,13 +58,13 @@ class IconWidget(object): # play button self.launch_btn = QPushButton(parent=self.mini_widget) - self.launch_btn.setObjectName(f"{type(self).__name__}LaunchButton") + self.launch_btn.setObjectName(f"{type(self).__name__}Button") self.launch_btn.setIcon(icon("ei.play-alt", color="white")) self.launch_btn.setIconSize(QSize(20, 20)) self.launch_btn.setFixedSize(QSize(widget.width() // 4, widget.width() // 4)) self.install_btn = QPushButton(parent=self.mini_widget) - self.install_btn.setObjectName(f"{type(self).__name__}InstallButton") + self.install_btn.setObjectName(f"{type(self).__name__}Button") self.install_btn.setIcon(icon("ri.install-fill", color="white")) self.install_btn.setIconSize(QSize(20, 20)) self.install_btn.setFixedSize(QSize(widget.width() // 4, widget.width() // 4)) diff --git a/rare/components/tabs/games/game_widgets/library_widget.py b/rare/components/tabs/games/game_widgets/library_widget.py index a2aaebdf..c2a34851 100644 --- a/rare/components/tabs/games/game_widgets/library_widget.py +++ b/rare/components/tabs/games/game_widgets/library_widget.py @@ -40,11 +40,7 @@ class ProgressLabel(QLabel): f"QLabel#{type(self).__name__} {{" f"background-color: rgba({bg.red()}, {bg.green()}, {bg.blue()}, 65%);" f"color: rgb({fg.red()}, {fg.green()}, {fg.blue()});" - f"border-width: 1px;" - f"border-radius: 5%;" f"border-color: rgb({brd.red()}, {brd.green()}, {brd.blue()});" - f"font-weight: bold;" - f"font-size: 16pt;" f"}}" ) self.setStyleSheet(sheet) diff --git a/rare/components/tabs/games/game_widgets/list_widget.py b/rare/components/tabs/games/game_widgets/list_widget.py index 78cfcbf3..d06cd8fc 100644 --- a/rare/components/tabs/games/game_widgets/list_widget.py +++ b/rare/components/tabs/games/game_widgets/list_widget.py @@ -39,14 +39,14 @@ class ListWidget(object): self.tooltip_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.install_btn = QPushButton(parent=widget) + self.install_btn.setObjectName(f"{type(self).__name__}Button") self.install_btn.setIcon(icon("ri.install-fill")) - self.install_btn.setStyleSheet("text-align:left") self.install_btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.install_btn.setFixedWidth(120) self.launch_btn = QPushButton(parent=widget) + self.launch_btn.setObjectName(f"{type(self).__name__}Button") self.launch_btn.setIcon(icon("ei.play-alt")) - self.launch_btn.setStyleSheet("text-align:left") self.launch_btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.launch_btn.setFixedWidth(120) @@ -58,15 +58,15 @@ class ListWidget(object): self.install_btn.setFocusPolicy(Qt.NoFocus) self.developer_label = ElideLabel(parent=widget) - self.developer_label.setObjectName(f"{type(self).__name__}DeveloperLabel") + self.developer_label.setObjectName(f"{type(self).__name__}InfoLabel") self.developer_label.setFixedWidth(120) self.version_label = ElideLabel(parent=widget) - self.version_label.setObjectName(f"{type(self).__name__}VersionLabel") + self.version_label.setObjectName(f"{type(self).__name__}InfoLabel") self.version_label.setFixedWidth(120) self.size_label = ElideLabel(parent=widget) - self.size_label.setObjectName(f"{type(self).__name__}SizeLabel") + self.size_label.setObjectName(f"{type(self).__name__}InfoLabel") self.size_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.size_label.setFixedWidth(60) diff --git a/rare/components/tabs/settings/rare.py b/rare/components/tabs/settings/rare.py index 84009dcf..230349c2 100644 --- a/rare/components/tabs/settings/rare.py +++ b/rare/components/tabs/settings/rare.py @@ -193,8 +193,8 @@ class RareSettings(QWidget, Ui_RareSettings): self.tr("Permission error, cannot remove {}").format(self.start_menu_link), ) - def on_color_select_changed(self, color): - if color: + def on_color_select_changed(self, scheme): + if scheme: self.style_select.setCurrentIndex(0) self.style_select.setDisabled(True) self.settings.setValue("color_scheme", self.color_select.currentText()) diff --git a/rare/resources/static_css/__init__.py b/rare/resources/static_css/__init__.py index 54f20323..a6b16f52 100644 Binary files a/rare/resources/static_css/__init__.py and b/rare/resources/static_css/__init__.py differ diff --git a/rare/resources/static_css/stylesheet.py b/rare/resources/static_css/stylesheet.py index f8cc898c..ba1e0db4 100644 --- a/rare/resources/static_css/stylesheet.py +++ b/rare/resources/static_css/stylesheet.py @@ -57,8 +57,8 @@ def processResourceFile(filenamesIn, filenameOut, listFiles): return library.output(filenameOut) -def css_name(widget: Union[wrappertype,QObject,Type]): - return f"#{widget_object_name(widget, '')}" +def css_name(widget: Union[wrappertype,QObject,Type], subwidget: str = ""): + return f"#{widget_object_name(widget, '')}{subwidget}" css = qstylizer.style.StyleSheet() @@ -109,12 +109,22 @@ css.QLabel["#QueueWorkerLabel"]['[workerType="Move"]'].setValues( ) +# ProgressLabel +from rare.components.tabs.games.game_widgets.library_widget import ProgressLabel +css.QLabel[css_name(ProgressLabel)].setValues( + borderWidth="1px", + borderRadius="5%", + fontWeight="bold", + fontSize="16pt", +) + + # IconGameWidget -icon_name = lambda x: f"#IconWidget{x}" +from rare.components.tabs.games.game_widgets.icon_widget import IconWidget icon_background_props = { - "backgroundColor":"rgba(0, 0, 0, 65%)", + "backgroundColor": "rgba(0, 0, 0, 65%)", } -css.QLabel[icon_name("StatusLabel")].setValues( +css.QLabel[css_name(IconWidget, "StatusLabel")].setValues( fontWeight="bold", color="white", **icon_background_props, @@ -122,7 +132,7 @@ css.QLabel[icon_name("StatusLabel")].setValues( borderTopLeftRadius="11%", borderTopRightRadius="11%", ) -css.QWidget[icon_name("MiniWidget")].setValues( +css.QWidget[css_name(IconWidget, "MiniWidget")].setValues( color="rgb(238, 238, 238)", **icon_background_props, borderRadius="5%", @@ -133,11 +143,11 @@ icon_bottom_label_props = { "color": "white", "backgroundColor": "rgba(0, 0, 0, 0%)", } -css.QLabel[icon_name("TitleLabel")].setValues( +css.QLabel[css_name(IconWidget, "TitleLabel")].setValues( fontWeight="bold", **icon_bottom_label_props, ) -css.QLabel[icon_name("TooltipLabel")].setValues( +css.QLabel[css_name(IconWidget, "TooltipLabel")].setValues( **icon_bottom_label_props, ) icon_square_button_props = { @@ -145,35 +155,30 @@ icon_square_button_props = { "borderRadius": "10%", } icon_square_button_props.update(icon_background_props) -css.QPushButton[icon_name("LaunchButton")].setValues( +css.QPushButton[css_name(IconWidget, "Button")].setValues( **icon_square_button_props ) -css.QPushButton[icon_name("LaunchButton")].hover.borderColor.setValue("gray") -css.QPushButton[icon_name("InstallButton")].setValues( - **icon_square_button_props -) -css.QPushButton[icon_name("InstallButton")].hover.borderColor.setValue("gray") +css.QPushButton[css_name(IconWidget, "Button")].hover.borderColor.setValue("gray") # ListGameWidget -list_name = lambda x: f"#ListWidget{x}" -css.QLabel[list_name("TitleLabel")].fontWeight.setValue("bold") +from rare.components.tabs.games.game_widgets.list_widget import ListWidget +css.QLabel[css_name(ListWidget,"TitleLabel")].fontWeight.setValue("bold") list_status_label_props = { + "color": "white", "backgroundColor": "rgba(0, 0, 0, 75%)", "border": "1px solid black", "borderRadius": "5px", } -css.QLabel[list_name("StatusLabel")].setValues( +css.QLabel[css_name(ListWidget, "StatusLabel")].setValues( fontWeight="bold", **list_status_label_props, ) -css.QLabel[list_name("TooltipLabel")].setValues( +css.QLabel[css_name(ListWidget, "TooltipLabel")].setValues( **list_status_label_props, ) -list_info_label_color = "#999" -css.QLabel[list_name("DeveloperLabel")].color.setValue(list_info_label_color) -css.QLabel[list_name("VersionLabel")].color.setValue(list_info_label_color) -css.QLabel[list_name("SizeLabel")].color.setValue(list_info_label_color) +css.QPushButton[css_name(ListWidget, "Button")].textAlign.setValue("left") +css.QLabel[css_name(ListWidget, "InfoLabel")].color.setValue("#999") # WaitingSpinner @@ -186,7 +191,7 @@ css.QLabel[css_name(WaitingSpinner)].setValues( # SelectViewWidget from rare.utils.extra_widgets import SelectViewWidget -css.QPushButton[f"{css_name(SelectViewWidget)}Button"].setValues( +css.QPushButton[css_name(SelectViewWidget, "Button")].setValues( border="none", backgroundColor="transparent", ) diff --git a/rare/resources/static_css/stylesheet.qss b/rare/resources/static_css/stylesheet.qss index 80895846..4b74aebd 100644 --- a/rare/resources/static_css/stylesheet.qss +++ b/rare/resources/static_css/stylesheet.qss @@ -38,6 +38,12 @@ QLabel#QueueWorkerLabel[workerType="Move"] { border-color: #20656c; background-color: #103236; } +QLabel#ProgressLabel { + border-width: 1px; + border-radius: 5%; + font-weight: bold; + font-size: 16pt; +} QLabel#IconWidgetStatusLabel { font-weight: bold; color: white; @@ -62,20 +68,12 @@ QLabel#IconWidgetTooltipLabel { color: white; background-color: rgba(0, 0, 0, 0%); } -QPushButton#IconWidgetLaunchButton { +QPushButton#IconWidgetButton { border: 1px solid black; border-radius: 10%; background-color: rgba(0, 0, 0, 65%); } -QPushButton#IconWidgetLaunchButton:hover { - border-color: gray; -} -QPushButton#IconWidgetInstallButton { - border: 1px solid black; - border-radius: 10%; - background-color: rgba(0, 0, 0, 65%); -} -QPushButton#IconWidgetInstallButton:hover { +QPushButton#IconWidgetButton:hover { border-color: gray; } QLabel#ListWidgetTitleLabel { @@ -83,22 +81,21 @@ QLabel#ListWidgetTitleLabel { } QLabel#ListWidgetStatusLabel { font-weight: bold; + color: white; background-color: rgba(0, 0, 0, 75%); border: 1px solid black; border-radius: 5px; } QLabel#ListWidgetTooltipLabel { + color: white; background-color: rgba(0, 0, 0, 75%); border: 1px solid black; border-radius: 5px; } -QLabel#ListWidgetDeveloperLabel { - color: #999; +QPushButton#ListWidgetButton { + text-align: left; } -QLabel#ListWidgetVersionLabel { - color: #999; -} -QLabel#ListWidgetSizeLabel { +QLabel#ListWidgetInfoLabel { color: #999; } QLabel#WaitingSpinner { diff --git a/rare/utils/misc.py b/rare/utils/misc.py index 67b97987..6d2b53b4 100644 --- a/rare/utils/misc.py +++ b/rare/utils/misc.py @@ -81,16 +81,28 @@ def load_color_scheme(path: str) -> QPalette: return palette -def set_color_pallete(color_scheme: str): +def get_static_style() -> str: + file = QFile(":/static_css/stylesheet.qss") + file.open(QFile.ReadOnly) + static = file.readAll().data().decode("utf-8") + file.close() + return static + + +def set_color_pallete(color_scheme: str) -> None: + static = get_static_style() + if not color_scheme: qApp.setStyle(QStyleFactory.create(qApp.property("rareDefaultQtStyle"))) - qApp.setStyleSheet("") qApp.setPalette(qApp.style().standardPalette()) + qApp.setStyleSheet(static) return + qApp.setStyle(QStyleFactory.create("Fusion")) custom_palette = load_color_scheme(f":/schemes/{color_scheme}") if custom_palette is not None: qApp.setPalette(custom_palette) + qApp.setStyleSheet(static) icon_color = qApp.palette().color(QPalette.Foreground).name() qtawesome.set_defaults(color=icon_color) @@ -102,11 +114,8 @@ def get_color_schemes() -> List[str]: return colors -def set_style_sheet(style_sheet: str): - file = QFile(":/static_css/stylesheet.qss") - file.open(QFile.ReadOnly) - static = file.readAll().data().decode("utf-8") - file.close() +def set_style_sheet(style_sheet: str) -> None: + static = get_static_style() if not style_sheet: qApp.setStyle(QStyleFactory.create(qApp.property("rareDefaultQtStyle"))) @@ -208,11 +217,11 @@ def icon(icn_str: str, fallback: str = None, **kwargs): return qtawesome.icon("ei.error", **kwargs) -def widget_object_name(widget: Union[wrappertype,QObject,Type], suffix: str) -> str: +def widget_object_name(widget: Union[QObject,wrappertype,Type], suffix: str) -> str: suffix = f"_{suffix}" if suffix else "" if isinstance(widget, QObject): return f"{type(widget).__name__}{suffix}" - elif isinstance(widget, wrappertype): + elif isinstance(widget, wrappertype) or isinstance(widget, type): return f"{widget.__name__}{suffix}" else: raise RuntimeError(f"Argument {widget} not a QObject or type of QObject") diff --git a/rare/widgets/rare_app.py b/rare/widgets/rare_app.py index 85cc73fa..d4d0332a 100644 --- a/rare/widgets/rare_app.py +++ b/rare/widgets/rare_app.py @@ -12,7 +12,7 @@ from PyQt5.QtWidgets import QApplication import rare.resources.resources from rare.utils import paths -from rare.utils.misc import set_color_pallete, set_style_sheet +from rare.utils.misc import set_color_pallete, set_style_sheet, get_static_style class RareApp(QApplication): @@ -91,14 +91,11 @@ class RareApp(QApplication): if color_scheme := self.settings.value("color_scheme", False): self.settings.setValue("style_sheet", "") set_color_pallete(color_scheme) - # lk: set the static stylesheet - set_style_sheet("") elif style_sheet := self.settings.value("style_sheet", False): self.settings.setValue("color_scheme", "") set_style_sheet(style_sheet) else: - # lk: set the static stylesheet - set_style_sheet("") + self.setStyleSheet(get_static_style()) self.setWindowIcon(QIcon(":/images/Rare.png")) def load_translator(self, lang: str):