Ejemplo n.º 1
0
    def __init__(self, parent, message: str):
        """
        Information dialog

        :param parent: gui's main window
        :param message: Message to display
        """
        QDialog.__init__(self, parent)

        self.setFixedSize(QSize(350, 80))

        self.info = QLabel(message)
        self.info.setAlignment(Qt.AlignCenter)

        # Quit buttons
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFixedSize(QSize(60, 33))

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.info)
        layout.addWidget(self.ok_btn)
        layout.setAlignment(self.ok_btn, Qt.AlignCenter)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog"))
    def __init__(self, parent, message_key: str):
        """
        Confirm dialog for dangerous actions

        :param parent: gui's main window
        :param message_key: Key to the dictionary for the message to display
        """
        QDialog.__init__(self, parent)

        self.setFixedSize(QSize(350, 120))

        self.question = QLabel(tr(message_key))
        self.question.setAlignment(Qt.AlignCenter)

        # Quit buttons
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFixedSize(QSize(60, 33))

        self.cancel_btn = QPushButton(tr("btn_cancel"))
        self.cancel_btn.clicked.connect(self.reject)
        self.cancel_btn.setFixedSize(QSize(90, 33))

        # Layout
        layout = QGridLayout()
        layout.addWidget(self.question, 0, 0, 1, 2)
        layout.addWidget(self.ok_btn, 1, 0)
        layout.setAlignment(self.ok_btn, Qt.AlignCenter)
        layout.addWidget(self.cancel_btn, 1, 1)
        layout.setAlignment(self.cancel_btn, Qt.AlignLeft)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog"))
Ejemplo n.º 3
0
    def __init__(self):
        """
        Application side panel. Contains room, groups and skills lists.

        :param config: application's parsed configuration
        """
        QTabWidget.__init__(self)

        self.setMinimumSize(QSize(300, 500))

        self.setTabPosition(QTabWidget.South)
        self.setTabsClosable(False)

        self.tabBar().setIconSize(QSize(46, 46))

        # widgets
        self.courses_panel = ViewCoursePanel(self.minimumWidth())
        self.students_panel = ViewStudentPanel()
        self.attributes_panel = ViewAttributePanel()

        # Tabs
        self.addTab(self.courses_panel, get_icon("classroom"), "")
        self.setTabToolTip(0, tr("crs_tab_tooltip"))
        self.addTab(self.students_panel, get_icon("magic"), "")
        self.setTabToolTip(1, tr("grp_tab_tooltip"))
        self.addTab(self.attributes_panel, get_icon("competence"), "")
        self.setTabToolTip(2, tr("attr_tab_tooltip"))

        self.setStyleSheet(get_stylesheet("tabbar"))
Ejemplo n.º 4
0
 def __set_style(self) -> None:
     """
     Inits the stylesheet of this widget
     """
     # Toolbar
     self.setStyleSheet(get_stylesheet("toolbar"))
     self.delete_btn.setStyleSheet("border: none;")
Ejemplo n.º 5
0
    def __init__(self, parent, groups: list):
        """
        Displays a Dialog with a file chooser for the .csv to import and a group selection combo.

        :param parent: MainApplication
        """
        QDialog.__init__(self, parent)

        self.setWindowTitle(tr("grp_action_import_csv"))

        # Widgets
        self.fileDialog = QFileDialog(self)
        self.fileDialog.setOption(QFileDialog.DontUseNativeDialog)
        self.fileDialog.setWindowFlags(Qt.Widget)
        self.fileDialog.setNameFilter("Fichiers excel (*.csv)")
        self.fileDialog.finished.connect(self.done)

        self.lab_sep = QLabel()  # Separator
        self.lab_sep.setFixedHeight(3)
        self.lab_sep.setStyleSheet(get_stylesheet("separator"))

        self.lab_group = QLabel(tr("add_to_group"))

        self.combo_group = QComboBox()
        self.combo_group.addItems(groups)
        self.combo_group.setFixedWidth(200)

        # Layout
        self.__set_layout()
