Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
about_window.py 6.14 KiB
from PySide2.QtWidgets import QVBoxLayout, QHBoxLayout, QWidget, QDialog, QLabel, QFrame, QScrollArea
from PySide2.QtCore import Qt


QUESTIONS = {
    "Adding operations": "Select an operation under 'Special operations' or 'Core operations' to add it to the workspace.",
    "Moving operations": "To drag an operation, select the operation on the workspace and drag it around.",
    "Selecting operations": "To select one operation just press it once, it will then turn grey.",
    "Selecting multiple operations using dragging": "To select multiple operations using your mouse, \ndrag the mouse while pressing left mouse button, any operation under the selection box will then be selected.",
    "Selecting multiple operations using without dragging": "To select mutliple operations using without dragging, \npress 'Ctrl+LMouseButton' on any operation. Alternatively press 'Ctrl+A' to select all operations.",
    "Remove operations": "To remove an operation, select the operation to be deleted, \nfinally press RMouseButton to bring up the context menu, then press 'Delete'.",
    "Remove multiple operations": "To remove multiple operations, \nselect all operations to be deleted and press 'Delete' on your keyboard.",
    "Connecting operations": "To connect operations, select the ports on the operation to connect from, \nthen select the next port by pressing 'Ctrl+LMouseButton' on the destination port. Tip: You can chain connection by selecting the ports in the order they should be connected.",
    "Creating a signal-flow-graph": "To create a signal-flow-graph (SFG), \ncouple together the operations you wish to create a sfg from, then select all operations you wish to include in the sfg, \nfinally press 'Create SFG' in the upper left corner and enter the name of the sfg.",
    "Simulating a signal-flow-graph": "To simulate a signal-flow-graph (SFG), press the run button in the toolbar, \nthen press 'Simulate SFG' and enter the properties of the simulation.",
    "Properties of simulation": "The properties of the simulation are, 'Iteration Count': The number of iterations to run the simulation for, \n'Plot Results': Open a plot over the output in matplotlib, \n'Get All Results': Print the detailed output from simulating the sfg in the terminal, \n'Input Values': The input values to the SFG by index of the port."
}


class KeybindsWindow(QDialog):
    def __init__(self, window):
        super(KeybindsWindow, self).__init__()
        self._window = window
        self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
        self.setWindowTitle("B-ASIC Keybinds")

        self.dialog_layout = QVBoxLayout()
        self.setLayout(self.dialog_layout)

        self.add_information_to_layout()

    def add_information_to_layout(self):
        information_layout = QVBoxLayout()

        title_label = QLabel("B-ASIC / Better ASIC Toolbox")
        subtitle_label = QLabel("Keybinds in the GUI.")

        frame = QFrame()
        frame.setFrameShape(QFrame.HLine)
        frame.setFrameShadow(QFrame.Sunken)
        self.dialog_layout.addWidget(frame)

        keybinds_label = QLabel(
            "'Ctrl+A' - Select all operations on the workspace.\n"
            "'Ctrl+R' - Reload the operation list to add any new operations created.\n"
            "'Ctrl+Q' - Quit the application.\n"
            "'Ctrl+LMouseButton' - On a operation will select the operation, without deselecting the other operations.\n"
        )

        information_layout.addWidget(title_label)
        information_layout.addWidget(subtitle_label)

        self.dialog_layout.addLayout(information_layout)
        self.dialog_layout.addWidget(frame)

        self.dialog_layout.addWidget(keybinds_label)


class AboutWindow(QDialog):
    def __init__(self, window):
        super(AboutWindow, self).__init__()
        self._window = window
        self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
        self.setWindowTitle("About B-ASIC")

        self.dialog_layout = QVBoxLayout()
        self.setLayout(self.dialog_layout)

        self.add_information_to_layout()

    def add_information_to_layout(self):
        information_layout = QVBoxLayout()

        title_label = QLabel("B-ASIC / Better ASIC Toolbox")
        subtitle_label = QLabel("Construct, simulate and analyze components of an ASIC.")

        frame = QFrame()
        frame.setFrameShape(QFrame.HLine)
        frame.setFrameShadow(QFrame.Sunken)
        self.dialog_layout.addWidget(frame)

        about_label = QLabel(
            "B-ASIC is a open source tool using the B-ASIC library to construct, simulate and analyze ASICs.\n"
            "B-ASIC is developed under the MIT-license and any extension to the program should follow that same license.\n"
            "To read more about how the GUI works please refer to the FAQ under 'Help'."
        )

        information_layout.addWidget(title_label)
        information_layout.addWidget(subtitle_label)

        self.dialog_layout.addLayout(information_layout)
        self.dialog_layout.addWidget(frame)

        self.dialog_layout.addWidget(about_label)


class FaqWindow(QDialog):
    def __init__(self, window):
        super(FaqWindow, self).__init__()
        self._window = window
        self.setWindowFlags(Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
        self.setWindowTitle("Frequently Asked Questions")

        self.dialog_layout = QVBoxLayout()
        self.scroll_area = QScrollArea()
        self.setLayout(self.dialog_layout)
        for question, answer in QUESTIONS.items():
            self.add_question_to_layout(question, answer)

        self.scroll_area.setWidget(self)
        self.scroll_area.setWidgetResizable(True)

    def add_question_to_layout(self, question, answer):
        question_layout = QVBoxLayout()
        answer_layout = QHBoxLayout()

        question_label = QLabel(question)
        question_layout.addWidget(question_label)

        answer_label = QLabel(answer)
        answer_layout.addWidget(answer_label)

        frame = QFrame()
        frame.setFrameShape(QFrame.HLine)
        frame.setFrameShadow(QFrame.Sunken)
        self.dialog_layout.addWidget(frame)

        question_layout.addLayout(answer_layout)
        self.dialog_layout.addLayout(question_layout)