Ejemplo n.º 1
0
    def __init__(self, icon_name, color, hover_color, *args, **kwargs):
        super(IconButton, self).__init__(*args, **kwargs)

        self.icon = qtawesome.icon(icon_name, color=color)
        self.hover_icon = qtawesome.icon(icon_name, color=hover_color)

        self.setIcon(self.icon)
Ejemplo n.º 2
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == self.ItemRole:
            node = index.internalPointer()
            return node

        # Add icon
        if role == QtCore.Qt.DecorationRole:
            if index.column() == 0:
                node = index.internalPointer()
                icon = node.get("icon")
                if icon:
                    return qtawesome.icon("fa.{0}".format(icon),
                                          color=colors.default)
            if index.column() == 1:
                node = index.internalPointer()
                if "subset" in node:
                    if node["subset"] == UNDEFINED_SUBSET:
                        return qtawesome.icon("fa.question-circle",
                                              color="#BD2D2D")
                    else:
                        return qtawesome.icon("fa.bookmark", color="#BBC0C6")

        return super(AssetModel, self).data(index, role)
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent=parent)

        self.setWindowIcon(qtawesome.icon("fa.users", color="#F0F3F4"))
        self.setWindowTitle("Project Member")
        self.setWindowFlags(QtCore.Qt.Window)

        widget = {
            "refresh": QtWidgets.QPushButton(),
            "projects": QtWidgets.QComboBox(),
            "btnAdd": QtWidgets.QPushButton(),
            "btnDel": QtWidgets.QPushButton(),
        }

        layout = QtWidgets.QHBoxLayout(self)
        layout.addWidget(widget["refresh"])
        layout.addWidget(widget["projects"], stretch=True)
        layout.addWidget(widget["btnAdd"])
        layout.addWidget(widget["btnDel"])

        widget["refresh"].setIcon(qtawesome.icon("fa.refresh",
                                                 color="#E5E7E9"))
        widget["btnAdd"].setIcon(
            qtawesome.icon("fa.user-plus", color="#58D68D"))
        widget["btnDel"].setIcon(
            qtawesome.icon("fa.user-times", color="#A93226"))

        widget["projects"].currentTextChanged.connect(self.on_text_changed)
        widget["refresh"].clicked.connect(self.on_refresh_clicked)
        widget["btnAdd"].clicked.connect(self.on_add_clicked)
        widget["btnDel"].clicked.connect(self.on_del_clicked)

        self.widget = widget
        self.init_projects()
        self.resize(480, 40)
Ejemplo n.º 4
0
 def __init__(self, parent=None):
     super(TaskList, self).__init__(parent=parent)
     self._icons = {
         "__default__": qtawesome.icon("fa.male",
                                       color=style.colors.default),
         "__no_task__": qtawesome.icon("fa.exclamation-circle",
                                       color="darkred")
     }
Ejemplo n.º 5
0
 def __init__(self, parent=None):
     super(SequenceModel, self).__init__(parent)
     self._stereo = False
     self._stereo_icons = {
         "Left": qtawesome.icon("fa.bullseye", color="#FC3731"),
         "Right": qtawesome.icon("fa.bullseye", color="#53D8DF"),
         None: qtawesome.icon("fa.circle", color="#656565"),
     }
Ejemplo n.º 6
0
    def __init__(self):
        super(TasksModel, self).__init__()
        self._num_assets = 0
        self._icons = {
            "__default__":
            qtawesome.icon("fa.male", color=style.colors.default),
            "__no_task__":
            qtawesome.icon("fa.exclamation-circle", color=style.colors.mid)
        }

        self._get_task_icons()
Ejemplo n.º 7
0
    def __init__(self, dbcon, parent=None):
        super(TaskModel, self).__init__(parent=parent)
        self.dbcon = dbcon

        self._num_assets = 0

        self.default_icon = qtawesome.icon("fa.male",
                                           color=style.colors.default)
        self.no_task_icon = qtawesome.icon("fa.exclamation-circle",
                                           color=style.colors.mid)

        self._icons = {}

        self._get_task_icons()
Ejemplo n.º 8
0
    def __init__(self, parent=None):
        super(SelectionModel, self).__init__(parent=parent)

        self.status_icon = [
            qtawesome.icon("fa.{}".format(icon), color=color)
            for icon, color in self.STATUS_ICONS
        ]
        self.reference_icon = [
            qtawesome.icon("fa.{}".format(icon), color=color)
            for icon, color in self.REFERENCE_ICONS
        ]

        self._duplicated_id = set()
        self._selecting_back = False
        self._selection_freezed = False
