Ejemplo n.º 1
0
 def show_qr(self):
     self.qr_dialog = VQRCode(self.gui)
     if self.qr_dialog.has_internet:
         self.qr_dialog.exec_()
     else:
         self.gui.status_bar.showMessage(tr("no_internet"), 5000)
         VInfoDialog(self.gui, tr("no_internet")).exec_()
Ejemplo n.º 2
0
    def on_edit_config(self) -> None:
        """
        Displays the edition dialog for application settings
        """
        dlg = SettingsEditionDialog()

        if dlg.exec_():
            if dlg.restore_default():
                AssetManager.getInstance().restore_default_settings()
            else:
                AssetManager.getInstance().save_config(dlg.new_config())

            self.status_bar.showMessage(tr("acknowledge_changes"), 3000)
            self.repaint()

            if dlg.need_restart():
                restart_confirm = VConfirmDialog(self, "need_restart")
                restart_confirm.ok_btn.setText(tr("restart_now"))
                restart_confirm.ok_btn.setFixedSize(QSize(105, 33))
                restart_confirm.cancel_btn.setText(tr("restart_later"))
                restart_confirm.cancel_btn.setFixedSize(QSize(105, 33))

                if restart_confirm.exec_():
                    self.reboot_requested = True
                    self.close()
                    self.restart()
Ejemplo n.º 3
0
    def init_table(self, list_courses=[], selected_id=None):
        """
        Inits the data_model with the specified objects list and sets it to the view.
        An object is represented like this: (course_id, course_name, topic_name)

        :param list_courses: list of objects to add
        :type list_courses: list
        :param selected_id: Id of the course to select
        :type selected_id: int
        """
        self.datamodel = None
        self.items = {}
        data_list = []
        selection = -1

        for course_id, name, topic in list_courses:
            data = (name, topic)
            self.items[data] = course_id
            data_list.append(data)

            if course_id == selected_id:
                selection = len(data_list) - 1

        self.datamodel = CustomTableModel(self.tableview, data_list,
                                          (tr("crs_courses"),
                                           tr("crs_topic")))
        self.tableview.selectionModel().selectionChanged.connect(
            lambda: self.courses_toolbar.enable_delete_btn(len(self.tableview.selectionModel().selectedRows()) > 0))

        self.tableview.setCurrentIndex(self.datamodel.index(selection, 0))
        self.current_selection = selected_id

        self.repaint()
    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.º 5
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.º 6
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.º 7
0
    def __init__(self):
        """
        Widget proposing an add button, with a text entry that will appear only when the add button is pressed. The
        attribute type selection combo will also appear next to it.
        We also display a remove button, that will be shown only when the other fields are not.

        A new click on the add button (or an <Escape> press) will cancel the action, and a press on <Enter> will
        validate.
        """
        QWidget.__init__(self)

        self.setFixedSize(QSize(290, 50))

        self.attr_types_dico = {}
        for attr_type in [t.value for t in EAttributesTypes]:
            self.attr_types_dico[tr(attr_type)] = attr_type

        self.add_btn = QPushButton()
        self.add_btn.setIcon(get_icon("add"))
        self.add_btn.setIconSize(QSize(35, 35))
        self.add_btn.setToolTip(tr("crs_create_btn_tooltip"))

        self.field = QLineEdit()
        self.field.setVisible(False)

        self.combo = QComboBox()
        self.combo.setFixedWidth(105)
        self.combo.addItems(list(self.attr_types_dico.keys()))
        self.combo.setVisible(False)

        self.ok_btn = QPushButton()
        self.ok_btn.setIcon(get_icon("valid"))
        self.ok_btn.setIconSize(QSize(35, 35))
        self.ok_btn.setToolTip(tr("crs_create_btn_tooltip"))
        self.ok_btn.setVisible(False)

        self.delete_btn = QPushButton()
        self.delete_btn.setIcon(get_icon("del"))
        self.delete_btn.setIconSize(QSize(35, 35))
        self.delete_btn.setToolTip(tr("btn_suppr"))
        self.delete_btn.setEnabled(False)

        # Current state
        self.is_creating = False

        # Signals
        self.ok_btn.clicked.connect(self.__on_field_enter)
        self.add_btn.clicked.connect(self.__on_add_pressed)
        self.sig_new_element = None  # Signal emitted when a new element is created
        self.sig_delete = None  # Signal emitted when the delete button is clicked
        self.field.returnPressed.connect(self.__on_field_enter)
        QShortcut(QKeySequence("Escape"), self.field).activated.connect(
            lambda: self.__on_add_pressed())  # Cancel
        self.delete_btn.clicked.connect(lambda: self.sig_delete.emit())

        # Layout
        self.__init_layout()
        self.__init_style()
