Ejemplo n.º 1
0
    def mousePressEvent(self, event):
        """
        Overrides base QListView mousePressEvent function
        :param event: QMouseEvent
        """

        item = self.item_at(event.pos())
        if not item:
            self.clearSelection()

        mixinview.ViewerViewWidgetMixin.mousePressEvent(self, event)
        if event.isAccepted():
            QListView.mousePressEvent(self, event)
            if item:
                # NOTE: This causes viewer tree widget selectionChanged signal to be emitted multiple times.
                # NOTE: This causes that item preview widgets are created twice when selecting an item in the viewer.
                # NOTE: For this reason, we block tree widgets signals before selecting the item
                with qt_contexts.block_signals(self.tree_widget()):
                    item.setSelected(True)

        self.endDrag()
        self._drag_start_pos = event.pos()

        is_left_button = self.mouse_press_button() == Qt.LeftButton
        is_item_draggable = item and item.drag_enabled()
        is_selection_empty = not self.selected_items()

        if is_left_button and (is_selection_empty or not is_item_draggable):
            self.rubber_band_start_event(event)
Ejemplo n.º 2
0
 def _on_houdini_slider_value_changed(self, value):
     in_value = mathlib.map_range_unclamped(
         self._input.value(), self._input.minimum(), self._input.maximum(),
         self._slider.minimum(), self._slider.maximum())
     with qt_contexts.block_signals(self._slider):
         self._slider.setValue(int(in_value))
     self.valueChanged.emit(value)
    def _on_global_tolerance_changed(self, tolerance_value):
        """
        Internal callback function that is called when global tolerance value is updated in the model
        :param tolerance_value: float, global tolerance value used to check symmetry of the geometry
        """

        with qt_contexts.block_signals(self._model):
            self._global_tolerance_spn.setValue(tolerance_value)
    def _on_use_pivot_as_origin_changed(self, flag):
        """
        Internal callback function that is called when use pivot as origin flag changes in the model
        :param flag: bool
        """

        with qt_contexts.block_signals(self._model):
            self._use_pivot_as_origin_cbx.setChecked(flag)
    def _on_revert_bias_changed(self, value):
        """
        Internal callback function that is called when revert bias value changes in the model
        :param value: float, value that sets how much the revert to base geo should be applied to selected vertices
        """

        with qt_contexts.block_signals(self._model):
            self._revert_bias_slider.set_value(value)
    def _on_live_revert_bias_changed(self, flag):
        """
        Internal callback function that is called when live revert bias flag changes in the model
        :param flag: bool, Whether or not revert bias should be applied while its value changes
        """

        with qt_contexts.block_signals(self._model):
            self._live_revert_bias_cbx.setChecked(flag)
Ejemplo n.º 7
0
    def _on_script_text_changed(self, text):
        """
        Internal callback function that is called when script text changes
        :param text: str
        """

        with qt_contexts.block_signals(self._model):
            self._controller.set_current_text(text)
Ejemplo n.º 8
0
    def _on_joints_display_size_changed(self, value):
        live = self._model.joints_display_size_live

        with qt_contexts.block_signals(self._joints_display_size_spn):
            self._joints_display_size_spn.setValue(value)

        if live:
            self._controller.joint_display_size()
    def _on_operate_positive_to_negative_x_axis_changed(self, flag):
        """
        Internal callback function that is called when operate positive ot negate x axis flag changes in the model
        :param flag: bool
        """

        with qt_contexts.block_signals(self._model):
            self._neg_to_pos_cbx.setChecked(flag)
Ejemplo n.º 10
0
    def set_expanded(self, flag):
        """
        Expands the options if True, otherwise collapses the options
        :param flag: bool
        """

        with qt_contexts.block_signals(self._title_widget):
            self._title_widget.setChecked(flag)
            self._fields_frame.setVisible(flag)
