Dan Albert 306971230b Update to PySide6.
It sounds like PySide2 will not be moving to Python 3.11, so we're stuck
on 3.10 without this. Upgrading to a newer Qt also fixes some high DPI
bugs (the file browser dialog for save/load is no longer tiny on 4k).

https://github.com/pyinstaller/pyinstaller/issues/5414 previously
blocked this, but the bug appears to be fixed now.
2022-12-29 16:26:50 -08:00

73 lines
1.8 KiB
Python

from PySide6.QtCore import Qt
from PySide6.QtWidgets import (
QCheckBox,
QGridLayout,
QGroupBox,
QLabel,
QVBoxLayout,
QWidget,
)
from game.plugins import LuaPlugin, LuaPluginManager
class PluginsBox(QGroupBox):
def __init__(self) -> None:
super().__init__("Plugins")
layout = QGridLayout()
layout.setAlignment(Qt.AlignTop)
self.setLayout(layout)
for row, plugin in enumerate(LuaPluginManager.plugins()):
if not plugin.show_in_ui:
continue
layout.addWidget(QLabel(plugin.name), row, 0)
checkbox = QCheckBox()
checkbox.setChecked(plugin.enabled)
checkbox.toggled.connect(plugin.set_enabled)
layout.addWidget(checkbox, row, 1)
class PluginsPage(QWidget):
def __init__(self) -> None:
super().__init__()
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignTop)
self.setLayout(layout)
layout.addWidget(PluginsBox())
class PluginOptionsBox(QGroupBox):
def __init__(self, plugin: LuaPlugin) -> None:
super().__init__(plugin.name)
layout = QGridLayout()
layout.setAlignment(Qt.AlignTop)
self.setLayout(layout)
for row, option in enumerate(plugin.options):
layout.addWidget(QLabel(option.name), row, 0)
checkbox = QCheckBox()
checkbox.setChecked(option.enabled)
checkbox.toggled.connect(option.set_enabled)
layout.addWidget(checkbox, row, 1)
class PluginOptionsPage(QWidget):
def __init__(self) -> None:
super().__init__()
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignTop)
self.setLayout(layout)
for plugin in LuaPluginManager.plugins():
if plugin.options:
layout.addWidget(PluginOptionsBox(plugin))