Example #1
0
    def _setup_checkable_action(self,
                                name: str,
                                checked: bool,
                                target: object,
                                action_grp: QActionGroup = None):
        check_icon = IconRsc.get_icon('check_box_empty')
        check_icon.addPixmap(IconRsc.get_pixmap('check_box'), QIcon.Normal,
                             QIcon.On)

        if action_grp:
            action = QAction(check_icon, name, action_grp)
        else:
            action = QAction(check_icon, name, self)
        action.setCheckable(True)
        action.setChecked(checked)
        action.triggered.connect(target)
        self.addAction(action)

        return action
Example #2
0
    def __init__(self, wizard):
        """ Wizard Page to select FaKom Items

        :param modules.gui.wizard.wizard.PresetWizard wizard: The parent wizard
        """
        super(FakomWizardPage, self).__init__()
        self.wizard = wizard
        SetupWidget.from_ui_file(self, Resource.ui_paths['wizard_fakom'])

        self.setTitle(_('Preset Selection'))
        self.setSubTitle(_('Farbkombinationen auswählen aus denen Presets erstellt werden sollen.'))

        # -- Setup Page Ui --
        self.selection_icon.setPixmap(IconRsc.get_pixmap('fakom_trim'))
        self.selection_label.setText(_('Ausgewählte Presets'))

        # --- Tree Views ---
        self.fakom_tree = self._init_tree_view(self.fakom_tree)
        self.result_tree: QTreeWidget
        self.result_tree.itemPressed.connect(self._result_item_pressed)
Example #3
0
    def __init__(self, wizard, model: str, fakom: str):
        """ Page for one Preset with available PR-Options and Packages tree's

        :param modules.gui.wizard.wizard.PresetWizard wizard: The parent wizard
        :param str model: model code
        :param str fakom: fakom code
        """
        super(PresetWizardPage, self).__init__()
        self.wizard = wizard
        self.model = model
        self.fakom = fakom

        trim = [
            x for x in wizard.session.data.import_data.models
            if x.model == model
        ][0]
        self.model_text = trim.model_text

        SetupWidget.from_ui_file(self, Resource.ui_paths['wizard_preset'])

        # -- Title --
        self.page_num = 1 + len(self.wizard.session.data.preset_page_ids)

        # -- Sub Title Update Timer --
        self.update_title_timer = QTimer()
        self.update_title_timer.setInterval(25)
        self.update_title_timer.setSingleShot(True)
        self.update_title_timer.timeout.connect(self.update_page_title)

        # -- Trigger filter update for all views ---
        self.update_filter_timer = QTimer()
        self.update_filter_timer.setInterval(5)
        self.update_filter_timer.setSingleShot(True)
        self.update_filter_timer.timeout.connect(self.update_filter_all_views)

        self.line_edit_preset: QLineEdit
        self.line_edit_preset.textChanged.connect(
            self.update_filter_timer.start)

        # -- Setup Page Ui --
        self.option_auto_btn: QPushButton
        self.option_auto_btn.setText(_('Preset auto&magisch befüllen'))
        self.option_auto_btn.setIcon(IconRsc.get_icon('qub_button'))
        self.option_auto_btn.setStatusTip(
            _('Aktuelles Preset automagisch mit nicht verwendeten Optionen befüllen. '
              'Bezugs-, Sitz-, Leder oder Fahrwerksoptionen werden ignoriert.')
        )
        self.option_auto_btn.released.connect(self.fill_automagically)

        self.option_hide_btn: QPushButton
        eye_icon = IconRsc.get_icon('eye')
        eye_icon.addPixmap(IconRsc.get_pixmap('eye-disabled'), QIcon.Normal,
                           QIcon.On)
        self.option_hide_btn.setIcon(eye_icon)
        self.option_hide_btn.setStatusTip(
            _('Bereits verwendete Optionen ein- oder ausblenden'))
        self.option_hide_btn.toggled.connect(self.update_available_options)

        self.option_lock_btn: QPushButton
        lock_icon = IconRsc.get_icon('lock_open')
        lock_icon.addPixmap(IconRsc.get_pixmap('lock'), QIcon.Normal, QIcon.On)
        self.option_lock_btn.setIcon(lock_icon)
        self.option_lock_btn.setStatusTip(
            _('Bereits verwendete Optionen für die Bearbeitung sperren'))
        self.option_lock_btn.toggled.connect(self.update_available_options)

        self.option_tree_btn: QPushButton
        opt_icon = QIcon(IconRsc.get_pixmap('options'))
        opt_icon.addPixmap(IconRsc.get_pixmap('options-neg'), QIcon.Normal,
                           QIcon.On)
        self.option_tree_btn.setIcon(opt_icon)
        self.option_tree_btn.setStatusTip(
            _('Spalte Beschreibung ein- oder ausblenden'))
        self.option_tree_btn.toggled.connect(self.update_view_headers)

        # -- Replace Placeholder TreeViews --
        self.pkg_tree = self._init_tree_view(
            self.pkg_tree, self.wizard.session.pkg_models.get(model))
        self.pkg_tree.permanent_type_filter_column = Kg.VALUE
        self.pkg_tree.context = OptionTreeContextMenu(self.pkg_tree, self)
        self.option_tree = self._init_tree_view(
            self.option_tree, self.wizard.session.opt_models.get(model))
        self.option_tree.permanent_type_filter_column = Kg.NAME
        self.option_tree.context = OptionTreeContextMenu(
            self.option_tree, self)

        # -- Setup Preset Tree --
        self.preset_tree = self._init_tree_view(self.preset_tree,
                                                KnechtModel())
        self.preset_tree.supports_drop = True
        self.preset_tree.supports_drag_move = True
        self.preset_tree.is_wizard_preset_view = True
        self.preset_tree.context = PresetTreeContextMenu(
            self.preset_tree, self.wizard)
        self.preset_tree.shortcut_override = PresetTreeViewShortcutOverrides(
            self.preset_tree)
        self.preset_tree.view_refreshed.connect(self.update_available_options)

        # Initial Tree sort
        QTimer.singleShot(50, self.update_view_headers)