Ejemplo n.º 11
0
    def _on_output_text_changed(self, output_text):
        """
        Internal callback function that is called when output text is updated in the model
        :param output_text: str
        """

        with qt_contexts.block_signals(self._model):
            self._output_console.setText(output_text)
            self._output_console.move_cursor_to_line_end()
Ejemplo n.º 12
0
    def _on_selection_changed(self, text):
        """
        Internal callback function that is called when user selects new script text
        :param text: str
        """

        with qt_contexts.block_signals(self._model):
            self._controller.set_selected_text(text)
        self._execute_selected_action.setEnabled(
            bool(self._model.selected_text))
Ejemplo n.º 13
0
    def _on_current_text_changed(self, script_text):
        """
        Internal callback function that is called when current script text is updated by the model
        :param script_text: str
        """

        script_widget = self._scripts_tab.currentWidget()
        if not script_widget:
            return

        with qt_contexts.block_signals(self._model):
            script_widget.editor.setPlainText(script_text)
Ejemplo n.º 14
0
    def set_items_selected(self, items, value):
        """
        Sets the selected state for the given items
        :param items: list(LibraryItem)
        :param value: bool
        """

        with qt_contexts.block_signals(self.tree_widget()):
            try:
                for item in items:
                    item.setSelected(value)
            except Exception:
                LOGGER.error(str(traceback.format_exc()))
Ejemplo n.º 15
0
    def set_value(self, value):
        """
        Overrides FileWidget set_value function
        Sets the value of the widget
        :param value: str
        """

        pos = self.widget().cursorPosition()

        with qt_contexts.block_signals(self.widget()):
            self.widget().setText(value)

        self.widget().setCursorPosition(pos)

        super(StringFieldWidget, self).set_value(value)
Ejemplo n.º 16
0
    def set_value(self, value):
        """
        Overrides FileWidget set_value function
        Sets the path of the image in disk
        :param value: str
        """

        self._value = value

        with qt_contexts.block_signals(self):
            for button in list(self._buttons.values()):
                button.setChecked(False)
            if value in self._buttons:
                self._buttons[value].setChecked(True)

        super(ButtonGroupFieldWidget, self).set_value(value)
Ejemplo n.º 17
0
    def _on_current_tab_changed(self, index):
        """
        Internal callback function that is called when current user selects a new script tab
        :param index: int
        """

        script_widget = self._scripts_tab.widget(index)
        if not script_widget:
            return

        script_path = script_widget.file_path

        all_text = self._scripts_tab.get_current_text()
        with qt_contexts.block_signals(self._model):
            self._controller.set_current_script(script_path)
            self._controller.set_current_text(
                all_text.strip() if all_text else '')
Ejemplo n.º 18
0
    def set_data(self, data, root='', split=None):
        """
        Sets the items to the given items
        :param data: list(str)
        :param root: str
        :param split: str
        """

        self._data = data
        settings = self.settings()
        with qt_contexts.block_signals(self):
            self.clear()
            if not root:
                root = self.find_root(list(data.keys()), self.separator())
            self.add_paths(data, root=root, split=split)
            self.set_settings(settings)

        self.parent().search()
Ejemplo n.º 19
0
    def _on_script_saved(self, script_path):
        """
        Internal callback function that is called when a script is saved
        :param script_path: str
        """

        script_widget = self._scripts_tab.currentWidget()
        if not script_widget:
            return

        with qt_contexts.block_signals(self._model):
            script_path = path_utils.clean_path(script_path)
            current_file_path = path_utils.clean_path(script_widget.file_path)
            if script_path != current_file_path:
                script_widget.file_path = script_path
            self._scripts_tab.set_current_tab_name(
                os.path.basename(script_widget.file_path))
            self._controller.set_current_script(script_widget.file_path)
            self._controller.set_current_text(
                self._scripts_tab.get_current_text())
            self._controller.set_selected_text(
                self._scripts_tab.get_current_selected_text())
