Skip to content

Commit 6fbb2d0

Browse files
refactor: further simplify external games, about, and auto categorize dialogs
1 parent 5f0bb98 commit 6fbb2d0

3 files changed

Lines changed: 400 additions & 402 deletions

File tree

steam_library_manager/ui/dialogs/about_dialog.py

Lines changed: 90 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@
2828

2929
__all__ = ["AboutDialog"]
3030

31-
# Hardcoded project metadata (NOT i18n - intentional)
32-
# These are curated by SwitchBros, not pulled from i18n files.
33-
31+
# hardcoded metadata - NOT i18n (curated by SwitchBros)
3432
_GITHUB_URL = "https://github.com/Switch-Bros/SteamLibraryManager"
3533

3634

3735
class AboutTexts(NamedTuple):
38-
"""Curated About dialog texts - controlled by SwitchBros, not i18n."""
39-
36+
# curated texts - controlled by SwitchBros, not i18n files
4037
description: str
4138
credits: str
4239
built_with: str
@@ -49,24 +46,22 @@ class AboutTexts(NamedTuple):
4946
"auto-categorization, and cloud sync."
5047
),
5148
credits="Contributors will be listed here.",
52-
built_with="", # set at runtime with emoji
49+
built_with="", # set at runtime
5350
)
5451

5552
_ABOUT_DE = AboutTexts(
5653
description=(
57-
"Der ultimative Steam-Bibliotheksmanager f\u00fcr Linux.\n"
54+
"Der ultimative Steam-Bibliotheksmanager für Linux.\n"
5855
"Verwalte tausende Spiele mit smarten Kollektionen,\n"
5956
"Auto-Kategorisierung und Cloud-Sync."
6057
),
61-
credits="Mitwirkende werden hier aufgef\u00fchrt.",
62-
built_with="", # set at runtime with emoji
58+
credits="Mitwirkende werden hier aufgeführt.",
59+
built_with="", # set at runtime
6360
)
6461

6562

66-
def _get_about_texts() -> AboutTexts:
67-
"""Returns curated About texts - DE or EN (fallback)."""
68-
from steam_library_manager.utils.i18n import t
69-
63+
def _get_texts():
64+
# returns curated About texts - DE or EN (fallback)
7065
# BVB 09 Dortmund colors - had to pick my club!
7166
hearts = "%s%s%s" % (t("emoji.yellow_heart"), t("emoji.black_heart"), t("emoji.yellow_heart"))
7267

@@ -75,19 +70,18 @@ def _get_about_texts() -> AboutTexts:
7570
return base._replace(built_with="%s Python, PyQt6 & %s" % (prefix, hearts))
7671

7772

78-
# Colors
79-
_BG_DARK = "#1b2838"
73+
# Colors - Steam dark theme
74+
_BG = "#1b2838"
8075
_TXT = "#c7d5e0"
81-
_TXT_DIM = "#8f98a0"
82-
_TXT_LINK = "#66c0f4"
83-
_DIV = "#2a475e"
76+
_DIM = "#8f98a0"
77+
_LINK = "#66c0f4"
78+
_SEP = "#2a475e"
8479
_BTN_BG = "#2a475e"
8580
_BTN_BD = "#3d6c8e"
8681

8782

8883
class _ClickableLabel(QLabel):
89-
"""QLabel that emits clicked on mouse press."""
90-
84+
# QLabel that emits clicked on mouse press
9185
clicked = pyqtSignal()
9286

9387
def mousePressEvent(self, ev):
@@ -98,10 +92,12 @@ def mousePressEvent(self, ev):
9892
class AboutDialog(BaseDialog):
9993
"""Two-column About dialog with dark Steam theme,
10094
showing version info, credits, and project links.
95+
96+
Has a secret easter egg if you click the logo 5 times.
10197
"""
10298

10399
def __init__(self, parent=None):
104-
self._click_count = 0
100+
self._clicks = 0 # easter egg counter
105101

106102
super().__init__(
107103
parent,
@@ -112,33 +108,31 @@ def __init__(self, parent=None):
112108
)
113109
self.setFixedSize(650, 400)
114110

115-
# -- UI --
116-
117111
def _build_content(self, layout):
118112
layout.setContentsMargins(24, 24, 24, 24)
119113
layout.setSpacing(0)
120114

121115
root = QHBoxLayout()
122116
root.setSpacing(0)
123117

124-
# Left: logo
125-
root.addLayout(self._build_logo_col())
118+
# left: logo column
119+
root.addLayout(self._logo_col())
126120

