From 34e9413db106fd2573e1046bcb2cd3f1c5836021 Mon Sep 17 00:00:00 2001 From: Rob <5183487+Rexeh@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:13:02 +0000 Subject: [PATCH] New UI for plugin management, stored/retrieved plugin states and new PluginWrapper for UI --- .gitignore | 1 + joystick_diagrams/db/db_init.py | 5 +- joystick_diagrams/db/db_plugin_data.py | 55 ++++ .../ui/mock_main/plugin_settings.py | 149 ++++++++++ .../qt_designer/plugin_settings_ui.py | 116 ++++++++ .../mock_main/qt_designer/setting_page_ui.py | 273 ++++++------------ .../ui/mock_main/setting_page.py | 138 ++++----- joystick_diagrams/ui/plugin_wrapper.py | 18 ++ qt_ui/device_templates_ui.py | 91 ++++++ qt_ui/plugin_settings_ui_ui.py | 116 ++++++++ qt_ui/setup_page_widget_ui.py | 177 ++++++++++++ 11 files changed, 893 insertions(+), 246 deletions(-) create mode 100644 joystick_diagrams/db/db_plugin_data.py create mode 100644 joystick_diagrams/ui/mock_main/plugin_settings.py create mode 100644 joystick_diagrams/ui/mock_main/qt_designer/plugin_settings_ui.py create mode 100644 joystick_diagrams/ui/plugin_wrapper.py create mode 100644 qt_ui/device_templates_ui.py create mode 100644 qt_ui/plugin_settings_ui_ui.py create mode 100644 qt_ui/setup_page_widget_ui.py diff --git a/.gitignore b/.gitignore index 7c7311a..fa79407 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ htmlcov /data .ruff* /local_test_data +test_export/ # IDE *.code-workspace diff --git a/joystick_diagrams/db/db_init.py b/joystick_diagrams/db/db_init.py index 6c0af99..6c5c106 100644 --- a/joystick_diagrams/db/db_init.py +++ b/joystick_diagrams/db/db_init.py @@ -3,14 +3,13 @@ Author: Robert Cox """ -from db import db_device_management - -from joystick_diagrams.db import db_value_store +from joystick_diagrams.db import db_device_management, db_plugin_data, db_value_store def init(): db_device_management.create_new_db_if_not_exist() db_value_store.create_new_db_if_not_exist() + db_plugin_data.create_new_db_if_not_exist() if __name__ == "__main__": diff --git a/joystick_diagrams/db/db_plugin_data.py b/joystick_diagrams/db/db_plugin_data.py new file mode 100644 index 0000000..cc8ef3a --- /dev/null +++ b/joystick_diagrams/db/db_plugin_data.py @@ -0,0 +1,55 @@ +import os +from sqlite3 import connect + +DB_DIR = "data" +DB_NAME = "plugins.db" +TABLE_NAME = "plugins" + + +def create_new_db_if_not_exist(): + path = os.path.join(os.getcwd(), DB_DIR, DB_NAME) + connection = connect(path) + cur = connection.cursor() + cur.execute(f"CREATE TABLE IF NOT EXISTS {TABLE_NAME}(plugin_name TEXT PRIMARY KEY, enabled BOOL)") + + +def add__update_plugin_configuration(plugin_name: str, enabled: bool): + path = os.path.join(os.getcwd(), DB_DIR, DB_NAME) + connection = connect(path) + cur = connection.cursor() + + query = "SELECT * from plugins WHERE plugin_name = ?" + params = (plugin_name,) + + cur.execute(query, params) + result = cur.fetchall() + + if result: + query = "UPDATE plugins SET enabled = ? WHERE plugin_name = ? " + params = (enabled, plugin_name) + cur.execute(query, params) + + else: + query = "INSERT INTO plugins (plugin_name, enabled) VALUES(?,?)" + params = (plugin_name, enabled) + cur.execute(query, params) + + connection.commit() + + +def get_plugin_configuration(plugin_name: str): + path = os.path.join(os.getcwd(), DB_DIR, DB_NAME) + connection = connect(path) + cur = connection.cursor() + + query = "SELECT * from plugins WHERE plugin_name = ?" + params = [plugin_name] + + cur.execute(query, params) + result = cur.fetchone() + + return result if result else None + + +if __name__ == "__main__": + pass diff --git a/joystick_diagrams/ui/mock_main/plugin_settings.py b/joystick_diagrams/ui/mock_main/plugin_settings.py new file mode 100644 index 0000000..99e92c5 --- /dev/null +++ b/joystick_diagrams/ui/mock_main/plugin_settings.py @@ -0,0 +1,149 @@ +import logging +import sys +from pathlib import Path + +from PySide6.QtCore import QMetaMethod, Qt, Signal, Slot +from PySide6.QtGui import QIcon +from PySide6.QtWidgets import ( + QApplication, + QFileDialog, + QListWidgetItem, + QMainWindow, + QMessageBox, +) +from qt_material import apply_stylesheet + +from joystick_diagrams import app_init +from joystick_diagrams.app_state import AppState +from joystick_diagrams.exceptions import JoystickDiagramsException +from joystick_diagrams.plugins.plugin_interface import PluginInterface +from joystick_diagrams.ui.mock_main.qt_designer import plugin_settings_ui +from joystick_diagrams.ui.plugin_wrapper import PluginWrapper + +_logger = logging.getLogger(__name__) + +RECONFIGURE_TEXT = "Reconfigure" + + +class PluginSettings(QMainWindow, plugin_settings_ui.Ui_Form): # Refactor pylint: disable=too-many-instance-attributes + pluginModified = Signal(object) + pluginPathConfigured = Signal(object) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.setupUi(self) + self.plugin = None + + # Attributes + + # Connections + self.pluginEnabled.stateChanged.connect(self.handle_enabled_change) + self.configureLink.clicked.connect(self.open_file_dialog) + + # Setup + + # Style Overrides + self.configureLink.setStyleSheet("color: white !important;") + + def setup(self): + """Initialise the widget configuration""" + + # Setup labels + self.pluginEnabled.setChecked(self.plugin.enabled) + self.plugin_name_label.setText(self.plugin.plugin_name) + self.plugin_version_label.setText(self.plugin.plugin_version) + + # Setup file selection + self.configureLink.setText(self.get_plugin_path_type().dialog_title) + self.configureLink.setDescription("") + + if self.plugin.plugin.path: + self.set_plugin_path(self.plugin.plugin.path) + + # TODO if file already set from storage... + + def handle_enabled_change(self, data): + self.plugin.enabled = data if data == 0 else 1 + print(f"Plugin enabled state is now {self.plugin.enabled}") + self.pluginModified.emit(self.plugin) + + def get_plugin_file_extensions(self): + return [] + + def get_plugin_path_type(self) -> PluginInterface.FilePath | PluginInterface.FolderPath: + return self.plugin.plugin.path_type + + def set_plugin_path(self, path: Path): + if not isinstance(path, Path): + return + + try: + load = self.plugin.plugin.set_path(path) + + if not load: + raise JoystickDiagramsException("Error loading plugin") + if load: + self.configureLink.setText(RECONFIGURE_TEXT) + self.configureLink.setDescription(path.__str__()) + self.pluginPathConfigured.emit(self.plugin) + except JoystickDiagramsException: + QMessageBox.warning( + self, + "Plugin failure", + "Something went very wrong.", + buttons=QMessageBox.Discard, + defaultButton=QMessageBox.Discard, + ) + + def open_file_dialog(self) -> None: + plugin_path = self.get_plugin_path_type() + + match type(plugin_path): + case PluginInterface.FilePath: + exts = " ".join(f"*{ext}" for ext in plugin_path.supported_extensions) + + _file = QFileDialog.getOpenFileName( + self, + caption=plugin_path.dialog_title, + dir=plugin_path.default_path, + filter=(f"All Files ({exts})"), + ) + + if _file[0]: + self.set_plugin_path(Path(_file[0])) + case PluginInterface.FolderPath: + _folder = QFileDialog.getExistingDirectory(self, plugin_path.dialog_title, plugin_path.default_path) + if _folder: + self.set_plugin_path(Path(_folder)) + case _: + _logger.error("Unexpected plugin path type given.") + + # def load_plugin_settings(self, data): + + +# self.pluginVersionInfo.setText(f"Version {data.version}") +# self.pluginName.setText(f"{data.name} Settings") + +# # Path Setup +# self.pluginPath.setText(data.path) + +# # Prevents duplicate signals from being connected +# if self.pluginPathButton.isSignalConnected(QMetaMethod.fromSignal(self.pluginPathButton.clicked)): +# self.pluginPathButton.clicked.disconnect() + +# # Clean up +# # Additional validation to be added to PluginInterface/Plugin loading +# if isinstance(data.path_type, PluginInterface.FilePath): +# self.pluginPathButton.clicked.connect(lambda: self.file_dialog(data.path_type)) + +# if isinstance(data.path_type, PluginInterface.FolderPath): +# self.pluginPathButton.clicked.connect(lambda: self.folder_dialog(data.path_type)) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + init = app_init.init() + window = PluginSettings() + window.show() + apply_stylesheet(app, theme="dark_blue.xml", invert_secondary=False) + app.exec() diff --git a/joystick_diagrams/ui/mock_main/qt_designer/plugin_settings_ui.py b/joystick_diagrams/ui/mock_main/qt_designer/plugin_settings_ui.py new file mode 100644 index 0000000..5cfa19c --- /dev/null +++ b/joystick_diagrams/ui/mock_main/qt_designer/plugin_settings_ui.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file 'plugin_settings_ui.ui' +## +## Created by: Qt User Interface Compiler version 6.6.1 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QCheckBox, QCommandLinkButton, QFrame, + QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, + QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(750, 596) + Form.setMaximumSize(QSize(750, 600)) + self.verticalLayoutWidget = QWidget(Form) + self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") + self.verticalLayoutWidget.setGeometry(QRect(9, 9, 731, 87)) + self.verticalLayout_3 = QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_3.setObjectName(u"verticalLayout_3") + self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.plugin_name_label = QLabel(self.verticalLayoutWidget) + self.plugin_name_label.setObjectName(u"plugin_name_label") + font = QFont() + font.setPointSize(12) + self.plugin_name_label.setFont(font) + + self.horizontalLayout.addWidget(self.plugin_name_label) + + self.plugin_version_label = QLabel(self.verticalLayoutWidget) + self.plugin_version_label.setObjectName(u"plugin_version_label") + + self.horizontalLayout.addWidget(self.plugin_version_label) + + + self.verticalLayout_3.addLayout(self.horizontalLayout) + + self.horizontalLayout_2 = QHBoxLayout() + self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") + self.pluginEnabled = QCheckBox(self.verticalLayoutWidget) + self.pluginEnabled.setObjectName(u"pluginEnabled") + sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pluginEnabled.sizePolicy().hasHeightForWidth()) + self.pluginEnabled.setSizePolicy(sizePolicy) + font1 = QFont() + font1.setPointSize(14) + self.pluginEnabled.setFont(font1) + + self.horizontalLayout_2.addWidget(self.pluginEnabled) + + self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum) + + self.horizontalLayout_2.addItem(self.horizontalSpacer) + + self.configureLink = QCommandLinkButton(self.verticalLayoutWidget) + self.configureLink.setObjectName(u"configureLink") + sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.configureLink.sizePolicy().hasHeightForWidth()) + self.configureLink.setSizePolicy(sizePolicy1) + self.configureLink.setStyleSheet(u"color: rgb(255, 255, 255);\n" +"selection-color: rgb(255, 255, 255);") + + self.horizontalLayout_2.addWidget(self.configureLink) + + + self.verticalLayout_3.addLayout(self.horizontalLayout_2) + + self.frame = QFrame(Form) + self.frame.setObjectName(u"frame") + self.frame.setGeometry(QRect(9, 102, 116, 33)) + self.frame.setAutoFillBackground(False) + self.frame.setFrameShape(QFrame.Box) + self.frame.setFrameShadow(QFrame.Plain) + self.frame.setLineWidth(0) + self.frame.setMidLineWidth(1) + self.verticalLayout_2 = QVBoxLayout(self.frame) + self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.label_3 = QLabel(self.frame) + self.label_3.setObjectName(u"label_3") + + self.verticalLayout_2.addWidget(self.label_3) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None)) + self.plugin_name_label.setText(QCoreApplication.translate("Form", u"Plugin_Name", None)) + self.plugin_version_label.setText(QCoreApplication.translate("Form", u"TextLabel", None)) + self.pluginEnabled.setText(QCoreApplication.translate("Form", u"Enable Plugin", None)) + self.configureLink.setText(QCoreApplication.translate("Form", u"Configure plugin", None)) + self.configureLink.setDescription(QCoreApplication.translate("Form", u"Select your file/folder", None)) + self.label_3.setText(QCoreApplication.translate("Form", u"No options available", None)) + # retranslateUi + diff --git a/joystick_diagrams/ui/mock_main/qt_designer/setting_page_ui.py b/joystick_diagrams/ui/mock_main/qt_designer/setting_page_ui.py index 29a3e3a..34c2bf0 100644 --- a/joystick_diagrams/ui/mock_main/qt_designer/setting_page_ui.py +++ b/joystick_diagrams/ui/mock_main/qt_designer/setting_page_ui.py @@ -15,36 +15,63 @@ QFont, QFontDatabase, QGradient, QIcon, QImage, QKeySequence, QLinearGradient, QPainter, QPalette, QPixmap, QRadialGradient, QTransform) -from PySide6.QtWidgets import (QApplication, QFormLayout, QFrame, QHBoxLayout, - QLabel, QLayout, QListWidget, QListWidgetItem, - QPushButton, QSizePolicy, QSpacerItem, QVBoxLayout, - QWidget) +from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QListWidget, + QListWidgetItem, QPushButton, QSizePolicy, QSplitter, + QVBoxLayout, QWidget) class Ui_Form(object): def setupUi(self, Form): if not Form.objectName(): Form.setObjectName(u"Form") - Form.resize(1053, 651) - self.activeScreenWidget = QWidget(Form) - self.activeScreenWidget.setObjectName(u"activeScreenWidget") - self.activeScreenWidget.setGeometry(QRect(0, 0, 1041, 631)) - self.verticalLayout_2 = QVBoxLayout(self.activeScreenWidget) + Form.resize(1024, 682) + sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + Form.setMinimumSize(QSize(1024, 0)) + Form.setMaximumSize(QSize(1024, 16777215)) + Form.setBaseSize(QSize(1024, 0)) + self.verticalLayoutWidget = QWidget(Form) + self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") + self.verticalLayoutWidget.setGeometry(QRect(9, 9, 1006, 664)) + self.verticalLayout_2 = QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout_2.setObjectName(u"verticalLayout_2") - self.label = QLabel(self.activeScreenWidget) - self.label.setObjectName(u"label") + self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_3 = QVBoxLayout() + self.verticalLayout_3.setObjectName(u"verticalLayout_3") + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.pageTitle = QLabel(self.verticalLayoutWidget) + self.pageTitle.setObjectName(u"pageTitle") + sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.pageTitle.sizePolicy().hasHeightForWidth()) + self.pageTitle.setSizePolicy(sizePolicy1) - self.verticalLayout_2.addWidget(self.label) + self.horizontalLayout.addWidget(self.pageTitle) - self.label_2 = QLabel(self.activeScreenWidget) - self.label_2.setObjectName(u"label_2") + self.pageDescription = QLabel(self.verticalLayoutWidget) + self.pageDescription.setObjectName(u"pageDescription") + sizePolicy1.setHeightForWidth(self.pageDescription.sizePolicy().hasHeightForWidth()) + self.pageDescription.setSizePolicy(sizePolicy1) - self.verticalLayout_2.addWidget(self.label_2) + self.horizontalLayout.addWidget(self.pageDescription) - self.horizontalLayout_2 = QHBoxLayout() - self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") - self.parserPluginList = QListWidget(self.activeScreenWidget) - icon = QIcon() - icon.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/dcs.ico", QSize(), QIcon.Normal, QIcon.Off) + + self.verticalLayout_3.addLayout(self.horizontalLayout) + + self.verticalLayout_4 = QVBoxLayout() + self.verticalLayout_4.setObjectName(u"verticalLayout_4") + self.splitter = QSplitter(self.verticalLayoutWidget) + self.splitter.setObjectName(u"splitter") + sizePolicy1.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) + self.splitter.setSizePolicy(sizePolicy1) + self.splitter.setMinimumSize(QSize(1006, 600)) + self.splitter.setMaximumSize(QSize(1006, 600)) + self.splitter.setOrientation(Qt.Horizontal) + self.parserPluginList = QListWidget(self.splitter) brush = QBrush(QColor(0, 0, 0, 255)) brush.setStyle(Qt.NoBrush) font = QFont() @@ -52,181 +79,76 @@ def setupUi(self, Form): font.setPointSize(12) font.setBold(True) __qlistwidgetitem = QListWidgetItem(self.parserPluginList) + __qlistwidgetitem.setCheckState(Qt.Unchecked); __qlistwidgetitem.setFont(font); __qlistwidgetitem.setBackground(brush); - __qlistwidgetitem.setIcon(icon); - icon1 = QIcon() - icon1.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/jg.ico", QSize(), QIcon.Normal, QIcon.Off) + __qlistwidgetitem.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled); + icon = QIcon() + icon.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/jg.ico", QSize(), QIcon.Normal, QIcon.Off) __qlistwidgetitem1 = QListWidgetItem(self.parserPluginList) __qlistwidgetitem1.setFont(font); - __qlistwidgetitem1.setIcon(icon1); - icon2 = QIcon() - icon2.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/sc.png", QSize(), QIcon.Normal, QIcon.Off) + __qlistwidgetitem1.setIcon(icon); + icon1 = QIcon() + icon1.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/sc.png", QSize(), QIcon.Normal, QIcon.Off) font1 = QFont() font1.setFamilies([u"Cascadia Code SemiBold"]) font1.setPointSize(11) font1.setBold(True) __qlistwidgetitem2 = QListWidgetItem(self.parserPluginList) __qlistwidgetitem2.setFont(font1); - __qlistwidgetitem2.setIcon(icon2); + __qlistwidgetitem2.setIcon(icon1); self.parserPluginList.setObjectName(u"parserPluginList") - sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.parserPluginList.sizePolicy().hasHeightForWidth()) - self.parserPluginList.setSizePolicy(sizePolicy) + sizePolicy2 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) + sizePolicy2.setHorizontalStretch(0) + sizePolicy2.setVerticalStretch(0) + sizePolicy2.setHeightForWidth(self.parserPluginList.sizePolicy().hasHeightForWidth()) + self.parserPluginList.setSizePolicy(sizePolicy2) self.parserPluginList.setMaximumSize(QSize(1087, 16777215)) - - self.horizontalLayout_2.addWidget(self.parserPluginList) - - self.verticalLayout_3 = QVBoxLayout() - self.verticalLayout_3.setSpacing(10) - self.verticalLayout_3.setObjectName(u"verticalLayout_3") - self.pluginOptionsWidget = QWidget(self.activeScreenWidget) + self.parserPluginList.setBaseSize(QSize(1, 0)) + self.splitter.addWidget(self.parserPluginList) + self.pluginOptionsWidget = QWidget(self.splitter) self.pluginOptionsWidget.setObjectName(u"pluginOptionsWidget") - sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) - sizePolicy1.setHorizontalStretch(0) - sizePolicy1.setVerticalStretch(0) - sizePolicy1.setHeightForWidth(self.pluginOptionsWidget.sizePolicy().hasHeightForWidth()) - self.pluginOptionsWidget.setSizePolicy(sizePolicy1) - self.pluginOptionsWidget.setMinimumSize(QSize(800, 600)) + sizePolicy.setHeightForWidth(self.pluginOptionsWidget.sizePolicy().hasHeightForWidth()) + self.pluginOptionsWidget.setSizePolicy(sizePolicy) + self.pluginOptionsWidget.setMinimumSize(QSize(600, 600)) self.pluginOptionsWidget.setAutoFillBackground(False) - self.verticalLayoutWidget_4 = QWidget(self.pluginOptionsWidget) - self.verticalLayoutWidget_4.setObjectName(u"verticalLayoutWidget_4") - self.verticalLayoutWidget_4.setGeometry(QRect(0, 0, 821, 571)) - self.verticalLayout_4 = QVBoxLayout(self.verticalLayoutWidget_4) - self.verticalLayout_4.setObjectName(u"verticalLayout_4") - self.verticalLayout_4.setSizeConstraint(QLayout.SetDefaultConstraint) - self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) - self.line_2 = QFrame(self.verticalLayoutWidget_4) - self.line_2.setObjectName(u"line_2") - sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) - sizePolicy2.setHorizontalStretch(0) - sizePolicy2.setVerticalStretch(0) - sizePolicy2.setHeightForWidth(self.line_2.sizePolicy().hasHeightForWidth()) - self.line_2.setSizePolicy(sizePolicy2) - self.line_2.setFrameShape(QFrame.HLine) - self.line_2.setFrameShadow(QFrame.Sunken) - - self.verticalLayout_4.addWidget(self.line_2) - - self.horizontalLayout = QHBoxLayout() - self.horizontalLayout.setObjectName(u"horizontalLayout") - self.pluginName = QLabel(self.verticalLayoutWidget_4) - self.pluginName.setObjectName(u"pluginName") - sizePolicy3 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) - sizePolicy3.setHorizontalStretch(0) - sizePolicy3.setVerticalStretch(0) - sizePolicy3.setHeightForWidth(self.pluginName.sizePolicy().hasHeightForWidth()) - self.pluginName.setSizePolicy(sizePolicy3) - font2 = QFont() - font2.setPointSize(12) - font2.setBold(True) - self.pluginName.setFont(font2) - self.pluginName.setTextFormat(Qt.RichText) - self.pluginName.setScaledContents(False) - self.pluginName.setAlignment(Qt.AlignRight|Qt.AlignTop|Qt.AlignTrailing) - self.pluginName.setWordWrap(False) - - self.horizontalLayout.addWidget(self.pluginName) - - self.pluginVersionInfo = QLabel(self.verticalLayoutWidget_4) - self.pluginVersionInfo.setObjectName(u"pluginVersionInfo") - sizePolicy3.setHeightForWidth(self.pluginVersionInfo.sizePolicy().hasHeightForWidth()) - self.pluginVersionInfo.setSizePolicy(sizePolicy3) - self.pluginVersionInfo.setFont(font2) - self.pluginVersionInfo.setTextFormat(Qt.RichText) - self.pluginVersionInfo.setScaledContents(False) - self.pluginVersionInfo.setAlignment(Qt.AlignRight|Qt.AlignTop|Qt.AlignTrailing) - self.pluginVersionInfo.setWordWrap(False) - - self.horizontalLayout.addWidget(self.pluginVersionInfo) - - - self.verticalLayout_4.addLayout(self.horizontalLayout) - - self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Minimum) + self.horizontalLayout_6 = QHBoxLayout(self.pluginOptionsWidget) + self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") + self.splitter.addWidget(self.pluginOptionsWidget) - self.verticalLayout_4.addItem(self.verticalSpacer_2) + self.verticalLayout_4.addWidget(self.splitter) - self.formLayout = QFormLayout() - self.formLayout.setObjectName(u"formLayout") - self.formLayout.setSizeConstraint(QLayout.SetMaximumSize) - self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) - self.pluginPath = QLabel(self.verticalLayoutWidget_4) - self.pluginPath.setObjectName(u"pluginPath") - sizePolicy4 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) - sizePolicy4.setHorizontalStretch(0) - sizePolicy4.setVerticalStretch(0) - sizePolicy4.setHeightForWidth(self.pluginPath.sizePolicy().hasHeightForWidth()) - self.pluginPath.setSizePolicy(sizePolicy4) - self.formLayout.setWidget(1, QFormLayout.LabelRole, self.pluginPath) - - self.pluginPathButton = QPushButton(self.verticalLayoutWidget_4) - self.pluginPathButton.setObjectName(u"pluginPathButton") - sizePolicy5 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) - sizePolicy5.setHorizontalStretch(0) - sizePolicy5.setVerticalStretch(0) - sizePolicy5.setHeightForWidth(self.pluginPathButton.sizePolicy().hasHeightForWidth()) - self.pluginPathButton.setSizePolicy(sizePolicy5) - self.pluginPathButton.setFlat(False) - - self.formLayout.setWidget(1, QFormLayout.FieldRole, self.pluginPathButton) + self.verticalLayout_3.addLayout(self.verticalLayout_4) self.verticalLayout_5 = QVBoxLayout() self.verticalLayout_5.setObjectName(u"verticalLayout_5") - - self.formLayout.setLayout(0, QFormLayout.LabelRole, self.verticalLayout_5) - - - self.verticalLayout_4.addLayout(self.formLayout) - - self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) - - self.verticalLayout_4.addItem(self.verticalSpacer) - - - self.verticalLayout_3.addWidget(self.pluginOptionsWidget) - - self.horizontalLayout_4 = QHBoxLayout() - self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") - self.pushButton_2 = QPushButton(self.activeScreenWidget) - self.pushButton_2.setObjectName(u"pushButton_2") - - self.horizontalLayout_4.addWidget(self.pushButton_2) - - self.pushButton = QPushButton(self.activeScreenWidget) - self.pushButton.setObjectName(u"pushButton") - sizePolicy4.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth()) - self.pushButton.setSizePolicy(sizePolicy4) - - self.horizontalLayout_4.addWidget(self.pushButton) - - - self.verticalLayout_3.addLayout(self.horizontalLayout_4) - - - self.horizontalLayout_2.addLayout(self.verticalLayout_3) - - - self.verticalLayout_2.addLayout(self.horizontalLayout_2) - - self.horizontalLayout_3 = QHBoxLayout() - self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") - self.addParserPlugin = QPushButton(self.activeScreenWidget) + self.splitter_2 = QSplitter(self.verticalLayoutWidget) + self.splitter_2.setObjectName(u"splitter_2") + sizePolicy1.setHeightForWidth(self.splitter_2.sizePolicy().hasHeightForWidth()) + self.splitter_2.setSizePolicy(sizePolicy1) + self.splitter_2.setMinimumSize(QSize(1006, 23)) + self.splitter_2.setMaximumSize(QSize(1006, 23)) + self.splitter_2.setOrientation(Qt.Horizontal) + self.addParserPlugin = QPushButton(self.splitter_2) self.addParserPlugin.setObjectName(u"addParserPlugin") - sizePolicy5.setHeightForWidth(self.addParserPlugin.sizePolicy().hasHeightForWidth()) - self.addParserPlugin.setSizePolicy(sizePolicy5) + sizePolicy3 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) + sizePolicy3.setHorizontalStretch(0) + sizePolicy3.setVerticalStretch(0) + sizePolicy3.setHeightForWidth(self.addParserPlugin.sizePolicy().hasHeightForWidth()) + self.addParserPlugin.setSizePolicy(sizePolicy3) + self.splitter_2.addWidget(self.addParserPlugin) + self.pushButton = QPushButton(self.splitter_2) + self.pushButton.setObjectName(u"pushButton") + self.splitter_2.addWidget(self.pushButton) - self.horizontalLayout_3.addWidget(self.addParserPlugin) + self.verticalLayout_5.addWidget(self.splitter_2) - self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) - self.horizontalLayout_3.addItem(self.horizontalSpacer) + self.verticalLayout_3.addLayout(self.verticalLayout_5) - self.verticalLayout_2.addLayout(self.horizontalLayout_3) + self.verticalLayout_2.addLayout(self.verticalLayout_3) self.retranslateUi(Form) @@ -236,8 +158,8 @@ def setupUi(self, Form): def retranslateUi(self, Form): Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None)) - self.label.setText(QCoreApplication.translate("Form", u"