Ejemplo n.º 8
0
    def __init__(self, parent, current_val: str):
        """
        Generic class dialog to inherit for the specifics of each edition contexts (text, color, mark or counter)

        :param parent: gui's main window
        :param current_val: current field actual value (to set by default)
        """
        QDialog.__init__(self, parent)

        self.setWindowTitle("Edition")
        self.setWindowFlag(Qt.WindowStaysOnTopHint)

        # Quit buttons
        self.ok_btn = QPushButton("Ok")
        self.ok_btn.clicked.connect(self.accept)

        self.cancel_btn = QPushButton(tr("btn_cancel"))
        self.cancel_btn.clicked.connect(self.reject)

        # Layout
        self.main_layout = QGridLayout()

        self.main_layout.addWidget(self.ok_btn, 10, 0)
        self.main_layout.addWidget(self.cancel_btn, 10, 1)

        self.setLayout(self.main_layout)
Ejemplo n.º 9
0
    def __init__(self):
        """
        Toolbar for the Room list side panel tab
        """
        QToolBar.__init__(self)

        # Widgets
        self.delete_btn = QPushButton()
        self.delete_btn.setIcon(get_icon("del"))
        self.delete_btn.setIconSize(QSize(35, 35))
        self.delete_btn.setToolTip(tr("btn_suppr"))
        self.delete_btn.setEnabled(False)

        self.add_widget = ViewAddWidget(self.delete_btn)

        self.sig_delete: Signal = None
        self.delete_btn.clicked.connect(lambda: self.sig_delete.emit())

        # Layout
        self.addWidget(self.add_widget)
        # Empty space to align the about button to the right
        spacer = QWidget()
        spacer.setStyleSheet("background-color: transparent;")
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.addWidget(spacer)

        self.addWidget(self.delete_btn)

        self.__set_style()
Ejemplo n.º 10
0
    def __init__(self, btn_to_disable: QPushButton):
        """
        Widget proposing an add button, with a text entry that will appear only when the add button is pressed.
        A new click on the add button will cancel the action, and a press on <Enter> will validate.

        :param btn_to_disable: button to disable when the creation field is shown
        """
        QWidget.__init__(self)

        self.setFixedSize(QSize(150, 50))

        self.add_btn = QPushButton()
        self.add_btn.setIcon(get_icon("add"))
        self.add_btn.setIconSize(QSize(35, 35))
        self.add_btn.setToolTip(tr("crs_create_btn_tooltip"))

        self.field = QLineEdit()
        self.field.setVisible(False)

        # Current state
        self.is_creating = False
        self.btn_to_disable = btn_to_disable

        # Signals
        self.add_btn.clicked.connect(self.__on_add_pressed)
        self.sig_new_element = None  # Signal emitted when a new element is created
        self.field.returnPressed.connect(self.__on_field_enter)
        QShortcut(QKeySequence("Escape"), self.field).activated.connect(
            lambda: self.__on_add_pressed())  # Cancel

        # Layout
        self.__init_layout()
        self.__init_style()
Ejemplo n.º 11
0
    def show_field(self, origin: str, default_text: str = None) -> None:
        """
        Shows and focus the creation field

        :param origin: action that triggered the displayal
        :param default_text: default text to display in the field
        """
        self.creator = origin
        self.create_field.setVisible(True)
        self.create_field.setFocus()

        if origin == 'create_group':
            self.create_field.setPlaceholderText(tr("group_name"))
        elif origin == 'create_student':
            self.create_field.setPlaceholderText(tr("std_name"))
        else:  # We are editing a student, the origin is the student id
            self.create_field.setText(default_text)
Ejemplo n.º 12
0
    def choose_bdd_path(self) -> None:
        """
        Opens a file chooser to select the bdd path. Then sets the name as button text.
        """
        bdd_path = QFileDialog.getOpenFileName(self, tr("bdd_path"),
                                               self.btn_bdd_path.text())[0]

        if bdd_path:
            self.btn_bdd_path.setText(bdd_path)