127-
# Vertical divider
121+
# vertical divider
128122
div = QFrame()
129123
div.setFrameShape(QFrame.Shape.VLine)
130-
div.setStyleSheet("color: %s;" % _DIV)
124+
div.setStyleSheet("color: %s;" % _SEP)
131125
div.setFixedWidth(1)
132126
root.addSpacing(20)
133127
root.addWidget(div)
134128
root.addSpacing(20)
135129

136-
# Right: info
137-
root.addLayout(self._build_info_col(), stretch=1)
130+
# right: info column
131+
root.addLayout(self._info_col(), stretch=1)
138132

139133
layout.addLayout(root)
140134

141-
# Global stylesheet
135+
# global stylesheet
142136
self.setStyleSheet("""
143137
QDialog {
144138
background-color: %s;
@@ -157,20 +151,20 @@ def _build_content(self, layout):
157151
QPushButton:hover {
158152
background-color: %s;
159153
}
160-
""" % (_BG_DARK, _TXT, _BTN_BG, _TXT, _BTN_BD, _BTN_BD))
154+
""" % (_BG, _TXT, _BTN_BG, _TXT, _BTN_BD, _BTN_BD))
161155

162-
def _build_logo_col(self):
156+
def _logo_col(self):
163157
col = QVBoxLayout()
164158
col.setAlignment(Qt.AlignmentFlag.AlignCenter)
165159

166-
logo_lbl = _ClickableLabel()
167-
logo_lbl.setCursor(Qt.CursorShape.PointingHandCursor)
168-
logo_lbl.setToolTip("SwitchBros")
160+
lbl = _ClickableLabel()
161+
lbl.setCursor(Qt.CursorShape.PointingHandCursor)
162+
lbl.setToolTip("SwitchBros")
169163

170164
logo_path = config.RESOURCES_DIR / "images" / "default_icons.webp"
171165
if logo_path.exists():
172166
px = QPixmap(str(logo_path))
173-
logo_lbl.setPixmap(
167+
lbl.setPixmap(
174168
px.scaled(
175169
200,
176170
200,
@@ -179,103 +173,103 @@ def _build_logo_col(self):
179173
)
180174
)
181175
else:
182-
logo_lbl.setText(__app_name__)
183-
logo_lbl.setFont(FontHelper.get_font(16, FontHelper.BOLD))
176+
lbl.setText(__app_name__)
177+
lbl.setFont(FontHelper.get_font(16, FontHelper.BOLD))
184178

185-
logo_lbl.clicked.connect(self._on_logo_clicked)
186-
col.addWidget(logo_lbl, alignment=Qt.AlignmentFlag.AlignCenter)
179+
lbl.clicked.connect(self._logo_click)
180+
col.addWidget(lbl, alignment=Qt.AlignmentFlag.AlignCenter)
187181
return col
188182

189-
def _build_info_col(self):
183+
def _info_col(self):
190184
col = QVBoxLayout()
191185
col.setSpacing(6)
192186

193-
# App name
194-
name_lbl = QLabel(__app_name__)
195-
name_lbl.setFont(FontHelper.get_font(18, FontHelper.BOLD))
196-
name_lbl.setStyleSheet("color: white;")
197-
col.addWidget(name_lbl)
187+
# app name header
188+
name = QLabel(__app_name__)
189+
name.setFont(FontHelper.get_font(18, FontHelper.BOLD))
190+
name.setStyleSheet("color: white;")
191+
col.addWidget(name)
198192

199-
# Version + release date
200-
ver_lbl = QLabel("Version %s - Release: %s" % (__version__, __release_date__))
201-
ver_lbl.setStyleSheet("color: %s; font-size: 12px;" % _TXT_DIM)
202-
col.addWidget(ver_lbl)
193+
# version + release date
194+
ver = QLabel("Version %s - Release: %s" % (__version__, __release_date__))
195+
ver.setStyleSheet("color: %s; font-size: 12px;" % _DIM)
196+
col.addWidget(ver)
203197

204198
col.addSpacing(8)
205199

206-
# Description
207-
about = _get_about_texts()
208-
desc_lbl = QLabel(about.description)
209-
desc_lbl.setWordWrap(True)
210-
desc_lbl.setStyleSheet("font-size: 13px;")
211-
col.addWidget(desc_lbl)
200+
# description text
201+
about = _get_texts()
202+
desc = QLabel(about.description)
203+
desc.setWordWrap(True)
204+
desc.setStyleSheet("font-size: 13px;")
205+
col.addWidget(desc)
212206

213207
col.addSpacing(4)
214208
col.addWidget(self._hline())
215209

216-
# Credits
217-
cr_hdr = QLabel("Credits")
218-
cr_hdr.setFont(FontHelper.get_font(11, FontHelper.BOLD))
219-
col.addWidget(cr_hdr)
210+
# credits section
211+
hdr = QLabel("Credits")
212+
hdr.setFont(FontHelper.get_font(11, FontHelper.BOLD))
213+
col.addWidget(hdr)
220214

221-
cr_txt = QLabel(about.credits)
222-
cr_txt.setStyleSheet("color: %s; font-size: 12px;" % _TXT_DIM)
223-
cr_txt.setWordWrap(True)
224-
col.addWidget(cr_txt)
215+
txt = QLabel(about.credits)
216+
txt.setStyleSheet("color: %s; font-size: 12px;" % _DIM)
217+
txt.setWordWrap(True)
218+
col.addWidget(txt)
225219

226220
col.addWidget(self._hline())
227221

228-
# License + GitHub
229-
lic_lbl = QLabel("License: %s | Author: %s" % (__license__, __author__))
230-
lic_lbl.setStyleSheet("color: %s; font-size: 12px;" % _TXT_DIM)
231-
col.addWidget(lic_lbl)
222+
# license & author
223+
lic = QLabel("License: %s | Author: %s" % (__license__, __author__))
224+
lic.setStyleSheet("color: %s; font-size: 12px;" % _DIM)
225+
col.addWidget(lic)
232226

233-
gh_lbl = QLabel('GitHub: <a href="%s" style="color: %s;">%s</a>' % (_GITHUB_URL, _TXT_LINK, _GITHUB_URL))
234-
gh_lbl.setTextFormat(Qt.TextFormat.RichText)
235-
gh_lbl.setCursor(Qt.CursorShape.PointingHandCursor)
236-
gh_lbl.linkActivated.connect(lambda url: open_url(url))
237-
gh_lbl.setStyleSheet("font-size: 12px;")
238-
col.addWidget(gh_lbl)
227+
# github link
228+
link = QLabel('GitHub: <a href="%s" style="color: %s;">%s</a>' % (_GITHUB_URL, _LINK, _GITHUB_URL))
229+
link.setTextFormat(Qt.TextFormat.RichText)
230+
link.setCursor(Qt.CursorShape.PointingHandCursor)
231+
link.linkActivated.connect(lambda url: open_url(url))
232+
link.setStyleSheet("font-size: 12px;")
233+
col.addWidget(link)
239234

240235
col.addStretch()
241236

242-
# Built-with tagline
243-
bw_lbl = QLabel(about.built_with)
244-
bw_lbl.setStyleSheet("color: %s; font-size: 11px;" % _TXT_DIM)
245-
bw_lbl.setAlignment(Qt.AlignmentFlag.AlignRight)
246-
col.addWidget(bw_lbl)
237+
# built-with footer
238+
tag = QLabel(about.built_with)
239+
tag.setStyleSheet("color: %s; font-size: 11px;" % _DIM)
240+
tag.setAlignment(Qt.AlignmentFlag.AlignRight)
241+
col.addWidget(tag)
247242

248243
col.addSpacing(4)
249244

250-
# Close button
251-
btn_row = QHBoxLayout()
252-
btn_row.addStretch()
253-
close_btn = QPushButton(t("common.close"))
254-
close_btn.setMinimumWidth(100)
255-
close_btn.clicked.connect(self.accept)
256-
btn_row.addWidget(close_btn)
257-
col.addLayout(btn_row)
245+
# close button
246+
row = QHBoxLayout()
247+
row.addStretch()
248+
btn = QPushButton(t("common.close"))
249+
btn.setMinimumWidth(100)
250+
btn.clicked.connect(self.accept)
251+
row.addWidget(btn)
252+
col.addLayout(row)
258253

259254
return col
260255

261-
# -- Helpers --
262-
263256
@staticmethod
264257
def _hline():
265-
# Subtle horizontal separator
258+
# subtle horizontal separator
266259
line = QFrame()
267260
line.setFrameShape(QFrame.Shape.HLine)
268-
line.setStyleSheet("color: %s;" % _DIV)
261+
line.setStyleSheet("color: %s;" % _SEP)
269262
line.setFixedHeight(1)
270263
return line
271264

272-
def _on_logo_clicked(self):
273-
self._click_count += 1
265+
def _logo_click(self):
266+
self._clicks += 1
274267

275-
if self._click_count == 3:
268+
if self._clicks == 3:
276269
open_url(_GITHUB_URL)
277270

278-
elif self._click_count >= 5:
271+
elif self._clicks >= 5:
272+
# load easter egg
279273
from steam_library_manager.utils.enigma import load_easter_egg
280274
from steam_library_manager.ui.widgets.ui_helper import UIHelper
281275

@@ -286,4 +280,4 @@ def _on_logo_clicked(self):
286280
egg.get("message", ""),
287281
title=egg.get("title", ""),
288282
)
289-
self._click_count = 0
283+
self._clicks = 0

0 commit comments

Comments
 (0)