Ejemplo n.º 6
0
    def __init__(self, btn_name: str, show_field, actions_map: list):
        """
        Creates a QPushButton with a dropdown menu on it.

        :param btn_name: Button name (always displayed)
        :type btn_name: str
        :param actions_map: list of actions to put in the dropdown menu [(action_name, action_key), (separator_name), ...]
        :type actions_map: list
        :param show_field: entry field to display on create operations
        :type show_field: function
        """
        QPushButton.__init__(self, btn_name)

        self.menu = QMenu(self)

        for a in actions_map:
            if a == 'sep':  # This is a separator
                self.menu.addSeparator()
            else:  # Regular action
                t, k = a
                if k.startswith(
                        'create_'
                ):  # If we have a create feature, we display the entry field
                    self.menu.addAction(t, lambda k=k: show_field(k))
                else:
                    self.menu.addAction(t, lambda k=k: self.sig_action.emit(k))

        self.setMenu(self.menu)
        self.menu.setStyleSheet(get_stylesheet("menu"))
    def __init__(self, parent, sig_attribute_edition: Signal, student: Student,
                 attributes: list):
        """
        Confirm dialog for dangerous actions

        :param parent: gui's main window
        :param sig_attribute_edition: Signal to emit in order to edit the selected attribute
        :param student: Current student
        :param attributes: List of attributes
        """
        QDialog.__init__(self, parent)

        self.setFixedSize(QSize(350, 350))
        self.setWindowFlag(Qt.WindowStaysOnTopHint)

        self.student = student
        self.attributes = attributes

        # Widgets
        self.std_info = QLabel(f"{student.firstname} {student.lastname}")

        self.table_attributes = QTableView()
        self.table_attributes.setFixedWidth(300)
        self.table_attributes.horizontalHeader().setStretchLastSection(True)
        self.table_attributes.horizontalHeader().hide()
        self.table_attributes.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table_attributes.setSelectionMode(
            QAbstractItemView.SingleSelection)
        self.table_attributes.verticalHeader().setSectionResizeMode(
            QHeaderView.Fixed)
        self.table_attributes.verticalHeader().setFixedWidth(150)

        self.dm: AttributesTableModel = None
        self.attr_idx = {
        }  # Attributes ids to indexes -> {attr_id: attr_idx, ...}

        # Close button
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFixedSize(QSize(60, 33))

        # Signals
        self.sig_attribute_edition = sig_attribute_edition
        self.table_attributes.clicked.connect(self.on_attr_clicked)

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.std_info)
        layout.setAlignment(self.std_info, Qt.AlignCenter)
        layout.addWidget(self.table_attributes)
        layout.addWidget(self.ok_btn)
        layout.setAlignment(self.ok_btn, Qt.AlignCenter)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog"))

        # Initialization with the given attributes
        self.attributes_updated(self.attributes)
Ejemplo n.º 8
0
    def __init__(self, width, layout: QVBoxLayout):
        """
        Separator for the config dialog
        """
        QLabel.__init__(self)

        self.setFixedHeight(3)
        self.setFixedWidth(int(width))
        self.setStyleSheet(get_stylesheet("separator"))

        # Layout
        self.setAlignment(Qt.AlignCenter)
        layout.addWidget(self, alignment=Qt.AlignCenter)
Ejemplo n.º 9
0
    def __init__(self, width, box: QVBoxLayout):
        """
        Separator for the about box
        """
        QLabel.__init__(self)

        self.setFixedHeight(3)
        self.setFixedWidth(int(width))
        self.setStyleSheet(get_stylesheet("separator"))

        # Layout
        self.setAlignment(Qt.AlignCenter)
        box.addSpacing(SPACING_SIZE)
        box.addWidget(self, alignment=Qt.AlignCenter)
        box.addSpacing(SPACING_SIZE)
Ejemplo n.º 10
0
    def __init__(self, bdd_version: str):
        """
        About-us frame.

        :param bdd_version: current BDD version
        """
        QDialog.__init__(self)

        self.setWindowTitle(f"{tr('app_title')} | {tr('about_us')}")
        self.setFixedSize(QSize(600, 500))

        self.bdd_version = bdd_version

        self.links_style = "<style>a { text-decoration:none; color:#416284; font-weight: bold;}</style>"

        self._set_labels_and_layout()
        self.setStyleSheet(get_stylesheet("dialog2"))