Ejemplo n.º 20
0
    def update_items(self):
        """
        Sets the items to the viewer
        """

        selected_items = self.selected_items()

        with qt_contexts.block_signals(self.tree_widget()):

            try:
                self.clear_selection()
                if self.library():
                    results = self.library().grouped_results()
                    item_views = list()
                    for group in results:
                        if group != 'None':
                            group_item = self.create_group_item(group)
                            item_views.append(group_item)
                        for item in results[group]:
                            view_class = self.library_window(
                            ).factory.get_view(item)
                            if not view_class:
                                continue
                            item_view = view_class(
                                item, library_window=self.library_window())
                            item_views.append(item_view)

                    if item_views:
                        self.tree_widget().set_items(item_views)
                        if selected_items:
                            self.select_items(selected_items)
                            self.scroll_to_selected_item()
                    else:
                        self.clear()
                else:
                    self.clear()
            finally:
                self.itemSelectionChanged.emit()
Ejemplo n.º 21
0
 def _set_directory(self, directory):
     with qt_contexts.block_signals(self):
         self.set_directory(directory)
Ejemplo n.º 22
0
    def set_data(self, data):
        """
        Sets the current state of the field widget using a dictionary
        :param data: dict
        """

        state = data

        with qt_contexts.block_signals(self):
            items = state.get('items', None)
            if items is not None:
                self.set_items(items)

            value = state.get('value', None)
            default = state.get('default', None)

            if default is not None:
                self.set_default(default)
            elif value is not None:
                self.set_default(value)

            if value is not None or (value and value != self.value()):
                try:
                    self.set_value(value)
                except TypeError:
                    LOGGER.exception(str(traceback.format_exc()))

            enabled = state.get('enabled', None)
            if enabled is not None:
                self.setEnabled(enabled)
                self._label.setEnabled(enabled)
            hidden = state.get('hidden', None)
            if hidden is not None:
                self.setHidden(hidden)
            required = state.get('required', None)
            if required is not None:
                self.set_required(required)
            error = state.get('error', None)
            if error is not None:
                self.set_error(error)
            error_visible = data.get('errorVisible')
            if error_visible is not None:
                self.set_error_visible(error_visible)
            tooltip = state.get('toolTip', None)
            if tooltip is not None:
                self.setToolTip(tooltip)
                self.setStatusTip(tooltip)
            style = state.get('style', None)
            if style is not None:
                self.setStyleSheet(style)
            title = self.title() or ''
            self.set_text(title)
            lbl = state.get('label')
            if lbl is not None:
                text = lbl.get('name', None)
                if text is not None:
                    self.set_text(text)
                visible = lbl.get('visible', None)
                if visible is not None:
                    self.label().setVisible(visible)

            # Menu items
            actions = state.get('actions', None)
            if actions is not None:
                self._menu_button.setVisible(True)
            menu = state.get('menu', None)
            if menu is not None:
                text = menu.get('name')
                if text is not None:
                    self._menu_button.setText(text)
                visible = menu.get('visible', True)
                self._menu_button.setVisible(visible)
            self._data.update(data)
            self.refresh()
Ejemplo n.º 23
0
 def _set_value(self, value):
     with qt_contexts.block_signals(self, children=True):
         self.setValue(value)
Ejemplo n.º 24
0
 def _set_checked(self, flag):
     with qt_contexts.block_signals(self):
         self.setChecked(flag)
Ejemplo n.º 25
0
 def _set_value(self, value):
     with qt_contexts.block_signals(self):
         self.set_value(value)
Ejemplo n.º 26
0
 def _on_slider_value_changed(self, value):
     out_value = mathlib.map_range_unclamped(
         value, self._slider.minimum(), self._slider.maximum(), self._input.minimum(), self._input.maximum())
     with qt_contexts.block_signals(self._input):
         self._input.setValue(out_value)
     self.valueChanged.emit(out_value)