Example #4
0
    def __init__(self, ui):
        """ Dialog to import Datapool items

        :param modules.gui.main_ui.KnechtWindow ui: Main Window
        """
        super(DatapoolDialog, self).__init__(ui)
        SetupWidget.from_ui_file(self, Resource.ui_paths['knecht_datapool'])
        self.setWindowTitle('Datapool Import')

        self._asked_for_close = False
        self._current_project_name = ''
        self.ui = ui

        # Avoid db/thread polling within timeout
        self.action_timeout = QTimer()
        self.action_timeout.setSingleShot(True)
        self.action_timeout.setInterval(300)

        # --- Translations n Style ---
        self.project_icon: QLabel
        self.project_icon.setPixmap(IconRsc.get_pixmap('storage'))
        self.project_title: QLabel
        self.project_title.setText(_('Datapool Projekte'))
        self.image_icon: QLabel
        self.image_icon.setPixmap(IconRsc.get_pixmap('img'))
        self.image_title: QLabel
        self.image_title.setText(_('Bildeinträge'))
        self.details_btn: QPushButton
        self.details_btn.setText(_('Detailspalten anzeigen'))
        self.details_btn.toggled.connect(self.toggle_view_columns)
        self.filter_box: QLineEdit
        self.filter_box.setPlaceholderText(
            _('Im Baum tippen um zu filtern...'))

        # -- Trigger filter update for all views ---
        self.update_filter_timer = QTimer()
        self.update_filter_timer.setInterval(5)
        self.update_filter_timer.setSingleShot(True)
        self.update_filter_timer.timeout.connect(self.update_filter_all_views)

        self.filter_box: QLineEdit
        self.filter_box.textChanged.connect(self.update_filter_timer.start)

        # --- Init Tree Views ---
        self.project_view = KnechtTreeViewCheckable(
            self,
            None,
            filter_widget=self.filter_box,
            replace=self.project_view)
        self.image_view = KnechtTreeViewCheckable(
            self, None, filter_widget=self.filter_box, replace=self.image_view)

        # --- Database Connector ---
        self.dp = DatapoolController(self)
        self.dp.add_projects.connect(self.update_project_view)
        self.dp.add_images.connect(self.update_image_view)
        self.dp.error.connect(self.error)

        # Connection timeout
        self.connection_timeout = QTimer()
        self.connection_timeout.setInterval(self.timeout)
        self.connection_timeout.setSingleShot(True)
        self.connection_timeout.timeout.connect(self.connection_timed_out)

        # Make sure to end thread on App close
        self.ui.is_about_to_quit.connect(self.close)

        # Intercept mouse press events from project view
        self.org_view_mouse_press_event = self.project_view.mousePressEvent
        self.project_view.mousePressEvent = self.view_mouse_press_event

        # Start thread
        QTimer.singleShot(100, self.start_datapool_connection)