def _setup_tools(self) -> None: for row, tool in enumerate(self._tools): action = self.addAction(theme_manager.icon_from_resources(tool[1]), tool[2]()) action.setCheckable(True) action.setShortcut(f"Alt+{row + 1}") self._action_group.addAction(action) # always start with first tool active = 0 self._action_group.actions()[active].setChecked(True) self.sidebar.tool = self._tools[active][0]
def _setup_tools(self) -> None: for row, tool in enumerate(self._tools): action = self.addAction(theme_manager.icon_from_resources(tool[1]), tool[2]()) action.setCheckable(True) action.setShortcut(f"Alt+{row + 1}") self._action_group.addAction(action) saved = self.sidebar.col.get_config("sidebarTool", 0) active = saved if saved < len(self._tools) else 0 self._action_group.actions()[active].setChecked(True) self.sidebar.tool = self._tools[active][0]
def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> QVariant: if not index.isValid(): return QVariant() if role not in (Qt.DisplayRole, Qt.DecorationRole, Qt.ToolTipRole, Qt.EditRole): return QVariant() item: SidebarItem = index.internalPointer() if role in (Qt.DisplayRole, Qt.EditRole): return QVariant(item.name) if role == Qt.ToolTipRole: return QVariant(item.tooltip) return QVariant(theme_manager.icon_from_resources(item.icon))
def data(self, index, role=Qt.DisplayRole): if not index.isValid(): return QVariant() item: SidebarItem = index.internalPointer() if role == Qt.DisplayRole: return QVariant(item.name) elif role == Qt.DecorationRole: if POINT_VERSION < 20: return QVariant(self.iconFromRef(item.icon)) return QVariant(theme_manager.icon_from_resources(item.icon)) elif role == Qt.BackgroundRole: return QVariant(item.background) elif role == Qt.ForegroundRole: return QVariant(item.foreground) elif role == Qt.ToolTipRole: return QVariant(item.tooltip) else: return QVariant()
def _update_icons(self) -> None: for idx, action in enumerate(self._action_group.actions()): action.setIcon( theme_manager.icon_from_resources(self._tools[idx][1]))
def iconFromRef(self, iconRef: str) -> QIcon: print("iconFromRef() deprecated") return theme_manager.icon_from_resources(iconRef)