Configure

", None)) - self.label_2.setText(QCoreApplication.translate("Form", u"Setup your things... in order to customise stuff", None)) + self.pageTitle.setText(QCoreApplication.translate("Form", u"

Plugin Setup

", None)) + self.pageDescription.setText(QCoreApplication.translate("Form", u"Setup your things... in order to customise stuff", None)) __sortingEnabled = self.parserPluginList.isSortingEnabled() self.parserPluginList.setSortingEnabled(False) @@ -246,15 +168,10 @@ def retranslateUi(self, Form): ___qlistwidgetitem1 = self.parserPluginList.item(1) ___qlistwidgetitem1.setText(QCoreApplication.translate("Form", u"Joystick Gremlin", None)); ___qlistwidgetitem2 = self.parserPluginList.item(2) - ___qlistwidgetitem2.setText(QCoreApplication.translate("Form", u"Star Citizen", None)); + ___qlistwidgetitem2.setText(QCoreApplication.translate("Form", u"Star Citizen PTOATO", None)); self.parserPluginList.setSortingEnabled(__sortingEnabled) - self.pluginName.setText(QCoreApplication.translate("Form", u"PLUGIN NAME", None)) - self.pluginVersionInfo.setText(QCoreApplication.translate("Form", u"PLUGIN VERSION", None)) - self.pluginPath.setText(QCoreApplication.translate("Form", u"Path to ", None)) - self.pluginPathButton.setText(QCoreApplication.translate("Form", u"Select File/Folder", None)) - self.pushButton_2.setText(QCoreApplication.translate("Form", u"PushButton", None)) - self.pushButton.setText(QCoreApplication.translate("Form", u"PushButton", None)) self.addParserPlugin.setText(QCoreApplication.translate("Form", u"Add Plugin", None)) + self.pushButton.setText(QCoreApplication.translate("Form", u"Remove Plugin", None)) # retranslateUi diff --git a/joystick_diagrams/ui/mock_main/setting_page.py b/joystick_diagrams/ui/mock_main/setting_page.py index b71208e..d197b1d 100644 --- a/joystick_diagrams/ui/mock_main/setting_page.py +++ b/joystick_diagrams/ui/mock_main/setting_page.py @@ -14,110 +14,118 @@ from joystick_diagrams import app_init from joystick_diagrams.app_state import AppState +from joystick_diagrams.db import db_init, db_plugin_data +from joystick_diagrams.exceptions import JoystickDiagramsException from joystick_diagrams.plugins.plugin_interface import PluginInterface +from joystick_diagrams.ui.mock_main.plugin_settings import PluginSettings from joystick_diagrams.ui.mock_main.qt_designer import setting_page_ui +from joystick_diagrams.ui.plugin_wrapper import PluginWrapper _logger = logging.getLogger(__name__) class PluginsPage(QMainWindow, setting_page_ui.Ui_Form): # Refactor pylint: disable=too-many-instance-attributes - pluginPathSet = Signal(object) parsePlugins = Signal() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.appState = AppState() - self.remove_defaults() - self.initialise_plugins_list() + + # Attributes + self.plugin_wrappers = [] + self.window_content = None + + # Connections self.parserPluginList.itemClicked.connect(self.plugin_selected) - self.pluginPathSet.connect(self.set_plugin_path) self.parsePlugins.connect(self.execute_plugin_parsers) + # Setup + self.remove_defaults() + self.initialise_plugins() + self.populate_available_plugin_list() + + # Styling Overrides + def remove_defaults(self): self.parserPluginList.clear() - def initialise_plugins_list(self): + def get_plugin_configuration(self, plugin_name: str): + return db_plugin_data.get_plugin_configuration(plugin_name) + + @Slot() + def store_plugin_configuration(self, plugin_object: PluginWrapper): + db_plugin_data.add__update_plugin_configuration(plugin_object.plugin_name, plugin_object.enabled) + + def initialise_plugins(self): + """Initialise the available plugins into wrapper objects for use in UI. + + PluginWrapper enriches the Plugin model with UI specific data + """ for plugin in self.appState.plugin_manager.get_available_plugins(): - item = QListWidgetItem(QIcon(plugin.icon), plugin.name) - item.setData(Qt.UserRole, plugin) + plugin_lookup = self.get_plugin_configuration(plugin.name) + + if plugin_lookup: + enabled_flag = plugin_lookup[1] + self.plugin_wrappers.append( + PluginWrapper(plugin.name, plugin.version, plugin.icon, plugin, enabled=enabled_flag) + ) + else: + # Create Wrapper + wrapper = PluginWrapper(plugin.name, plugin.version, plugin.icon, plugin, enabled=False) + # Store the plugin with default of FALSE for enabled + self.store_plugin_configuration(wrapper) + + self.plugin_wrappers.append(wrapper) + + def populate_available_plugin_list(self): + for plugin_data in self.plugin_wrappers: + item = QListWidgetItem(QIcon(plugin_data.plugin_icon), plugin_data.plugin_name) + item.setData(Qt.UserRole, plugin_data) self.parserPluginList.addItem(item) @Slot() def plugin_selected(self, item): - self.load_plugin_settings(self.get_selected_plugin_object()) + if self.window_content: + self.window_content.hide() + + self.window_content = PluginSettings() + + # Page Setup For now + self.window_content.plugin = self.get_selected_plugin_object() + self.window_content.setup() + + # Signals/Slots + self.window_content.pluginModified.connect(self.store_plugin_configuration) + self.window_content.pluginPathConfigured.connect(self.handle_plugin_path_load) + + self.window_content.setParent(self.pluginOptionsWidget) + self.window_content.show() @Slot() - def set_plugin_path(self, data): - print(f"Data is {data}") + def handle_plugin_path_load(self, plugin: PluginWrapper): + print(f"Data is {plugin}") try: - currentPlugin = self.get_selected_plugin_object() - success = currentPlugin.set_path(data) - # TODO Plugin module needs improving to give better information? - if success: - self.parsePlugins.emit() - else: - QMessageBox.warning( - self, - "Plugin failure", - "Something went very wrong.", - buttons=QMessageBox.Discard, - defaultButton=QMessageBox.Discard, - ) - except FileExistsError: # Fix up - print("Bang") + plugin.plugin_profile_collection = plugin.plugin.process() + print(f"Data is {plugin.plugin_profile_collection}") + except JoystickDiagramsException: + pass @Slot() def execute_plugin_parsers(self): print("Executing plugin parsers") self.appState.process_loaded_plugins() - def load_plugin_settings(self, data): - self.pluginVersionInfo.setText(f"Version {data.version}") - self.pluginName.setText(f"{data.name} Settings") - - # Path Setup - self.pluginPath.setText(data.path) - - # Prevents duplicate signals from being connected - if self.pluginPathButton.isSignalConnected(QMetaMethod.fromSignal(self.pluginPathButton.clicked)): - self.pluginPathButton.clicked.disconnect() - - # Clean up - # Additional validation to be added to PluginInterface/Plugin loading - if isinstance(data.path_type, PluginInterface.FilePath): - self.pluginPathButton.clicked.connect(lambda: self.file_dialog(data.path_type)) - - if isinstance(data.path_type, PluginInterface.FolderPath): - self.pluginPathButton.clicked.connect(lambda: self.folder_dialog(data.path_type)) - def get_selected_plugin_object(self) -> PluginInterface: return self.parserPluginList.currentItem().data(Qt.UserRole) - def file_dialog(self, data) -> None: - exts = " ".join(f"*{ext}" for ext in data.supported_extensions) - - _file = QFileDialog.getOpenFileName( - self, - caption=data.dialog_title, - dir=data.default_path, - filter=(f"All Files ({exts})"), - ) - - if _file[0]: - self.pluginPathSet.emit(_file[0]) - - def folder_dialog(self, data): - _folder = QFileDialog.getExistingDirectory(self, data.dialog_title, data.default_path) - - if _folder: - self.pluginPathSet.emit(_folder) - if __name__ == "__main__": app = QApplication(sys.argv) - app_init + db = db_init.init() + init = app_init.init() window = PluginsPage() window.show() - apply_stylesheet(app, theme="dark_blue.xml", invert_secondary=False) + + apply_stylesheet(app, theme="light_blue.xml", invert_secondary=True) app.exec() diff --git a/joystick_diagrams/ui/plugin_wrapper.py b/joystick_diagrams/ui/plugin_wrapper.py new file mode 100644 index 0000000..f71e8b5 --- /dev/null +++ b/joystick_diagrams/ui/plugin_wrapper.py @@ -0,0 +1,18 @@ +from dataclasses import dataclass, field +from pathlib import Path + +from joystick_diagrams.input.profile_collection import ProfileCollection +from joystick_diagrams.plugins.plugin_interface import PluginInterface + + +@dataclass +class PluginWrapper: + plugin_name: str + plugin_version: str + plugin_icon: Path + plugin: PluginInterface + plugin_profile_collection: ProfileCollection = field(init=False) + enabled: bool + + def __post_init__(self): + self.plugin_profile_collection = None diff --git a/qt_ui/device_templates_ui.py b/qt_ui/device_templates_ui.py new file mode 100644 index 0000000..7ddb8ac --- /dev/null +++ b/qt_ui/device_templates_ui.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file 'device_templates.ui' +## +## Created by: Qt User Interface Compiler version 6.6.1 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QListWidget, + QListWidgetItem, QPushButton, QSizePolicy, QSpacerItem, + QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(453, 300) + self.verticalLayoutWidget = QWidget(Form) + self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") + self.verticalLayoutWidget.setGeometry(QRect(0, 0, 451, 301)) + self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setObjectName(u"verticalLayout") + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.label_2 = QLabel(self.verticalLayoutWidget) + self.label_2.setObjectName(u"label_2") + + self.verticalLayout.addWidget(self.label_2) + + self.label = QLabel(self.verticalLayoutWidget) + self.label.setObjectName(u"label") + + self.verticalLayout.addWidget(self.label) + + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.listWidget = QListWidget(self.verticalLayoutWidget) + QListWidgetItem(self.listWidget) + self.listWidget.setObjectName(u"listWidget") + font = QFont() + font.setPointSize(8) + font.setBold(True) + self.listWidget.setFont(font) + + self.horizontalLayout.addWidget(self.listWidget) + + self.verticalLayout_2 = QVBoxLayout() + self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.pushButton = QPushButton(self.verticalLayoutWidget) + self.pushButton.setObjectName(u"pushButton") + + self.verticalLayout_2.addWidget(self.pushButton) + + + self.horizontalLayout.addLayout(self.verticalLayout_2) + + + self.verticalLayout.addLayout(self.horizontalLayout) + + self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) + + self.verticalLayout.addItem(self.verticalSpacer) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None)) + self.label_2.setText(QCoreApplication.translate("Form", u"Devices", None)) + self.label.setText(QCoreApplication.translate("Form", u"Map your devices to a template file", None)) + + __sortingEnabled = self.listWidget.isSortingEnabled() + self.listWidget.setSortingEnabled(False) + ___qlistwidgetitem = self.listWidget.item(0) + ___qlistwidgetitem.setText(QCoreApplication.translate("Form", u"Device Name - {2020202-022930293-923929320}", None)); + self.listWidget.setSortingEnabled(__sortingEnabled) + + self.pushButton.setText(QCoreApplication.translate("Form", u"PushButton", None)) + # retranslateUi + diff --git a/qt_ui/plugin_settings_ui_ui.py b/qt_ui/plugin_settings_ui_ui.py new file mode 100644 index 0000000..5cfa19c --- /dev/null +++ b/qt_ui/plugin_settings_ui_ui.py @@ -0,0 +1,116 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file 'plugin_settings_ui.ui' +## +## Created by: Qt User Interface Compiler version 6.6.1 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QCheckBox, QCommandLinkButton, QFrame, + QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, + QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(750, 596) + Form.setMaximumSize(QSize(750, 600)) + self.verticalLayoutWidget = QWidget(Form) + self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") + self.verticalLayoutWidget.setGeometry(QRect(9, 9, 731, 87)) + self.verticalLayout_3 = QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_3.setObjectName(u"verticalLayout_3") + self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.plugin_name_label = QLabel(self.verticalLayoutWidget) + self.plugin_name_label.setObjectName(u"plugin_name_label") + font = QFont() + font.setPointSize(12) + self.plugin_name_label.setFont(font) + + self.horizontalLayout.addWidget(self.plugin_name_label) + + self.plugin_version_label = QLabel(self.verticalLayoutWidget) + self.plugin_version_label.setObjectName(u"plugin_version_label") + + self.horizontalLayout.addWidget(self.plugin_version_label) + + + self.verticalLayout_3.addLayout(self.horizontalLayout) + + self.horizontalLayout_2 = QHBoxLayout() + self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") + self.pluginEnabled = QCheckBox(self.verticalLayoutWidget) + self.pluginEnabled.setObjectName(u"pluginEnabled") + sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pluginEnabled.sizePolicy().hasHeightForWidth()) + self.pluginEnabled.setSizePolicy(sizePolicy) + font1 = QFont() + font1.setPointSize(14) + self.pluginEnabled.setFont(font1) + + self.horizontalLayout_2.addWidget(self.pluginEnabled) + + self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum) + + self.horizontalLayout_2.addItem(self.horizontalSpacer) + + self.configureLink = QCommandLinkButton(self.verticalLayoutWidget) + self.configureLink.setObjectName(u"configureLink") + sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.configureLink.sizePolicy().hasHeightForWidth()) + self.configureLink.setSizePolicy(sizePolicy1) + self.configureLink.setStyleSheet(u"color: rgb(255, 255, 255);\n" +"selection-color: rgb(255, 255, 255);") + + self.horizontalLayout_2.addWidget(self.configureLink) + + + self.verticalLayout_3.addLayout(self.horizontalLayout_2) + + self.frame = QFrame(Form) + self.frame.setObjectName(u"frame") + self.frame.setGeometry(QRect(9, 102, 116, 33)) + self.frame.setAutoFillBackground(False) + self.frame.setFrameShape(QFrame.Box) + self.frame.setFrameShadow(QFrame.Plain) + self.frame.setLineWidth(0) + self.frame.setMidLineWidth(1) + self.verticalLayout_2 = QVBoxLayout(self.frame) + self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.label_3 = QLabel(self.frame) + self.label_3.setObjectName(u"label_3") + + self.verticalLayout_2.addWidget(self.label_3) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None)) + self.plugin_name_label.setText(QCoreApplication.translate("Form", u"Plugin_Name", None)) + self.plugin_version_label.setText(QCoreApplication.translate("Form", u"TextLabel", None)) + self.pluginEnabled.setText(QCoreApplication.translate("Form", u"Enable Plugin", None)) + self.configureLink.setText(QCoreApplication.translate("Form", u"Configure plugin", None)) + self.configureLink.setDescription(QCoreApplication.translate("Form", u"Select your file/folder", None)) + self.label_3.setText(QCoreApplication.translate("Form", u"No options available", None)) + # retranslateUi + diff --git a/qt_ui/setup_page_widget_ui.py b/qt_ui/setup_page_widget_ui.py new file mode 100644 index 0000000..34c2bf0 --- /dev/null +++ b/qt_ui/setup_page_widget_ui.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- + +################################################################################ +## Form generated from reading UI file 'setup_page_widget.ui' +## +## Created by: Qt User Interface Compiler version 6.6.1 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale, + QMetaObject, QObject, QPoint, QRect, + QSize, QTime, QUrl, Qt) +from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, + QFont, QFontDatabase, QGradient, QIcon, + QImage, QKeySequence, QLinearGradient, QPainter, + QPalette, QPixmap, QRadialGradient, QTransform) +from PySide6.QtWidgets import (QApplication, QHBoxLayout, QLabel, QListWidget, + QListWidgetItem, QPushButton, QSizePolicy, QSplitter, + QVBoxLayout, QWidget) + +class Ui_Form(object): + def setupUi(self, Form): + if not Form.objectName(): + Form.setObjectName(u"Form") + Form.resize(1024, 682) + sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + Form.setMinimumSize(QSize(1024, 0)) + Form.setMaximumSize(QSize(1024, 16777215)) + Form.setBaseSize(QSize(1024, 0)) + self.verticalLayoutWidget = QWidget(Form) + self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") + self.verticalLayoutWidget.setGeometry(QRect(9, 9, 1006, 664)) + self.verticalLayout_2 = QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) + self.verticalLayout_3 = QVBoxLayout() + self.verticalLayout_3.setObjectName(u"verticalLayout_3") + self.horizontalLayout = QHBoxLayout() + self.horizontalLayout.setObjectName(u"horizontalLayout") + self.pageTitle = QLabel(self.verticalLayoutWidget) + self.pageTitle.setObjectName(u"pageTitle") + sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + sizePolicy1.setHorizontalStretch(0) + sizePolicy1.setVerticalStretch(0) + sizePolicy1.setHeightForWidth(self.pageTitle.sizePolicy().hasHeightForWidth()) + self.pageTitle.setSizePolicy(sizePolicy1) + + self.horizontalLayout.addWidget(self.pageTitle) + + self.pageDescription = QLabel(self.verticalLayoutWidget) + self.pageDescription.setObjectName(u"pageDescription") + sizePolicy1.setHeightForWidth(self.pageDescription.sizePolicy().hasHeightForWidth()) + self.pageDescription.setSizePolicy(sizePolicy1) + + self.horizontalLayout.addWidget(self.pageDescription) + + + self.verticalLayout_3.addLayout(self.horizontalLayout) + + self.verticalLayout_4 = QVBoxLayout() + self.verticalLayout_4.setObjectName(u"verticalLayout_4") + self.splitter = QSplitter(self.verticalLayoutWidget) + self.splitter.setObjectName(u"splitter") + sizePolicy1.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) + self.splitter.setSizePolicy(sizePolicy1) + self.splitter.setMinimumSize(QSize(1006, 600)) + self.splitter.setMaximumSize(QSize(1006, 600)) + self.splitter.setOrientation(Qt.Horizontal) + self.parserPluginList = QListWidget(self.splitter) + brush = QBrush(QColor(0, 0, 0, 255)) + brush.setStyle(Qt.NoBrush) + font = QFont() + font.setFamilies([u"Cascadia Code SemiBold"]) + font.setPointSize(12) + font.setBold(True) + __qlistwidgetitem = QListWidgetItem(self.parserPluginList) + __qlistwidgetitem.setCheckState(Qt.Unchecked); + __qlistwidgetitem.setFont(font); + __qlistwidgetitem.setBackground(brush); + __qlistwidgetitem.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled); + icon = QIcon() + icon.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/jg.ico", QSize(), QIcon.Normal, QIcon.Off) + __qlistwidgetitem1 = QListWidgetItem(self.parserPluginList) + __qlistwidgetitem1.setFont(font); + __qlistwidgetitem1.setIcon(icon); + icon1 = QIcon() + icon1.addFile(u"../joystick_diagrams/ui/main_window/images/3rd_party/sc.png", QSize(), QIcon.Normal, QIcon.Off) + font1 = QFont() + font1.setFamilies([u"Cascadia Code SemiBold"]) + font1.setPointSize(11) + font1.setBold(True) + __qlistwidgetitem2 = QListWidgetItem(self.parserPluginList) + __qlistwidgetitem2.setFont(font1); + __qlistwidgetitem2.setIcon(icon1); + self.parserPluginList.setObjectName(u"parserPluginList") + sizePolicy2 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) + sizePolicy2.setHorizontalStretch(0) + sizePolicy2.setVerticalStretch(0) + sizePolicy2.setHeightForWidth(self.parserPluginList.sizePolicy().hasHeightForWidth()) + self.parserPluginList.setSizePolicy(sizePolicy2) + self.parserPluginList.setMaximumSize(QSize(1087, 16777215)) + self.parserPluginList.setBaseSize(QSize(1, 0)) + self.splitter.addWidget(self.parserPluginList) + self.pluginOptionsWidget = QWidget(self.splitter) + self.pluginOptionsWidget.setObjectName(u"pluginOptionsWidget") + sizePolicy.setHeightForWidth(self.pluginOptionsWidget.sizePolicy().hasHeightForWidth()) + self.pluginOptionsWidget.setSizePolicy(sizePolicy) + self.pluginOptionsWidget.setMinimumSize(QSize(600, 600)) + self.pluginOptionsWidget.setAutoFillBackground(False) + self.horizontalLayout_6 = QHBoxLayout(self.pluginOptionsWidget) + self.horizontalLayout_6.setObjectName(u"horizontalLayout_6") + self.splitter.addWidget(self.pluginOptionsWidget) + + self.verticalLayout_4.addWidget(self.splitter) + + + self.verticalLayout_3.addLayout(self.verticalLayout_4) + + self.verticalLayout_5 = QVBoxLayout() + self.verticalLayout_5.setObjectName(u"verticalLayout_5") + self.splitter_2 = QSplitter(self.verticalLayoutWidget) + self.splitter_2.setObjectName(u"splitter_2") + sizePolicy1.setHeightForWidth(self.splitter_2.sizePolicy().hasHeightForWidth()) + self.splitter_2.setSizePolicy(sizePolicy1) + self.splitter_2.setMinimumSize(QSize(1006, 23)) + self.splitter_2.setMaximumSize(QSize(1006, 23)) + self.splitter_2.setOrientation(Qt.Horizontal) + self.addParserPlugin = QPushButton(self.splitter_2) + self.addParserPlugin.setObjectName(u"addParserPlugin") + sizePolicy3 = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) + sizePolicy3.setHorizontalStretch(0) + sizePolicy3.setVerticalStretch(0) + sizePolicy3.setHeightForWidth(self.addParserPlugin.sizePolicy().hasHeightForWidth()) + self.addParserPlugin.setSizePolicy(sizePolicy3) + self.splitter_2.addWidget(self.addParserPlugin) + self.pushButton = QPushButton(self.splitter_2) + self.pushButton.setObjectName(u"pushButton") + self.splitter_2.addWidget(self.pushButton) + + self.verticalLayout_5.addWidget(self.splitter_2) + + + self.verticalLayout_3.addLayout(self.verticalLayout_5) + + + self.verticalLayout_2.addLayout(self.verticalLayout_3) + + + self.retranslateUi(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi + + def retranslateUi(self, Form): + Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None)) + self.pageTitle.setText(QCoreApplication.translate("Form", u"

Plugin Setup

", None)) + self.pageDescription.setText(QCoreApplication.translate("Form", u"Setup your things... in order to customise stuff", None)) + + __sortingEnabled = self.parserPluginList.isSortingEnabled() + self.parserPluginList.setSortingEnabled(False) + ___qlistwidgetitem = self.parserPluginList.item(0) + ___qlistwidgetitem.setText(QCoreApplication.translate("Form", u"DCS World", None)); + ___qlistwidgetitem1 = self.parserPluginList.item(1) + ___qlistwidgetitem1.setText(QCoreApplication.translate("Form", u"Joystick Gremlin", None)); + ___qlistwidgetitem2 = self.parserPluginList.item(2) + ___qlistwidgetitem2.setText(QCoreApplication.translate("Form", u"Star Citizen PTOATO", None)); + self.parserPluginList.setSortingEnabled(__sortingEnabled) + + self.addParserPlugin.setText(QCoreApplication.translate("Form", u"Add Plugin", None)) + self.pushButton.setText(QCoreApplication.translate("Form", u"Remove Plugin", None)) + # retranslateUi +