Ejemplo n.º 9
0
 def __init__(self, selectable=True):
     super(TasksTemplateModel, self).__init__()
     self.selectable = selectable
     self.icon = qtawesome.icon(
         'fa.calendar-check-o',
         color=style.colors.default
     )
Ejemplo n.º 10
0
    def __init__(self, parent=None):
        super(SelectionModel, self).__init__(parent=parent)

        self.status_icon = [
            qtawesome.icon("fa.{}".format(icon), color=color)
            for icon, color in self.STATUS_ICONS
        ]
Ejemplo n.º 11
0
 def __init__(self):
     super(TasksTemplateModel, self).__init__()
     self.selectable = False
     self._icons = {
         "__default__": awesome.icon("fa.folder-o",
                                     color=style.colors.default)
     }
Ejemplo n.º 12
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)

        layout = QtWidgets.QHBoxLayout()

        context = QtWidgets.QLabel()
        context.setMinimumWidth(50)
        context.setStyleSheet("QLabel {font-weight: bold}")

        set_context_icon = qta.icon("fa.arrow-right",
                                    color=style.colors.default)
        set_context_button = QtWidgets.QPushButton()
        set_context_button.setIcon(set_context_icon)
        set_context_button.setFixedWidth(28)

        layout.addWidget(context)
        layout.addWidget(set_context_button)

        self.setLayout(layout)

        self.set_context_btn = set_context_button
        self.context_label = context

        self.connections()

        self._set_context_label()
Ejemplo n.º 13
0
def get_action_icon(action):
    icon_name = action.icon
    if not icon_name:
        return None

    global ICON_CACHE

    icon = ICON_CACHE.get(icon_name)
    if icon is NOT_FOUND:
        return None
    elif icon:
        return icon

    icon_path = resources.get_resource(icon_name)
    if os.path.exists(icon_path):
        icon = QtGui.QIcon(icon_path)
        ICON_CACHE[icon_name] = icon
        return icon

    try:
        icon_color = getattr(action, "color", None) or "white"
        icon = qtawesome.icon(
            "fa.{}".format(icon_name), color=icon_color
        )

    except Exception:
        ICON_CACHE[icon_name] = NOT_FOUND
        print("Can't load icon \"{}\"".format(icon_name))

    return icon
Ejemplo n.º 14
0
    def __init__(self, dbcon, parent=None):
        super(ProjectModel, self).__init__(parent=parent)

        self.dbcon = dbcon

        self.hide_invisible = False
        self.project_icon = qtawesome.icon("fa.map", color="white")
Ejemplo n.º 15
0
    def __init__(self, file_extensions, parent=None):
        super(FilesModel, self).__init__(parent=parent)

        self._root = None
        self._file_extensions = file_extensions
        self._icons = {
            "file": qtawesome.icon("fa.file-o", color=style.colors.default)
        }
Ejemplo n.º 16
0
    def __init__(self, parent=None):
        super(DiffDelegate, self).__init__(parent)

        self.name_pixmap = [
            qtawesome.icon("fa.{}".format(icon),
                           color=color).pixmap(self.ICON_SIZE, self.ICON_SIZE)
            for icon, color in self.NAME_ICONS
        ]
        self.points_pixmap = [
            qtawesome.icon("fa.{}".format(icon),
                           color=color).pixmap(self.ICON_SIZE, self.ICON_SIZE)
            for icon, color in self.POINTS_ICONS
        ]
        self.uvmap_pixmap = [
            qtawesome.icon("fa.{}".format(icon),
                           color=color).pixmap(self.ICON_SIZE, self.ICON_SIZE)
            for icon, color in self.UVMAP_ICONS
        ]
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)

        self._comp = avalon.get_current_comp()
        self._comp_name = self._get_comp_name()

        self.setWindowTitle("Set Render Mode")
        self.setFixedSize(300, 175)

        layout = QtWidgets.QVBoxLayout()

        # region comp info
        comp_info_layout = QtWidgets.QHBoxLayout()

        update_btn = QtWidgets.QPushButton(
            qtawesome.icon("fa.refresh", color="white"), "")
        update_btn.setFixedWidth(25)
        update_btn.setFixedHeight(25)

        comp_information = QtWidgets.QLineEdit()
        comp_information.setEnabled(False)

        comp_info_layout.addWidget(comp_information)
        comp_info_layout.addWidget(update_btn)
        # endregion comp info

        # region modes
        mode_options = QtWidgets.QComboBox()
        mode_options.addItems(_help.keys())

        mode_information = QtWidgets.QTextEdit()
        mode_information.setReadOnly(True)
        # endregion modes

        accept_btn = QtWidgets.QPushButton("Accept")

        layout.addLayout(comp_info_layout)
        layout.addWidget(mode_options)
        layout.addWidget(mode_information)
        layout.addWidget(accept_btn)

        self.setLayout(layout)

        self.comp_information = comp_information
        self.update_btn = update_btn

        self.mode_options = mode_options
        self.mode_information = mode_information

        self.accept_btn = accept_btn

        self.connections()
        self.update()

        # Force updated render mode help text
        self._update_rendermode_info()
