Esempio n. 1
0
    def _init_widget(self):
        """Summary
        
        Returns:
            TYPE: Description
        """
        self.name_lab.setText(str(self.controller.name))
        self.name_lab.setToolTip(str(self.controller.name))
        self.description_lab.setText(str(self.controller.description))
        self.description_lab.setToolTip(str(self.controller.description))

        self.update_check_state()

        self.pass_btn.setIcon(
            QtGui.QIcon(
                os.path.join(IMAGE_PATH, "general",
                             "ic_exit_to_app_white_24dp_1x.png")))
        self.fix_btn.setIcon(
            QtGui.QIcon(
                os.path.join(IMAGE_PATH, "general",
                             "ic_build_white_24dp_1x.png")))
        self.copy_btn.setIcon(
            QtGui.QIcon(
                os.path.join(IMAGE_PATH, "general",
                             "ic_content_copy_white_24dp_1x.png")))
        self.select_btn.setIcon(
            QtGui.QIcon(
                os.path.join(IMAGE_PATH, "general",
                             "ic_tab_unselected_white_24dp_1x.png")))
Esempio n. 2
0
 def get_color_lvl(self, lvl):
     if not lvl.upper() in self._level_supported:
         raise Exception("Level not supported")
     if lvl.upper() == 'ERROR':
         return QtGui.QColor(128, 21, 21)
     elif lvl.upper() == 'INFO':
         return QtGui.QColor(7.1, 21.6, 32.2)
     elif lvl.upper() == 'WARNING':
         return QtGui.QColor(212, 196, 106)
Esempio n. 3
0
    def __init_icons(self):
        # Warning
        icon = QtGui.QIcon(os.path.join(IMAGE_PATH, "warning.png"))
        self.report_btn.setIcon(icon)
        # question
        icon = QtGui.QIcon(os.path.join(IMAGE_PATH, "question.png"))
        self.help_btn.setIcon(icon)

        pixmap = QtGui.QPixmap(os.path.join(IMAGE_PATH, "miguel.png"))
        self.icon.setPixmap(pixmap)
Esempio n. 4
0
    def __init__(self, title, level='INFO', msg=None):
        super(MessageWindow, self).__init__()
        set_style_sheet(self, os.path.join(get_css_path(), "dark_style1.qss"))
        self._state = False
        self.vertical_layout = QtWidgets.QVBoxLayout(self)
        self.horizontal_layout_btns = QtWidgets.QHBoxLayout()
        self.label_layout = QtWidgets.QHBoxLayout()

        title_font = QtGui.QFont()
        title_font.setPointSize(11)
        self.title_label = QtWidgets.QLabel()
        self.title_label.setText(title)
        self.title_label.setFont(title_font)

        level_font = QtGui.QFont()
        level_font.setPointSize(11)
        level_font.setBold(True)
        self.level_label = QtWidgets.QLabel()
        self.level_label.setFont(level_font)
        self.level_label.setText(level.upper())
        self.set_lvl_color(self.level_label, level)
        self.label_layout.addWidget(self.title_label)
        self.label_layout.addWidget(self.level_label)

        self.right_btn = QtWidgets.QPushButton()
        self.right_btn.setMinimumHeight(30)
        self.right_btn.setMinimumWidth(100)
        self.right_btn.setText(self.name_btn_right)
        self.right_btn.clicked.connect(self.on_right_btn)

        self.left_btn = QtWidgets.QPushButton()
        self.left_btn.setMinimumHeight(30)
        self.left_btn.setMinimumWidth(100)
        self.left_btn.setText(self.name_btn_left)
        self.left_btn.clicked.connect(self.on_left_btn)

        self.vertical_layout.addLayout(self.label_layout)

        if msg:
            self.text = QtWidgets.QTextEdit()
            self.text.setPlainText(msg)
            self.vertical_layout.addWidget(self.text)
            self.text.setReadOnly(True)

        self.horizontal_layout_btns.addWidget(self.left_btn)
        self.horizontal_layout_btns.addWidget(self.right_btn)

        self.vertical_layout.addLayout(self.horizontal_layout_btns)

        self.resize(100, 10)
        self.exec_()
Esempio n. 5
0
 def add_item_in_list(self, key):
     if key.startswith("P:bm2"):
         print "VERGA"
     listItem = QtWidgets.QListWidgetItem(key)
     listItem.setIcon(QtGui.QIcon(os.path.join(ICO_PATH, "question.png")))
     self.dependency_list.addItem(listItem)
     QtWidgets.QApplication.processEvents()