Ejemplo n.º 13
0
    def set_students_list(self, students: list) -> None:
        """
        Sets the specified student list inside the table view

        :param students: students list
        """
        self.datamodel = None
        self.students = {}
        self.tableview.clearSelection()
        data_list = []

        for s in students:
            data = (s.lastname, s.firstname)
            self.students[data] = s.id
            data_list.append(data)

        self.datamodel = CustomTableModel(self.tableview, data_list,
                                          (tr("grp_surname"), tr("grp_name")))
        self.repaint()
Ejemplo n.º 14
0
 def on_export_csv(self) -> None:
     """
     Displays a save dialog to select a file path for the export csv of the attributes table.
     Then signals this path to the controller
     """
     file_path = QFileDialog.getSaveFileName(self,
                                             tr("export_dialog_title"),
                                             "untitled", "(*.csv)")[0]
     if file_path:
         self.sig_export_csv.emit(file_path)
Ejemplo n.º 15
0
    def __init__(self, sig_move_animation_ended):
        """
        Widget containing the main canvas (classroom), the board's position and topic selection.

        :param sig_move_animation_ended: Signal to trigger when the move animation ended
        """
        QWidget.__init__(self)

        # Widgets
        self.v_canvas = ViewCanvas(sig_move_animation_ended)  # Central canvas
        self.view_students = ViewTeacherDeskLabel(
            tr("perspective_student_txt"),
            AssetManager.getInstance().config('colors', 'board_bg'))
        self.view_teacher = ViewTeacherDeskLabel(
            tr("perspective_teacher_txt"),
            AssetManager.getInstance().config('colors', 'board_bg'))

        # Layout
        self.__set_layout()
Ejemplo n.º 16
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.º 17
0
    def on_perspective_changed(self):
        """
        Switches the current view perspective and updates boards display and canvas
        """
        if self.is_view_students is None:  # To prevent updating the canvas for the initialization
            self.is_view_students = True
        else:
            self.sig_enable_animation_btns.emit(
                False)  # Freeze btn for preventing multiple clicks
            self.is_view_students = not self.is_view_students
            self.classroom_tab.v_canvas.perspective_changed()

        if self.is_view_students:
            self.classroom_tab.view_students.set_label_visible(True)
            self.classroom_tab.view_teacher.set_label_visible(False)
            self.status_message(tr("status_bar_active_view_student"), 3000)
        else:
            self.classroom_tab.view_students.set_label_visible(False)
            self.classroom_tab.view_teacher.set_label_visible(True)
            self.status_message(tr("status_bar_active_view_teacher"), 3000)
Ejemplo n.º 18
0
    def __on_add_pressed(self):
        """
        Performs the action associated to the add button, given the current state
        """
        self.is_creating = not self.is_creating
        self.btn_to_disable.setEnabled(not self.is_creating)

        if self.is_creating:
            self.add_btn.setIcon(get_icon("close"))
            self.add_btn.setToolTip(tr("btn_cancel"))

            self.field.setVisible(True)
            self.field.setFocus()
            self.field.setText(self.get_prefix())
        else:
            self.field.clear()
            self.add_btn.setIcon(get_icon("add"))
            self.add_btn.setToolTip(tr("crs_create_btn_tooltip"))

            self.field.setVisible(False)
Ejemplo n.º 19
0
    def killstudent(self):
        if not VConfirmDialog(self.gui, "confirm_message_delete").exec_():
            return

        self.gui.status_bar.showMessage(tr("grp_action_del_student"), 3000)
        list_id_students = self.gui.sidewidget.students().selected_students()
        for id_std in list_id_students:
            self.mod_bdd.remove_student_from_group(id_std,
                                                   self.main_ctrl.id_group)
        self.course_ctrl.show_course()
        self.show_all_groups(current=self.main_ctrl.id_group)
        self.__bdd.commit()
Ejemplo n.º 20
0
 def sort_alpha(self, desc):
     self.gui.status_bar.showMessage(tr("grp_action_alpha_sort"), 3000)
     group_name = self.mod_bdd.get_group_name_by_id(self.main_ctrl.id_group)
     list_students = self.mod_bdd.get_students_in_group(group_name)
     sortlist = [(s.lastname, s.id) for s in list_students]
     sortlist.sort(reverse=desc)
     orderkey = 1
     for s in sortlist:
         self.mod_bdd.update_student_order_with_id(s[1], orderkey)
         orderkey += 1
     self.__bdd.commit()
     self.main_ctrl.on_config_changed()
     self.course_ctrl.synchronize_canvas_selection_with_side_list()