Ejemplo n.º 18
0
 def get_task_icons(self):
     # Get the project configured icons from database
     project = io.find_one({"type": "project"})
     tasks = project["config"].get("tasks", [])
     for task in tasks:
         icon_name = task.get("icon", None)
         if icon_name:
             icon = qtawesome.icon("fa.{}".format(icon_name),
                                   color=style.colors.default)
             self._icons[task["name"]] = icon
Ejemplo n.º 19
0
    def refresh(self):
        self.clear()
        self.beginResetModel()

        root = self._root

        if not root:
            self.endResetModel()
            return

        if not os.path.exists(root):
            # Add Work Area does not exist placeholder
            log.debug("Work Area does not exist: %s", root)
            message = "Work Area does not exist. Use Save As to create it."
            item = Item({
                "filename":
                message,
                "date":
                None,
                "filepath":
                None,
                "enabled":
                False,
                "icon":
                qtawesome.icon("fa.times", color=style.colors.mid)
            })
            self.add_child(item)
            self.endResetModel()
            return

        extensions = self._file_extensions

        for filename in os.listdir(root):
            path = os.path.join(root, filename)
            if os.path.isdir(path):
                continue

            ext = os.path.splitext(filename)[1]
            if extensions and ext not in extensions:
                continue

            modified = os.path.getmtime(path)

            item = Item({
                "filename": filename,
                "date": modified,
                "filepath": path
            })

            self.add_child(item)

        if self.rowCount() == 0:
            self._add_empty()

        self.endResetModel()
Ejemplo n.º 20
0
    def __init__(self, parent=None):
        super(ComparerModel, self).__init__(parent=parent)

        self.header_icon = [
            qtawesome.icon("fa.{}".format(icon), color=color)
            for icon, color in self.HEADER_ICONS
        ]

        self._use_long_name = False
        self._origin_shared_root = ""
        self._contrast_shared_root = ""
Ejemplo n.º 21
0
    def _get_task_icons(self):
        if not self.dbcon.Session.get("AVALON_PROJECT"):
            return

        # Get the project configured icons from database
        project = self.dbcon.find_one({"type": "project"})
        for task in project["config"].get("tasks") or []:
            icon_name = task.get("icon")
            if icon_name:
                self._icons[task["name"]] = qtawesome.icon(
                    "fa.{}".format(icon_name), color=style.colors.default)
Ejemplo n.º 22
0
    def data(self, index, role):

        if not index.isValid():
            return

        # Add icon
        if role == QtCore.Qt.DecorationRole:
            if index.column() == 0:
                return qtawesome.icon("fa.paint-brush", color="#BBC0C6")

        return super(_LookModel, self).data(index, role)
Ejemplo n.º 23
0
    def __init__(self, dbcon, parent=None):
        super(ActionModel, self).__init__(parent=parent)
        self.dbcon = dbcon

        self.application_manager = ApplicationManager()

        self._groups = {}
        self.default_icon = qtawesome.icon("fa.cube", color="white")
        # Cache of available actions
        self._registered_actions = list()
        self.items_by_id = {}
Ejemplo n.º 24
0
    def __init__(self, dbcon, parent=None):
        super(ActionModel, self).__init__(parent=parent)
        self.dbcon = dbcon

        self._session = {}
        self._groups = {}
        self.default_icon = qtawesome.icon("fa.cube", color="white")
        # Cache of available actions
        self._registered_actions = list()

        self.discover()
Ejemplo n.º 25
0
    def __init__(self, parent=None):
        super(ActionHistory, self).__init__(parent=parent)

        self.max_history = 15

        self.setFixedWidth(25)
        self.setFixedHeight(25)

        self.setIcon(qtawesome.icon("fa.history", color="#CCCCCC"))
        self.setIconSize(QtCore.QSize(15, 15))

        self._history = []
        self.clicked.connect(self.show_history)