Esempio n. 6
0
def recursive_advance_tree(tree, data):
    '''
        {"value":{
            0:{"checked": None,
               "icon": spackage_ico_path,
               "value":"RIG"},
            1:{"checked": 2,
               "icon": download_ico_path,
               "text":"Load msg"},

            2:{"checked": 2,
               "icon": update_ico_path,
               "text":"text message"},

            3:{"checked": 2,
               "icon": upload_ico_path,
               "text":"text message"}
            },
    '''
    #     row = len(data.keys())
    for row, value_info in enumerate(data):
        tree_item = QtWidgets.QTreeWidgetItem(tree)
        #         tree_item = tree.topLevelItem(row)
        if isinstance(value_info["value"], str):
            tree_item.setText(0, value_info["value"])
        elif isinstance(value_info["value"], dict):
            for column, column_info in value_info["value"].iteritems():
                # Set text
                if "text" in column_info:
                    tree_item.setText(column, column_info["text"])
                # Set check box if exists
                if "checked" in column_info:
                    if isinstance(column_info["checked"], int):
                        tree_item.setCheckState(
                            column, get_qt_check_state(column_info["checked"]))
                # Set icon
                if "icon" in column_info:
                    if os.path.exists(column_info["icon"]):
                        tree_item.setIcon(column,
                                          (QtGui.QIcon(column_info["icon"])))
            if "children" in value_info:
                if isinstance(value_info["children"],
                              list) and value_info["children"]:
                    recursive_advance_tree(tree_item, value_info["children"])
        tree_item.setExpanded(True)
        if isinstance(tree, QtWidgets.QTreeWidget):
            tree.addTopLevelItem(tree_item)
        elif isinstance(tree, QtWidgets.QTreeWidgetItem):
            tree.addChild(tree_item)
    return tree
Esempio n. 7
0
    def download_file(self, file, item):
        try:
            if not self.dropboxManager:
                self.dropboxManager = DropboxManager(
                    token=self._config["dpx_token"])

            item.setIcon(QtGui.QIcon(os.path.join(ICO_PATH,
                                                  "downloading.png")))
            QtWidgets.QApplication.processEvents()
            if self.dropboxManager.downloadFile(file):
                item.setIcon(QtGui.QIcon(os.path.join(ICO_PATH,
                                                      "checked.png")))
                return True
            else:
                item.setIcon(QtGui.QIcon(os.path.join(ICO_PATH, "error.png")))
                return False

        except Exception as e:
            item.setIcon(QtGui.QIcon(os.path.join(ICO_PATH, "error.png")))
            print e
            return False
        finally:
            QtWidgets.QApplication.processEvents()
Esempio n. 8
0
 def __set_user_picture(self, picture):
     pixmap = QtGui.QIcon(picture)
     self.usernameIcon.setIconSize(QtCore.QSize(80, 80))
     self.usernameIcon.setIcon(pixmap)
Esempio n. 9
0
 def icon(self, button_icon):
     self._icon = button_icon
     self.setIconSize(QtCore.QSize(32, 32))
     self.setIcon(QtGui.QIcon(self._icon))
Esempio n. 10
0
 def __setStyleSheet(self):
     bold_font = QtGui.QFont()
     bold_font.setBold(True)
     self.setFont(bold_font)
Esempio n. 11
0
 def __setFont(self):
     font = QtGui.QFont()
     font.setBold(True)
     self.name_lab.setFont(font)