Ejemplo n.º 21
0
    def __init__(self):
        """
        Information point that displays a tooltip when hovered
        """
        QLabel.__init__(self, "i")
        self.setFixedSize(QSize(20, 20))
        self.setAlignment(Qt.AlignCenter)

        self.setStyleSheet(
            "font-weight: bold; border: 1px solid transparent; border-radius: 10px; "
            "background-color: orange; color: black;")

        self.setToolTip(tr("shutdown_required"))
Ejemplo n.º 22
0
    def __init__(self, text_key: str):
        """
        Information point that displays a tooltip when hovered

        :param text_key: tooltip text
        """
        QLabel.__init__(self, "i")
        self.setFixedSize(QSize(28, 28))
        self.setAlignment(Qt.AlignCenter)

        self.setStyleSheet("font-weight: bold; border: 1px solid transparent; border-radius: 14px; "
                           "background-color: lightblue; color: black;")

        self.setToolTip(tr(text_key))
Ejemplo n.º 23
0
    def __on_add_pressed(self) -> None:
        """
        Performs the action associated to the add button, given the current state
        """
        self.is_creating = not self.is_creating

        if self.is_creating:
            self.add_btn.setIcon(get_icon("close"))
            self.add_btn.setToolTip(tr("btn_cancel"))

            self.delete_btn.setVisible(False)
            self.field.setVisible(True)
            self.field.setFocus()
            self.combo.setVisible(True)
            self.ok_btn.setVisible(True)
        else:
            self.field.clear()
            self.add_btn.setIcon(get_icon("add"))
            self.add_btn.setToolTip(tr("crs_create_btn_tooltip"))

            self.field.setVisible(False)
            self.combo.setVisible(False)
            self.ok_btn.setVisible(False)
            self.delete_btn.setVisible(True)
Ejemplo n.º 24
0
    def set_attributes_list(self, attributes: list) -> None:
        """
        Sets the specified attributes list inside the table view. Attributes list is built that way:
        [(id, name, type), ...]

        :param attributes: attributes list
        :type attributes: list
        """
        self.datamodel = None
        self.attributes = {}
        self.tableview.clearSelection()
        data_list = []

        for id, name, type in attributes:
            data = (name, tr(type))
            self.attributes[data] = id
            data_list.append(data)

        self.datamodel = CustomTableModel(self.tableview, data_list,
                                          (tr("attr_col"), tr("attr_type")))
        self.tableview.selectionModel().selectionChanged.connect(
            self.on_selection_changed)

        self.repaint()
Ejemplo n.º 25
0
    def __init__(self, text, bg_color):
        """
        Teacher's position in the class. Two possibilities: teacher's view are student's view.

        :param text: Label's text
        :type text: str
        :param bg_color: background color (when activated)
        :type bg_color: QColor
        """
        QWidget.__init__(self)

        self.setFixedSize(QSize(200, 30))

        self.label = QLabel(text)
        self.label.setToolTip(tr("perspective_tootip"))
        self.label.setStyleSheet(
            f"border-radius: 5px; background: {bg_color}; color: white;")
        self.label.setAlignment(Qt.AlignCenter)
        self.label.setFixedSize(QSize(200, 30))

        layout = QHBoxLayout()
        layout.setMargin(0)
        layout.addWidget(self.label)
        self.setLayout(layout)
