Exemple #1
0
    def button_rect(self):
        r = self.tabBar().tabRect(self.count() - 1)

        if dcc.is_maya() and dcc.get_version() > 2015:
            rect = QRect(2, 0, 30, 31)
        else:
            rect = QRect(6, 3, 26, 17)
        if r.isValid():
            if dcc.is_maya() and dcc.get_version() > 2015:
                rect.moveBottomLeft(r.bottomRight() + QPoint(1, 1))
            else:
                rect.moveBottomLeft(r.bottomRight() + QPoint(3, -1))
        return rect
Exemple #2
0
    def __init__(self, parent=None):
        super(TreeWidget, self).__init__(parent)

        self._auto_add_sub_items = True
        self._title_text_index = 0
        self._text_edit = True
        self._edit_state = None
        self._current_name = None
        self._old_name = None
        self._current_item = None
        self._last_item = None
        self._drop_indicator_rect = QRect()
        self._drop_indicator_position = None
        self._name_filter = None

        self.setIndentation(25)
        self.setExpandsOnDoubleClick(False)
        self.setSortingEnabled(True)
        self.sortByColumn(0, Qt.AscendingOrder)

        if dcc.is_maya():
            self.setAlternatingRowColors(dcc.get_version() < 2016)
        if not dcc.is_maya() and not not dcc.is_nuke():
            palette = QPalette()
            palette.setColor(palette.Highlight, Qt.gray)
            self.setPalette(palette)

        self.itemActivated.connect(self._on_item_activated)
        self.itemChanged.connect(self._on_item_changed)
        self.itemSelectionChanged.connect(self._on_item_selection_changed)
        self.itemClicked.connect(self._on_item_clicked)
        self.itemExpanded.connect(self._on_item_expanded)
        self.itemCollapsed.connect(self._on_item_collapsed)
Exemple #3
0
def delete_workspace_control(control_name, reset_floating=True):
    """
    Handles the deletion of a workspace control with a specific name
    :param control_name: str
    :param reset_floating: bool
    :return: bool
    """

    if not dcc.get_version() > 2017:
        return None

    if maya.cmds.workspaceControl(control_name, query=True, exists=True):
        floating = maya.cmds.workspaceControl(control_name,
                                              query=True,
                                              floating=True)
        maya.cmds.deleteUI(control_name)
    else:
        floating = None

    # If the window is not currently floating, we remove stored preferences
    if maya.cmds.workspaceControlState(
            control_name, query=True,
            exists=True) and not (floating or floating and reset_floating):
        maya.cmds.workspaceControlState(control_name, remove=True)

    return floating
Exemple #4
0
    def data_to_save(self):
        """
        Returns data to save
        Can be override to store custom data
        :return: dict
        """

        encoding = locale.getpreferredencoding()
        user = getpass.getuser()
        if user:
            user = user.decode(encoding)

        ctime = str(time.time()).split('.')[0]
        references = get_reference_data(self.objects())

        self.set_metadata('user', user)
        self.set_metadata('ctime', ctime)
        self.set_metadata('references', references)
        self.set_metadata('mayaVersion', str(dcc.get_version())),
        self.set_metadata('mayaSceneFile', dcc.scene_name())

        metadata = {'metadata': self.metadata()}
        data = self.dump(metadata)[:-1] + ','

        objects = {'objects': self.objects()}
        data += self.dump(objects)[1:]

        return data
Exemple #5
0
 def _on_set_color(self, color_index):
     if dcc.get_version() <= 2016:
         self.color_dialog.setCurrentColor(
             QColor.fromRgb(self.maya_colors[color_index][0] * 255,
                            self.maya_colors[color_index][1] * 255,
                            self.maya_colors[color_index][2] * 255))
     else:
         super(MayaColorDialog, self)._on_set_color()
    def metadata_dict(cls):

        # references = utils.get_reference_data(self.metadata().get('objects', list()))

        return {
            # 'references': references,
            'references': list(),
            'mayaVersion': str(dcc.get_version())
        }
Exemple #7
0
    def set_inset_dark(self):
        value = self.background_shade
        value -= 15
        if dcc.is_maya():
            if dcc.get_version() < 2016:
                self.setFrameStyle(self.Panel | self.Sunken)

        palette = self.palette()
        palette.setColor(self.backgroundRole(), QColor(value, value, value))
        self.setAutoFillBackground(True)
        self.setPalette(palette)
    def _set_metadata(self):
        """
        Internal function that sets the metadata of the data transfer object
        Called before saving the data
        """

        super(MayaDataTransferObject, self)._set_metadata()

        references = reference.get_reference_data(list(self.objects().keys()))

        self.set_metadata('references', references)
        self.set_metadata('maya_version', dcc.get_version())
        self.set_metadata('maya_scene_file', dcc.scene_name())