Esempio n. 12
0
class ChecksUIWidget(form, base):
    """Summary
    
    Attributes:
        battery_checker_list (TYPE): Description
        rows (list): Description
    """
    CHECKNAMEICON = QtGui.QPixmap(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/name_tag.png"))
    DESCRIPTIONICON = QtGui.QPixmap(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/description.png"))
    LOGICON = QtGui.QPixmap(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/log.png"))
    RUNICON = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/run.png"))
    FIXICON = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/fix.png"))

    def __init__(self, battery_checker_list=None):
        """Summary
        
        Args:
            battery_checker_list (TYPE): Description
        """
        super(ChecksUIWidget, self).__init__()
        self.setupUi(self)
        self.__defaultStateWindow()
        self.__connectDefaultSignals()
        self.__addTabs()

    def __connectDefaultSignals(self):
        self.runallBT.clicked.connect(self.runAll)
        self.fixallBT.clicked.connect(self.fixAll)

    def __defaultStateWindow(self):
        self.nametag_icon.setPixmap(self.CHECKNAMEICON)
        self.description_icon.setPixmap(self.DESCRIPTIONICON)
        self.log_icon.setPixmap(self.LOGICON)
        self.runallBT.setIcon(self.RUNICON)
        self.fixallBT.setIcon(self.FIXICON)

    def __addTabs(self):
        batteriesChecks = checks_configuration.ALLBATTERIES
        for battery in batteriesChecks:
            scrollArea = QtWidgets.QScrollArea()
            scrollArea.setWidgetResizable(True)
            scrollWidget = QtWidgets.QWidget()
            scrollLayout = QtWidgets.QVBoxLayout()
            scrollLayout.setSpacing(0)
            scrollLayout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize)
            scrollLayout.setContentsMargins(0, 0, 0, 0)
            for check in battery.checks:
                checkWidget = CheckWidget(check, self)
                scrollLayout.addWidget(checkWidget)
            spacer = QtWidgets.QSpacerItem(100, 20,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
            scrollLayout.addItem(spacer)
            scrollWidget.setLayout(scrollLayout)
            scrollArea.setWidget(scrollWidget)
            self.checksTab.addTab(scrollArea, battery.name)

    def runAll(self):
        currentWidget = self.checksTab.currentWidget()
        for widget in currentWidget.findChildren(CheckWidget):
            if widget.checkObject.state == widget.checkObject.CHECK_PASSED:
                continue
            widget.runCheck()

    def fixAll(self):
        currentWidget = self.checksTab.currentWidget()
        for widget in currentWidget.findChildren(CheckWidget):
            if widget.checkObject.state == widget.checkObject.CHECK_PASSED or not widget.checkObject.fixable:
                continue
            widget.fixCheck()
Esempio n. 13
0
class CheckWidget(form, base):

    STATES = {
        -1:
        "border:1px outset; border-color: #880E4F; border-radius: 2px; background-color:#E91E63",
        0:
        "border:1px outset; border-color: #0D47A1; border-radius: 2px; background-color:#2196F3",
        1:
        "border:1px outset; border-color: #1B5E20; border-radius: 2px; background-color:#4CAF50",
        2:
        "border:1px outset; border-color: #E65100; border-radius: 2px; background-color:#FF9800",
        "disabled":
        "border:1px outset; border-color: #212121; border-radius: 2px; background-color:#9E9E9E"
    }
    RUNICON = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/run.png"))
    FIXICON = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/fix.png"))
    SELECTICON = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/select.png"))

    def __init__(self, checkObject, mainUI):
        super(CheckWidget, self).__init__()
        self.setupUi(self)
        if not isinstance(checkObject, baseCheck.BaseCheck):
            raise Exception("Unsupported check Object")
        self.checkObject = checkObject
        self.mainUI = mainUI
        self.name_lab.setText(str(self.checkObject.name))
        self.name_lab.setToolTip(str(self.checkObject.name))
        self.setAttribute(QtCore.Qt.WA_StyledBackground)
        self.setWidgetState()
        self.__connectDefaultSignals()
        self.__setIcons()
        self.__setFont()

    def __setIcons(self):
        self.runBT.setIcon(self.RUNICON)
        self.fixBT.setIcon(self.FIXICON)
        self.selBT.setIcon(self.SELECTICON)

    def __setFont(self):
        font = QtGui.QFont()
        font.setBold(True)
        self.name_lab.setFont(font)

    def __connectDefaultSignals(self):
        self.runBT.clicked.connect(self.runCheck)
        self.fixBT.clicked.connect(self.fixCheck)
        self.selBT.clicked.connect(self.selectAssets)

    def setWidgetState(self):
        self.mainUI.logTE.setText(self.checkObject.output)
        self.fixBT.setEnabled(self.checkObject.fixable)
        affectedElems_bool = True if self.checkObject.affectedElements != [] else False
        self.selBT.setEnabled(affectedElems_bool)
        if self.checkObject.disable:
            self.setStyleSheet(self.STATES["disabled"])
        else:
            self.setStyleSheet(self.STATES[self.checkObject.state])

    def runCheck(self):
        self.__refreshUI()
        self.checkObject.execute()
        self.setWidgetState()

    def fixCheck(self):
        self.__refreshUI()
        self.checkObject.fix()
        self.setWidgetState()

    def selectAssets(self):
        self.__refreshUI()
        if self.checkObject.affectedElements:
            cmds.select(self.checkObject.affectedElements)

    def enterEvent(self, event):
        super(CheckWidget, self).enterEvent(event)

    def leaveEvent(self, event):
        super(CheckWidget, self).enterEvent(event)

    def mousePressEvent(self, event):
        '''re-implemented to suppress Right-Clicks from selecting items.'''
        if event.type() == QtCore.QEvent.MouseButtonPress:
            if event.button() == QtCore.Qt.RightButton:
                if self.checkObject.state == self.checkObject.DEFAULT_STATE:
                    self.checkObject.disable = not self.checkObject.disable
                    if self.checkObject.disable:
                        self.setStyleSheet(self.STATES["disabled"])
                        self.runBT.setEnabled(False)
                    else:
                        self.setStyleSheet(self.STATES[self.checkObject.state])
                        self.runBT.setEnabled(True)
            else:
                if not self.checkObject.disable:
                    self.__refreshUI()
        super(CheckWidget, self).mousePressEvent(event)

    def __refreshUI(self):
        self.mainUI.nameLB.setText(self.checkObject.name)
        self.mainUI.descriptionTE.setText(self.checkObject.description)
        self.mainUI.logTE.setText(self.checkObject.output)
Esempio n. 14
0
 def set_lvl_color(self, label, lvl):
     sample = QtGui.QPalette()
     color = self.get_color_lvl(lvl)
     sample.setColor(QtGui.QPalette.WindowText, color)
     label.setPalette(sample)
Esempio n. 15
0
 def __refresh_scene_info(self, metadata_object):
     self.sceneNameLB.setText(metadata_object.scene_name)
     self.userLB.setText(metadata_object.author)
     self.dateLB.setText(metadata_object.modified)
     pixmap = metadata_object.image if metadata_object.image else None
     self.scene_image_pixmap.setPixmap(QtGui.QPixmap(pixmap))
Esempio n. 16
0
class SceneLoaderUI(form, base):

    OPENSCENE = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "gui/icons/open_scene.png"))

    def __init__(self):
        super(SceneLoaderUI, self).__init__()
        self.setupUi(self)
        # self.proyect_tree = controller.generate_paths_info(PROJECT_ROOT)['P:/BM2']# temp_config.PROJECT_TEMP['P:/BM2']#
        self.__root = "P:/BM2"
        self.__category = None
        self.__first_level = None
        self.__second_level = None
        self.__third_level = None
        self.__fourth_level = None
        self._path = None
        self.proyect_tree = controller.generate_paths_info2(
            self.__root)  # temp_config.PROJECT_TEMP['P:/BM2']#
        self.__current_tab = None
        # self.myProcess = FoldersTree()
        # self.myProcess.start()

        self.__default_window_state()
        self.__connect_default_signals()

    def __default_window_state(self):
        self.categoryCB.addItems(sorted(self.proyect_tree))
        self.__set_icons()

    def __set_icons(self):
        self.loadSceneBT.setIcon(self.OPENSCENE)

    def __connect_default_signals(self):
        self.categoryCB.currentIndexChanged[str].connect(
            self.__category_change)
        self.firstLevelLW.itemClicked.connect(self.__first_level_changed)
        self.secondLevelLW.itemClicked.connect(self.__second_level_changed)
        self.thirdLevelLW.itemClicked.connect(self.__third_level_changed)
        self.fourthLevelLW.itemClicked.connect(self.__fourth_level_changed)
        self.scenesTW.currentChanged.connect(self.__scene_type_changed)
        self.loadSceneBT.clicked.connect(self.__load_scene)
        self.saveLocalBT.clicked.connect(self.__save_local)
        # self.myProcess.finished.connect(self.__thread_finished)

    # def __thread_finished(self):
    #     self.all_paths = self.myProcess.project_tree
    #     print "SE FINI"

    def __category_change(self, category):
        self.__category = category
        self._path = os.path.join(self.__root, category)
        self.__reset_lists()
        self.firstLevelLW.addItems(
            sorted(controller.generate_paths_info2(self._path)))

    def __first_level_changed(self, list_item):
        # current_keys = sorted(self.proyect_tree[self.__category][list_item.text()].keys())
        self.__first_level = list_item.text()
        self._path = os.path.join(self.__root, self.__category,
                                  self.__first_level)
        self.secondLevelLW.clear()
        self.thirdLevelLW.clear()
        self.fourthLevelLW.clear()
        self.secondLevelLW.addItems(
            sorted(controller.generate_paths_info2(self._path)))
        self.firstLevelBT.setText(list_item.text())

    def __second_level_changed(self, list_item):
        # current_keys = sorted(self.proyect_tree[self.__category][self.__first_level][list_item.text()].keys())
        self.__second_level = list_item.text()
        self.thirdLevelLW.clear()
        self.fourthLevelLW.clear()
        self._path = os.path.join(self.__root, self.__category,
                                  self.__first_level, self.__second_level)
        self.thirdLevelLW.addItems(
            sorted(controller.generate_paths_info2(self._path)))
        self.secondLevelBT.setText(list_item.text())

    def __third_level_changed(self, list_item):
        # current_keys = sorted(self.proyect_tree[self.__category][self.__first_level]
        #                                        [self.__second_level][list_item.text()].keys())
        self.__third_level = list_item.text()
        self._path = os.path.join(self.__root, self.__category,
                                  self.__first_level, self.__second_level,
                                  self.__third_level)
        self.fourthLevelLW.clear()
        self.fourthLevelLW.addItems(
            sorted(controller.generate_paths_info2(self._path)))
        self.thirdLevelBT.setText(list_item.text())

    def __fourth_level_changed(self, list_item):
        self.__fourth_level = list_item.text()
        self._path = os.path.join(self.__root, self.__category,
                                  self.__first_level, self.__second_level,
                                  self.__third_level, self.__fourth_level)
        self.fourthLevelBT.setText(list_item.text())
        self.scenes_dictionary = controller.generate_paths_info(
            self._path).get(self.__fourth_level)
        self.__populate_scenes(self.scenes_dictionary)

    def __scene_type_changed(self, tab_index):
        self.__current_tab = self.scenesTW.tabText(tab_index)

    def __populate_scenes(self, scenes_tree):
        self.__delete_tabs()
        for folder, scenes in scenes_tree.iteritems():
            scenes_list_widget = QtWidgets.QListWidget()
            scenes_list_widget.addItems(
                sorted(
                    [item for item in scenes.keys() if item.endswith(".ma")],
                    reverse=True))
            scenes_list_widget.itemClicked.connect(self.__scene_selected)
            self.scenesTW.addTab(scenes_list_widget, folder)

    def __delete_tabs(self):
        while self.scenesTW.count() != 0:
            tab = self.scenesTW.currentIndex()
            self.scenesTW.removeTab(tab)

    def __scene_selected(self, scene):
        self.metadata_object = self.__generate_metadata_path_from_selection(
            scene.text().split(".")[0])
        self.__refresh_scene_info(self.metadata_object)
        # print os.path.join(self.__current_path, self.__current_tab, scene.text())

    def __generate_metadata_path_from_selection(self, scene):
        metadata_file = os.path.join(self._path, self.__current_tab,
                                     "metadata", "{}.metadata".format(scene))
        return metadata_utils.make_metadata_from_local(metadata_file)

    def __refresh_scene_info(self, metadata_object):
        self.sceneNameLB.setText(metadata_object.scene_name)
        self.userLB.setText(metadata_object.author)
        self.dateLB.setText(metadata_object.modified)
        pixmap = metadata_object.image if metadata_object.image else None
        self.scene_image_pixmap.setPixmap(QtGui.QPixmap(pixmap))

    def __set_scene_snapshot(self, metadata_object):
        image_path = metadata_object.scene_path.replace(".ma", ".png")
        controller.generate_snapshot(image_path)
        return image_path

    def __reset_lists(self):
        self.firstLevelLW.clear()
        self.secondLevelLW.clear()
        self.thirdLevelLW.clear()
        self.fourthLevelLW.clear()

    def __load_scene(self):
        if getattr(self, "metadata_object"):
            cmds.file(self.metadata_object.scene_path, o=True, f=True)

    def __save_local(self):
        current_m_object = metadata_utils.make_metadata_from_local(
            metadata_utils.generate_metadata_path(cmds.file(sn=True, q=True)))
        m_object, m_object_path = metadata_utils.generate_metadata_from_scene()
        if not current_m_object.image:
            image_path = self.__set_scene_snapshot(m_object)
            m_object.image = image_path
        else:
            m_object.image = current_m_object.image
        m_object.save_local_metadata()
        self.__refresh_scene_info(m_object)

    def generate_scene_name(self):
        if len(dep) > 3:
            short_dep = dep[:3]
        else:
            short_dep = dep
        scene = "bm2_{}{}_{}_{}_{}_{}_{}_default_none_{}{}".format(
            self.__second_level, short_dep, self.__category,
            self.__first_level, self.__second_level, self.__third_level,
            self.__fourth_level, self.__current_tab, "001")
        return scene
Esempio n. 17
0
    def set_loading_gif(self, label):

        movie = QtGui.QMovie(os.path.join(ICO_PATH, "gif", "loading.gif"))
        movie.setCacheMode(QtGui.QMovie.CacheAll)
        label.setMovie(movie)
        movie.start()