Ejemplo n.º 26
0
    def __init__(self):
        """
        Application main controller.
        """
        QObject.__init__(self)

        # Create the Views
        self.gui = ViewMainFrame(self.sig_quit, self.sig_config_mode_changed,
                                 self.sig_export_csv)
        self.v_canvas = self.gui.central_widget.classroom_tab.v_canvas

        # BDD connection
        bdd_path, bdd_exists = AssetManager.getInstance().bdd_path()
        if not bdd_exists:
            bp = QFileDialog.getExistingDirectory(self.gui, tr("select_db"))
            if bp == "" or not path.isdir(bp):
                self.mod_bdd = None
                return
            bdd_path = path.normpath(bp + "/sdc_db")
            if path.isfile(bdd_path):
                self.__bdd = sqlite3.connect(bdd_path)
            else:
                # we initialize a new BDD
                if not VConfirmDialog(self.gui, "confirm_db_creation").exec_():
                    self.mod_bdd = None
                    return
                self.__bdd = self.initialize_bdd(bdd_path)
            config = AssetManager.getInstance().get_config_parser()
            config.set('main', 'bdd_path', bdd_path)
            AssetManager.getInstance().save_config(config)
        else:
            self.__bdd = sqlite3.connect(bdd_path)
        self.mod_bdd = ModBdd(self.__bdd)
        self.gui.set_bdd_version(self.mod_bdd.get_version())

        # Create secondary controllers
        self.attr_ctrl = AttrController(self, self.__bdd)
        self.course_ctrl = CourseController(self, self.__bdd)
        self.group_ctrl = GroupController(self, self.__bdd)

        # Plugs the signals into the views
        self.v_canvas.sig_select_tile = self.sig_select_tile
        self.gui.central_widget.sig_shuffle = self.sig_shuffle
        self.gui.sig_quit = self.sig_quit
        self.v_canvas.sig_canvas_click = self.sig_canvas_click
        self.v_canvas.sig_desk_selected = self.sig_desk_selected
        self.v_canvas.sig_canvas_drag = self.sig_canvas_drag
        self.v_canvas.sig_tile_info = self.sig_canvas_right_click
        self.gui.sidewidget.courses(
        ).sig_course_changed = self.sig_course_changed
        self.gui.sidewidget.courses(
        ).courses_toolbar.add_widget.sig_new_element = self.sig_create_course
        self.gui.sidewidget.courses(
        ).sig_topic_changed = self.sig_topic_changed
        self.gui.sidewidget.students(
        ).students_toolbar.sig_combo_changed = self.sig_student_group_changed
        ViewMenuButton.sig_action = self.sig_action_triggered
        self.gui.maintoolbar.sig_TBbutton = self.sig_TBbutton
        self.gui.sidewidget.students(
        ).students_toolbar.create_field.sig_create = self.sig_create_grp_std
        self.gui.sidewidget.attributes(
        ).attributes_toolbar.add_widget.sig_new_element = self.sig_create_attribute
        self.gui.sidewidget.attributes(
        ).attributes_toolbar.add_widget.sig_delete = self.sig_delete_attributes
        self.gui.sidewidget.courses(
        ).courses_toolbar.sig_delete = self.sig_delete_course
        self.gui.sidewidget.attributes(
        ).sig_selection_changed = self.sig_attr_selection_changed
        self.gui.central_widget.attributes_tab.sig_cell_clicked = self.sig_attribute_cell_selected

        # Signals connection
        self.sig_select_tile.connect(
            self.attr_ctrl.on_attribute_selection_changed)
        self.sig_quit.connect(self.do_quit)
        self.sig_canvas_click.connect(self.course_ctrl.add_desk)
        self.sig_desk_selected.connect(
            self.course_ctrl.on_desk_selection_changed_on_app)
        self.sig_canvas_drag.connect(self.course_ctrl.move_desk)
        self.sig_canvas_right_click.connect(
            self.attr_ctrl.show_student_attributes)
        self.sig_shuffle.connect(self.course_ctrl.desk_shuffle)
        self.sig_course_changed.connect(self.course_ctrl.on_course_changed)
        self.sig_create_course.connect(self.course_ctrl.on_create_course)
        self.sig_topic_changed.connect(self.course_ctrl.on_topic_changed)
        self.sig_student_group_changed.connect(
            self.group_ctrl.on_student_group_changed)
        self.sig_action_triggered.connect(self.action_triggered)
        self.sig_TBbutton.connect(self.action_triggered)
        self.sig_create_grp_std.connect(self.group_ctrl.on_create_grp_std)
        self.sig_create_attribute.connect(self.attr_ctrl.on_create_attr)
        self.sig_delete_attributes.connect(self.attr_ctrl.on_delete_attributes)
        self.sig_delete_course.connect(self.course_ctrl.on_delete_course)
        self.sig_attr_selection_changed.connect(
            self.attr_ctrl.on_attribute_selection_changed)
        self.sig_attribute_cell_selected.connect(
            self.attr_ctrl.on_attribute_cell_selected)
        self.sig_flask_desk_selection_changed.connect(
            self.course_ctrl.on_desk_selection_changed_on_web)
        self.sig_close_qr.connect(self.close_qr)
        self.sig_config_mode_changed.connect(self.on_config_changed)
        self.sig_export_csv.connect(self.attr_ctrl.export_csv)

        self.actions_table = {  # Action buttons
            "import_csv": self.group_ctrl.import_pronote,
            "auto_place": self.group_ctrl.auto_place,
            "sort_asc": lambda: self.group_ctrl.sort_alpha(False),
            "sort_desc": lambda: self.group_ctrl.sort_alpha(True),
            "sort_desks_Z": lambda: self.course_ctrl.sort_desks(sort_type="Z"),
            "sort_desks_2": lambda: self.course_ctrl.sort_desks(sort_type="2"),
            "sort_desks_U": lambda: self.course_ctrl.sort_desks(sort_type="U"),
            "killstudent": self.group_ctrl.killstudent,
            "delete_group": self.group_ctrl.on_delete_group,

            # Toolbar buttons
            "filter_select": self.attr_ctrl.change_filter_selection,
            "select": self.course_ctrl.auto_select_desks,
            "choice": self.course_ctrl.student_random_pick,
            "choice_attr": self.course_ctrl.student_attr_pick,
            "delete": self.course_ctrl.delete,
            "lot_change": self.attr_ctrl.lot_change,
            "print": self.course_ctrl.export_pdf,
            "show_qr": self.show_qr
        }

        # properties
        self.id_course = 0
        self.id_group = 0
        self.selection_mode = self.SEL_ALL
        self.filter_selection = False
        self.std_dialog_info: VStdAttributesDialog = None
        self.qr_dialog: VQRCode = None

        # initialize the views
        self.course_ctrl.show_all_courses()
        self.group_ctrl.show_all_groups()
        self.attr_ctrl.show_all_attributes()
        self.gui.on_config_mode(False)
        self.gui.update()

        # initialize connection to flask server
        self.flask_client = socketio.Client()
        self.flask_client.connect(
            'http://localhost:' +
            AssetManager.getInstance().config('webapp', 'port'))
        self.flask_server = None

        # search for new version
        latest_version = AssetManager.getInstance().get_latest_version()
        if latest_version > AssetManager.getInstance().config(
                'main', 'version'):
            self.gui.status_bar.showMessage(tr("new_version") + latest_version)
