game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
env_var_checkbox.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// env_var_checkbox.h
4// ==============================================================================
5// Custom checkbox widget that displays the associated environment variable
6// Provides transparency for power users about what env vars will be set
7// ==============================================================================
8
9#pragma once
10
11#include <QCheckBox>
12#include <QLabel>
13#include <QWidget>
14
15class ThemeManager;
16
17/**
18 * @class EnvVarCheckBox
19 * @brief Checkbox that shows the associated environment variable
20 *
21 * Displays the checkbox label and the actual env var that will be set,
22 * providing transparency for power users.
23 *
24 * Visual layout:
25 * [x] Enable Feature
26 * ENV_VAR_NAME=value
27 */
28class EnvVarCheckBox : public QWidget
29{
30 Q_OBJECT
31
32 public:
33 /**
34 * @brief Construct an EnvVarCheckBox
35 * @param label User-friendly label for the checkbox
36 * @param envVar Environment variable string to display (e.g., "PROTON_USE_NTSYNC=1")
37 * @param tooltip Optional tooltip explaining the option
38 * @param parent Parent widget
39 * @param themeManager Optional ThemeManager. Falls back to the singleton
40 * when nullptr so existing call sites compile
41 * unchanged; tests can inject a fake.
42 */
43 EnvVarCheckBox(const QString& label, const QString& envVar, const QString& tooltip = QString(),
44 QWidget* parent = nullptr, ThemeManager* themeManager = nullptr);
45
46 bool isChecked() const;
47 void setChecked(bool checked);
48 void setEnabled(bool enabled);
49
50 /// Get the environment variable key (everything before '=')
51 QString envVarKey() const;
52
53 /// Get the full environment variable string
54 QString envVarString() const
55 {
56 return envVar_;
57 }
58
59 private:
60 void applyTheme();
61
62 signals:
63 void toggled(bool checked);
64
65 private:
66 QCheckBox* checkbox_;
67 QLabel* envVarLabel_;
68 QString envVar_;
69 ThemeManager* themeManager_;
70};
EnvVarCheckBox(const QString &label, const QString &envVar, const QString &tooltip=QString(), QWidget *parent=nullptr, ThemeManager *themeManager=nullptr)
Construct an EnvVarCheckBox.
void toggled(bool checked)
QString envVarKey() const
Get the environment variable key (everything before '=').
void setEnabled(bool enabled)
QString envVarString() const
Get the full environment variable string.
bool isChecked() const
void setChecked(bool checked)