Пример #1
0
class Ui_Main(QtGui.QMainWindow, ui_main.Ui_MainWindow):
    def __init__(self, parent=None):
        super(self.__class__, self).__init__(parent=parent)
        self.ui_settings_dict = {}
        self.created = False

        self.create_debuglog_widget()

        if env_mode.is_offline():
            self.create_ui_main_offline()
        else:
            self.create_ui_main()

    def create_project_dock(self, project_code, close_project=True, raise_tab=False):
        if project_code not in self.projects_docks.keys():
            project = env_inst.projects.get(project_code)
            if project:
                if not project.is_template():
                    dock_widget = QtGui.QDockWidget(self)
                    dock_widget.setObjectName(project_code)
                    dock_widget.setWindowTitle(project.info.get('title'))
                    dock_widget.setMinimumWidth(200)
                    dock_widget.setFeatures(
                        QtGui.QDockWidget.DockWidgetMovable | QtGui.QDockWidget.DockWidgetClosable)

                    main_tabs_widget = Ui_mainTabs(project_code, dock_widget)
                    dock_widget.setWidget(main_tabs_widget)

                    self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock_widget)
                    for dock in self.projects_docks.values():
                        self.tabifyDockWidget(dock, dock_widget)

                    self.projects_docks[project_code] = dock_widget

                    dock_widget.show()
                    dock_widget.raise_()
            else:
                print('No project with code: {0}'.format(project_code))

        elif close_project:
            self.projects_docks[project_code].widget().close()
            self.projects_docks[project_code].close()
            self.projects_docks[project_code].deleteLater()
            del self.projects_docks[project_code]
            env_inst.cleanup(project_code)

        if raise_tab:
            project_dock = self.projects_docks.get(project_code)
            if project_dock:
                project_dock.show()
                project_dock.raise_()

    def create_ui_main_offline(self):
        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.setupUi(self)
        self.setWindowTitle('TACTIC handler (OFFLINE)')

        # instance attributes
        self.menu = None
        self.menu_bar_actions()
        self.menuProject.setEnabled(False)
        self.readSettings()
        self.setIcon()

        self.customize_ui()

    def create_ui_main(self):
        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.setupUi(self)
        self.setWindowTitle('TACTIC Handler')
        self.customize_ui()

        # instance attributes
        self.menu = None
        self.mainwidget.deleteLater()
        self.query_projects()
        self.menu_bar_actions()
        self.menuProject.setEnabled(True)
        self.readSettings()
        self.setIcon()
        self.create_script_editor_widget()
        # self.create_messages_widget()

        self.created = True

    @staticmethod
    def execute_after_all_ui_started():
        # This func is executed after all ui started. File execute_after_start can contain any useful code that
        # should be executed after ui loaded

        from execute_after_start import execute

        execute()

        env_api.start_api_server_app()

    def create_debuglog_widget(self):
        env_inst.ui_debuglog = Ui_debugLogWidget(self)
        env_inst.ui_debuglog.setWindowState(QtCore.Qt.WindowMinimized)

        env_inst.ui_debuglog.show()
        env_inst.ui_debuglog.hide()
        env_inst.ui_debuglog.setWindowState(QtCore.Qt.WindowNoState)

    def create_script_editor_widget(self):
        env_inst.ui_script_editor = Ui_ScriptEditForm(self)

    def create_messages_widget(self):
        env_inst.ui_messages = Ui_messagesWidget(self)

    def create_info_label(self):
        self.label_layout = QtGui.QVBoxLayout(self.menubar)
        self.label_layout.setContentsMargins(0, 0, 6, 0)

        self.info_label = QtGui.QLabel()
        self.info_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.info_label.setText('')
        self.label_layout.addWidget(self.info_label)

    def set_status_text(self, text=''):
        self.setStatusTip(text)

    def set_info_status_text(self, status_text=''):
        self.info_label.setText(status_text)

    def check_for_update(self):
        if uf.check_need_update():
            self.info_label.setText('<span style=" font-size:8pt; color:#ff0000;">Need update</span>')

    def setIcon(self):
        icon = Qt4Gui.QIcon(':/ui_main/gliph/tactic_favicon.ico')
        self.setWindowIcon(icon)

    def customize_ui(self):
        if env_mode.get_mode() == 'standalone':
            self.actionDock_undock.setVisible(False)

        self.actionExit.setIcon(gf.get_icon('window-close', icons_set='mdi'))
        self.actionConfiguration.setIcon(gf.get_icon('settings', icons_set='mdi'))
        self.actionSave_Preferences.setIcon(gf.get_icon('content-save', icons_set='mdi'))
        self.actionReloadCache.setIcon(gf.get_icon('reload', icons_set='mdi'))
        self.actionApply_to_all_Tabs.setIcon(gf.get_icon('hexagon-multiple', icons_set='mdi'))
        self.actionScriptEditor.setIcon(gf.get_icon('script', icons_set='mdi'))
        self.actionDebug_Log.setIcon(gf.get_icon('bug', icons_set='mdi'))
        self.actionUpdate.setIcon(gf.get_icon('update', icons_set='mdi'))
        self.create_info_label()

    def menu_bar_actions(self):
        """
        Actions for the main menu bar
        """

        def close_routine():
            if env_mode.get_mode() == 'maya':

                self.close()

                from thlib.ui_classes.ui_maya_dock import close_all_instances
                close_all_instances()

                # Removing path from sys, so we can run other instance from different path
                import sys
                sys.path.remove(env_mode.get_current_path())

            if env_mode.get_mode() == 'standalone':

                self.close()

        self.actionExit.triggered.connect(close_routine)

        self.actionConfiguration.triggered.connect(self.open_config_dialog)

        self.actionApply_to_all_Tabs.triggered.connect(self.apply_current_view)
        self.actionReloadCache.triggered.connect(self.reload_cache)

        self.actionUpdate.triggered.connect(self.update_self)
        self.actionScriptEditor.triggered.connect(self.open_script_editor)
        self.actionDebug_Log.triggered.connect(lambda: env_inst.ui_debuglog.show())

        # User Menu items
        self.actionMessages.triggered.connect(lambda: env_inst.ui_messages.show())
        self.actionEdit_My_Account.triggered.connect(self.edit_my_account)

        self.actionDock_undock.triggered.connect(self.undock_window)

    def undock_window(self):
        env_inst.ui_maya_dock.toggle_docking()

    def edit_my_account(self):

        print 'Edit my Account'
        from thlib.ui_classes.ui_addsobject_classes import Ui_addTacticSobjectWidget

        login_stype = env_inst.get_stype_by_code('sthpw/login')
        # parent_stype = self.parent_sobject.get_stype()
        # search_key = self.parent_sobject.get_search_key()

        # print search_key

        add_sobject = Ui_addTacticSobjectWidget(
            stype=login_stype,
            parent_stype=None,
            # search_key=search_key,
            parent_search_key=None,
            # view='edit',
            parent=self,
        )

        add_sobject.show()

    # def create_ui_float_notify(self):
    #     self.float_notify = ui_float_notify_classes.Ui_floatNotifyWidget(self)
    #     self.float_notify.show()
    #     self.float_notify.setSizeGripEnabled(True)

    def open_script_editor(self):
        env_inst.ui_script_editor.show()

    def update_self(self):
        if env_mode.is_online():
            self.update_dialog = Ui_updateDialog(self)

            self.update_dialog.show()

    def reload_cache(self):
        tc.get_all_projects_and_logins(True)
        for project in env_inst.projects.values():
            project.query_search_types(True)

        if env_mode.get_mode() == 'maya':
            self.restart_ui_main()
        else:
            self.close()
            gf.restart_app()

    def open_config_dialog(self):
        conf_dialog = ui_conf_classes.Ui_configuration_dialogWidget(parent=self)
        conf_dialog.show()

    def restart_for_update_ui_main(self):

        if env_mode.get_mode() == 'maya':
            # import main_maya
            # thread = main_maya.main.restart()
            from thlib.ui_classes.ui_maya_dock import close_all_instances
            close_all_instances()
            # self.restart_ui_main()
        else:
            self.close()
            gf.restart_app()

        # if env_mode.get_mode() == 'standalone':
        #     import main_standalone
        #     thread = main_standalone.restart()
        #     thread.finished.connect(self.close)
        # if env_mode.get_mode() == 'maya':
        #     import main_maya
        #     thread = main_maya.main.restart()
        #     thread.finished.connect(main_maya.main.close_all_instances)

    def restart_ui_main(self, server_preset=None):
        if server_preset:
            new_server_preset = env_server.get_cur_srv_preset()
            env_server.set_cur_srv_preset(server_preset)

        # Closing main app itself
        self.close()

        # Closing server api
        env_api.close_server()

        if server_preset:
            env_server.set_cur_srv_preset(new_server_preset)

        if env_mode.is_online():
            self.create_ui_main()
        else:
            self.create_ui_main_offline()

        self.show()
        return self

    def apply_current_view(self):
        # TODO may be need to be rewriten to use env instance
        if env_inst.get_current_project():
            current_project_widget = self.projects_docks[env_inst.get_current_project()].widget()

            current_project_widget.ui_checkin_checkout.apply_current_view_to_all()

            # widget_name = current_project_widget.main_tabWidget.currentWidget().objectName()

            # if widget_name == 'checkInOutTab':
            #     current_project_widget.ui_checkin_checkout.apply_current_view_to_all()
            #
            # if widget_name == 'checkOutTab':
            #     current_project_widget.ui_checkout.apply_current_view_to_all()
            #
            # if widget_name == 'checkInTab':
            #     current_project_widget.ui_checkin.apply_current_view_to_all()

    def fill_projects_to_menu(self):

        all_projects_dicts = []

        for project_name, project in env_inst.projects.items():
            if project.get_code() != 'sthpw':
                all_projects_dicts.append(project.info)

        projects_by_categories = gf.group_dict_by(all_projects_dicts, 'category')

        for cat_name, projects in projects_by_categories.items():
            if cat_name:
                cat_name = gf.prettify_text(cat_name, True)
            else:
                cat_name = 'No Category'
            if cat_name != 'Template':
                category = self.menuProject.addMenu(cat_name)

            for e, project in enumerate(projects):
                if not project.get('is_template'):
                    project_code = project.get('code')

                    menu_action = QtGui.QAction(self)
                    menu_action.setCheckable(True)

                    if self.opened_projects:
                        if project_code in self.opened_projects:
                            menu_action.setChecked(True)
                    menu_action.setText(project.get('title'))
                    # Don't know why lambda did not work here
                    menu_action.triggered.connect(partial(self.create_project_dock, project_code))
                    category.addAction(menu_action)

    def restore_opened_projects(self):
        if self.ui_settings_dict:
            self.opened_projects = self.ui_settings_dict.get('opened_projects')
        else:
            self.opened_projects = None
        if not isinstance(self.opened_projects, list):
            if self.opened_projects:
                self.opened_projects = [self.opened_projects]

        if self.opened_projects:
            for project in self.opened_projects:
                if project:
                    self.create_project_dock(project)

            current_project_code = self.ui_settings_dict.get('current_active_project')

            if current_project_code:
                if self.projects_docks.get(current_project_code):
                    self.projects_docks[current_project_code].show()
                    self.projects_docks[current_project_code].raise_()

    def get_settings_dict(self):

        settings_dict = {}

        if self.windowState() == QtCore.Qt.WindowMaximized:
            state = True
            if self.ui_settings_dict:
                settings_dict['pos'] = self.ui_settings_dict['pos']
                settings_dict['size'] = self.ui_settings_dict['size']
            else:
                settings_dict['pos'] = self.pos().toTuple()
                settings_dict['size'] = self.size().toTuple()
        else:
            state = False
            settings_dict['pos'] = self.pos().toTuple()
            settings_dict['size'] = self.size().toTuple()
        settings_dict['windowState'] = state

        if self.projects_docks.keys():
            settings_dict['opened_projects'] = self.projects_docks.keys()
            if env_inst.get_current_project():
                settings_dict['current_active_project'] = str(env_inst.get_current_project())
        else:
            settings_dict['opened_projects'] = ''
            settings_dict['current_active_project'] = ''

        return settings_dict

    def set_settings_from_dict(self, settings_dict=None):

        if not settings_dict:
            settings_dict = {
                'pos': self.pos().toTuple(),
                'size': self.size().toTuple(),
                'windowState': False,
                'opened_projects': '',
                'current_active_project': '',
            }

        self.move(settings_dict['pos'][0], settings_dict['pos'][1])
        self.resize(settings_dict['size'][0], settings_dict['size'][1])

        if settings_dict['windowState']:
            self.setWindowState(QtCore.Qt.WindowMaximized)

    def readSettings(self):
        self.ui_settings_dict = env_read_config(filename='ui_settings', unique_id='ui_main', long_abs_path=True)
        self.set_settings_from_dict(self.ui_settings_dict)

    def writeSettings(self):
        env_write_config(self.get_settings_dict(), filename='ui_settings', unique_id='ui_main', long_abs_path=True)

    def closeEvent(self, event):

        # Closing server api
        env_api.close_server(self)

        for dock in self.projects_docks.values():
            # project_code = dock.widget().project.get_code()
            dock.widget().close()
            dock.close()
            dock.deleteLater()
            del dock
            # env_inst.cleanup(project_code)

        self.writeSettings()

        event.accept()

    def query_projects_finished(self, result=None):
        if result:
            self.restore_opened_projects()
            self.fill_projects_to_menu()
            env_inst.ui_main.set_info_status_text('')

            self.execute_after_all_ui_started()

    def query_projects(self):
        env_inst.ui_main.set_info_status_text(
            '<span style=" font-size:8pt; color:#00ff00;">Getting projects</span>')

        def get_all_projects_and_logins_agent():
            return tc.get_all_projects_and_logins()

        env_inst.set_thread_pool(None, 'server_query/server_thread_pool')

        projects_items_worker = gf.get_thread_worker(
            get_all_projects_and_logins_agent,
            env_inst.get_thread_pool('server_query/server_thread_pool'),
            result_func=self.query_projects_finished,
            error_func=gf.error_handle
        )
        projects_items_worker.start()