Ejemplo n.º 11
0
    def __init__(self, parent, topics: list, current_selection: str,
                 course_name: str):
        """
        Topic selection dialog

        :param parent: gui's main window
        :param topics: List of available topics
        :param current_selection: Currently selected topic
        :param course_name: Current course name
        """
        QDialog.__init__(self, parent)

        self.topics = topics
        self.current_selection = current_selection

        self.setWindowTitle(course_name + " - " + tr("select_topic"))
        self.setFixedSize(QSize(300, 140))

        # Widgets
        self.combo = QComboBox()
        self.combo.addItems(self.topics)
        self.__default_selection(current_selection)

        self.new_topic_line = QLineEdit()
        self.new_topic_line.setPlaceholderText(tr("create_new_topic"))
        self.new_topic_line.textChanged.connect(self.__enable_combo)

        # Close button
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFixedSize(QSize(60, 33))

        # Layout
        layout = QVBoxLayout()
        layout.addWidget(self.combo)
        layout.setAlignment(self.combo, Qt.AlignCenter)
        layout.addWidget(self.new_topic_line)
        layout.addWidget(self.ok_btn)
        layout.setAlignment(self.ok_btn, Qt.AlignCenter)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog"))
Ejemplo n.º 12
0
    def __set_layout(self) -> None:
        """
        Sets the dialog layout
        """
        # Main layout
        layout = QVBoxLayout()
        layout.setMargin(0)
        layout.addSpacing(5)

        # Main section
        main_layout = QFormLayout()
        main_layout.addRow(tr("app_version"), self.lab_version)
        main_layout.addRow(tr("language"), self.combo_language)
        main_layout.addRow(tr("csv_sep"), self.csv_sep_edit)
        main_layout.addRow(tr("bdd_path"), self.btn_bdd_path)

        # Web app
        widget_port = QWidget()
        layout_port = QHBoxLayout()
        layout_port.setMargin(0)
        layout_port.addWidget(self.wepapp_port)
        layout_port.addWidget(ShutDownToolTip())
        widget_port.setLayout(layout_port)
        main_layout.addRow(tr("web_port"), widget_port)

        layout.addLayout(main_layout)
        Separator(self.width(), layout)

        # Colors
        colors_layout1 = QFormLayout()
        colors_layout1.addRow(tr("tile"), self.tile_color)
        colors_layout1.addRow(tr("hovered_tile"), self.hovered_tile_color)
        colors_layout1.addRow(tr("hovered_empty_tile"),
                              self.hovered_empty_tile_color)
        colors_layout1.addRow(tr("dragged_tile"), self.dragged_tile_color)
        colors_layout1.addRow(tr("drag_selected_tile"),
                              self.drag_selected_tile_color)
        colors_layout1.addRow(tr("selected_tile"), self.selected_tile_color)

        colors_layout2 = QFormLayout()
        colors_layout2.addRow(tr("tile_text"), self.tile_text_color)
        colors_layout2.addRow(tr("room_bg"), self.room_bg_color)
        colors_layout2.addRow(tr("room_grid"), self.room_grid_color)
        colors_layout2.addRow(tr("main_bg"), self.main_bg_color)
        colors_layout2.addRow(tr("board_bg"), self.board_bg_color)

        colors_layout = QHBoxLayout()
        colors_layout.setMargin(0)
        colors_layout.addLayout(colors_layout1)
        colors_layout.addLayout(colors_layout2)

        layout.addLayout(colors_layout)
        layout.addSpacing(15)

        colors_layout3 = QFormLayout()
        colors_layout3.setMargin(0)
        colors_layout3.addRow(tr("attr_colors"),
                              self.attributes_colors_chooser)
        layout.addLayout(colors_layout3)

        Separator(self.width(), layout)

        # Unmodifiable data
        sizes_layout = QFormLayout()
        sizes_layout.setMargin(0)
        sizes_layout.addRow(tr("desk_size"), self.desk_size)
        sizes_layout.addRow(tr("grid_rows"), self.grid_rows)
        sizes_layout.addRow(tr("grid_cols"), self.grid_cols)

        layout.addWidget(self.unmodifiable, alignment=Qt.AlignCenter)
        layout.addSpacing(5)
        layout.addLayout(sizes_layout)

        Separator(self.width(), layout)

        # Buttons
        layout_buttons = QHBoxLayout()
        layout_buttons.addWidget(self.ok_btn)
        layout_buttons.addWidget(self.restore_btn)
        layout_buttons.addWidget(self.cancel_btn)

        layout.addLayout(layout_buttons)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog2"))
Ejemplo n.º 13
0
 def __set_style(self):
     """
     Inits the stylesheet of this widget
     """
     # Toolbar
     self.setStyleSheet(get_stylesheet("toolbar"))
