def setupUI(self):
        css_task_global = """
        QLabel { padding: 0px; background: none; }
        /*QTabWidget::pane { border-top: 2px solid #151515; top: -2px;}
        QTabBar::tab { padding: 6px 10px; background: #151515;
                       border-top: 2px solid #151515;
                       border-right: 2px solid #151515;
                       border-left: 2px solid #151515;
                       border-radius: 0px; }
        QTabBar::tab:selected { background: #333;
                                border-top-left-radius: 4px;
                                border-top-right-radius: 4px; }
        QTabBar::tab:hover { background: #222; }
        QTabBar::tab:!selected { margin-top: 2px; }*/
        """
        css_task_name_lbl = "font-size: 13px;"
        css_task_name = "color: #c3cfa4; font-size: 13px; font-weight: bold;"

        self.setStyleSheet(css_task_global)

        task_frame_layout = QtWidgets.QVBoxLayout(self)
        task_frame_layout.setContentsMargins(0, 0, 0, 0)
        task_frame_layout.setSpacing(15)

        # Display Task infos

        task_info_layout = QtWidgets.QFormLayout()
        task_info_layout.setContentsMargins(10, 10, 10, 10)
        task_info_layout.setSpacing(10)

        task_name_lbl = QtWidgets.QLabel("Task", self)
        task_name_lbl.setStyleSheet(css_task_name_lbl)
        self._task_name = QtWidgets.QLabel(self._t_name, self)
        self._task_name.setStyleSheet(css_task_name)

        project_lbl = QtWidgets.QLabel("Project", self)
        self._project_name = QtWidgets.QLabel(self._t_project_name, self)

        shot_lbl = QtWidgets.QLabel("Shot", self)
        shot_layout = QtWidgets.QHBoxLayout()
        shot_layout.setSpacing(6)
        self._shot_name = QtWidgets.QLabel(self)
        self._separator_shot = QtWidgets.QLabel("/", self)
        self._separator_shot.setVisible(False)
        self._sequence_name = QtWidgets.QLabel(self)
        spacer_shot = QtWidgets.QSpacerItem(0, 0,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        shot_layout.addWidget(self._sequence_name)
        shot_layout.addWidget(self._separator_shot)
        shot_layout.addWidget(self._shot_name)
        shot_layout.addItem(spacer_shot)

        shot_status_lbl = QtWidgets.QLabel("Shot status", self)
        shot_status = ftrack.getShotStatuses()
        self._shot_status = StatusWidget(shot_status, self)

        task_status_lbl = QtWidgets.QLabel("Task status", self)
        task_status = ftrack.getTaskStatuses()
        self._task_status = StatusWidget(task_status, self)

        due_date_lbl = QtWidgets.QLabel("Due date", self)
        self._due_date = QtWidgets.QLabel(self)

        task_info_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole,
                                   task_name_lbl)
        task_info_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole,
                                   self._task_name)
        task_info_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole,
                                   project_lbl)
        task_info_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole,
                                   self._project_name)
        task_info_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole,
                                   shot_lbl)
        task_info_layout.setItem(2, QtWidgets.QFormLayout.FieldRole,
                                 shot_layout)
        task_info_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole,
                                   shot_status_lbl)
        task_info_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole,
                                   self._shot_status)
        task_info_layout.setWidget(4, QtWidgets.QFormLayout.LabelRole,
                                   task_status_lbl)
        task_info_layout.setWidget(4, QtWidgets.QFormLayout.FieldRole,
                                   self._task_status)
        task_info_layout.setWidget(5, QtWidgets.QFormLayout.LabelRole,
                                   due_date_lbl)
        task_info_layout.setWidget(5, QtWidgets.QFormLayout.FieldRole,
                                   self._due_date)
        task_frame_layout.addItem(task_info_layout)

        self._tab_widget = QtWidgets.QTabWidget(self)

        # Display Nuke Assets from this task

        self.tab_asset_tree = QtWidgets.QWidget()

        self.tab_asset_tree.busy_overlay = LoadingOverlay(self.tab_asset_tree)
        self.tab_asset_tree.busy_overlay.hide()

        tab_asset_tree_layout = QtWidgets.QVBoxLayout(self.tab_asset_tree)
        tab_asset_tree_layout.setContentsMargins(0, 8, 0, 0)
        self.assets_widget = SceneAssetsWidget(self)

        self.assets_widget.worker_started.connect(
            self.tab_asset_tree.busy_overlay.show)
        self.assets_widget.worker_started.connect(
            self.tab_asset_tree.busy_overlay.raise_)

        self.assets_widget.worker_stopped.connect(
            self.tab_asset_tree.busy_overlay.hide)
        tab_asset_tree_layout.addWidget(self.assets_widget)
        self._tab_widget.addTab(self.tab_asset_tree, "All Scene Assets")

        task_frame_layout.addWidget(self._tab_widget)