Ejemplo n.º 27
0
    def __init__(self, available_colors: list):
        """
        Widget allowing the user to create between 2 and 6 colors for the Colors typed attributes

        :param available_colors: existing colors to initialize
        """
        QWidget.__init__(self)

        # Widgets
        self.__add_btn = QPushButton()
        self.__add_btn.setIcon(get_icon("add"))
        self.__add_btn.setIconSize(QSize(35, 35))
        self.__add_btn.setToolTip(tr("crs_create_btn_tooltip"))
        self.__add_btn.clicked.connect(self.__add_color)
        self.__add_btn.setStyleSheet("border: none;")

        self.__delete_btn = QPushButton()
        self.__delete_btn.setIcon(get_icon("del"))
        self.__delete_btn.setIconSize(QSize(35, 35))
        self.__delete_btn.setToolTip(tr("btn_suppr"))
        self.__delete_btn.clicked.connect(self.__remove_color)
        self.__delete_btn.setStyleSheet("border: none;")

        self.__btns = []

        for c in available_colors:  # Fill in existing colors
            self.__btns.append(ColorChooser(c, False))

        for i in range(AttrColorsChooser.MAX_COLORS -
                       len(available_colors)):  # Complete with 'empty' colors
            self.__btns.append(
                ColorChooser(AttrColorsChooser.DEFAULT_COLOR,
                             False))  # Use white as default color
            self.__btns[-1].setVisible(False)

        if len(available_colors) <= AttrColorsChooser.MIN_COLORS:
            self.__delete_btn.setEnabled(False)

            # Displays at least the minimum of buttons
            for i in range(AttrColorsChooser.MIN_COLORS):
                self.__btns[i].setVisible(True)

        elif len(available_colors) >= AttrColorsChooser.MAX_COLORS:
            self.__add_btn.setEnabled(False)

        # Layout
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.__delete_btn, 0, 0, 2, 1)
        r, c = 0, 1
        for b in self.__btns:
            layout.addWidget(b, r, c)

            c += 1
            if c == 4:
                r, c = 1, 1

        layout.addWidget(self.__add_btn, 0, 4, 2, 1)

        self.setLayout(layout)