Ejemplo n.º 26
0
    def data(self, index, role):

        if not index.isValid():
            return

        item = index.internalPointer()
        if role == QtCore.Qt.DecorationRole:        # icon

            column = index.column()
            if column == self.Name:

                # Allow a custom icon and custom icon color to be defined
                data = item.get("_document", {}).get("data", {})
                icon = data.get("icon", None)
                if icon is None and item.get("type") == "silo":
                    icon = "database"
                color = data.get("color", style.colors.default)

                if icon is None:
                    # Use default icons if no custom one is specified.
                    # If it has children show a full folder, otherwise
                    # show an open folder
                    has_children = self.rowCount(index) > 0
                    icon = "folder" if has_children else "folder-o"

                # Make the color darker when the asset is deprecated
                if item.get("deprecated", False):
                    color = QtGui.QColor(color).darker(250)

                try:
                    key = "fa.{0}".format(icon)  # font-awesome key
                    icon = qtawesome.icon(key, color=color)
                    return icon
                except Exception as exception:
                    # Log an error message instead of erroring out completely
                    # when the icon couldn't be created (e.g. invalid name)
                    log.error(exception)

                return

        if role == QtCore.Qt.ForegroundRole:        # font color
            if "deprecated" in item.get("tags", []):
                return QtGui.QColor(style.colors.light).darker(250)

        if role == self.ObjectIdRole:
            return item.get("_id", None)

        if role == self.DocumentRole:
            return item.get("_document", None)

        return super(AssetModel, self).data(index, role)
Ejemplo n.º 27
0
    def __init__(self, level, parent=None):
        super(DatabaseDocumentModel, self).__init__(parent=parent)
        self.lister = {
            "silo": self.list_silos,
            "asset": self.list_assets,
            "subset": self.list_subsets,
            "version": self.list_versions,
        }[level]

        self.placeholder = "< Select %s.. >" % level.capitalize()
        self.placeholder_item = QtGui.QStandardItem(
            qtawesome.icon("fa.hand-o-right", color="white"), self.placeholder)

        self.reset(None)
Ejemplo n.º 28
0
    def data(self, index, role):

        if not index.isValid():
            return

        if role == model.TreeModel.NodeRole:
            node = index.internalPointer()
            return node

        # Add icon
        if role == QtCore.Qt.DecorationRole:
            if index.column() == 0:
                node = index.internalPointer()
                icon = node.get("icon")
                if icon:
                    return qtawesome.icon("fa.{0}".format(icon),
                                          color=colors.default)
            if index.column() == 1:
                node = index.internalPointer()
                if "subset" in node:
                    return qtawesome.icon("fa.bookmark", color="gray")

        return super(AssetModel, self).data(index, role)
Ejemplo n.º 29
0
    def _build_menu(self, instances):

        _parent = self.collection_view
        menu = QtWidgets.QMenu(_parent)

        set_range_icon = qta.icon("fa.scissors", color=style.colors.default)
        set_range_action = QtWidgets.QAction(set_range_icon,
                                             "Update frame range", menu)
        set_range_action.triggered.connect(
            lambda: self._show_update_frame_range(instances))

        menu.addAction(set_range_action)

        return menu
Ejemplo n.º 30
0
    def __init__(self, parent=None):
        super(AssetWidget, self).__init__(parent=parent)
        self.setContentsMargins(0, 0, 0, 0)

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

        # Tree View
        model = AssetModel(self)
        proxy = RecursiveSortFilterProxyModel()
        proxy.setSourceModel(model)
        proxy.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)

        view = DeselectableTreeView()
        view.setIndentation(15)
        view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        view.setHeaderHidden(True)
        view.setModel(proxy)

        # Header
        header = QtWidgets.QHBoxLayout()

        icon = qtawesome.icon("fa.refresh", color=style.colors.light)
        refresh = QtWidgets.QPushButton(icon, "")
        refresh.setToolTip("Refresh items")

        filter = QtWidgets.QLineEdit()
        filter.textChanged.connect(proxy.setFilterFixedString)
        filter.setPlaceholderText("Filter assets..")

        header.addWidget(filter)
        header.addWidget(refresh)

        # Layout
        layout.addLayout(header)
        layout.addWidget(view)

        # Signals/Slots
        selection = view.selectionModel()
        selection.selectionChanged.connect(self.selection_changed)
        selection.currentChanged.connect(self.current_changed)
        refresh.clicked.connect(self.refresh)

        self.refreshButton = refresh
        self.model = model
        self.proxy = proxy
        self.view = view