Skip to content

Commit 385b357

Browse files
improv: use QResources to manage Steam Deck theme.
1 parent 629d1c6 commit 385b357

File tree

10 files changed

+200
-8
lines changed

10 files changed

+200
-8
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Auto detect text files and perform LF normalization
22
* text=auto
3+
4+
pupgui2/resources/themes/steamdeck/__init__.py binary

pupgui2/resources/themes/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pupgui2.resources.themes.steamdeck as steamdeck
2+
3+
__all__ = ["steamdeck"]
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Resource object code (Python 3)
2+
# Created by: object code
3+
# Created by: The Resource Compiler for Qt version 6.8.2
4+
# WARNING! All changes made in this file will be lost!
5+
6+
from PySide6 import QtCore
7+
8+
qt_resource_data = b"\
9+
\x00\x00\x02w\
10+
(\
11+
\xb5/\xfd`\xed\x07m\x13\x00\xb6\xdaQ% \x8d\xb8\
12+
\x01h\x1f\xd1Bb\xb3\xcf\x97\xfe\x08\x9b\x87\xaeKc\
13+
\x95?\x18\xfa\x12\x80\x0e\xf6\xadny\x12\xab\x00FT\
14+
\xa0\x08K\x00G\x00B\x00\x8d\xad\x027\x84}\xae\xdb\
15+
\x81\x92\x8b\x89\x96\xb4d\xf5\x01%\x17\x1fy\x81\x92\x8b\
16+
\xd7\xff\x97\xa4\x8a\x17\x03\x85a*\x18\x03\xc7\x89R\xbf\
17+
\xa2x-\xcd\xbf\x8e(\x80&\xcf\xe3i\xda\xbb\xda)\
18+
\x89\x89I\x06\x08\x01\xa9\xde\xae\xa7\xccL\xe6\x92\xbfT\
19+
c\x08J\x95>\x0e\xc8\x81&\x8f\x93X\xe4\x16i$\
20+
D\x91\xa8m\x8c\xebP!\x05\x93\x86\xa3\xe1[\xe9J\
21+
\x1b\x97\xb4\xf6Y\x15\x92J=n\x8d\xc1\x09\x08\xa5\xc6\
22+
\x8b\x1b\xf3f_\xbfT\xdf\xe6-9\xa2\x09\x04\x81.\
23+
\xf9\x9a\x7f\xda\xa8jY~\xf0\x0dW\xc7u\x86\x02\x08\
24+
8\xbfR\x97b\x16;\x9e\xd4\xea\x1b[\x12\xf6'\xc7\
25+
\x86\xfa\x98b\xef\xc6\xb5\xff\xebI\xba\xa2\xa5[\x03\xdb\
26+
\x9b*\xe3`\xf5\x7fK\xb0\x7f\xe2\xf7\xad@\xee\xa4~\
27+
\xc4\xba\xe61\xe5\xccr\xec_S\xb0wQtIK\
28+
\xbb\xb3\x06^N\xe4D\xcdck]{\xac\x82\xfd\x8f\
29+
\xc7#]q\xb1\x8f]\xd3\x1a\xd3*2\x01#O\xea\
30+
\xbfu\x06\xe3c\xfe\xce$\xce\xb5O\x0d\x03\x00T%\
31+
\x124\xaf'fHL\xdb,\xb6\x1f\x19q\xad\xad\x9e\
32+
\x11w\xf2{\xa0\xf1\xa5\x19\x91\x0bf4\x05%\xc9r\
33+
@Bb\x10\xb3\xea\x01\xa2\x9b\xd0\x05\xfeQ\x94sw\
34+
(\x81\x01{/J\xcc\x0fw\xd7m=\xaf:\x7f.\
35+
\x0f\x11\x0cL\xae\xc9Q \xfe\x8c\xceP\xce\x1b\x06#\
36+
d /Q\x1b3\xa5E2bi\xfa\xb8\xe8\x184\
37+
F\xb2LC%\x11\xf1\x11g\x18uV\x0e\xb5:\x86\
38+
\x84(\xb0y\xed\xf0pl\x01\xd6;\xc0-F)\xa6\
39+
I[d\xe7\xbd\x00\xce7\x97\x03k\xcbP\xd0\x1a\x01\
40+
3\xa1\x13@\x168\x94\xd2\x88$\x11\x9b+\x8b\xc85\
41+
%Hb\xb6\xf4\x91\xc0:\xcb\xac\xd6z\xd6\xe4\x86\xe7\
42+
#\x1f\x0bBv5\xe7\xde\x08\x8c\xc8\xb0\x7f\x08\x1a\x8f\
43+
\xd3P*\x91X\x15\x90\xd8\xa5\x85\x08h@Zi\xc7\
44+
q[\x9eLA\xc4t\x18|\x98S.'\xfaC!\
45+
w\xc6\x84C\xb7\xe6\xb8a\x05\x83H\xb72\xd6C\xf2\
46+
\x0eL\x03\x1b4\xb6\xe4\xb4E+\x14\xe8\xc3\xa6\xb4`\
47+
\x9fA\x95t\x0b\x06t1z\x1e\xe4\xb1\x935\xabG\
48+
\xcb\x9b\xd0x\x19\x93\x8c\x12\xd4\x92\xb3\xe2%-cS\
49+
1\x1f\x83\xfe\x91@\x99\xac\x1cRL\xaf\x1a\xab\xc7\x13\
50+
H8\xbez\x0b\xfe\
51+
\x00\x00\x00\xbc\
52+
(\
53+
\xb5/\xfd \xf0\x9d\x05\x00\x22\x8c& `g\xab\x03\
54+
\xc0\x16d\x14q\xb4~Iq\xb1\x86)\x0b\xff\xa3\xd5\
55+
\x8d/\x84\xd2\xe8\x13\x96\x0cq\x04\xc6\x01\x09l\x18\x84\
56+
\x18\x09\xd2\xf7\x1eA\xdd\xb2(\x047\xf4\x80\xfb0>\
57+
\xf7\xe9m\xde\x83\xcf\xe3Mo\xbbVa[\x9d\xde\xf6\
58+
\xdev^c~c>\x0b\xf7\x19\xbf\xed\xa1\xce\xdb\xcb\
59+
\xea\x01,\x15\x0f\xd6[`\xe7F\xa83<\xca\x01\x05\
60+
\xf2\xffF\xa2\xb0aPJI!h\x90\xd85w\xce\
61+
\x89P\x80B\xca\xa8\x8e)X\x10\x8b(\x0d\xca\xbc\xaa\
62+
\xf5\xf4\xa4n\x91\x10\x98\x07\xa5\xb9&\xb5\xd4\xc9\x08\x95\
63+
C<l\x18$\x08\x00pe\xa1LI\x09\x5c\xd4\x15\
64+
\xb2\xda\x13_\x10\xa6\xa8\xdc\xb9uO\
65+
\x00\x00\x00\xcd\
66+
(\
67+
\xb5/\xfd`\x0a\x00\x1d\x06\x00\xd2\x8d* `G\xdc\
68+
\x060;\x1c=\xa2n[\xa3\x11\xd1 \x88R\x87W\
69+
\xa5\x1a\xb6\xd0\xcav\x85\xb4\xb9\xe0A\x80\x03\x0a\x13=\
70+
\x0a)\x14\x85\xcb\xb2\x00`\xe28M\xc1\x0bL\xd8~\
71+
Kc\xd3\xf6Y\xf67\xd9\x9e\x93\xed\xdb\xae\xa3o\xb9\
72+
\x96\x91\xcd\xefl\xa9\xb3-m7\x05\xec:\xdb\xe9\xd8\
73+
\xd4\x92qZ\xdd\xe4\x95\xf4\x9d\xcbi9Z\x1e\x8b\x93\
74+
c\xccr5\xdfh\xb6\x9a\xed\xe0\x03&\x85;\x88 \
75+
\x81\xfc\x7f\xa1 \x13=JUY1\x07\x88\x5c/\xdf\
76+
{J\x09$ \xc8a\xf2\x188\x07\x04\x07\x15\x9aw\
77+
\xe4u\xbdb\x82\x80\x18x\x86&:*/L \xc7\
78+
4\x06w&z\x90\x08\x00\xe0\xca\x0d\x15>\xcb]\x98\
79+
\xca\x05XUp6\x16\x95&\xb7\xee\x09\
80+
\x00\x00\x00\xbf\
81+
(\
82+
\xb5/\xfd \xf1\xb5\x05\x00\xa2\xcc' Pg\xac\x03\
83+
\x88\xd0\xe2\x8d\xa0\x9f'Z\xa0\x223\xd3\x08\xf8d\xce\
84+
,dS\x1a\xf5\xf0\xe5\xa8\x1aV\x0f\x01\x0a|\x9c\x94\
85+
\x14J\xd2\xf7\x1eA]\xd30\x04/\xf4\x80\x1b!|\
86+
n\xd4\xdb\xbc\x06\xa3\xc7\xab\xde\x96\xb1c{\xa1\xde\xf6\
87+
\xde\x86^c~cF\x0d\xf7\x11~[c\x9d\xb7\x97\
88+
\xd7\x03`+\x1aH\xef\xc1\xd6\xb9\x0d\xea\x96G9\x80\
89+
H\xfe\xbfP\x14>NRJ\xad\x04\x0d\x0e\xcb\xe6\xce\
90+
9S\x0a@H\x19\xd59\x05\x8d!qU\x8b\xa9\x8b\
91+
ra\xe6\xd5bWW\xea\x12\x07\x81Y`\x9e\xab\xea\
92+
C\x9d\x8c\x90)\xc4\xc3\xc7I\x02\x07\x00pe\xa1L\
93+
I\x09\x5c\xd4\x15\xb2\xdaG`\x10\xb3\xbc&\x19\
94+
"
95+
96+
qt_resource_name = b"\
97+
\x00\x09\
98+
\x0alxC\
99+
\x00r\
100+
\x00e\x00s\x00o\x00u\x00r\x00c\x00e\x00s\
101+
\x00\x06\
102+
\x07\xae\xc3\xc3\
103+
\x00t\
104+
\x00h\x00e\x00m\x00e\x00s\
105+
\x00\x09\
106+
\x0b\x83^\xdb\
107+
\x00s\
108+
\x00t\x00e\x00a\x00m\x00d\x00e\x00c\x00k\
109+
\x00\x0e\
110+
\x03\xc2\xd5\xc3\
111+
\x00s\
112+
\x00t\x00y\x00l\x00e\x00s\x00h\x00e\x00e\x00t\x00.\x00q\x00s\x00s\
113+
\x00\x13\
114+
\x0a4fG\
115+
\x00i\
116+
\x00c\x00o\x00n\x00-\x00d\x00o\x00w\x00n\x00-\x00a\x00r\x00r\x00o\x00w\x00.\x00s\
117+
\x00v\x00g\
118+
\x00\x11\
119+
\x01R\xb3\xa7\
120+
\x00i\
121+
\x00c\x00o\x00n\x00-\x00u\x00p\x00-\x00a\x00r\x00r\x00o\x00w\x00.\x00s\x00v\x00g\
122+
\
123+
\x00\x12\
124+
\x0a$\xb9g\
125+
\x00i\
126+
\x00c\x00o\x00n\x00-\x00d\x00r\x00o\x00p\x00-\x00d\x00o\x00w\x00n\x00.\x00s\x00v\
127+
\x00g\
128+
"
129+
130+
qt_resource_struct = b"\
131+
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
132+
\x00\x00\x00\x00\x00\x00\x00\x00\
133+
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
134+
\x00\x00\x00\x00\x00\x00\x00\x00\
135+
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
136+
\x00\x00\x00\x00\x00\x00\x00\x00\
137+
\x00\x00\x00*\x00\x02\x00\x00\x00\x04\x00\x00\x00\x04\
138+
\x00\x00\x00\x00\x00\x00\x00\x00\
139+
\x00\x00\x00\x90\x00\x04\x00\x00\x00\x01\x00\x00\x03;\
140+
\x00\x00\x01\x96+}A\xa5\
141+
\x00\x00\x00B\x00\x04\x00\x00\x00\x01\x00\x00\x00\x00\
142+
\x00\x00\x01\x963FC\xbc\
143+
\x00\x00\x00\xb8\x00\x04\x00\x00\x00\x01\x00\x00\x04\x0c\
144+
\x00\x00\x01\x96+}A\xa5\
145+
\x00\x00\x00d\x00\x04\x00\x00\x00\x01\x00\x00\x02{\
146+
\x00\x00\x01\x96+}A\xa5\
147+
"
148+
149+
def qInitResources():
150+
QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
151+
152+
def qCleanupResources():
153+
QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
154+
155+
qInitResources()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
from PySide6.scripts.pyside_tool import qt_tool_wrapper
4+
5+
verbose = True
6+
compressLevel = 6
7+
compressAlgo = "zstd"
8+
compressThreshold = 0
9+
10+
if __name__ == "__main__":
11+
qt_tool_wrapper(
12+
"rcc",
13+
[
14+
"-g", "python",
15+
"--compress", str(compressLevel),
16+
"--compress-algo", compressAlgo,
17+
"--threshold", str(compressThreshold),
18+
"--verbose" if verbose else "",
19+
os.path.join(os.path.dirname(__file__), "stylesheet.qrc"),
20+
"-o", os.path.join(os.path.dirname(__file__), "__init__.py"),
21+
],
22+
True
23+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<RCC>
2+
<qresource prefix="/resources/themes/steamdeck">
3+
<file>icon-drop-down.svg</file>
4+
<file>icon-down-arrow.svg</file>
5+
<file>icon-up-arrow.svg</file>
6+
<file>stylesheet.qss</file>
7+
</qresource>
8+
</RCC>

pupgui2/resources/themes/steamdeck.qss renamed to pupgui2/resources/themes/steamdeck/stylesheet.qss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ QComboBox::drop-down {
5252
border: none;
5353
border-radius: 2px;
5454
width: 16px;
55-
image: url("drop-down_placeholder");
55+
image: url(":/resources/themes/steamdeck/icon-drop-down.svg");
5656
}
5757

5858
QScrollBar {
@@ -107,8 +107,8 @@ QScrollBar::down-arrow {
107107
height: 13px;
108108
}
109109
QScrollBar::up-arrow {
110-
image: url("up-arrow_placeholder");
110+
image: url(":/resources/themes/steamdeck/icon-up-arrow.svg");
111111
}
112112
QScrollBar::down-arrow {
113-
image: url("down-arrow_placeholder");
113+
image: url(":/resources/themes/steamdeck/icon-down-arrow.svg");
114114
}

pupgui2/util.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
from typing import Any, Callable
1818

1919
import PySide6
20-
from PySide6.QtCore import QCoreApplication
20+
from PySide6.QtCore import QCoreApplication, QFile
2121
from PySide6.QtWidgets import QApplication, QComboBox, QStyleFactory, QMessageBox, QCheckBox
2222

2323
from pupgui2.constants import POSSIBLE_INSTALL_LOCATIONS, CONFIG_FILE, PALETTE_DARK, PALETTE_STEAMUI, TEMP_DIR, IS_FLATPAK
2424
from pupgui2.constants import AWACY_GAME_LIST_URL, LOCAL_AWACY_GAME_LIST
2525
from pupgui2.constants import GITHUB_API, GITLAB_API, GITLAB_API_RATELIMIT_TEXT
2626
from pupgui2.datastructures import BasicCompatTool, CTType, Launcher, SteamApp, LutrisGame, HeroicGame
2727
from pupgui2.datastructures import HardwarePlatform
28+
from pupgui2.resources.themes import steamdeck
2829
from pupgui2.steamutil import remove_steamtinkerlaunch, is_valid_steam_install
2930

3031

@@ -105,10 +106,10 @@ def apply_dark_theme(app: QApplication) -> None:
105106
app.setPalette(PALETTE_DARK())
106107
elif theme == 'steam':
107108
app.setPalette(PALETTE_STEAMUI())
108-
stylesheet = pkgutil.get_data(__name__, 'resources/themes/steamdeck.qss').decode('utf-8')
109-
stylesheet = stylesheet.replace('drop-down_placeholder', os.path.join(os.path.dirname(__file__), 'resources/themes/steamdeck_drop-down.svg'))
110-
stylesheet = stylesheet.replace('up-arrow_placeholder', os.path.join(os.path.dirname(__file__), 'resources/themes/steamdeck_up-arrow.svg'))
111-
stylesheet = stylesheet.replace('down-arrow_placeholder', os.path.join(os.path.dirname(__file__), 'resources/themes/steamdeck_down-arrow.svg'))
109+
file = QFile(f":/resources/themes/steamdeck/stylesheet.qss")
110+
file.open(QFile.OpenModeFlag.ReadOnly)
111+
stylesheet = file.readAll().data().decode("utf-8")
112+
file.close()
112113
app.setStyleSheet(stylesheet)
113114
else:
114115
is_plasma = 'plasma' in os.environ.get('DESKTOP_SESSION', '')

0 commit comments

Comments
 (0)