Пример #2
0
class Ui_Main(QtGui.QMainWindow):
    def __init__(self, parent=None):
        super(self.__class__, self).__init__(parent=parent)
        self.ui_settings_dict = {}
        self.created = False
        self.app_closing = True

        self.create_ui_raw()

        if env_mode.is_offline():
            self.create_ui_main_offline()
        else:
            self.create_ui_main()

    def create_ui_raw(self):
        self.setObjectName("MainWindow")
        self.setWindowModality(QtCore.Qt.ApplicationModal)
        self.resize(820, 800)
        self.setMinimumSize(QtCore.QSize(600, 600))
        self.setStyleSheet(
            """
            QSplitter::handle {
                border: 0px;
                background: transparent;
                margin: 0px 0px 0px 0px;
            }
    
            QSplitter::handle:horizontal {
                width: 4px;
            }
    
            QSplitter::handle:vertical {
                height: 4px;
            }
    
            QSplitter::handle:pressed {
                border: 0px;
                background: rgb(128,128,128);
            }
            QSplitter::handle:hover {
                border: 0px;
                background: rgb(128,128,128);
            }
            QMainWindow::separator
            {
                width: 4px;
                border: 0px;
                background: transparent;
            }
            QMainWindow::separator:hover {
                border: 0px;
                background: rgb(128,128,128);
            }
            """
            "QTabWidget::pane {\n"
            "    border: 0px;\n"
            "}\n"
            "QTabBar::tab {\n"
            "    background: transparent;\n"
            "    border: 2px solid transparent;\n"
            "    border-top-right-radius: 0px;\n"
            "    border-top-left-radius: 0px;\n"
            "    border-bottom-right-radius: 3px;\n"
            "    border-bottom-left-radius: 3px;\n"
            "    padding: 4px;\n"
            "}\n"
            "QTabBar::tab:selected, QTabBar::tab:hover {\n"
            "    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255, 255, 255, 32), stop: 1 rgba(255, 255, 255, 48));\n"
            "}\n"
            "QTabBar::tab:selected {\n"
            "    border-color: transparent;\n"
            "}\n"
            "QTabBar::tab:!selected {\n"
            "    margin-top: 0px;\n"
            "}\n"
            "QDockWidget::title{\n"
            "    padding: 6px;\n"
            "    font-size: 10pt;\n"
            "    border: 1px;\n"
            "    border-radius: 0px;\n"
            "    padding-left: 10px;\n"
            "    background-color: rgb(72, 72, 72);\n"
            "}\n"
            "QDockWidget::close-button, QDockWidget::float-button {\n"
            "    padding: 0px;\n"
            "    color: rgb(0,0,128);\n"
            "    border: none;\n"
            "}\n"
            "\n"
            "QDockWidget {\n"
            "    border: 0px ;\n"
            "    border-radius: 0px;\n"
            "    font-size: 10pt;\n"
            "}\n"
            "QGroupBox {\n"
            "    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(175, 175, 175, 16), stop: 1 rgba(0, 0, 0, 0));\n"
            "    border: 0px;\n"
            "    border-radius: 4px;\n"
            "    padding: 0px 8px;\n"
            "}\n"
            "\n"
            "QGroupBox::title {\n"
            "    subcontrol-origin: margin;\n"
            "    subcontrol-position: left top; \n"
            "    padding: 2 6px;\n"
            "    background-color: transparent;\n"
            "    border-bottom: 2px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(128, 128, 128, 64), stop:1 rgba(128, 128,128, 0));\n"
            "}\n"
            "")
        self.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.setWindowFilePath("")
        self.mainwidget = QtGui.QWidget(self)
        self.mainwidget.setObjectName("mainwidget")
        self.setCentralWidget(self.mainwidget)
        self.statusBar().close()

    def create_central_widget(self):

        self.central_widget = QtGui.QWidget()

        self.main_layout = QtGui.QVBoxLayout()
        self.main_layout.setSpacing(0)
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.central_widget.setLayout(self.main_layout)

        self.setCentralWidget(self.central_widget)

    def create_top_bar(self):

        self.top_bar_widget = Ui_topBarWidget()

        self.main_layout.addWidget(self.top_bar_widget)
        self.main_layout.setStretch(0, 0)

        self.top_bar_widget.projects_chooser_button.clicked.connect(self.show_projects_cooser)

    def get_top_bar_widget(self):
        return self.top_bar_widget

    def create_projects_chooser(self):

        self.projects_chooser_widget_bg = QtGui.QFrame(self)
        self.projects_chooser_widget_bg.setStyleSheet("QFrame { border: 0px; background-color: black;}")
        self.projects_chooser_widget_bg.setHidden(True)
        effect = QtGui.QGraphicsDropShadowEffect(self)
        effect.setOffset(0, 0)
        effect.setColor(Qt4Gui.QColor(0, 0, 0, 128))
        effect.setBlurRadius(64)
        self.projects_chooser_widget_bg.setGraphicsEffect(effect)

        self.projects_chooser_widget = Ui_projectsChooserWidget(self)
        self.projects_chooser_widget.set_bg_widget(self.projects_chooser_widget_bg)

        self.projects_chooser_widget.setMinimumWidth(800)
        self.projects_chooser_widget.setMaximumWidth(800)
        self.projects_chooser_widget.setMinimumHeight(400)
        self.projects_chooser_widget.setMaximumHeight(1600)

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.projects_chooser_widget.setSizePolicy(sizePolicy)

        grid_layout = QtGui.QGridLayout()
        grid_layout.setContentsMargins(0, 0, 0, 0)

        grid_layout.addWidget(self.projects_chooser_widget, 1, 1, 1, 1)

        spacerItem = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Minimum)
        grid_layout.addItem(spacerItem, 1, 0, 1, 1)
        spacerItem1 = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Minimum)
        grid_layout.addItem(spacerItem1, 1, 2, 1, 1)
        spacerItem2 = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored)
        grid_layout.addItem(spacerItem2, 0, 0, 1, 3)
        spacerItem3 = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored)
        grid_layout.addItem(spacerItem3, 2, 0, 1, 3)

        self.main_layout.addLayout(grid_layout)

    def show_projects_cooser(self):

        if self.projects_chooser_widget.isVisible():
            self.projects_chooser_widget.setHidden(True)

            current_project = env_inst.get_current_project()
            if current_project:
                current_project_dock = self.projects_docks.get(current_project)
                current_project_dock.setHidden(False)
            else:
                self.projects_chooser_widget.setHidden(False)
        else:
            for opened_project in self.projects_docks.values():
                opened_project.setHidden(True)

            self.projects_chooser_widget.setHidden(False)

    def create_project_dock(self, project_code, dummy=None):

        if project_code not in list(self.projects_docks.keys()):

            for opened_project in self.projects_docks.values():
                opened_project.setHidden(True)

            project = env_inst.projects.get(project_code)

            if project:
                if not project.is_template():
                    main_tabs_widget = Ui_mainTabs(project_code, self)
                    self.projects_docks[project_code] = main_tabs_widget

                    self.projects_chooser_widget.setHidden(True)
                    self.main_layout.addWidget(main_tabs_widget, 1)

                    self.top_bar_widget.set_current_project(project)
            else:
                print('No project with code: {0}'.format(project_code))
        else:
            for opened_project in self.projects_docks.values():
                opened_project.setHidden(True)

            project = env_inst.projects.get(project_code)

            if project:
                project_dock = self.projects_docks.get(project_code)
                project_dock.setHidden(False)
                self.projects_chooser_widget.setHidden(True)

                self.top_bar_widget.set_current_project(project)

    def create_ui_main_offline(self):
        self.setWindowTitle('TACTIC-handler (OFFLINE)')

        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.create_debuglog_widget()

        # instance attributes
        self.menu = None

        self.create_central_widget()
        self.create_top_bar()
        self.create_projects_chooser()

        self.menu_bar_actions()

        self.readSettings()
        self.setIcon()

        self.created = True

    def create_ui_main(self):

        env_inst.start_pools()

        self.setWindowTitle('TACTIC-Handler')

        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.create_debuglog_widget()

        # instance attributes
        self.menu = None

        self.create_central_widget()
        self.create_top_bar()
        self.create_projects_chooser()

        self.query_projects()

        self.menu_bar_actions()

        self.readSettings()

        # if env_mode.get_mode() == 'standalone':
        #     self.create_tray()

        self.setIcon()

        self.create_script_editor_widget()
        # self.create_messages_widget()

        self.created = True

    @staticmethod
    def execute_after_all_ui_started():
        # This func is executed after all ui started. File execute_after_start can contain any useful code that
        # should be executed after ui loaded

        from execute_after_start import execute

        execute()

        # env_api.start_api_server_app()

    def create_debuglog_widget(self):
        env_inst.ui_debuglog = Ui_debugLogWidget(self)
        env_inst.ui_debuglog.setWindowState(QtCore.Qt.WindowMinimized)

        env_inst.ui_debuglog.show()
        env_inst.ui_debuglog.hide()
        env_inst.ui_debuglog.setWindowState(QtCore.Qt.WindowNoState)

    def create_script_editor_widget(self):
        env_inst.ui_script_editor = Ui_ScriptEditForm(self)

    def create_messages_widget(self):
        env_inst.ui_messages = Ui_messagesWidget(self)

    def set_info_status_text(self, status_text=''):
        self.top_bar_widget.set_info_status_text(status_text)

    # def check_for_update(self):
    #     if uf.check_need_update():
    #         self.info_label.setText('<span style=" font-size:8pt; color:#ff0000;">Need update</span>')

    def create_tray(self):
        self.tray_icon = QtGui.QSystemTrayIcon(self)
        self.tray_icon.activated.connect(self.tray_activated)

        icon = Qt4Gui.QIcon(':/ui_main/gliph/tactic_favicon.ico')
        self.tray_icon.setIcon(icon)

        self.tray_menu = QtGui.QMenu(self)

        self.show_main_window = QtGui.QAction('Show Main Window', self, triggered=self.show)
        self.tray_menu.addAction(self.show_main_window)
        self.tray_menu.addSeparator()

        self.close_app_action = QtGui.QAction('Exit', self, triggered=self.close_app)
        self.tray_menu.addAction(self.close_app_action)

        self.tray_icon.setContextMenu(self.tray_menu)

        self.tray_icon.show()

    def setIcon(self):
        icon = Qt4Gui.QIcon(':/ui_main/gliph/tactic_favicon.ico')
        self.setWindowIcon(icon)

    def tray_activated(self, reason):

        if reason in [QtGui.QSystemTrayIcon.DoubleClick, QtGui.QSystemTrayIcon.Trigger]:
            self.show()

    def close_app(self):
        self.close()
        self.deleteLater()

    # def customize_ui(self):
    #     if env_mode.get_mode() == 'standalone':
    #         self.actionDock_undock.setVisible(False)
    #
    #     self.actionExit.setIcon(gf.get_icon('window-close', icons_set='mdi'))
    #     self.actionConfiguration.setIcon(gf.get_icon('settings', icons_set='mdi'))
    #     self.actionSave_Preferences.setIcon(gf.get_icon('content-save', icons_set='mdi'))
    #     self.actionReloadCache.setIcon(gf.get_icon('reload', icons_set='mdi'))
    #     self.actionApply_to_all_Tabs.setIcon(gf.get_icon('hexagon-multiple', icons_set='mdi'))
    #     self.actionScriptEditor.setIcon(gf.get_icon('script', icons_set='mdi'))
    #     self.actionDebug_Log.setIcon(gf.get_icon('bug', icons_set='mdi'))
    #     self.actionUpdate.setIcon(gf.get_icon('update', icons_set='mdi'))
    #
    #     self.statusBar().close()

    def menu_bar_actions(self):
        """
        Actions for the main menu bar
        """

        def close_routine():

            self.app_closing = True

            if env_mode.get_mode() == 'maya':

                self.close()

                from thlib.ui_classes.ui_maya_dock import close_all_instances
                close_all_instances()

                # Removing path from sys, so we can run other instance from different path
                import sys
                sys.path.remove(env_mode.get_current_path())

            if env_mode.get_mode() == 'standalone':

                self.close()

        self.top_bar_widget.actionExit.triggered.connect(close_routine)

        self.top_bar_widget.actionConfiguration.triggered.connect(self.open_config_dialog)

        self.top_bar_widget.actionApply_to_all_Tabs.triggered.connect(self.apply_current_view)
        self.top_bar_widget.actionReloadCache.triggered.connect(self.reload_cache)

        self.top_bar_widget.actionUpdate.triggered.connect(self.update_self)
        self.top_bar_widget.actionScriptEditor.triggered.connect(self.open_script_editor)
        self.top_bar_widget.actionDebug_Log.triggered.connect(lambda: env_inst.ui_debuglog.show())

        # User Menu items
        # self.top_bar_widget.actionMessages.triggered.connect(lambda: env_inst.ui_messages.show())
        # self.top_bar_widget.actionEdit_My_Account.triggered.connect(self.edit_my_account)

        self.top_bar_widget.actionDock_undock.triggered.connect(self.undock_window)

    def undock_window(self):
        env_inst.ui_maya_dock.toggle_docking()

    def edit_my_account(self):

        print('Edit my Account')
        from thlib.ui_classes.ui_addsobject_classes import Ui_addTacticSobjectWidget

        login_stype = env_inst.get_stype_by_code('sthpw/login')
        # parent_stype = self.parent_sobject.get_stype()
        # search_key = self.parent_sobject.get_search_key()

        # print search_key

        add_sobject = Ui_addTacticSobjectWidget(
            stype=login_stype,
            parent_stype=None,
            # search_key=search_key,
            parent_search_key=None,
            # view='edit',
            parent=self,
        )

        add_sobject.show()

    # def create_ui_float_notify(self):
    #     self.float_notify = ui_float_notify_classes.Ui_floatNotifyWidget(self)
    #     self.float_notify.show()
    #     self.float_notify.setSizeGripEnabled(True)

    def open_script_editor(self):
        env_inst.ui_script_editor.show()

    def update_self(self):
        if env_mode.is_online():
            self.update_dialog = Ui_updateDialog(self)

            self.update_dialog.show()

    def reload_cache(self):
        tc.get_all_projects_and_logins(True)
        for project in env_inst.projects.values():
            project.query_search_types(True)

        if env_mode.get_mode() == 'maya':
            self.restart_ui_main()
        else:
            self.close()
            gf.restart_app()

    def open_config_dialog(self):
        conf_dialog = ui_conf_classes.Ui_configuration_dialogWidget(parent=self)
        conf_dialog.show()

    def restart_for_update_ui_main(self):

        if env_mode.get_mode() == 'maya':
            # import main_maya
            # thread = main_maya.main.restart()
            from thlib.ui_classes.ui_maya_dock import close_all_instances
            close_all_instances()
            # self.restart_ui_main()
        else:
            self.close()
            gf.restart_app()

        # if env_mode.get_mode() == 'standalone':
        #     import main_standalone
        #     thread = main_standalone.restart()
        #     thread.finished.connect(self.close)
        # if env_mode.get_mode() == 'maya':
        #     import main_maya
        #     thread = main_maya.main.restart()
        #     thread.finished.connect(main_maya.main.close_all_instances)

    def restart_ui_main(self, server_preset=None):
        if server_preset:
            new_server_preset = env_server.get_cur_srv_preset()
            env_server.set_cur_srv_preset(server_preset)

        # Closing main app itself
        self.close()

        # Closing server api
        # env_api.close_server()

        if server_preset:
            env_server.set_cur_srv_preset(new_server_preset)

        if env_mode.is_online():
            self.create_ui_main()
        else:
            self.create_ui_main_offline()

        self.show()
        return self

    def apply_current_view(self):

        if env_inst.get_current_project():
            current_project_widget = self.projects_docks[env_inst.get_current_project()]

            current_project_widget.ui_checkin_checkout.apply_current_view_to_all()

    def fill_projects_to_projects_chooser(self):
        self.projects_chooser_widget.initial_fill()

    def restore_opened_projects(self):
        if self.ui_settings_dict:
            self.opened_projects = self.ui_settings_dict.get('opened_projects')
        else:
            self.opened_projects = None
        if not isinstance(self.opened_projects, list):
            if self.opened_projects:
                self.opened_projects = [self.opened_projects]

        if self.opened_projects:

            current_project_code = self.ui_settings_dict.get('current_active_project')
            self.create_project_dock(current_project_code)

            if current_project_code:
                if self.projects_docks.get(current_project_code):
                    self.projects_docks[current_project_code].show()
                    self.projects_docks[current_project_code].raise_()

    def create_repo_sync_queue_ui(self):
        env_inst.ui_repo_sync_queue = Ui_repoSyncQueueWidget(parent=self)

    def get_settings_dict(self):

        settings_dict = {}

        if self.windowState() == QtCore.Qt.WindowMaximized:
            state = True
            if self.ui_settings_dict:
                settings_dict['pos'] = self.ui_settings_dict['pos']
                settings_dict['size'] = self.ui_settings_dict['size']
            else:
                settings_dict['pos'] = self.pos().toTuple()
                settings_dict['size'] = self.size().toTuple()
        else:
            state = False
            settings_dict['pos'] = self.pos().toTuple()
            settings_dict['size'] = self.size().toTuple()
        settings_dict['windowState'] = state

        if list(self.projects_docks.keys()):
            settings_dict['opened_projects'] = list(self.projects_docks.keys())
            if env_inst.get_current_project():
                settings_dict['current_active_project'] = str(env_inst.get_current_project())
        else:
            settings_dict['opened_projects'] = ''
            settings_dict['current_active_project'] = ''

        return settings_dict

    def set_settings_from_dict(self, settings_dict=None):

        ref_settings_dict = {
            'pos': self.pos().toTuple(),
            'size': self.size().toTuple(),
            'windowState': False,
            'opened_projects': '',
            'current_active_project': '',
        }

        settings = gf.check_config(ref_settings_dict, settings_dict)

        self.move(settings['pos'][0], settings['pos'][1])
        self.resize(settings['size'][0], settings['size'][1])

        if settings['windowState']:
            self.setWindowState(QtCore.Qt.WindowMaximized)

    def readSettings(self):
        self.ui_settings_dict = env_read_config(filename='ui_settings', unique_id='ui_main', long_abs_path=True)
        self.set_settings_from_dict(self.ui_settings_dict)

    def writeSettings(self):
        env_write_config(self.get_settings_dict(), filename='ui_settings', unique_id='ui_main', long_abs_path=True)

    def closeEvent(self, event):

        if self.app_closing:

            for dock in self.projects_docks.values():
                dock.close()
                dock.deleteLater()
                del dock
                # env_inst.cleanup(project_code)

            self.writeSettings()

            # Closing server api
            # env_api.close_server(self)

            # Waiting for all threads finished
            env_inst.exit_pools()

            event.accept()
        else:
            event.ignore()
            self.hide()
            self.tray_icon.showMessage('Tactic Handler Is in tray',
                                       'File > Exit to quit.',
                                       QtGui.QSystemTrayIcon.Information, 500)

    def query_projects_finished(self, result=None):

        if result:
            self.create_repo_sync_queue_ui()

            self.restore_opened_projects()
            self.fill_projects_to_projects_chooser()
            env_inst.ui_main.set_info_status_text('')

            self.execute_after_all_ui_started()

    def query_projects(self):
        env_inst.ui_main.set_info_status_text(
            '<span style=" font-size:8pt; color:#00ff00;">Getting projects</span>')

        worker = env_inst.server_pool.add_task(tc.get_all_projects_and_logins)
        worker.result.connect(self.query_projects_finished)
        worker.error.connect(gf.error_handle)
        worker.start()
