Esempio n. 1
0
    def _build(self):
        '''Build and layout widget.'''
        self.setMinimumHeight(400)
        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        layout = QtWidgets.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.setLayout(layout)

        self._webView = QtWebCompat.QWebView()
        layout.addWidget(self._webView)
    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)