Ejemplo n.º 28
0
    def __init__(self):
        QDialog.__init__(self)

        self.setWindowTitle(tr("btn_config"))
        self.setFixedSize(QSize(700, 670))

        # Retrieve current settings
        self.settings = AssetManager.getInstance().config_to_dico(
            AssetManager.getInstance().get_config_parser())
        self.__restart_needed = False
        self.__restore_required = False

        # Version
        self.lab_version = QLabel(self.settings['main']['version'])

        # Language
        self.combo_language = QComboBox()
        self.combo_language.addItems(list(self.languages.keys()))
        for lang in self.languages:  # Look for the current language to select it
            if self.languages[lang] == self.settings['main']['language']:
                self.combo_language.setCurrentText(lang)
                break

        # CSV separator
        self.csv_sep_edit = QLineEdit()
        self.csv_sep_edit.setMaxLength(2)
        self.csv_sep_edit.setFixedWidth(25)
        self.csv_sep_edit.setAlignment(Qt.AlignCenter)
        self.csv_sep_edit.setText(self.settings['main']['csv_separator'])

        # BDD path
        self.btn_bdd_path = QPushButton(self.settings['main']['bdd_path'])
        self.btn_bdd_path.clicked.connect(self.choose_bdd_path)

        # Port
        self.wepapp_port = QSpinBox()
        self.wepapp_port.setMinimum(1024)
        self.wepapp_port.setMaximum(65535)
        self.wepapp_port.setValue(int(self.settings['webapp']['port']))

        # Colors
        self.tile_color = ColorChooser(self.settings['colors']['tile'])
        self.hovered_tile_color = ColorChooser(
            self.settings['colors']['hovered_tile'])
        self.hovered_empty_tile_color = ColorChooser(
            self.settings['colors']['hovered_empty_tile'])
        self.dragged_tile_color = ColorChooser(
            self.settings['colors']['dragged_tile'])
        self.drag_selected_tile_color = ColorChooser(
            self.settings['colors']['drag_selected_tile'])
        self.selected_tile_color = ColorChooser(
            self.settings['colors']['selected_tile'])
        self.tile_text_color = ColorChooser(
            self.settings['colors']['tile_text'])
        self.room_bg_color = ColorChooser(self.settings['colors']['room_bg'])
        self.room_grid_color = ColorChooser(
            self.settings['colors']['room_grid'])
        self.main_bg_color = ColorChooser(self.settings['colors']['main_bg'])
        self.board_bg_color = ColorChooser(self.settings['colors']['board_bg'])

        self.attr_colors = ""  # Chosen colors
        self.attributes_colors_chooser = AttrColorsChooser(
            self.settings['colors']['attr_colors'].split())

        # Sizes (unmodifiable)
        self.unmodifiable = QLabel(tr("unmodifiable_data"))
        self.unmodifiable.setAlignment(Qt.AlignCenter)
        self.desk_size = QLineEdit(self.settings['size']['desk'])
        self.desk_size.setEnabled(False)
        self.desk_size.setFixedWidth(50)
        self.grid_rows = QLineEdit(self.settings['size']['default_room_rows'])
        self.grid_rows.setEnabled(False)
        self.grid_rows.setFixedWidth(50)
        self.grid_cols = QLineEdit(
            self.settings['size']['default_room_columns'])
        self.grid_cols.setEnabled(False)
        self.grid_cols.setFixedWidth(50)

        # --- Buttons ---

        # Confirm button
        self.ok_btn = QPushButton(tr("btn_save"))
        self.ok_btn.clicked.connect(self.accept)
        self.ok_btn.setFocus()

        # Cancel button
        self.cancel_btn = QPushButton(tr("btn_cancel"))
        self.cancel_btn.clicked.connect(self.reject)

        # Restore defaults button
        self.restore_btn = QPushButton(tr("btn_restore"))
        self.restore_btn.clicked.connect(self.__restore)

        self.__set_layout()
Ejemplo n.º 29
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.º 30
0
 def __set_layout(self):
     """
     Initializes the layout of this widget
     """
     self.addTab(self.classroom_tab, tr("tab_course_plan"))
     self.addTab(self.attributes_tab, tr("tab_attributes"))