Exemple #9
0
    def unique_id(self):
        """
        Returns the unique identifier of the wrapped native DCC object in current DCC scene
        :return: int or str
        """

        if dcc.get_version() >= 2016:
            node_name = node_utils.get_name(self._dcc_native_object,
                                            fullname=True)
            return maya.cmds.ls(node_name, uuid=True)[0]
        else:
            property_value = self._dcc_native_attribute('uuid', default=None)
            if property_value is None:
                return self._native_handle.hashCode()
Exemple #10
0
def is_window_floating(window_name):
    """
    Returns whether or not given window is floating
    :param window_name: str
    :return: bool
    """

    if dcc.get_version() < 2017:
        floating = maya.cmds.dockControl(window_name,
                                         floating=True,
                                         query=True)
    else:
        floating = maya.cmds.workspaceControl(window_name,
                                              floating=True,
                                              query=True)

    return floating
Exemple #11
0
    def _setup_logo_button_actions(self, logo_button):
        """
        Internal function that setup window dragger button logo actions
        """

        if not logo_button:
            return

        self._toggle_frameless = logo_button.addAction(
            'Toggle Frameless Mode',
            connect=self._on_toggle_frameless_mode,
            checkable=True)
        self._toggle_frameless.setChecked(self._window.is_frameless())

        if dcc.is_maya() and dcc.get_version() >= 2022:
            self._toggle_frameless.setText(
                'Toggle Frameless Mode (not available)')
            self._toggle_frameless.setEnabled(False)
Exemple #12
0
    def __init__(self, name, parent=None):
        super(OptionGroup, self).__init__(parent)

        if dcc.is_maya():
            if dcc.get_version() < 2016:
                # self.setFrameStyle(self.Panel | self.Raised)
                palette = self.palette()
                palette.setColor(self.backgroundRole(), QColor(80, 80, 80))
                self.setAutoFillBackground(True)
                self.setPalette(palette)
            # else:
            #     self.setFrameStyle(self.NoFrame)

        if dcc.is_maya():
            self._rollout_style = GroupStyles.Maya
        else:
            self._rollout_style = GroupStyles.Square

        self._expanded = True
        self._clicked = False
        self._collapsible = True

        self.close_height = 28
        self.setMinimumHeight(self.close_height)
        self.background_shade = 80

        self.main_layout = layouts.VerticalLayout()
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)
        self.setLayout(self.main_layout)

        self.child_layout = layouts.VerticalLayout()
        self.child_layout.setContentsMargins(0, 2, 0, 3)
        self.child_layout.setSpacing(0)
        self.child_layout.setAlignment(Qt.AlignTop)

        self.header_layout = layouts.HorizontalLayout()

        self.main_layout.addSpacing(4)
        self.main_layout.addLayout(self.child_layout)

        self.setObjectName(name)
        self.setTitle(name)
Exemple #13
0
    def stylesheet_file(self):
        """
        Returns path where theme stylesheet is located
        :return: str
        """

        style_name = self._style or 'default'
        dcc_name = dcc.get_name()
        dcc_version = dcc.get_version()
        dcc_style = '{}_{}{}'.format(style_name, dcc_name, dcc_version)
        all_styles = [dcc_style, style_name]

        style_extension = style.StyleSheet.EXTENSION
        if not style_extension.startswith('.'):
            style_extension = '.{}'.format(style_extension)

        for style_name in all_styles:
            style_file_name = '{}{}'.format(style_name, style_extension)
            style_path = resources.get('styles', style_file_name)
            if style_path and os.path.isfile(style_path):
                return style_path

        return style_path
Exemple #14
0
    def ui(self):
        if dcc.get_version() <= 2016:
            self.main_layout = self.get_main_layout()
            self.setLayout(self.main_layout)

            self.color_dialog = QColorDialog(parent=self)
            self.color_dialog.setWindowFlags(Qt.Widget)
            self.color_dialog.setOptions(QColorDialog.DontUseNativeDialog
                                         | QColorDialog.NoButtons)
            self.main_layout.addWidget(self.color_dialog)

            bottom_layout = layouts.HorizontalLayout()
            bottom_layout.setAlignment(Qt.AlignRight)
            self.main_layout.addLayout(bottom_layout)

            self.ok_btn = QPushButton('Ok')
            self.cancel_btn = QPushButton('Cancel')
            bottom_layout.addLayout(dividers.DividerLayout())
            bottom_layout.addWidget(self.ok_btn)
            bottom_layout.addWidget(self.cancel_btn)

        else:
            super(MayaColorDialog, self).ui()
Exemple #15
0
 def _on_ok_btn(self):
     if dcc.get_version() <= 2016:
         self.close()
     else:
         super(MayaColorDialog, self)._on_ok_btn()
Exemple #16
0
 def setup_signals(self):
     if dcc.get_version() <= 2016:
         pass
     else:
         super(MayaColorDialog, self).setup_signals()