Skip to content

Commit 417edad

Browse files
Merge pull request #42 from pythonlover02/next
small improvement on the welcome window
2 parents 0978a81 + d5d92e9 commit 417edad

File tree

2 files changed

+94
-88
lines changed

2 files changed

+94
-88
lines changed

src/volt-gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def show_welcome_window(self):
198198
Show the separate welcome window.
199199
"""
200200
if self.welcome_window is None:
201-
self.welcome_window = WelcomeManager.create_welcome_window(self)
201+
self.welcome_window = WelcomeManager.create_welcome_window()
202202

203203
self.welcome_window.show()
204204
self.welcome_window.activateWindow()

src/welcome.py

Lines changed: 93 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,61 @@ class WelcomeManager:
88
def get_welcome_info():
99
"""
1010
Returns a list of dictionaries containing welcome section information.
11+
Each section can have: title, content blocks (text, code blocks with optional labels)
1112
"""
1213
return [
1314
{
1415
"title": "Welcome to volt-gui:",
15-
"description": "First of all, thanks for using my tool! If you have any feature requests or issues, please report them to the volt-gui GitHub repository.",
16-
"copyable_blocks": []
16+
"content": [
17+
{"type": "text", "text": "First of all, thanks for using my tool! If you have any feature requests or issues, please report them to the volt-gui GitHub repository."}
18+
]
1719
},
1820
{
1921
"title": "Optional Dependencies:",
20-
"description": "• scx schedulers and Linux Kernel >= 6.12 if you want to make use of the CPU Pluggable Schedulers."
21-
"\n\n• MangoHud if you want to make use of the MangoHud Settings. Both the native or the Flatpak version satisfy the dependency."
22-
"\n\n• Note: You might need to install both versions, as the one installed with your distro package manager will be used for native programs, while the flatpak version will be used for flatpak programs. MangoHud is available on almost any distro and the flatpak version is quite easy to install with:",
23-
"copyable_blocks": ["flatpak install mangohud"],
24-
"additional_text": "• glxinfo is required to use the OpenGL Render Selector."
25-
"\n\n• vulkaninfo and the Vulkan Mesa layer are required to use the Vulkan Render Selector. One way to check if you have the Vulkan Mesa layer installed is to run this command:",
26-
"copyable_blocks_after_additional": ["MESA_VK_DEVICE_SELECT=list vulkaninfo"],
27-
"example_output": """selectable devices:
22+
"content": [
23+
{"type": "text", "text": "• scx schedulers and Linux Kernel >= 6.12 if you want to make use of the CPU Pluggable Schedulers."
24+
"\n\n• MangoHud if you want to make use of the MangoHud Settings. Both the native or the Flatpak version satisfy the dependency."
25+
"\n\n• Note: You might need to install both versions, as the one installed with your distro package manager will be used for native programs, while the flatpak version will be used for flatpak programs. MangoHud is available on almost any distro and the flatpak version is quite easy to install with:"},
26+
{"type": "code", "code": "flatpak install mangohud"},
27+
{"type": "text", "text": "• glxinfo is required to use the OpenGL Render Selector."
28+
"\n\n• vulkaninfo and the Vulkan Mesa layer are required to use the Vulkan Render Selector. One way to check if you have the Vulkan Mesa layer installed is to run this command:"},
29+
{"type": "code", "code": "MESA_VK_DEVICE_SELECT=list vulkaninfo"},
30+
{"type": "text", "text": "If the output doesn't look like the text below, then you don't have the Vulkan Mesa layer installed on your PC."},
31+
{"type": "code", "code": """selectable devices:
2832
GPU 0: 10de:128b "NVIDIA GeForce GT 710" discrete GPU 0000:01:00.0
29-
GPU 1: 10005:0 "llvmpipe (LLVM 20.1.8, 256 bits)" CPU 0000:00:00.0""",
30-
"closing_text": "If the output doesn't look like this text above, then you don't have the Vulkan Mesa layer installed on your PC."
33+
GPU 1: 10005:0 "llvmpipe (LLVM 20.1.8, 256 bits)" CPU 0000:00:00.0"""}
34+
]
3135
},
3236
{
3337
"title": "Key Notes:",
34-
"description": "• The apply buttons in the CPU/GPU/Disk/Kernel/Launch Options tabs are interconnected, meaning that pressing one of those apply buttons will apply all settings from these tabs. This helps avoid having to go tab by tab to apply all the settings."
35-
"\n\n• The settings that have the `unset` value, or in the case of the Kernel/Launch Options blank space on the text input, will be ignored when pressing apply."
36-
"\n\n• GPU settings labeled with (default) mean that, instead of setting the related environment variable, it will be unset. This ensures that the program or game run through the `volt` script receives an environment without that variable, guaranteeing the setting is truly at its default value."
37-
"\n\n• Kernel/Disk/CPU settings apply systemwide immediately, while the GPU settings are saved in the `volt` script when you press the apply button."
38-
"\n\n• All settings include tooltips with descriptions that appear when you hover your mouse over the input or switch widget. I do my best to provide accurate and helpful descriptions. If you notice any issues, please report them on the project GitHub."
39-
"\n\n• Note: If the OpenGL/Vulkan Render Selector its being used, it might broke some Linux Native games."
40-
"\n\n• Note: If you use any of the MangoHud Settings, you might have some issues running some games, hopefully MangoHud fixes those issues on the future."
41-
"\n\n• You can use the Options Tab settings to configure the volt-gui behavior."
42-
"\n\n• You can create, use, and delete different profiles. When a profile is created, it will base its settings on the current profile being used."
43-
"\n\n• The settings applied by the program are lost when the system is shut down or rebooted. The only exception is the `volt` script, as it is a physical file.",
44-
"copyable_blocks": []
38+
"content": [
39+
{"type": "text", "text": "• The apply buttons in the CPU/GPU/Disk/Kernel/Launch Options tabs are interconnected, meaning that pressing one of those apply buttons will apply all settings from these tabs. This helps avoid having to go tab by tab to apply all the settings."
40+
"\n\n• The settings that have the `unset` value, or in the case of the Kernel/Launch Options blank space on the text input, will be ignored when pressing apply."
41+
"\n\n• GPU settings labeled with (default) mean that, instead of setting the related environment variable, it will be unset. This ensures that the program or game run through the `volt` script receives an environment without that variable, guaranteeing the setting is truly at its default value."
42+
"\n\n• Kernel/Disk/CPU settings apply systemwide immediately, while the GPU settings are saved in the `volt` script when you press the apply button."
43+
"\n\n• All settings include tooltips with descriptions that appear when you hover your mouse over the input or switch widget. I do my best to provide accurate and helpful descriptions. If you notice any issues, please report them on the project GitHub."
44+
"\n\n• Note: If the OpenGL/Vulkan Render Selector its being used, it might broke some Linux Native games."
45+
"\n\n• Note: If you use any of the MangoHud Settings, you might have some issues running some games, hopefully MangoHud fixes those issues on the future."
46+
"\n\n• You can use the Options Tab settings to configure the volt-gui behavior, including enabling an update checker."
47+
"\n\n• You can create, use, and delete different profiles. When a profile is created, it will base its settings on the current profile being used."
48+
"\n\n• The settings applied by the program are lost when the system is shut down or rebooted. The only exception is the `volt` script, as it is a physical file."},
49+
{"type": "code", "code": "/usr/local/bin/volt", "label": "`volt` Script Path:"}
50+
]
4551
},
4652
{
4753
"title": "Apply the GPU Configuration:",
48-
"description": "The GPU settings are applied through the 'volt' script. Always launch games with the 'volt' script prepended to use these options. Examples:",
49-
"copyable_blocks": ["volt", "volt %command%", "volt flatpak run net.pcsx2.PCSX2"],
50-
"labels": ["Lutris (Native):", "Steam (Native):", "Flatpak Program:"]
54+
"content": [
55+
{"type": "text", "text": "The GPU settings are applied through the 'volt' script. Always launch games with the 'volt' script prepended to use these options. Examples:"},
56+
{"type": "code", "code": "volt", "label": "Lutris (Native):"},
57+
{"type": "code", "code": "volt %command%", "label": "Steam (Native):"},
58+
{"type": "code", "code": "volt flatpak run net.pcsx2.PCSX2", "label": "Flatpak Program:"}
59+
]
5160
},
5261
{
53-
"title": "Setup Complete!",
54-
"description": "You can disable or enable this welcome message in the Options Tab.\n\nThanks for reading the welcome guide!",
55-
"copyable_blocks": []
62+
"title": "All Set!",
63+
"content": [
64+
{"type": "text", "text": "You can disable or enable this welcome message in the Options Tab.\n\nThanks for reading the welcome guide!"}
65+
]
5666
}
5767
]
5868

@@ -147,7 +157,28 @@ def adjust_height():
147157
return frame
148158

149159
@staticmethod
150-
def create_step_page(section_info, step_number):
160+
def create_text_label(text):
161+
"""
162+
Creates a styled text label.
163+
"""
164+
label = QLabel(text)
165+
label.setAlignment(Qt.AlignLeft)
166+
label.setWordWrap(True)
167+
label.setStyleSheet("color: #E0E0E0; font-size: 14px; line-height: 1.5; padding: 0px; margin: 6px 0px 0px 0px;")
168+
label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
169+
return label
170+
171+
@staticmethod
172+
def create_code_label(text):
173+
"""
174+
Creates a label for code blocks.
175+
"""
176+
label = QLabel(text)
177+
label.setStyleSheet("color: #E0E0E0; font-size: 13px; margin-top: 8px; margin-bottom: 1px;")
178+
return label
179+
180+
@staticmethod
181+
def create_step_page(section_info):
151182
"""
152183
Creates a page widget for a single welcome step.
153184
"""
@@ -173,47 +204,22 @@ def create_step_page(section_info, step_number):
173204
title_label.setWordWrap(True)
174205
content_layout.addWidget(title_label)
175206

176-
desc_label = QLabel(section_info["description"])
177-
desc_label.setAlignment(Qt.AlignLeft)
178-
desc_label.setWordWrap(True)
179-
desc_label.setStyleSheet("color: #E0E0E0; font-size: 14px; line-height: 1.5; padding: 0px; margin: 0px;")
180-
desc_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
181-
content_layout.addWidget(desc_label)
182-
183-
copyable_blocks = section_info.get("copyable_blocks", [])
184-
labels = section_info.get("labels", [])
185-
186-
for i, block in enumerate(copyable_blocks):
187-
if i < len(labels):
188-
label = QLabel(labels[i])
189-
label.setStyleSheet("color: #E0E0E0; font-size: 13px; margin-top: 8px; margin-bottom: 1px;")
190-
content_layout.addWidget(label)
191-
192-
code_block = WelcomeManager.create_copyable_code_block(block)
193-
content_layout.addWidget(code_block)
194-
195-
if "additional_text" in section_info:
196-
additional_label = QLabel(section_info["additional_text"])
197-
additional_label.setAlignment(Qt.AlignLeft)
198-
additional_label.setWordWrap(True)
199-
additional_label.setStyleSheet("color: #E0E0E0; font-size: 14px; line-height: 1.5; padding: 0px; margin: 6px 0px 0px 0px;")
200-
content_layout.addWidget(additional_label)
201-
202-
if "copyable_blocks_after_additional" in section_info:
203-
for block in section_info["copyable_blocks_after_additional"]:
204-
code_block = WelcomeManager.create_copyable_code_block(block)
205-
content_layout.addWidget(code_block)
206-
207-
if "example_output" in section_info:
208-
example_block = WelcomeManager.create_copyable_code_block(section_info["example_output"])
209-
content_layout.addWidget(example_block)
210-
211-
if "closing_text" in section_info:
212-
closing_label = QLabel(section_info["closing_text"])
213-
closing_label.setAlignment(Qt.AlignLeft)
214-
closing_label.setWordWrap(True)
215-
closing_label.setStyleSheet("color: #E0E0E0; font-size: 14px; line-height: 1.5; padding: 0px; margin: 6px 0px 0px 0px;")
216-
content_layout.addWidget(closing_label)
207+
for item in section_info.get("content", []):
208+
item_type = item.get("type")
209+
210+
if item_type == "text":
211+
text_label = WelcomeManager.create_text_label(item["text"])
212+
if item == section_info["content"][0]:
213+
text_label.setStyleSheet("color: #E0E0E0; font-size: 14px; line-height: 1.5; padding: 0px; margin: 0px;")
214+
content_layout.addWidget(text_label)
215+
216+
elif item_type == "code":
217+
if "label" in item:
218+
label = WelcomeManager.create_code_label(item["label"])
219+
content_layout.addWidget(label)
220+
221+
code_block = WelcomeManager.create_copyable_code_block(item["code"])
222+
content_layout.addWidget(code_block)
217223

218224
content_layout.addStretch()
219225
scroll_area.setWidget(content_widget)
@@ -266,12 +272,9 @@ def update_navigation(widgets):
266272
widgets['progress_label'].setText(f"Step {current_step + 1} of {total_steps}")
267273
widgets['back_button'].setEnabled(current_step > 0)
268274

269-
if current_step == total_steps - 1:
270-
widgets['next_button'].hide()
271-
widgets['finish_button'].show()
272-
else:
273-
widgets['next_button'].show()
274-
widgets['finish_button'].hide()
275+
is_last_step = current_step == total_steps - 1
276+
widgets['next_button'].setVisible(not is_last_step)
277+
widgets['finish_button'].setVisible(is_last_step)
275278

276279
@staticmethod
277280
def go_back(widgets):
@@ -288,7 +291,8 @@ def go_next(widgets):
288291
"""
289292
Go to the next step.
290293
"""
291-
if widgets['current_step'] < len(WelcomeManager.get_welcome_info()) - 1:
294+
total_steps = len(WelcomeManager.get_welcome_info())
295+
if widgets['current_step'] < total_steps - 1:
292296
widgets['current_step'] += 1
293297
widgets['stacked_widget'].setCurrentIndex(widgets['current_step'])
294298
WelcomeManager.update_navigation(widgets)
@@ -298,11 +302,12 @@ def finish_wizard(widgets):
298302
"""
299303
Finish the wizard and close the window.
300304
"""
301-
if 'welcome_window' in widgets and widgets['welcome_window']:
302-
widgets['welcome_window'].close()
305+
welcome_window = widgets.get('welcome_window')
306+
if welcome_window:
307+
welcome_window.close()
303308

304309
@staticmethod
305-
def create_welcome_window(main_window):
310+
def create_welcome_window():
306311
"""
307312
Creates a separate welcome window with the welcome wizard.
308313
"""
@@ -315,13 +320,14 @@ def create_welcome_window(main_window):
315320
main_layout.setContentsMargins(16, 16, 16, 16)
316321
main_layout.setSpacing(16)
317322

318-
widgets = {}
319-
widgets['current_step'] = 0
320-
widgets['welcome_window'] = welcome_window
321-
widgets['stacked_widget'] = QStackedWidget()
323+
widgets = {
324+
'current_step': 0,
325+
'welcome_window': welcome_window,
326+
'stacked_widget': QStackedWidget()
327+
}
322328

323-
for i, section in enumerate(WelcomeManager.get_welcome_info()):
324-
page = WelcomeManager.create_step_page(section, i)
329+
for section in WelcomeManager.get_welcome_info():
330+
page = WelcomeManager.create_step_page(section)
325331
widgets['stacked_widget'].addWidget(page)
326332

327333
main_layout.addWidget(widgets['stacked_widget'], 1)

0 commit comments

Comments
 (0)