예제 #2
0
    def __init__(self, parent=None):
        '''Initialise widget with *parent*.'''
        super(NukeCrew, self).__init__(parent=parent)

        ftrack_connect.ui.theme.applyTheme(self, 'integration')

        self.setMinimumWidth(400)
        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        self.vertical_layout = QtWidgets.QVBoxLayout(self)
        self.horizontal_layout = QtWidgets.QHBoxLayout()

        self.header = Header(username=getpass.getuser(), parent=self)

        self.vertical_layout.addWidget(self.header)

        self.notification_list = _notification_list.Notification(self)

        self._hub = ftrack_connect_nuke.crew_hub.crew_hub

        self._classifier = UserClassifier()
        self._classifier.update_context(self._read_context_from_environment())

        current_user = ftrack.getUser(getpass.getuser())
        groups = ['Assigned', 'Contributors', 'Supervisors']
        self.chat = _crew.Crew(groups,
                               current_user,
                               hub=self._hub,
                               classifier=self._classifier,
                               parent=self)

        self.chat.chat.busyOverlay.setStyleSheet(NUKE_OVERLAY_STYLE)

        added_user_ids = []
        for _user in session.query('select id, username, first_name, last_name'
                                   ' from User where is_active is True'):
            if _user['id'] != current_user.getId():
                self.chat.addUser(
                    u'{0} {1}'.format(_user['first_name'], _user['last_name']),
                    _user['id'])

                added_user_ids.append(_user['id'])

        self.tab_panel = QtWidgets.QTabWidget(parent=self)
        self.tab_panel.addTab(self.chat, 'Chat')
        self.tab_panel.addTab(self.notification_list, 'Notifications')

        self.horizontal_layout.addWidget(self.tab_panel)

        # TODO: This styling should probably be done in a global stylesheet
        # for the entire Nuke plugin.
        self.notification_list.overlay.setStyleSheet(NUKE_OVERLAY_STYLE)

        self.vertical_layout.setContentsMargins(0, 0, 0, 0)
        self.vertical_layout.addLayout(self.horizontal_layout)

        self.setObjectName('Crew')
        self.setWindowTitle('Crew')

        # Import inline to avoid mysterious segfault in nuke 9.1dev build.
        from ftrack_connect.connector.panelcom import (PanelComInstance as
                                                       _PanelComInstance)

        panel_communication_singleton = _PanelComInstance.instance()
        panel_communication_singleton.addRefreshListener(self.on_refresh_event)

        self.on_refresh_event()

        if not self._hub.compatibleServerVersion:
            logging.info('Incompatible server version.')

            self.blockingOverlay = ftrack_connect.ui.widget.overlay.BlockingOverlay(
                self, message='Incompatible server version.')
            self.blockingOverlay.setStyleSheet(NUKE_OVERLAY_STYLE)
            self.blockingOverlay.show()
        else:
            self._hub.populateUnreadConversations(current_user.getId(),
                                                  added_user_ids)