Пример #3
0
class Ui_Main(QtGui.QMainWindow, ui_main.Ui_MainWindow):
    def __init__(self, parent=None):
        super(self.__class__, self).__init__(parent=parent)
        self.ui_settings_dict = {}
        self.created = False

        self.create_debuglog_widget()

        if env_mode.is_offline():
            self.create_ui_main_offline()
        else:
            self.create_ui_main()

    def create_project_dock(self,
                            project_code,
                            close_project=True,
                            raise_tab=False):
        if project_code not in self.projects_docks.keys():
            project = env_inst.projects.get(project_code)
            if project:
                if not project.is_template():
                    dock_widget = QtGui.QDockWidget(self)
                    dock_widget.setObjectName(project_code)
                    # print project.info['title'].replace('_', ' ').capitalize()
                    dock_widget.setWindowTitle(project.info.get('title'))
                    dock_widget.setMinimumWidth(200)
                    dock_widget.setFeatures(
                        QtGui.QDockWidget.DockWidgetMovable
                        | QtGui.QDockWidget.DockWidgetClosable)

                    main_tabs_widget = Ui_mainTabs(project_code, dock_widget)
                    dock_widget.setWidget(main_tabs_widget)

                    self.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                                       dock_widget)
                    for dock in self.projects_docks.values():
                        self.tabifyDockWidget(dock, dock_widget)

                    self.projects_docks[project_code] = dock_widget

                    dock_widget.setStyleSheet(
                        '#complex_testing_phase_four > QTabBar::tab {background: transparent;border: 2px solid transparent;'
                        'border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;padding: 4px;}'
                        '#complex_testing_phase_four > QTabBar::tab:selected, #complex_testing_phase_four > QTabBar::tab:hover {'
                        'background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255, 255, 255, 48), stop: 1 rgba(255, 255, 255, 32));}'
                        '#complex_testing_phase_four > QTabBar::tab:selected {border-color: transparent;}'
                        '#complex_testing_phase_four > QTabBar::tab:!selected {margin-top: 0px;}'
                    )

                    dock_widget.show()
                    dock_widget.raise_()
            else:
                print('No project with code: {0}'.format(project_code))

        elif close_project:
            self.projects_docks[project_code].widget().close()
            self.projects_docks[project_code].close()
            self.projects_docks[project_code].deleteLater()
            del self.projects_docks[project_code]
            env_inst.cleanup(project_code)

        if raise_tab:
            project_dock = self.projects_docks.get(project_code)
            if project_dock:
                project_dock.show()
                project_dock.raise_()

    def create_ui_main_offline(self):
        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.setupUi(self)
        self.setWindowTitle('TACTIC handler (OFFLINE)')

        # instance attributes
        self.menu = None
        self.menu_bar_actions()
        self.menuProject.setEnabled(False)
        self.readSettings()
        self.setIcon()

        self.customize_ui()

    def create_ui_main(self):
        self.projects_docks = collections.OrderedDict()

        env_inst.ui_main = self

        self.setupUi(self)
        self.setWindowTitle('TACTIC Handler')
        self.customize_ui()

        # instance attributes
        self.menu = None
        self.mainwidget.deleteLater()
        self.query_projects()
        self.menu_bar_actions()
        self.menuProject.setEnabled(True)
        self.readSettings()
        self.setIcon()
        self.created = True
        self.create_messages_widget()

    def create_debuglog_widget(self):
        env_inst.ui_debuglog = ui_misc_classes.Ui_debugLogWidget(self)

    def create_messages_widget(self):
        env_inst.ui_messages = ui_misc_classes.Ui_messagesWidget(self)

    def create_info_label(self):
        self.label_layout = QtGui.QVBoxLayout(self.menubar)
        self.label_layout.setContentsMargins(0, 0, 6, 0)

        self.info_label = QtGui.QLabel()
        self.info_label.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignVCenter)
        self.info_label.setText('')
        self.label_layout.addWidget(self.info_label)

    def set_status_text(self, text=''):
        self.setStatusTip(text)

    def set_info_status_text(self, status_text=''):
        self.info_label.setText(status_text)

    def check_for_update(self):
        if uf.check_need_update():
            self.info_label.setText(
                '<span style=" font-size:8pt; color:#ff0000;">Need update</span>'
            )

    def setIcon(self):
        icon = Qt4Gui.QIcon(':/ui_main/gliph/tactic_favicon.ico')
        self.setWindowIcon(icon)

    def customize_ui(self):
        if env_mode.get_mode() == 'standalone':
            self.actionDock_undock.setVisible(False)

        self.actionExit.setIcon(gf.get_icon('close'))
        self.actionConfiguration.setIcon(gf.get_icon('wrench'))
        self.create_info_label()

    def menu_bar_actions(self):
        """
        Actions for the main menu bar
        """
        def close_routine():
            if env_mode.get_mode() == 'maya':
                from thlib.ui_classes.ui_maya_dock import close_all_instances
                close_all_instances()
                self.close()
            if env_mode.get_mode() == 'standalone':
                self.close()

        self.actionExit.triggered.connect(close_routine)

        self.actionConfiguration.triggered.connect(self.open_config_dialog)

        self.actionApply_to_all_Tabs.triggered.connect(self.apply_current_view)

        self.actionUpdate.triggered.connect(self.update_self)
        self.actionServerside_Script.triggered.connect(
            self.create_server_side_script_editor)
        self.actionDebug_Log.triggered.connect(
            lambda: env_inst.ui_debuglog.show())

        # User Menu items
        self.actionMessages.triggered.connect(
            lambda: env_inst.ui_messages.show())
        self.actionEdit_My_Account.triggered.connect(self.edit_my_account)

        self.actionDock_undock.triggered.connect(self.undock_window)

    def undock_window(self):
        env_inst.ui_maya_dock.toggle_docking()

    def edit_my_account(self):

        import thlib.tactic_widgets as tw
        import thlib.ui_classes.ui_tactic_widgets_classes as twc

        wd = {
            u'input_prefix': u'insert',
            u'element_titles':
            [u'Preview', u'Name', u'Description', u'Keywords'],
            u'title': u'',
            u'element_names':
            [u'preview', u'name', u'description', u'keywords'],
            u'kwargs': {
                u'search_type': u'melnitsapipeline/episode',
                u'code': u'',
                u'title_width': u'',
                u'parent_key': None,
                u'title': u'',
                u'default': u'',
                u'search_key': u'',
                u'input_prefix': u'insert',
                u'config_base': u'',
                u'single': u'',
                u'cbjs_edit_path': u'',
                u'access': u'',
                u'width': u'',
                u'show_header': u'',
                u'cbjs_cancel': u'',
                u'mode': u'insert',
                u'cbjs_insert_path': u'',
                u'ignore': u'',
                u'show_action': u'',
                u'search_id': u'',
                u'view': u'insert'
            },
            u'element_descriptions':
            [None, u'Name', u'Description', u'Keywords'],
            u'mode': u'insert',
            u'security_denied': False
        }
        tactic_edit_widget = tw.TacticEditWdg(wd)
        tactic_edit_widget.set_stype(
            env_inst.get_current_stypes()['tactichandler/bug'])

        input_widgets_list = []

        class Item(object):
            def __init__(self):
                self.get_pipeline = None
                self.type = 'fake'

        self.item = Item()

        # class item(object):
        def get_pipeline():
            return None

        self.item.get_pipeline = get_pipeline
        # self.item.get_pipeline = get_pipeline
        edit_window = twc.QtTacticEditWidget(tactic_widget=tactic_edit_widget,
                                             qt_widgets=input_widgets_list,
                                             stype=self.item,
                                             parent=self)

        edit_window.show()

        self.dlg = QtGui.QDialog(self)
        self.l = QtGui.QVBoxLayout()
        self.l.addWidget(edit_window)
        self.dlg.setLayout(self.l)
        self.dlg.show()

        import ui_addsobject_classes
        # edit_current_account = ui_addsobject_classes.Ui_addTacticSobjectWidget(
        #     stype=env_inst.get_current_stypes().values()[0],
        #     view='edit',
        #     parent=self,
        # )
        # edit_current_account.setWindowTitle(u'Editing User Account')
        # edit_current_account.show()

    def create_ui_float_notify(self):
        self.float_notify = ui_float_notify_classes.Ui_floatNotifyWidget(self)
        self.float_notify.show()
        self.float_notify.setSizeGripEnabled(True)

    def create_server_side_script_editor(self):
        if env_mode.is_online():
            self.serverside_script_editor = Ui_serverScriptEditForm(self)
            self.serverside_script_editor.show()

    def update_self(self):
        if env_mode.is_online():
            self.update_dialog = Ui_updateDialog(self)

            self.update_dialog.show()

    def open_config_dialog(self):
        conf_dialog = ui_conf_classes.Ui_configuration_dialogWidget(
            parent=self)
        conf_dialog.show()

    def restart_for_update_ui_main(self):
        if env_mode.get_mode() == 'standalone':
            import main_standalone
            thread = main_standalone.restart()
            thread.finished.connect(self.close)
        if env_mode.get_mode() == 'maya':
            import main_maya
            thread = main_maya.main.restart()
            thread.finished.connect(main_maya.main.close_all_instances)

    def restart_ui_main(self):
        self.close()
        self.projects_docks = collections.OrderedDict()

        if env_mode.is_online():
            self.create_ui_main()
        else:
            self.create_ui_main_offline()

        self.show()
        return self

    def apply_current_view(self):
        # TODO may be need to be rewriten to use env instance
        if env_inst.get_current_project():
            current_project_widget = self.projects_docks[
                env_inst.get_current_project()].widget()

            current_project_widget.ui_checkin_checkout.apply_current_view_to_all(
            )

            # widget_name = current_project_widget.main_tabWidget.currentWidget().objectName()

            # if widget_name == 'checkInOutTab':
            #     current_project_widget.ui_checkin_checkout.apply_current_view_to_all()
            #
            # if widget_name == 'checkOutTab':
            #     current_project_widget.ui_checkout.apply_current_view_to_all()
            #
            # if widget_name == 'checkInTab':
            #     current_project_widget.ui_checkin.apply_current_view_to_all()

    def fill_projects_to_menu(self):

        all_projects_dicts = []

        for project_name, project in env_inst.projects.iteritems():
            all_projects_dicts.append(project.info)

        projects_by_categories = gf.group_dict_by(all_projects_dicts,
                                                  'category')

        for cat_name, projects in projects_by_categories.iteritems():
            if cat_name:
                cat_name = gf.prettify_text(cat_name, True)
            else:
                cat_name = 'No Category'
            if cat_name != 'Template':
                category = self.menuProject.addMenu(cat_name)

            for e, project in enumerate(projects):
                if not project.get('is_template'):
                    project_code = project.get('code')

                    menu_action = QtGui.QAction(self)
                    menu_action.setCheckable(True)

                    if self.opened_projects:
                        if project_code in self.opened_projects:
                            menu_action.setChecked(True)
                    menu_action.setText(project.get('title'))
                    # Don't know why lambda did not work here
                    menu_action.triggered.connect(
                        partial(self.create_project_dock, project_code))
                    category.addAction(menu_action)

    def restore_opened_projects(self):
        if self.ui_settings_dict:
            self.opened_projects = self.ui_settings_dict.get('opened_projects')
        else:
            self.opened_projects = None
        if not isinstance(self.opened_projects, list):
            if self.opened_projects:
                self.opened_projects = [self.opened_projects]

        if self.opened_projects:
            for project in self.opened_projects:
                if project:
                    self.create_project_dock(project)

            current_project_code = self.ui_settings_dict.get(
                'current_active_project')

            if current_project_code:
                if self.projects_docks.get(current_project_code):
                    self.projects_docks[current_project_code].show()
                    self.projects_docks[current_project_code].raise_()

    def get_settings_dict(self):

        settings_dict = {}

        if self.windowState() == QtCore.Qt.WindowMaximized:
            state = True
            if self.ui_settings_dict:
                settings_dict['pos'] = self.ui_settings_dict['pos']
                settings_dict['size'] = self.ui_settings_dict['size']
            else:
                settings_dict['pos'] = self.pos().toTuple()
                settings_dict['size'] = self.size().toTuple()
        else:
            state = False
            settings_dict['pos'] = self.pos().toTuple()
            settings_dict['size'] = self.size().toTuple()
        settings_dict['windowState'] = state

        if self.projects_docks.keys():
            settings_dict['opened_projects'] = self.projects_docks.keys()
            if env_inst.get_current_project():
                settings_dict['current_active_project'] = str(
                    env_inst.get_current_project())
        else:
            settings_dict['opened_projects'] = ''
            settings_dict['current_active_project'] = ''

        return settings_dict

    def set_settings_from_dict(self, settings_dict=None):

        if not settings_dict:
            settings_dict = {
                'pos': self.pos().toTuple(),
                'size': self.size().toTuple(),
                'windowState': False,
                'opened_projects': '',
                'current_active_project': '',
            }

        self.move(settings_dict['pos'][0], settings_dict['pos'][1])
        self.resize(settings_dict['size'][0], settings_dict['size'][1])

        if settings_dict['windowState']:
            self.setWindowState(QtCore.Qt.WindowMaximized)

    def readSettings(self):
        self.ui_settings_dict = env_read_config(filename='ui_settings',
                                                unique_id='ui_main',
                                                long_abs_path=True)
        self.set_settings_from_dict(self.ui_settings_dict)

    def writeSettings(self):
        env_write_config(self.get_settings_dict(),
                         filename='ui_settings',
                         unique_id='ui_main',
                         long_abs_path=True)

    def closeEvent(self, event):
        for dock in self.projects_docks.values():
            # project_code = dock.widget().project.get_code()
            dock.widget().close()
            dock.close()
            dock.deleteLater()
            del dock
            # env_inst.cleanup(project_code)
        self.writeSettings()
        event.accept()

    def query_projects_finished(self, result=None):
        if result:
            self.restore_opened_projects()
            self.fill_projects_to_menu()
            env_inst.ui_main.set_info_status_text('')

            # self.create_ui_float_notify()

    def query_projects(self):
        env_inst.ui_main.set_info_status_text(
            '<span style=" font-size:8pt; color:#00ff00;">Getting projects</span>'
        )

        def get_all_projects_and_logins_agent():
            return tc.get_all_projects_and_logins()

        env_inst.set_thread_pool(None, 'server_query/server_thread_pool')

        projects_items_worker = gf.get_thread_worker(
            get_all_projects_and_logins_agent,
            env_inst.get_thread_pool('server_query/server_thread_pool'),
            result_func=self.query_projects_finished,
            error_func=gf.error_handle)
        projects_items_worker.start()