lambda/src/ui/settings.py

71 lines
2.5 KiB
Python
Raw Normal View History

2025-01-07 15:25:29 +01:00
import sys
from PySide6 import QtWidgets
class SettingsDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Settings")
self.setMinimumSize(400, 300)
# Position the dialog relative to the parent (main window)
if parent:
x = parent.geometry().x() + parent.geometry().width() // 2 - self.width() // 2
y = parent.geometry().y() + parent.geometry().height() // 2 - self.height() // 2
self.move(x, y)
# Create layout
layout = QtWidgets.QVBoxLayout(self)
# Checkbox: Enable Notifications
self.notifications_checkbox = QtWidgets.QCheckBox("Enable Notifications")
layout.addWidget(self.notifications_checkbox)
# Checkbox: Dark Mode
self.dark_mode_checkbox = QtWidgets.QCheckBox("Enable Dark Mode")
layout.addWidget(self.dark_mode_checkbox)
# Dropdown: Language Selection
self.language_label = QtWidgets.QLabel("Language:")
layout.addWidget(self.language_label)
self.language_dropdown = QtWidgets.QComboBox()
self.language_dropdown.addItems(["English", "Spanish", "French", "German"])
layout.addWidget(self.language_dropdown)
# Dropdown: Theme Selection
self.theme_label = QtWidgets.QLabel("Theme:")
layout.addWidget(self.theme_label)
self.theme_dropdown = QtWidgets.QComboBox()
self.theme_dropdown.addItems(["Light", "Dark", "System Default"])
layout.addWidget(self.theme_dropdown)
# Buttons
button_layout = QtWidgets.QHBoxLayout()
self.save_button = QtWidgets.QPushButton("Save")
self.save_button.clicked.connect(self.save_settings)
button_layout.addWidget(self.save_button)
self.cancel_button = QtWidgets.QPushButton("Cancel")
self.cancel_button.clicked.connect(self.reject)
button_layout.addWidget(self.cancel_button)
layout.addLayout(button_layout)
def save_settings(self):
# Example of how to fetch settings
notifications = self.notifications_checkbox.isChecked()
dark_mode = self.dark_mode_checkbox.isChecked()
language = self.language_dropdown.currentText()
theme = self.theme_dropdown.currentText()
print("Settings Saved:")
print(f"Notifications: {notifications}")
print(f"Dark Mode: {dark_mode}")
print(f"Language: {language}")
print(f"Theme: {theme}")
self.accept()