Ejemplo n.º 14
0
    def __set_layout(self) -> None:
        """
        Sets the dialog layout
        """
        # Main layout
        layout = QVBoxLayout()
        layout.setMargin(0)
        layout.addSpacing(5)

        # Main section
        main_layout = SettingsFormLayout()
        main_layout.addRow(tr("app_version"), self.lab_version)
        main_layout.addRow(tr("language"), self.combo_language)
        main_layout.addRow(tr("csv_sep"), self.csv_sep_edit)
        main_layout.addRow(tr("bdd_path"), self.btn_bdd_path)

        # Web app
        widget_port = QWidget()
        layout_port = QHBoxLayout()
        layout_port.setMargin(0)
        layout_port.addWidget(self.wepapp_port)
        layout_port.addWidget(WarningToolTip("shutdown_required"))
        widget_port.setLayout(layout_port)
        main_layout.addRow(tr("web_port"), widget_port)

        layout.addLayout(main_layout)
        Separator(self.width(), layout)

        # Colors
        colors_layout1 = SettingsFormLayout()
        colors_layout1.addRow(tr("tile"), self.tile_color)
        colors_layout1.addRow(tr("hovered_tile"), self.hovered_tile_color)
        colors_layout1.addRow(tr("hovered_empty_tile"),
                              self.hovered_empty_tile_color)
        colors_layout1.addRow(tr("dragged_tile"), self.dragged_tile_color)
        colors_layout1.addRow(tr("drag_selected_tile"),
                              self.drag_selected_tile_color)
        colors_layout1.addRow(tr("selected_tile"), self.selected_tile_color)

        colors_layout2 = SettingsFormLayout()
        colors_layout2.addRow(tr("tile_text"), self.tile_text_color)
        colors_layout2.addRow(tr("room_bg"), self.room_bg_color)
        colors_layout2.addRow(tr("room_grid"), self.room_grid_color)
        colors_layout2.addRow(tr("main_bg"), self.main_bg_color)
        colors_layout2.addRow(tr("board_bg"), self.board_bg_color)

        colors_layout = QHBoxLayout()
        colors_layout.setMargin(0)
        colors_layout.addLayout(colors_layout1)
        colors_layout.addLayout(colors_layout2)

        layout.addLayout(colors_layout)
        layout.addSpacing(15)

        colors_layout3 = SettingsFormLayout()
        colors_layout3.setMargin(0)
        colors_layout3.addRow(tr("attr_colors"),
                              self.attributes_colors_chooser)
        layout.addLayout(colors_layout3)

        Separator(self.width(), layout)

        # size data
        sizes_layout = SettingsFormLayout()
        sizes_layout.setMargin(0)

        widget_desk = QWidget()
        layout_desk = QHBoxLayout()
        layout_desk.setMargin(0)
        layout_desk.addWidget(self.desk_size_h)
        layout_desk.addWidget(self.desk_size_w)
        layout_desk.addWidget(WarningToolTip("dangerous_parameter"))
        widget_desk.setLayout(layout_desk)
        sizes_layout.addRow(tr("desk_size"), widget_desk)

        sizes_layout.addRow(tr("font_size"), self.desk_font_size)

        widget_rows = QWidget()
        layout_rows = QHBoxLayout()
        layout_rows.setMargin(0)
        layout_rows.addWidget(self.grid_rows)
        layout_rows.addWidget(WarningToolTip("dangerous_parameter"))
        widget_rows.setLayout(layout_rows)
        sizes_layout.addRow(tr("grid_rows"), widget_rows)

        widget_cols = QWidget()
        layout_cols = QHBoxLayout()
        layout_cols.setMargin(0)
        layout_cols.addWidget(self.grid_cols)
        layout_cols.addWidget(WarningToolTip("dangerous_parameter"))
        widget_cols.setLayout(layout_cols)
        sizes_layout.addRow(tr("grid_cols"), widget_cols)

        layout.addLayout(sizes_layout)

        Separator(self.width(), layout)

        # Buttons
        layout_buttons = QHBoxLayout()
        layout_buttons.addWidget(self.ok_btn)
        layout_buttons.addWidget(self.restore_btn)
        layout_buttons.addWidget(self.cancel_btn)

        layout.addLayout(layout_buttons)
        layout.addSpacing(5)
        self.setLayout(layout)

        self.setStyleSheet(get_stylesheet("dialog2"))